this repo has no description
at trunk 32 lines 702 B view raw
1// Copyright (c) Facebook, Inc. and its affiliates. (http://www.facebook.com) 2#include "space.h" 3 4#include <cstring> 5 6#include "os.h" 7 8namespace py { 9 10Space::Space(word size) { 11 raw_ = OS::allocateMemory(size, &size); 12 CHECK(raw_ != nullptr, "out of memory"); 13 start_ = fill_ = reinterpret_cast<uword>(raw_); 14 end_ = start_ + size; 15} 16 17Space::~Space() { 18 if (raw_ != nullptr) { 19 OS::freeMemory(raw_, size()); 20 } 21} 22 23void Space::protect() { OS::protectMemory(raw_, size(), OS::kNoAccess); } 24 25void Space::unprotect() { OS::protectMemory(raw_, size(), OS::kReadWrite); } 26 27void Space::reset() { 28 std::memset(reinterpret_cast<void*>(start()), 0xFF, size()); 29 fill_ = start(); 30} 31 32} // namespace py