Chromium Code Reviews| Index: third_party/WebKit/Source/wtf/PartitionAlloc.h |
| diff --git a/third_party/WebKit/Source/wtf/PartitionAlloc.h b/third_party/WebKit/Source/wtf/PartitionAlloc.h |
| index b0e233f4e2d24a442be2936fc08401c1fddc2866..e2f90d12477056abbcd0349696d58cf46ace6ed7 100644 |
| --- a/third_party/WebKit/Source/wtf/PartitionAlloc.h |
| +++ b/third_party/WebKit/Source/wtf/PartitionAlloc.h |
| @@ -411,6 +411,17 @@ WTF_EXPORT NEVER_INLINE void* partitionReallocGeneric(PartitionRootGeneric*, voi |
| WTF_EXPORT void partitionDumpStats(PartitionRoot*, const char* partitionName, bool isLightDump, PartitionStatsDumper*); |
| WTF_EXPORT void partitionDumpStatsGeneric(PartitionRootGeneric*, const char* partitionName, bool isLightDump, PartitionStatsDumper*); |
| +class WTF_EXPORT PartitionHooks { |
|
Primiano Tucci (use gerrit)
2015/10/14 10:10:12
nit: PartitionAllocHooks ? otherwise it seems that
Ruud van Asseldonk
2015/10/14 12:30:18
Done.
|
| +public: |
| + typedef void AllocationHook(void* address, size_t); |
| + typedef void FreeHook(void* address); |
| + |
| + // Pointers to hook functions that PartitionAlloc will call on allocation and |
| + // free if the pointers are non-null. |
| + static AllocationHook* allocationHook; |
|
Primiano Tucci (use gerrit)
2015/10/14 10:10:12
nit: m_allocationHook i believe
Ruud van Asseldonk
2015/10/14 12:30:18
Done.
|
| + static FreeHook* freeHook; |
|
Primiano Tucci (use gerrit)
2015/10/14 10:10:12
I think you can make the static private: and expos
Ruud van Asseldonk
2015/10/14 12:30:18
Great idea, done.
|
| +}; |
| + |
| ALWAYS_INLINE PartitionFreelistEntry* partitionFreelistMask(PartitionFreelistEntry* ptr) |
| { |
| // We use bswap on little endian as a fast mask for two reasons: |
| @@ -613,6 +624,10 @@ ALWAYS_INLINE void* partitionBucketAlloc(PartitionRootBase* root, int flags, siz |
| partitionCookieWriteValue(charRet); |
| partitionCookieWriteValue(charRet + kCookieSize + noCookieSize); |
| #endif |
| + |
| + if (UNLIKELY(PartitionHooks::allocationHook != nullptr)) |
| + PartitionHooks::allocationHook(ret, size); |
| + |
| return ret; |
| } |
| @@ -645,6 +660,10 @@ ALWAYS_INLINE void partitionFreeWithPage(void* ptr, PartitionPage* page) |
| partitionCookieCheckValue(reinterpret_cast<char*>(ptr) + slotSize - kCookieSize); |
| memset(ptr, kFreedByte, slotSize); |
| #endif |
| + |
| + if (UNLIKELY(PartitionHooks::freeHook != nullptr)) |
| + PartitionHooks::freeHook(ptr); |
| + |
| ASSERT(page->numAllocatedSlots); |
| PartitionFreelistEntry* freelistHead = page->freelistHead; |
| ASSERT(!freelistHead || partitionPointerIsValid(freelistHead)); |