Chromium Code Reviews| Index: Source/platform/heap/ThreadState.cpp |
| diff --git a/Source/platform/heap/ThreadState.cpp b/Source/platform/heap/ThreadState.cpp |
| index b7756d3418cab62cb43047a1743b329f49086dc6..8cf46bc838b85e16891bef56a875d0963850abb5 100644 |
| --- a/Source/platform/heap/ThreadState.cpp |
| +++ b/Source/platform/heap/ThreadState.cpp |
| @@ -33,12 +33,15 @@ |
| #include "platform/ScriptForbiddenScope.h" |
| #include "platform/TraceEvent.h" |
| +#include "platform/heap/BlinkGCMemoryDumpProvider.h" |
| #include "platform/heap/CallbackStack.h" |
| #include "platform/heap/Handle.h" |
| #include "platform/heap/Heap.h" |
| #include "platform/heap/MarkingVisitor.h" |
| #include "platform/heap/SafePoint.h" |
| #include "public/platform/Platform.h" |
| +#include "public/platform/WebMemoryAllocatorDump.h" |
| +#include "public/platform/WebProcessMemoryDump.h" |
| #include "public/platform/WebScheduler.h" |
| #include "public/platform/WebThread.h" |
| #include "public/platform/WebTraceLocation.h" |
| @@ -377,6 +380,14 @@ void ThreadState::visitPersistents(Visitor* visitor) |
| } |
| } |
| +ThreadState::GCSnapshotInfo::GCSnapshotInfo(size_t numObjectTypes) |
| + : liveCount(Vector<int>(numObjectTypes)) |
|
haraken
2015/08/10 23:54:48
You can just use GCInfoTable::maxIndex instead of
ssid
2015/08/11 09:03:03
um, We will be allocating 4 vectors of size 2^14 e
haraken
2015/08/11 11:07:37
ah, makes sense.
|
| + , deadCount(Vector<int>(numObjectTypes)) |
| + , liveSize(Vector<size_t>(numObjectTypes)) |
| + , deadSize(Vector<size_t>(numObjectTypes)) |
| +{ |
| +} |
| + |
| #if ENABLE(GC_PROFILING) |
| const GCInfo* ThreadState::findGCInfo(Address address) |
| { |
| @@ -1409,22 +1420,27 @@ void ThreadState::takeSnapshot(SnapshotType type) |
| { |
| ASSERT(isInGC()); |
| + // 0 is used as index for freelist entries. Objects are indexed 1 to |
| + // gcInfoIndex. |
| + GCSnapshotInfo info(GCInfoTable::gcInfoIndex() + 1); |
| + String threadDumpName = String::format("blink_gc/thread_%lu", (unsigned long)m_thread); |
|
haraken
2015/08/10 23:54:48
(unsigned long) => static_cast
ssid
2015/08/11 09:03:03
Done.
|
| + const String heapsDumpName = threadDumpName + "/heaps"; |
| + const String classesDumpName = threadDumpName + "/classes"; |
| + |
| int numberOfHeapsReported = 0; |
| -#define SNAPSHOT_HEAP(HeapType) \ |
| - { \ |
| - numberOfHeapsReported++; \ |
| - String allocatorBaseName; \ |
| - allocatorBaseName = String::format("blink_gc/thread_%lu/heaps/" #HeapType, (unsigned long)(m_thread)); \ |
| - switch (type) { \ |
| - case SnapshotType::HeapSnapshot: \ |
| - m_heaps[HeapType##HeapIndex]->takeSnapshot(allocatorBaseName); \ |
| - break; \ |
| - case SnapshotType::FreelistSnapshot: \ |
| - m_heaps[HeapType##HeapIndex]->takeFreelistSnapshot(allocatorBaseName); \ |
| - break; \ |
| - default: \ |
| - ASSERT_NOT_REACHED(); \ |
| - } \ |
| +#define SNAPSHOT_HEAP(HeapType) \ |
| + { \ |
| + numberOfHeapsReported++; \ |
| + switch (type) { \ |
| + case SnapshotType::HeapSnapshot: \ |
| + m_heaps[HeapType##HeapIndex]->takeSnapshot(heapsDumpName + "/" #HeapType, info); \ |
| + break; \ |
| + case SnapshotType::FreelistSnapshot: \ |
| + m_heaps[HeapType##HeapIndex]->takeFreelistSnapshot(heapsDumpName + "/" #HeapType); \ |
| + break; \ |
| + default: \ |
| + ASSERT_NOT_REACHED(); \ |
| + } \ |
| } |
| SNAPSHOT_HEAP(NormalPage1); |
| @@ -1444,6 +1460,40 @@ void ThreadState::takeSnapshot(SnapshotType type) |
| ASSERT(numberOfHeapsReported == NumberOfHeaps); |
| #undef SNAPSHOT_HEAP |
| + |
| + if (type == SnapshotType::FreelistSnapshot) |
| + return; |
| + |
| + if (!GCInfoTable::gcInfoIndex()) |
|
haraken
2015/08/10 23:54:48
This check won't be needed.
ssid
2015/08/11 09:03:03
I added this to make sure it does not create the d
haraken
2015/08/11 11:07:37
We've already shipped oilpan for a bunch of object
|
| + return; |
| + |
| + size_t totalLiveCount = 0; |
| + size_t totalDeadCount = 0; |
| + size_t totalLiveSize = 0; |
| + size_t totalDeadSize = 0; |
| + for (size_t i = 1; i <= GCInfoTable::gcInfoIndex(); ++i) { |
| + String dumpName = classesDumpName + "/" + Heap::gcInfo(i)->m_className; |
|
haraken
2015/08/10 23:54:48
We should add a getter for m_className.
ssid
2015/08/11 09:03:03
Done.
|
| + WebMemoryAllocatorDump* classDump = BlinkGCMemoryDumpProvider::instance()->createMemoryAllocatorDumpForCurrentGC(dumpName); |
| + classDump->AddScalar("live_count", "objects", info.liveCount[i]); |
| + classDump->AddScalar("dead_count", "objects", info.deadCount[i]); |
| + classDump->AddScalar("live_size", "bytes", info.liveSize[i]); |
| + classDump->AddScalar("dead_size", "bytes", info.deadSize[i]); |
| + |
| + totalLiveCount += info.liveCount[i]; |
| + totalDeadCount += info.deadCount[i]; |
| + totalLiveSize += info.liveSize[i]; |
| + totalDeadSize += info.deadSize[i]; |
| + } |
| + |
| + WebMemoryAllocatorDump* threadDump = BlinkGCMemoryDumpProvider::instance()->createMemoryAllocatorDumpForCurrentGC(threadDumpName); |
| + threadDump->AddScalar("live_count", "objects", totalLiveCount); |
| + threadDump->AddScalar("dead_count", "objects", totalDeadCount); |
| + threadDump->AddScalar("live_size", "bytes", totalLiveSize); |
| + threadDump->AddScalar("dead_size", "bytes", totalDeadSize); |
| + |
| + WebMemoryAllocatorDump* heapsDump = BlinkGCMemoryDumpProvider::instance()->createMemoryAllocatorDumpForCurrentGC(heapsDumpName); |
| + WebMemoryAllocatorDump* classesDump = BlinkGCMemoryDumpProvider::instance()->createMemoryAllocatorDumpForCurrentGC(classesDumpName); |
| + BlinkGCMemoryDumpProvider::instance()->currentProcessMemoryDump()->AddOwnershipEdge(classesDump->guid(), heapsDump->guid()); |
| } |
| #if ENABLE(GC_PROFILING) |