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

Unified Diff: Source/wtf/PageAllocator.cpp

Issue 25640003: Optimize test for pointer being in a partition on 32-bit. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Review 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
« no previous file with comments | « Source/wtf/PageAllocator.h ('k') | Source/wtf/PartitionAlloc.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/wtf/PageAllocator.cpp
diff --git a/Source/wtf/PageAllocator.cpp b/Source/wtf/PageAllocator.cpp
index 35b24df67c7c92d33928df89a8717f34c26301fd..d71ff526e7dc65e70e047ab038fb21783e549def 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,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);
Tom Sepez 2013/10/02 22:56:53 I think you can get rid of these ifdefs as well by
+#endif
return ret;
}
@@ -111,6 +113,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 +169,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 idx = raw >> 3;
+ size_t bit = raw & 7;
+ ASSERT(idx < sizeof(s_bitmap));
+ s_bitmap[idx] |= (1 << bit);
+}
+
+void SuperPageBitmap::unregisterSuperPage(void* ptr)
+{
+ ASSERT(isPointerInSuperPage(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));
+ s_bitmap[idx] &= ~(1 << bit);
+}
+#endif
+
} // namespace WTF
« no previous file with comments | « Source/wtf/PageAllocator.h ('k') | Source/wtf/PartitionAlloc.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698