Index: Source/platform/heap/Heap.cpp |
diff --git a/Source/platform/heap/Heap.cpp b/Source/platform/heap/Heap.cpp |
index da86dc9910321051af139a72fb216daa19533166..621bb84b897e4f6d3578f44b3cb5ed9df3768c0a 100644 |
--- a/Source/platform/heap/Heap.cpp |
+++ b/Source/platform/heap/Heap.cpp |
@@ -34,6 +34,7 @@ |
#include "platform/ScriptForbiddenScope.h" |
#include "platform/Task.h" |
#include "platform/TraceEvent.h" |
+#include "platform/heap/BlinkGCMemoryDumpProvider.h" |
#include "platform/heap/CallbackStack.h" |
#include "platform/heap/MarkingVisitor.h" |
#include "platform/heap/PageMemory.h" |
@@ -41,6 +42,7 @@ |
#include "platform/heap/SafePoint.h" |
#include "platform/heap/ThreadState.h" |
#include "public/platform/Platform.h" |
+#include "public/platform/WebMemoryAllocatorDump.h" |
#include "wtf/Assertions.h" |
#include "wtf/ContainerAnnotations.h" |
#include "wtf/LeakAnnotations.h" |
@@ -213,6 +215,16 @@ void BaseHeap::cleanupPages() |
m_firstPage = nullptr; |
} |
+void BaseHeap::takeSnapshot(const String& dumpBaseName) |
+{ |
+ size_t pageCount = 0; |
+ for (BasePage* page = m_firstPage; page; page = page->next()) { |
+ pageCount++; |
+ } |
+ WebMemoryAllocatorDump* allocatorDump = BlinkGCMemoryDumpProvider::instance()->createMemoryAllocatorDumpForCurrentGC(dumpBaseName); |
+ allocatorDump->AddScalar("blink_page_count", "objects", pageCount); |
+} |
+ |
#if ENABLE(ASSERT) || ENABLE(GC_PROFILING) |
BasePage* BaseHeap::findPageFromAddress(Address address) |
{ |
@@ -1635,10 +1647,15 @@ void Heap::init() |
s_estimatedMarkingTimePerByte = 0.0; |
GCInfoTable::init(); |
+ |
+ if (Platform::current()->currentThread()) |
+ Platform::current()->registerMemoryDumpProvider(BlinkGCMemoryDumpProvider::instance()); |
} |
void Heap::shutdown() |
{ |
+ if (Platform::current()->currentThread()) |
+ Platform::current()->unregisterMemoryDumpProvider(BlinkGCMemoryDumpProvider::instance()); |
s_shutdownCalled = true; |
ThreadState::shutdownHeapIfNecessary(); |
} |