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

Unified Diff: Source/bindings/v8/V8GCController.cpp

Issue 301743006: Report DOM partitionAlloc size to V8 GC. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 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/bindings/v8/V8GCController.cpp
diff --git a/Source/bindings/v8/V8GCController.cpp b/Source/bindings/v8/V8GCController.cpp
index 5af7b234619775b879b93a29707a24e302f1a738..0a37a1cdae5c5c15e94770c9f9741e089eda599a 100644
--- a/Source/bindings/v8/V8GCController.cpp
+++ b/Source/bindings/v8/V8GCController.cpp
@@ -48,6 +48,7 @@
#include "core/html/HTMLTemplateElement.h"
#include "core/inspector/InspectorTraceEvents.h"
#include "core/svg/SVGElement.h"
+#include "platform/Partitions.h"
#include "platform/TraceEvent.h"
namespace WebCore {
@@ -319,6 +320,7 @@ void V8GCController::gcPrologue(v8::GCType type, v8::GCCallbackFlags flags)
// FIXME: It would be nice if the GC callbacks passed the Isolate directly....
v8::Isolate* isolate = v8::Isolate::GetCurrent();
TRACE_EVENT_BEGIN1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "GCEvent", "usedHeapSizeBefore", usedHeapSize(isolate));
+ reportDOMMemoryUsageToV8(isolate);
if (type == v8::kGCTypeScavenge)
minorGCPrologue(isolate);
else if (type == v8::kGCTypeMarkSweepCompact)
@@ -417,4 +419,18 @@ void V8GCController::collectGarbage(v8::Isolate* isolate)
V8ScriptRunner::compileAndRunInternalScript(v8String(isolate, "if (gc) gc();"), isolate);
}
+void V8GCController::reportDOMMemoryUsageToV8(v8::Isolate* isolate)
+{
+ if (!isMainThread())
jochen (gone - plz use gerrit) 2014/05/28 07:23:03 why?
kouhei (in TOK) 2014/05/28 07:35:20 We only want to notify main thread isolate, as all
+ return;
+
+ static size_t lastUsageReportedToV8 = 0;
+
+ size_t currentUsage = Partitions::currentDOMMemoryUsage();
+ ssize_t diff = static_cast<ssize_t>(currentUsage) - static_cast<ssize_t>(lastUsageReportedToV8);
+ isolate->AdjustAmountOfExternalAllocatedMemory(diff);
+
+ lastUsageReportedToV8 = currentUsage;
+}
+
} // namespace WebCore

Powered by Google App Engine
This is Rietveld 408576698