Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2117)

Unified Diff: Source/platform/heap/Heap.cpp

Issue 1149673002: Adding blink gc memory dump infrastructure for thread specific dumps. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fixing nits. Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/platform/heap/Heap.cpp
diff --git a/Source/platform/heap/Heap.cpp b/Source/platform/heap/Heap.cpp
index 3fef547f1660fe8dc9a2fddf735d751d6e8f191d..b8a8b7ff5a3ef792467aa30caa04b0dc3ee98f67 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,8 @@
#include "platform/heap/SafePoint.h"
#include "platform/heap/ThreadState.h"
#include "public/platform/Platform.h"
+#include "public/platform/WebMemoryAllocatorDump.h"
+#include "public/platform/WebProcessMemoryDump.h"
Primiano Tucci (use gerrit) 2015/05/22 19:45:57 I think you don't need this anymore
ssid 2015/05/26 11:08:43 Done.
#include "wtf/Assertions.h"
#include "wtf/ContainerAnnotations.h"
#include "wtf/LeakAnnotations.h"
@@ -213,6 +216,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 +1638,16 @@ void Heap::init()
s_estimatedMarkingTimePerByte = 0.0;
GCInfoTable::init();
+
+ if (Platform::current()->mainThread())
Primiano Tucci (use gerrit) 2015/05/22 19:45:57 Question for haraken@: for production (i.e. non te
ssid 2015/05/26 11:08:43 changed it.
+ Platform::current()->registerMemoryDumpProvider(BlinkGCMemoryDumpProvider::instance());
}
void Heap::shutdown()
{
+ if (Platform::current()->mainThread())
+ Platform::current()->unregisterMemoryDumpProvider(BlinkGCMemoryDumpProvider::instance());
+
s_shutdownCalled = true;
ThreadState::shutdownHeapIfNecessary();
}
@@ -1863,9 +1882,24 @@ void Heap::preGC()
void Heap::postGC(ThreadState::GCType gcType)
{
+ // TODO(ssid): Change this to use api from memory-infra to check tracing
+ // memory_tracing_enabled (crbug.com/490087).
+ bool enabled;
Primiano Tucci (use gerrit) 2015/05/22 19:45:57 Can you encapsulate this into a "static inline boo
ssid 2015/05/26 11:08:43 Done.
+ TRACE_EVENT_CATEGORY_GROUP_ENABLED(TRACE_DISABLED_BY_DEFAULT("memory-infra"), &enabled);
+ if (enabled)
+ BlinkGCMemoryDumpProvider::instance()->clearLastProcessMemoryDump();
+
ASSERT(ThreadState::current()->isInGC());
- for (ThreadState* state : ThreadState::attachedThreads())
+ for (ThreadState* state : ThreadState::attachedThreads()) {
+ if (enabled)
+ state->dumpMemory();
+
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)

Powered by Google App Engine
This is Rietveld 408576698