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

Unified Diff: third_party/WebKit/Source/platform/heap/Heap.h

Issue 1721333002: Bug fix: Add BlinkGC allocation hooks to CSS, Node and vector/table backing (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use COMMA Created 4 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 | « third_party/WebKit/Source/core/dom/Node.h ('k') | third_party/WebKit/Source/platform/heap/HeapAllocator.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/platform/heap/Heap.h
diff --git a/third_party/WebKit/Source/platform/heap/Heap.h b/third_party/WebKit/Source/platform/heap/Heap.h
index 984ab60c5eaecabe614203060f4f0a83c56fc9e7..a2081bd3ffc87aa21dd6f33e98576ac77cfa1147 100644
--- a/third_party/WebKit/Source/platform/heap/Heap.h
+++ b/third_party/WebKit/Source/platform/heap/Heap.h
@@ -68,17 +68,6 @@ public:
freeHook(address);
}
- static void reallocHookIfEnabled(Address oldAddress, Address newAddress, size_t size, const char* typeName)
- {
- // Report a reallocation as a free followed by an allocation.
- AllocationHook* allocationHook = m_allocationHook;
- FreeHook* freeHook = m_freeHook;
- if (UNLIKELY(allocationHook && freeHook)) {
- freeHook(oldAddress);
- allocationHook(newAddress, size, typeName);
- }
- }
-
private:
static AllocationHook* m_allocationHook;
static FreeHook* m_freeHook;
@@ -239,7 +228,7 @@ public:
allocationSize = (allocationSize + allocationMask) & ~allocationMask;
return allocationSize;
}
- static Address allocateOnArenaIndex(ThreadState*, size_t, int arenaIndex, size_t gcInfoIndex);
+ static Address allocateOnArenaIndex(ThreadState*, size_t, int arenaIndex, size_t gcInfoIndex, const char* typeName);
template<typename T> static Address allocate(size_t, bool eagerlySweep = false);
template<typename T> static Address reallocate(void* previous, size_t);
@@ -485,22 +474,22 @@ public: \
#define EAGERLY_FINALIZE_WILL_BE_REMOVED()
#endif
-inline Address Heap::allocateOnArenaIndex(ThreadState* state, size_t size, int arenaIndex, size_t gcInfoIndex)
+inline Address Heap::allocateOnArenaIndex(ThreadState* state, size_t size, int arenaIndex, size_t gcInfoIndex, const char* typeName)
{
ASSERT(state->isAllocationAllowed());
ASSERT(arenaIndex != BlinkGC::LargeObjectArenaIndex);
NormalPageArena* arena = static_cast<NormalPageArena*>(state->arena(arenaIndex));
- return arena->allocateObject(allocationSizeFromSize(size), gcInfoIndex);
+ Address address = arena->allocateObject(allocationSizeFromSize(size), gcInfoIndex);
+ HeapAllocHooks::allocationHookIfEnabled(address, size, typeName);
+ return address;
}
template<typename T>
Address Heap::allocate(size_t size, bool eagerlySweep)
{
ThreadState* state = ThreadStateFor<ThreadingTrait<T>::Affinity>::state();
- Address address = Heap::allocateOnArenaIndex(state, size, eagerlySweep ? BlinkGC::EagerSweepArenaIndex : Heap::arenaIndexForObjectSize(size), GCInfoTrait<T>::index());
const char* typeName = WTF_HEAP_PROFILER_TYPE_NAME(T);
- HeapAllocHooks::allocationHookIfEnabled(address, size, typeName);
- return address;
+ return Heap::allocateOnArenaIndex(state, size, eagerlySweep ? BlinkGC::EagerSweepArenaIndex : Heap::arenaIndexForObjectSize(size), GCInfoTrait<T>::index(), typeName);
}
template<typename T>
@@ -528,13 +517,13 @@ Address Heap::reallocate(void* previous, size_t size)
// TODO(haraken): We don't support reallocate() for finalizable objects.
ASSERT(!Heap::gcInfo(previousHeader->gcInfoIndex())->hasFinalizer());
ASSERT(previousHeader->gcInfoIndex() == GCInfoTrait<T>::index());
- Address address = Heap::allocateOnArenaIndex(state, size, arenaIndex, GCInfoTrait<T>::index());
+ const char* typeName = WTF_HEAP_PROFILER_TYPE_NAME(T);
+ HeapAllocHooks::freeHookIfEnabled(static_cast<Address>(previous));
+ Address address = Heap::allocateOnArenaIndex(state, size, arenaIndex, GCInfoTrait<T>::index(), typeName);
size_t copySize = previousHeader->payloadSize();
if (copySize > size)
copySize = size;
memcpy(address, previous, copySize);
- const char* typeName = WTF_HEAP_PROFILER_TYPE_NAME(T);
- HeapAllocHooks::reallocHookIfEnabled(static_cast<Address>(previous), address, size, typeName);
return address;
}
« no previous file with comments | « third_party/WebKit/Source/core/dom/Node.h ('k') | third_party/WebKit/Source/platform/heap/HeapAllocator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698