| Index: src/platform-win32.cc
|
| diff --git a/src/platform-win32.cc b/src/platform-win32.cc
|
| index 8673f047ee2a7bac6786a8463322d03d0fab9cce..33844916ed4356a1a1772d2e6c0c2489771948f7 100644
|
| --- a/src/platform-win32.cc
|
| +++ b/src/platform-win32.cc
|
| @@ -1434,7 +1434,7 @@ bool VirtualMemory::IsReserved() {
|
|
|
|
|
| VirtualMemory::VirtualMemory(size_t size) {
|
| - address_ = VirtualAlloc(NULL, size, MEM_RESERVE, PAGE_NOACCESS);
|
| + address_ = ReserveRegion(size);
|
| size_ = size;
|
| }
|
|
|
| @@ -1447,22 +1447,47 @@ VirtualMemory::~VirtualMemory() {
|
|
|
|
|
| bool VirtualMemory::Commit(void* address, size_t size, bool is_executable) {
|
| + if (CommitRegion(address, size, is_executable)) {
|
| + UpdateAllocatedSpaceLimits(address, static_cast<int>(size));
|
| + return true;
|
| + }
|
| + return false;
|
| +}
|
| +
|
| +
|
| +bool VirtualMemory::Uncommit(void* address, size_t size) {
|
| + ASSERT(IsReserved());
|
| + return UncommitRegion(address, size);
|
| +}
|
| +
|
| +
|
| +void* VirtualMemory::ReserveRegion(size_t size) {
|
| + return VirtualAlloc(NULL, size, MEM_RESERVE, PAGE_NOACCESS);
|
| +}
|
| +
|
| +
|
| +bool VirtualMemory::CommitRegion(void* base, size_t size, bool is_executable) {
|
| int prot = is_executable ? PAGE_EXECUTE_READWRITE : PAGE_READWRITE;
|
| - if (NULL == VirtualAlloc(address, size, MEM_COMMIT, prot)) {
|
| + if (NULL == VirtualAlloc(base, size, MEM_COMMIT, prot)) {
|
| return false;
|
| }
|
|
|
| - UpdateAllocatedSpaceLimits(address, static_cast<int>(size));
|
| + UpdateAllocatedSpaceLimits(base, static_cast<int>(size));
|
| return true;
|
| }
|
|
|
|
|
| -bool VirtualMemory::Uncommit(void* address, size_t size) {
|
| - ASSERT(IsReserved());
|
| - return VirtualFree(address, size, MEM_DECOMMIT) != false;
|
| +bool VirtualMemory::UncommitRegion(void* base, size_t size) {
|
| + return VirtualFree(base, size, MEM_DECOMMIT) != false;
|
| }
|
|
|
|
|
| +bool VirtualMemory::ReleaseRegion(void* base, size_t size) {
|
| + return VirtualFree(base, size, MEM_DECOMMIT) != false;
|
| +}
|
| +
|
| +
|
| +
|
| // ----------------------------------------------------------------------------
|
| // Win32 thread support.
|
|
|
|
|