Commit 8727d5da authored by hajimehoshi's avatar hajimehoshi Committed by Commit bot

Show type names in Oilpan heap profiler

This CL enables to show object type names in Oilpan heap profiler.

BUG=585063

Review URL: https://codereview.chromium.org/1711643002

Cr-Commit-Position: refs/heads/master@{#376146}
parent 8604e081
......@@ -31,9 +31,9 @@ void dumpMemoryTotals(blink::WebProcessMemoryDump* memoryDump)
objectsDump->addScalar("size", "bytes", Heap::allocatedObjectSize() + Heap::markedObjectSize());
}
void reportAllocation(Address address, size_t size)
void reportAllocation(Address address, size_t size, const char* typeName)
{
BlinkGCMemoryDumpProvider::instance()->insert(address, size);
BlinkGCMemoryDumpProvider::instance()->insert(address, size, typeName);
}
void reportFree(Address address)
......@@ -114,11 +114,10 @@ BlinkGCMemoryDumpProvider::BlinkGCMemoryDumpProvider()
{
}
void BlinkGCMemoryDumpProvider::insert(Address address, size_t size)
void BlinkGCMemoryDumpProvider::insert(Address address, size_t size, const char* typeName)
{
base::trace_event::AllocationContext context = base::trace_event::AllocationContextTracker::GetContextSnapshot();
// TODO(hajimehoshi): Implement to use a correct type name.
context.type_name = "";
context.type_name = typeName;
MutexLocker locker(m_allocationRegisterMutex);
if (m_allocationRegister)
m_allocationRegister->Insert(address, size, context);
......
......@@ -46,7 +46,7 @@ public:
WebProcessMemoryDump* currentProcessMemoryDump() { return m_currentProcessMemoryDump.get(); }
void insert(Address, size_t);
void insert(Address, size_t, const char*);
void remove(Address);
private:
......
......@@ -48,17 +48,17 @@ namespace blink {
class PLATFORM_EXPORT HeapAllocHooks {
public:
// TODO(hajimehoshi): Pass a type name of the allocated object.
typedef void AllocationHook(Address, size_t);
typedef void AllocationHook(Address, size_t, const char*);
typedef void FreeHook(Address);
static void setAllocationHook(AllocationHook* hook) { m_allocationHook = hook; }
static void setFreeHook(FreeHook* hook) { m_freeHook = hook; }
static void allocationHookIfEnabled(Address address, size_t size)
static void allocationHookIfEnabled(Address address, size_t size, const char* typeName)
{
AllocationHook* allocationHook = m_allocationHook;
if (UNLIKELY(!!allocationHook))
allocationHook(address, size);
allocationHook(address, size, typeName);
}
static void freeHookIfEnabled(Address address)
......@@ -68,14 +68,14 @@ public:
freeHook(address);
}
static void reallocHookIfEnabled(Address oldAddress, Address newAddress, size_t size)
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);
allocationHook(newAddress, size, typeName);
}
}
......@@ -496,7 +496,8 @@ 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());
HeapAllocHooks::allocationHookIfEnabled(address, size);
const char* typeName = WTF_HEAP_PROFILER_TYPE_NAME(T);
HeapAllocHooks::allocationHookIfEnabled(address, size, typeName);
return address;
}
......@@ -530,7 +531,8 @@ Address Heap::reallocate(void* previous, size_t size)
if (copySize > size)
copySize = size;
memcpy(address, previous, copySize);
HeapAllocHooks::reallocHookIfEnabled(static_cast<Address>(previous), address, size);
const char* typeName = WTF_HEAP_PROFILER_TYPE_NAME(T);
HeapAllocHooks::reallocHookIfEnabled(static_cast<Address>(previous), address, size, typeName);
return address;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment