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

Unified Diff: Source/wtf/PartitionAlloc.h

Issue 172533004: Add partitionAllocActualSize() for predicting actual size of allocation (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 10 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 | « no previous file | Source/wtf/PartitionAlloc.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
« no previous file with comments | « no previous file | Source/wtf/PartitionAlloc.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698