// Copyright (c) Facebook, Inc. and its affiliates. (http://www.facebook.com) #include "space.h" #include #include "os.h" namespace py { Space::Space(word size) { raw_ = OS::allocateMemory(size, &size); CHECK(raw_ != nullptr, "out of memory"); start_ = fill_ = reinterpret_cast(raw_); end_ = start_ + size; } Space::~Space() { if (raw_ != nullptr) { OS::freeMemory(raw_, size()); } } void Space::protect() { OS::protectMemory(raw_, size(), OS::kNoAccess); } void Space::unprotect() { OS::protectMemory(raw_, size(), OS::kReadWrite); } void Space::reset() { std::memset(reinterpret_cast(start()), 0xFF, size()); fill_ = start(); } } // namespace py