Index: Source/wtf/PageAllocator.cpp |
diff --git a/Source/wtf/PageAllocator.cpp b/Source/wtf/PageAllocator.cpp |
index 35b24df67c7c92d33928df89a8717f34c26301fd..58b60cc2556d962004b47fd6a47cbdbc10b68fa3 100644 |
--- a/Source/wtf/PageAllocator.cpp |
+++ b/Source/wtf/PageAllocator.cpp |
@@ -97,6 +97,10 @@ void* allocSuperPages(void* addr, size_t len) |
ret = VirtualAlloc(0, len, MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE); |
RELEASE_ASSERT(ret); |
#endif // OS(POSIX) |
+ |
+#if CPU(32BIT) |
+ SuperPageBitmap::registerSuperPage(ret); |
+#endif |
return ret; |
} |
@@ -111,6 +115,10 @@ void freeSuperPages(void* addr, size_t len) |
BOOL ret = VirtualFree(addr, 0, MEM_RELEASE); |
ASSERT(ret); |
#endif |
+ |
+#if CPU(32BIT) |
+ SuperPageBitmap::unregisterSuperPage(addr); |
+#endif |
} |
void setSystemPagesInaccessible(void* addr, size_t len) |
@@ -163,5 +171,27 @@ 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); |
+ size_t idx = raw >> (kSuperPageShift + 3); |
Tom Sepez
2013/10/02 16:51:31
same issue here with bit within byte index.
|
+ size_t bit = raw & 7; |
+ s_bitmap[idx] |= (1 << bit); |
+} |
+ |
+void SuperPageBitmap::unregisterSuperPage(void* ptr) |
+{ |
+ ASSERT(isPointerInSuperPage(ptr)); |
+ uintptr_t raw = reinterpret_cast<uintptr_t>(ptr); |
+ size_t idx = raw >> (kSuperPageShift + 3); |
+ size_t bit = raw & 7; |
+ s_bitmap[idx] &= ~(1 << bit); |
+} |
+#endif |
+ |
} // namespace WTF |