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

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: Hook in allocateOnHeapIndex 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
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 9762d092378cd86c26cb7a15f283c1e230bcb974..21022cb0e28fb85097669f3807adcd1267519e08 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 allocateOnHeapIndex(ThreadState*, size_t, int heapIndex, size_t gcInfoIndex);
+ static Address allocateOnHeapIndex(ThreadState*, size_t, int heapIndex, 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::allocateOnHeapIndex(ThreadState* state, size_t size, int heapIndex, size_t gcInfoIndex)
+inline Address Heap::allocateOnHeapIndex(ThreadState* state, size_t size, int heapIndex, size_t gcInfoIndex, const char* typeName)
{
ASSERT(state->isAllocationAllowed());
ASSERT(heapIndex != BlinkGC::LargeObjectHeapIndex);
NormalPageHeap* heap = static_cast<NormalPageHeap*>(state->heap(heapIndex));
- return heap->allocateObject(allocationSizeFromSize(size), gcInfoIndex);
+ Address address = heap->allocateObject(allocationSizeFromSize(size), gcInfoIndex);
sof 2016/02/29 18:36:59 Given that allocateOnHeapIndex() is also inlined,
Primiano Tucci (use gerrit) 2016/02/29 18:38:45 All the builds support allocation hooks, the macro
+ 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::allocateOnHeapIndex(state, size, eagerlySweep ? BlinkGC::EagerSweepHeapIndex : Heap::heapIndexForObjectSize(size), GCInfoTrait<T>::index());
const char* typeName = WTF_HEAP_PROFILER_TYPE_NAME(T);
- HeapAllocHooks::allocationHookIfEnabled(address, size, typeName);
- return address;
+ return Heap::allocateOnHeapIndex(state, size, eagerlySweep ? BlinkGC::EagerSweepHeapIndex : Heap::heapIndexForObjectSize(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::allocateOnHeapIndex(state, size, heapIndex, GCInfoTrait<T>::index());
+ const char* typeName = WTF_HEAP_PROFILER_TYPE_NAME(T);
+ HeapAllocHooks::freeHookIfEnabled(static_cast<Address>(previous));
+ Address address = Heap::allocateOnHeapIndex(state, size, heapIndex, 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;
}

Powered by Google App Engine
This is Rietveld 408576698