Chromium Code Reviews| Index: Source/wtf/PartitionAlloc.h |
| diff --git a/Source/wtf/PartitionAlloc.h b/Source/wtf/PartitionAlloc.h |
| index 74871483107e1b6dff4e01454d7f9dfb07605085..c0709d9d62b1e200e83aa112513ee0395bb5e65c 100644 |
| --- a/Source/wtf/PartitionAlloc.h |
| +++ b/Source/wtf/PartitionAlloc.h |
| @@ -254,6 +254,7 @@ struct PartitionSuperPageExtentEntry { |
| }; |
| struct WTF_EXPORT PartitionRootBase { |
| + size_t totalAllocationSize; |
| size_t totalSizeOfSuperPages; |
| unsigned numBuckets; |
| unsigned maxAllocation; |
| @@ -464,6 +465,7 @@ ALWAYS_INLINE void* partitionBucketAlloc(PartitionRootBase* root, int flags, siz |
| // The value given to the application is actually just after the cookie. |
| ret = static_cast<char*>(ret) + kCookieSize; |
| #endif |
| + root->totalAllocationSize += bucket->slotSize; |
|
Chris Evans
2014/06/05 18:00:26
My gut reaction is I don't like this. It adds over
|
| return ret; |
| } |
| @@ -487,8 +489,8 @@ ALWAYS_INLINE void* partitionAlloc(PartitionRoot* root, size_t size) |
| ALWAYS_INLINE void partitionFreeWithPage(void* ptr, PartitionPage* page) |
| { |
| // If these asserts fire, you probably corrupted memory. |
| -#ifndef NDEBUG |
| size_t bucketSize = page->bucket->slotSize; |
| +#ifndef NDEBUG |
| partitionCookieCheckValue(ptr); |
| partitionCookieCheckValue(reinterpret_cast<char*>(ptr) + bucketSize - kCookieSize); |
| memset(ptr, kFreedByte, bucketSize); |
| @@ -502,6 +504,10 @@ ALWAYS_INLINE void partitionFreeWithPage(void* ptr, PartitionPage* page) |
| entry->next = partitionFreelistMask(freelistHead); |
| page->freelistHead = entry; |
| --page->numAllocatedSlots; |
| + |
| + PartitionRootBase* root = partitionPageToRoot(page); |
| + root->totalAllocationSize -= bucketSize; |
|
Tom Sepez
2014/06/05 17:52:01
nit: assert you don't underflow here.
|
| + |
| if (UNLIKELY(page->numAllocatedSlots <= 0)) |
| partitionFreeSlowPath(page); |
| } |