Index: Source/wtf/PageAllocator.h |
diff --git a/Source/wtf/PageAllocator.h b/Source/wtf/PageAllocator.h |
index c3e75b1c3ef00b30b3d1bbcbfd50be9af9c0d86c..78922381135e39597e0fdfd9c04e5e189e74329d 100644 |
--- a/Source/wtf/PageAllocator.h |
+++ b/Source/wtf/PageAllocator.h |
@@ -31,6 +31,9 @@ |
#ifndef WTF_PageAllocator_h |
#define WTF_PageAllocator_h |
+#include "wtf/CPU.h" |
+#include <stdint.h> |
+ |
namespace WTF { |
// Our granulatity of page allocation is 64KB. This is a Windows limitation, |
@@ -38,7 +41,8 @@ namespace WTF { |
// things simple and consistent. |
// We term these 64KB allocations "super pages". They're just a clump of |
// underlying 4KB system pages. |
-static const size_t kSuperPageSize = 1 << 16; // 64KB |
+static const size_t kSuperPageShift = 16; // 64KB |
+static const size_t kSuperPageSize = 1 << kSuperPageShift; |
static const size_t kSuperPageOffsetMask = kSuperPageSize - 1; |
static const size_t kSuperPageBaseMask = ~kSuperPageOffsetMask; |
@@ -72,7 +76,8 @@ void setSystemPagesInaccessible(void* addr, size_t len); |
// System pages are re-committed by writing to them. |
// Clients should not make any assumptions about the contents of decommitted |
// system pages, before or after they write to the page. The only guarantee |
-// provided is that the contents of the system page will be deterministic again // after writing to it. In particlar note that system pages are not guaranteed |
+// provided is that the contents of the system page will be deterministic again |
+// after writing to it. In particlar note that system pages are not guaranteed |
// to be zero-filled upon re-commit. |
// len must be a multiple of kSystemPageSize bytes. |
void decommitSystemPages(void* addr, size_t len); |
@@ -83,6 +88,25 @@ void decommitSystemPages(void* addr, size_t len); |
// provide reasonable ASLR. |
char* getRandomSuperPageBase(); |
+#if CPU(32BIT) |
+class SuperPageBitmap { |
Tom Sepez
2013/10/02 16:51:31
Not sure this buys a lot over just having the s_bi
Tom Sepez
2013/10/02 16:57:33
Alternatively, you could call this a SuperPageTrac
|
+public: |
+ ALWAYS_INLINE static bool isPointerInSuperPage(void* ptr) |
+ { |
+ uintptr_t raw = reinterpret_cast<uintptr_t>(ptr); |
+ size_t idx = raw >> (kSuperPageShift + 3); |
+ size_t bit = raw & 7; |
Tom Sepez
2013/10/02 16:51:31
This doesn't seem right. You want the low 3 bits
|
+ return s_bitmap[idx] & (1 << bit); |
+ } |
+ |
+ static void registerSuperPage(void* ptr); |
+ static void unregisterSuperPage(void* ptr); |
+ |
+private: |
+ static unsigned char s_bitmap[1 << (32 - kSuperPageShift - 3)]; |
Tom Sepez
2013/10/02 16:51:31
I'd like this as a constant so we can assert that
|
+}; |
+#endif |
+ |
} // namespace WTF |
#endif // WTF_PageAllocator_h |