OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 30 matching lines...) Expand all Loading... | |
41 #include "bindings/v8/WrapperTypeInfo.h" | 41 #include "bindings/v8/WrapperTypeInfo.h" |
42 #include "core/dom/Attr.h" | 42 #include "core/dom/Attr.h" |
43 #include "core/dom/NodeTraversal.h" | 43 #include "core/dom/NodeTraversal.h" |
44 #include "core/dom/TemplateContentDocumentFragment.h" | 44 #include "core/dom/TemplateContentDocumentFragment.h" |
45 #include "core/dom/shadow/ElementShadow.h" | 45 #include "core/dom/shadow/ElementShadow.h" |
46 #include "core/dom/shadow/ShadowRoot.h" | 46 #include "core/dom/shadow/ShadowRoot.h" |
47 #include "core/html/HTMLImageElement.h" | 47 #include "core/html/HTMLImageElement.h" |
48 #include "core/html/HTMLTemplateElement.h" | 48 #include "core/html/HTMLTemplateElement.h" |
49 #include "core/inspector/InspectorTraceEvents.h" | 49 #include "core/inspector/InspectorTraceEvents.h" |
50 #include "core/svg/SVGElement.h" | 50 #include "core/svg/SVGElement.h" |
51 #include "platform/Partitions.h" | |
51 #include "platform/TraceEvent.h" | 52 #include "platform/TraceEvent.h" |
52 | 53 |
53 namespace WebCore { | 54 namespace WebCore { |
54 | 55 |
55 // FIXME: This should use opaque GC roots. | 56 // FIXME: This should use opaque GC roots. |
56 static void addReferencesForNodeWithEventListeners(v8::Isolate* isolate, Node* n ode, const v8::Persistent<v8::Object>& wrapper) | 57 static void addReferencesForNodeWithEventListeners(v8::Isolate* isolate, Node* n ode, const v8::Persistent<v8::Object>& wrapper) |
57 { | 58 { |
58 ASSERT(node->hasEventListeners()); | 59 ASSERT(node->hasEventListeners()); |
59 | 60 |
60 EventListenerIterator iterator(node); | 61 EventListenerIterator iterator(node); |
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
312 v8::HeapStatistics heapStatistics; | 313 v8::HeapStatistics heapStatistics; |
313 isolate->GetHeapStatistics(&heapStatistics); | 314 isolate->GetHeapStatistics(&heapStatistics); |
314 return heapStatistics.used_heap_size(); | 315 return heapStatistics.used_heap_size(); |
315 } | 316 } |
316 | 317 |
317 void V8GCController::gcPrologue(v8::GCType type, v8::GCCallbackFlags flags) | 318 void V8GCController::gcPrologue(v8::GCType type, v8::GCCallbackFlags flags) |
318 { | 319 { |
319 // FIXME: It would be nice if the GC callbacks passed the Isolate directly.. .. | 320 // FIXME: It would be nice if the GC callbacks passed the Isolate directly.. .. |
320 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 321 v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
321 TRACE_EVENT_BEGIN1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "GCEvent" , "usedHeapSizeBefore", usedHeapSize(isolate)); | 322 TRACE_EVENT_BEGIN1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "GCEvent" , "usedHeapSizeBefore", usedHeapSize(isolate)); |
323 reportDOMMemoryUsageToV8(isolate); | |
322 if (type == v8::kGCTypeScavenge) | 324 if (type == v8::kGCTypeScavenge) |
323 minorGCPrologue(isolate); | 325 minorGCPrologue(isolate); |
324 else if (type == v8::kGCTypeMarkSweepCompact) | 326 else if (type == v8::kGCTypeMarkSweepCompact) |
325 majorGCPrologue(flags & v8::kGCCallbackFlagConstructRetainedObjectInfos, isolate); | 327 majorGCPrologue(flags & v8::kGCCallbackFlagConstructRetainedObjectInfos, isolate); |
326 } | 328 } |
327 | 329 |
328 void V8GCController::minorGCPrologue(v8::Isolate* isolate) | 330 void V8GCController::minorGCPrologue(v8::Isolate* isolate) |
329 { | 331 { |
330 TRACE_EVENT_BEGIN0("v8", "minorGC"); | 332 TRACE_EVENT_BEGIN0("v8", "minorGC"); |
331 if (isMainThread()) { | 333 if (isMainThread()) { |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
410 if (isMainThread()) | 412 if (isMainThread()) |
411 TRACE_EVENT_SET_NONCONST_SAMPLING_STATE(V8PerIsolateData::from(isolate)- >previousSamplingState()); | 413 TRACE_EVENT_SET_NONCONST_SAMPLING_STATE(V8PerIsolateData::from(isolate)- >previousSamplingState()); |
412 } | 414 } |
413 | 415 |
414 void V8GCController::collectGarbage(v8::Isolate* isolate) | 416 void V8GCController::collectGarbage(v8::Isolate* isolate) |
415 { | 417 { |
416 V8ExecutionScope scope(isolate); | 418 V8ExecutionScope scope(isolate); |
417 V8ScriptRunner::compileAndRunInternalScript(v8String(isolate, "if (gc) gc(); "), isolate); | 419 V8ScriptRunner::compileAndRunInternalScript(v8String(isolate, "if (gc) gc(); "), isolate); |
418 } | 420 } |
419 | 421 |
422 void V8GCController::reportDOMMemoryUsageToV8(v8::Isolate* isolate) | |
423 { | |
424 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
| |
425 return; | |
426 | |
427 static size_t lastUsageReportedToV8 = 0; | |
428 | |
429 size_t currentUsage = Partitions::currentDOMMemoryUsage(); | |
430 ssize_t diff = static_cast<ssize_t>(currentUsage) - static_cast<ssize_t>(las tUsageReportedToV8); | |
431 isolate->AdjustAmountOfExternalAllocatedMemory(diff); | |
432 | |
433 lastUsageReportedToV8 = currentUsage; | |
434 } | |
435 | |
420 } // namespace WebCore | 436 } // namespace WebCore |
OLD | NEW |