Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2033)

Unified Diff: Source/wtf/PageAllocator.h

Issue 25640003: Optimize test for pointer being in a partition on 32-bit. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fixes. Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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
« no previous file with comments | « Source/wtf/CPU.h ('k') | Source/wtf/PageAllocator.cpp » ('j') | Source/wtf/PageAllocator.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698