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

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: 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
Index: Source/wtf/PartitionAlloc.h
diff --git a/Source/wtf/PartitionAlloc.h b/Source/wtf/PartitionAlloc.h
index 5b8d4ff04f194365f991c6d41dfb7ec8cd96f45d..5c3d3edd6a5104da59dfde035b8ce434e26728cb 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>
@@ -272,6 +274,15 @@ ALWAYS_INLINE void partitionFreeWithPage(void* ptr, PartitionPageHeader* page)
ALWAYS_INLINE bool partitionPointerIsValid(PartitionRoot* root, void* ptr)
{
+ // 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.
+ if (SuperPageBitmap::isAvailable())
+ return SuperPageBitmap::isPointerInSuperPage(ptr);
+
+ // 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;

Powered by Google App Engine
This is Rietveld 408576698