Chromium Code Reviews| 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 |