| Index: third_party/WebKit/Source/wtf/PartitionAlloc.cpp
|
| diff --git a/third_party/WebKit/Source/wtf/PartitionAlloc.cpp b/third_party/WebKit/Source/wtf/PartitionAlloc.cpp
|
| index d076568fcfc59bd6984d319884c0c6c19b18d6af..7f474b4a523161a8c3a17d0e9bce54833b500cce 100644
|
| --- a/third_party/WebKit/Source/wtf/PartitionAlloc.cpp
|
| +++ b/third_party/WebKit/Source/wtf/PartitionAlloc.cpp
|
| @@ -60,6 +60,8 @@ bool PartitionRootBase::gInitialized = false;
|
| PartitionPage PartitionRootBase::gSeedPage;
|
| PartitionBucket PartitionRootBase::gPagedBucket;
|
| void (*PartitionRootBase::gOomHandlingFunction)() = nullptr;
|
| +PartitionHooks::AllocationHook* PartitionHooks::allocationHook = nullptr;
|
| +PartitionHooks::FreeHook* PartitionHooks::freeHook = nullptr;
|
|
|
| static uint16_t partitionBucketNumSystemPages(size_t size)
|
| {
|
| @@ -1060,8 +1062,16 @@ void* partitionReallocGeneric(PartitionRootGeneric* root, void* ptr, size_t newS
|
| // We may be able to perform the realloc in place by changing the
|
| // accessibility of memory pages and, if reducing the size, decommitting
|
| // them.
|
| - if (partitionReallocDirectMappedInPlace(root, page, newSize))
|
| + if (partitionReallocDirectMappedInPlace(root, page, newSize)) {
|
| + // Report a realloc as a free followed by alloc when heap profiling
|
| + // is enabled.
|
| + if (UNLIKELY(PartitionHooks::allocationHook && PartitionHooks::freeHook)) {
|
| + PartitionHooks::freeHook(ptr);
|
| + PartitionHooks::allocationHook(ptr, newSize);
|
| + }
|
| +
|
| return ptr;
|
| + }
|
| }
|
|
|
| size_t actualNewSize = partitionAllocActualSize(root, newSize);
|
| @@ -1085,6 +1095,14 @@ void* partitionReallocGeneric(PartitionRootGeneric* root, void* ptr, size_t newS
|
|
|
| memcpy(ret, ptr, copySize);
|
| partitionFreeGeneric(root, ptr);
|
| +
|
| + // Report a realloc as a free followed by alloc when heap profiling is
|
| + // enabled.
|
| + if (UNLIKELY(PartitionHooks::allocationHook && PartitionHooks::freeHook)) {
|
| + PartitionHooks::freeHook(ptr);
|
| + PartitionHooks::allocationHook(ret, newSize);
|
| + }
|
| +
|
| return ret;
|
| #endif
|
| }
|
|
|