| Index: Source/platform/heap/Heap.cpp
|
| diff --git a/Source/platform/heap/Heap.cpp b/Source/platform/heap/Heap.cpp
|
| index 71ffd4fe938cf55e8bbaf6f19b47d8f5c285fae0..725a025011133b6bcee970fbcf12516d28b73430 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"
|
| @@ -257,6 +259,16 @@ void BaseHeap::cleanupPages()
|
| m_firstPage = nullptr;
|
| }
|
|
|
| +void BaseHeap::takeSnapshot(const String& dumpBaseName)
|
| +{
|
| + size_t pageCount = 0;
|
| + for (BasePage* page = m_firstUnsweptPage; 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)
|
| {
|
| @@ -1746,10 +1758,15 @@ void Heap::init()
|
| s_estimatedMarkingTimePerByte = 0.0;
|
|
|
| GCInfoTable::init();
|
| +
|
| + if (Platform::current() && Platform::current()->currentThread())
|
| + Platform::current()->registerMemoryDumpProvider(BlinkGCMemoryDumpProvider::instance());
|
| }
|
|
|
| void Heap::shutdown()
|
| {
|
| + if (Platform::current() && Platform::current()->currentThread())
|
| + Platform::current()->unregisterMemoryDumpProvider(BlinkGCMemoryDumpProvider::instance());
|
| s_shutdownCalled = true;
|
| ThreadState::shutdownHeapIfNecessary();
|
| }
|
| @@ -2003,6 +2020,9 @@ void Heap::collectGarbage(ThreadState::StackState stackState, ThreadState::GCTyp
|
| TRACE_EVENT_SCOPED_SAMPLING_STATE("blink_gc", "BlinkGC");
|
| double timeStamp = WTF::currentTimeMS();
|
|
|
| + if (gcType == ThreadState::TakeSnapshot)
|
| + BlinkGCMemoryDumpProvider::instance()->clearProcessDumpForCurrentGC();
|
| +
|
| // Disallow allocation during garbage collection (but not during the
|
| // finalization that happens when the gcScope is torn down).
|
| ThreadState::NoAllocationScope noAllocationScope(state);
|
|
|