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

Unified Diff: Source/wtf/PartitionAlloc.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/PartitionAlloc.h
diff --git a/Source/wtf/PartitionAlloc.h b/Source/wtf/PartitionAlloc.h
index aa779f3d0fb9e1a1f10f8813994630e3f930fead..28360116267f93ed7f2490b89c5e7c3310429c49 100644
--- a/Source/wtf/PartitionAlloc.h
+++ b/Source/wtf/PartitionAlloc.h
@@ -88,7 +88,9 @@
#include "wtf/Assertions.h"
#include "wtf/FastMalloc.h"
+#include "wtf/PageAllocator.h"
#include "wtf/SpinLock.h"
+#include "wtf/UnusedParam.h"
#if defined(MEMORY_TOOL_REPLACES_ALLOCATOR)
#include <stdlib.h>
@@ -266,6 +268,16 @@ ALWAYS_INLINE void partitionFreeWithPage(void* ptr, PartitionPageHeader* page)
ALWAYS_INLINE bool partitionPointerIsValid(PartitionRoot* root, void* ptr)
{
+#if CPU(32BIT)
+ // On 32-bit systems, we have an optimization where we have a bitmap that
+ // can instantly tell us if a pointer is in a super page or not.
+ // It is a global bitmap instead of a per-partition bitmap but this is a
+ // reasonable space vs. accuracy trade off.
+ UNUSED_PARAM(root);
+ return SuperPageBitmap::isPointerInSuperPage(ptr);
+#else
+ // On 64-bit systems, we check the list of super page extents. Due to the
+ // massive address space, we typically have a single extent.
// Dominant case: the pointer is in the first extent, which grew without any collision.
if (LIKELY(ptr >= root->firstExtent.superPageBase) && LIKELY(ptr < root->firstExtent.superPagesEnd))
return true;
@@ -279,6 +291,7 @@ ALWAYS_INLINE bool partitionPointerIsValid(PartitionRoot* root, void* ptr)
}
return false;
+#endif
}
ALWAYS_INLINE void partitionFree(void* ptr)

Powered by Google App Engine
This is Rietveld 408576698