Chromium Code Reviews| Index: Source/platform/heap/Heap.cpp |
| diff --git a/Source/platform/heap/Heap.cpp b/Source/platform/heap/Heap.cpp |
| index 3fef547f1660fe8dc9a2fddf735d751d6e8f191d..d9baebd1951d0718ff4ba720370b51c115697154 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::dumpMemory(const String& dumpBaseName) |
| +{ |
| + size_t pageCount = 0; |
| + for (BasePage* page = m_firstPage; page; page = page->next()) { |
| + pageCount++; |
| + } |
| + WebMemoryAllocatorDump* allocatorDump = BlinkGCMemoryDumpProvider::instance()->createMemoryAllocatorDumpForLastGC(dumpBaseName); |
| + allocatorDump->AddScalar("blink_page_count", "objects", pageCount); |
| +} |
| + |
| #if ENABLE(ASSERT) || ENABLE(GC_PROFILING) |
| BasePage* BaseHeap::findPageFromAddress(Address address) |
| { |
| @@ -1625,10 +1637,16 @@ 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(); |
| } |
| @@ -1863,9 +1881,21 @@ void Heap::preGC() |
| void Heap::postGC(ThreadState::GCType gcType) |
| { |
| + bool enabled = BlinkGCMemoryDumpProvider::isMemoryTracingEnabled(); |
|
Primiano Tucci (use gerrit)
2015/05/26 11:24:06
nit: const bool isMemoryTracingEnabled = BlinkGCMe
ssid
2015/05/27 13:15:06
Done.
|
| + if (enabled) |
| + BlinkGCMemoryDumpProvider::instance()->clearLastGCProcessMemoryDump(); |
| + |
| ASSERT(ThreadState::current()->isInGC()); |
| - for (ThreadState* state : ThreadState::attachedThreads()) |
| + for (ThreadState* state : ThreadState::attachedThreads()) { |
| + if (enabled) |
| + state->dumpMemory(); |
|
haraken
2015/05/26 12:21:59
postGC wouldn't be a good timing to take memory du
Primiano Tucci (use gerrit)
2015/05/26 14:18:03
Oh, I think did it in PostGC because the existing
|
| + |
| state->postGC(gcType); |
| + } |
| + |
| + // TODO(ssid): Request global dump from blink when support is available |
| + // (crbug.com/490087). For the moment the dump is periodically invoked by |
| + // the MemoryDumpManager every X secs. |
| } |
| const char* Heap::gcReasonString(GCReason reason) |