| Index: Source/wtf/PageAllocator.cpp
|
| diff --git a/Source/wtf/PageAllocator.cpp b/Source/wtf/PageAllocator.cpp
|
| index 35b24df67c7c92d33928df89a8717f34c26301fd..11b5aa1ce0b71964de7cf71bea0818cf13a1339b 100644
|
| --- a/Source/wtf/PageAllocator.cpp
|
| +++ b/Source/wtf/PageAllocator.cpp
|
| @@ -31,8 +31,6 @@
|
| #include "config.h"
|
| #include "wtf/PageAllocator.h"
|
|
|
| -#include "wtf/Assertions.h"
|
| -#include "wtf/CPU.h"
|
| #include "wtf/CryptographicallyRandomNumber.h"
|
|
|
| #if OS(POSIX)
|
| @@ -97,6 +95,8 @@ void* allocSuperPages(void* addr, size_t len)
|
| ret = VirtualAlloc(0, len, MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE);
|
| RELEASE_ASSERT(ret);
|
| #endif // OS(POSIX)
|
| +
|
| + SuperPageBitmap::registerSuperPage(ret);
|
| return ret;
|
| }
|
|
|
| @@ -111,6 +111,8 @@ void freeSuperPages(void* addr, size_t len)
|
| BOOL ret = VirtualFree(addr, 0, MEM_RELEASE);
|
| ASSERT(ret);
|
| #endif
|
| +
|
| + SuperPageBitmap::unregisterSuperPage(addr);
|
| }
|
|
|
| void setSystemPagesInaccessible(void* addr, size_t len)
|
| @@ -163,5 +165,31 @@ char* getRandomSuperPageBase()
|
| return reinterpret_cast<char*>(random);
|
| }
|
|
|
| +#if CPU(32BIT)
|
| +unsigned char SuperPageBitmap::s_bitmap[1 << (32 - kSuperPageShift - 3)];
|
| +
|
| +void SuperPageBitmap::registerSuperPage(void* ptr)
|
| +{
|
| + ASSERT(!isPointerInSuperPage(ptr));
|
| + uintptr_t raw = reinterpret_cast<uintptr_t>(ptr);
|
| + raw >>= kSuperPageShift;
|
| + size_t byteIndex = raw >> 3;
|
| + size_t bit = raw & 7;
|
| + ASSERT(byteIndex < sizeof(s_bitmap));
|
| + s_bitmap[byteIndex] |= (1 << bit);
|
| +}
|
| +
|
| +void SuperPageBitmap::unregisterSuperPage(void* ptr)
|
| +{
|
| + ASSERT(isPointerInSuperPage(ptr));
|
| + uintptr_t raw = reinterpret_cast<uintptr_t>(ptr);
|
| + raw >>= kSuperPageShift;
|
| + size_t byteIndex = raw >> 3;
|
| + size_t bit = raw & 7;
|
| + ASSERT(byteIndex < sizeof(s_bitmap));
|
| + s_bitmap[byteIndex] &= ~(1 << bit);
|
| +}
|
| +#endif
|
| +
|
| } // namespace WTF
|
|
|
|
|