Index: Source/platform/heap/ThreadState.cpp |
diff --git a/Source/platform/heap/ThreadState.cpp b/Source/platform/heap/ThreadState.cpp |
index 6128cc158873b46a2adad6c85f38efdd4d6e7305..7cb24a5767344b19ca2a976aa1793ab9a06d8430 100644 |
--- a/Source/platform/heap/ThreadState.cpp |
+++ b/Source/platform/heap/ThreadState.cpp |
@@ -33,12 +33,14 @@ |
#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/WebScheduler.h" |
#include "public/platform/WebThread.h" |
#include "public/platform/WebTraceLocation.h" |
@@ -380,6 +382,18 @@ void ThreadState::visitPersistents(Visitor* visitor) |
} |
} |
+size_t ThreadState::GCSnapshotInfo::getClassTag(const GCInfo* gcInfo) |
+{ |
+ ClassTagMap::AddResult result = classTags.add(gcInfo, 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) |
{ |
@@ -1378,6 +1392,7 @@ void ThreadState::promptlyFreed(size_t gcInfoIndex) |
void ThreadState::takeSnapshot(SnapshotType type) |
{ |
+ GCSnapshotInfo info; |
ASSERT(isInGC()); |
int numberOfHeapsReported = 0; |
@@ -1388,7 +1403,7 @@ void ThreadState::takeSnapshot(SnapshotType type) |
allocatorBaseName = String::format("blink_gc/thread_%lu/heaps/" #HeapType, (unsigned long)(m_thread)); \ |
switch (type) { \ |
case SnapshotType::HeapSnapshot: \ |
- m_heaps[HeapType##HeapIndex]->takeSnapshot(allocatorBaseName); \ |
+ m_heaps[HeapType##HeapIndex]->takeSnapshot(allocatorBaseName, info); \ |
break; \ |
case SnapshotType::FreelistSnapshot: \ |
m_heaps[HeapType##HeapIndex]->takeFreelistSnapshot(allocatorBaseName); \ |
@@ -1415,6 +1430,19 @@ void ThreadState::takeSnapshot(SnapshotType type) |
ASSERT(numberOfHeapsReported == NumberOfHeaps); |
#undef SNAPSHOT_HEAP |
+ |
+ Vector<String> classNameVector(info.classTags.size()); |
+ for (GCSnapshotInfo::ClassTagMap::iterator it = info.classTags.begin(); it != info.classTags.end(); ++it) |
+ classNameVector[it->value] = it->key->m_className; |
+ |
+ for (size_t i = 0; i < classNameVector.size(); ++i) { |
+ String dumpName = String::format("blink_gc/thread_%lu/classes/", (unsigned long)(m_thread)) + 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]); |
+ } |
} |
#if ENABLE(GC_PROFILING) |