| Index: Source/platform/heap/ThreadState.cpp
|
| diff --git a/Source/platform/heap/ThreadState.cpp b/Source/platform/heap/ThreadState.cpp
|
| index d8cdece435b143ebbc3fcebf7e01af93fcf22b28..b1f0df82434ffaa24913fcbd2707b312f8bc6132 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"
|
| @@ -380,6 +383,18 @@ void ThreadState::visitPersistents(Visitor* visitor)
|
| }
|
| }
|
|
|
| +size_t ThreadState::GCSnapshotInfo::getClassTag(const size_t gcInfoIndex)
|
| +{
|
| + ClassTagMap::AddResult result = classTags.add(gcInfoIndex, classTags.size());
|
| + if (result.isNewEntry) {
|
| + liveCount.append(0);
|
| + deadCount.append(0);
|
| + liveSize.append(0);
|
| + deadSize.append(0);
|
| + }
|
| + return result.storedValue->value;
|
| +}
|
| +
|
| #if ENABLE(GC_PROFILING)
|
| const GCInfo* ThreadState::findGCInfo(Address address)
|
| {
|
| @@ -1381,22 +1396,25 @@ void ThreadState::takeSnapshot(SnapshotType type)
|
| ASSERT(isInGC());
|
|
|
| GCSnapshotInfo info;
|
| + String threadDumpName = String::format("blink_gc/thread_%lu", (unsigned long)m_thread);
|
| + String heapsDumpName = threadDumpName + "/heaps";
|
| + 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, info); \
|
| - 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: \
|
| + case SnapshotType::HeapSnapshotWithClasses: \
|
| + 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);
|
| @@ -1416,6 +1434,44 @@ void ThreadState::takeSnapshot(SnapshotType type)
|
| ASSERT(numberOfHeapsReported == NumberOfHeaps);
|
|
|
| #undef SNAPSHOT_HEAP
|
| +
|
| + if (type != SnapshotType::HeapSnapshotWithClasses)
|
| + return;
|
| +
|
| + if (!info.classTags.size())
|
| + return;
|
| +
|
| + Vector<String> classNameVector(info.classTags.size());
|
| + for (GCSnapshotInfo::ClassTagMap::iterator it = info.classTags.begin(); it != info.classTags.end(); ++it)
|
| + classNameVector[it->value] = Heap::gcInfo(it->key)->m_className;
|
| +
|
| + size_t totalLiveCount = 0;
|
| + size_t totalDeadCount = 0;
|
| + size_t totalLiveSize = 0;
|
| + size_t totalDeadSize = 0;
|
| + for (size_t i = 0; i < classNameVector.size(); ++i) {
|
| + String dumpName = classesDumpName + "/" + classNameVector[i];
|
| + 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)
|
|
|