Index: Source/wtf/PartitionAlloc.h |
diff --git a/Source/wtf/PartitionAlloc.h b/Source/wtf/PartitionAlloc.h |
index 3da9adcfe90b9004e0f144cede94e9c4074d84d4..ac7edb2b80c0704b904148d74a08f1084cdf0abe 100644 |
--- a/Source/wtf/PartitionAlloc.h |
+++ b/Source/wtf/PartitionAlloc.h |
@@ -565,6 +565,33 @@ ALWAYS_INLINE void partitionFreeGeneric(PartitionRootGeneric* root, void* ptr) |
#endif |
} |
+ALWAYS_INLINE size_t partitionDirectMapSize(size_t size) |
+{ |
Chris Evans
2014/02/21 22:33:37
Can we have a comment such as "caller must handle
Jens Widell
2014/02/22 09:23:30
Assuming (which I hear is a good idea in general)
|
+ return (size + kSystemPageOffsetMask) & kSystemPageBaseMask; |
+} |
+ |
+ALWAYS_INLINE size_t partitionAllocPredictSize(PartitionRootGeneric* root, size_t size) |
Chris Evans
2014/02/21 22:33:37
I think we're doing a more accurate job than predi
Jens Widell
2014/02/22 09:23:30
Renamed it.
|
+{ |
+#if defined(MEMORY_TOOL_REPLACES_ALLOCATOR) |
+ return size; |
+#else |
+ ASSERT(root->initialized); |
+ size = partitionCookieSizeAdjustAdd(size); |
+ PartitionBucket* bucket = partitionGenericSizeToBucket(root, size); |
+ if (LIKELY(bucket->numSystemPagesPerSlotSpan)) { |
Chris Evans
2014/02/21 22:33:37
Can we make this into a small function? This check
Chris Evans
2014/02/21 22:33:37
Can we abstract this to a simple function, partiti
Jens Widell
2014/02/22 09:23:30
Added such a helper. Also made a constant out of "
|
+ size = bucket->slotSize; |
+ } else { |
+ ASSERT(bucket == &PartitionRootGeneric::gPagedBucket); |
+ if (size > INT_MAX - kSystemPageSize) { |
+ // Too large to allocate => return the size unchanged. |
+ } else { |
+ size = partitionDirectMapSize(size); |
+ } |
+ } |
+ return partitionCookieSizeAdjustSubtract(size); |
+#endif |
+} |
+ |
ALWAYS_INLINE bool partitionAllocSupportsGetSize() |
{ |
#if defined(MEMORY_TOOL_REPLACES_ALLOCATOR) |
@@ -623,6 +650,7 @@ using WTF::partitionFree; |
using WTF::partitionAllocGeneric; |
using WTF::partitionFreeGeneric; |
using WTF::partitionReallocGeneric; |
+using WTF::partitionAllocPredictSize; |
using WTF::partitionAllocSupportsGetSize; |
using WTF::partitionAllocGetSize; |