Index: Source/platform/heap/ThreadState.cpp |
diff --git a/Source/platform/heap/ThreadState.cpp b/Source/platform/heap/ThreadState.cpp |
index 8c04580dfc449885f57d413eae4add969da34d43..6b28a80f937b90cbc314b7988a4d26ae870501a1 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) |
{ |
@@ -1376,6 +1390,7 @@ void ThreadState::promptlyFreed(size_t gcInfoIndex) |
void ThreadState::takeSnapshot() |
{ |
+ GCSnapshotInfo info; |
ASSERT(isInGC()); |
int numberOfHeapsReported = 0; |
@@ -1384,7 +1399,8 @@ void ThreadState::takeSnapshot() |
numberOfHeapsReported++; \ |
String allocatorBaseName; \ |
allocatorBaseName = String::format("blink_gc/thread_%lu/heaps/" #HeapType, (unsigned long)(m_thread)); \ |
- m_heaps[HeapType##HeapIndex]->takeSnapshot(allocatorBaseName); \ |
+ m_heaps[HeapType##HeapIndex]->takeSnapshot(allocatorBaseName, info); \ |
+ m_heaps[HeapType##HeapIndex]->takeFreelistSnapshot(allocatorBaseName); \ |
} |
SNAPSHOT_HEAP(NormalPage1); |
@@ -1404,6 +1420,20 @@ void ThreadState::takeSnapshot() |
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 classDumpName = classNameVector[i].isolatedCopy(); |
+ classDumpName.insert(String("blink_gc/classes/"), 0); |
+ WebMemoryAllocatorDump* classDump = BlinkGCMemoryDumpProvider::instance()->createMemoryAllocatorDumpForCurrentGC(classDumpName); |
+ 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) |