| Index: Source/wtf/PageAllocator.h
|
| diff --git a/Source/wtf/PageAllocator.h b/Source/wtf/PageAllocator.h
|
| index c3e75b1c3ef00b30b3d1bbcbfd50be9af9c0d86c..9df84f54b5704ff6c5ae61398c68dfb0420705c5 100644
|
| --- a/Source/wtf/PageAllocator.h
|
| +++ b/Source/wtf/PageAllocator.h
|
| @@ -31,6 +31,10 @@
|
| #ifndef WTF_PageAllocator_h
|
| #define WTF_PageAllocator_h
|
|
|
| +#include "wtf/Assertions.h"
|
| +#include "wtf/CPU.h"
|
| +#include <stdint.h>
|
| +
|
| namespace WTF {
|
|
|
| // Our granulatity of page allocation is 64KB. This is a Windows limitation,
|
| @@ -38,7 +42,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 +77,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 +89,52 @@ void decommitSystemPages(void* addr, size_t len);
|
| // provide reasonable ASLR.
|
| char* getRandomSuperPageBase();
|
|
|
| +#if CPU(32BIT)
|
| +class SuperPageBitmap {
|
| +public:
|
| + ALWAYS_INLINE static bool isAvailable()
|
| + {
|
| + return true;
|
| + }
|
| +
|
| + ALWAYS_INLINE static bool isPointerInSuperPage(void* ptr)
|
| + {
|
| + uintptr_t raw = reinterpret_cast<uintptr_t>(ptr);
|
| + raw >>= kSuperPageShift;
|
| + size_t idx = raw >> 3;
|
| + size_t bit = raw & 7;
|
| + ASSERT(idx < sizeof(s_bitmap));
|
| + 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)];
|
| +};
|
| +
|
| +#else // CPU(32BIT)
|
| +
|
| +class SuperPageBitmap {
|
| +public:
|
| + ALWAYS_INLINE static bool isAvailable()
|
| + {
|
| + return false;
|
| + }
|
| +
|
| + ALWAYS_INLINE static bool isPointerInSuperPage(void* ptr)
|
| + {
|
| + ASSERT(false);
|
| + return false;
|
| + }
|
| +
|
| + static void registerSuperPage(void* ptr) { }
|
| + static void unregisterSuperPage(void* ptr) { }
|
| +};
|
| +
|
| +#endif // CPU(32BIT)
|
| +
|
| } // namespace WTF
|
|
|
| #endif // WTF_PageAllocator_h
|
|
|