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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 #include "core/dom/NodeTraversal.h" | 44 #include "core/dom/NodeTraversal.h" |
45 #include "core/dom/TemplateContentDocumentFragment.h" | 45 #include "core/dom/TemplateContentDocumentFragment.h" |
46 #include "core/dom/shadow/ElementShadow.h" | 46 #include "core/dom/shadow/ElementShadow.h" |
47 #include "core/dom/shadow/ShadowRoot.h" | 47 #include "core/dom/shadow/ShadowRoot.h" |
48 #include "core/html/HTMLTemplateElement.h" | 48 #include "core/html/HTMLTemplateElement.h" |
49 #include "core/html/imports/HTMLImportsController.h" | 49 #include "core/html/imports/HTMLImportsController.h" |
50 #include "core/inspector/InspectorTraceEvents.h" | 50 #include "core/inspector/InspectorTraceEvents.h" |
51 #include "core/svg/SVGElement.h" | 51 #include "core/svg/SVGElement.h" |
52 #include "platform/Histogram.h" | 52 #include "platform/Histogram.h" |
53 #include "platform/TraceEvent.h" | 53 #include "platform/TraceEvent.h" |
| 54 #include "public/platform/BlameContext.h" |
| 55 #include "public/platform/Platform.h" |
54 #include "wtf/Partitions.h" | 56 #include "wtf/Partitions.h" |
55 #include "wtf/Vector.h" | 57 #include "wtf/Vector.h" |
56 #include <algorithm> | 58 #include <algorithm> |
57 | 59 |
58 namespace blink { | 60 namespace blink { |
59 | 61 |
60 // FIXME: This should use opaque GC roots. | 62 // FIXME: This should use opaque GC roots. |
61 static void addReferencesForNodeWithEventListeners(v8::Isolate* isolate, Node* n
ode, const v8::Persistent<v8::Object>& wrapper) | 63 static void addReferencesForNodeWithEventListeners(v8::Isolate* isolate, Node* n
ode, const v8::Persistent<v8::Object>& wrapper) |
62 { | 64 { |
63 ASSERT(node->hasEventListeners()); | 65 ASSERT(node->hasEventListeners()); |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
262 objectGroupingForMajorGC(isolate, constructRetainedObjectInfos); | 264 objectGroupingForMajorGC(isolate, constructRetainedObjectInfos); |
263 } | 265 } |
264 | 266 |
265 } // namespace | 267 } // namespace |
266 | 268 |
267 void V8GCController::gcPrologue(v8::Isolate* isolate, v8::GCType type, v8::GCCal
lbackFlags flags) | 269 void V8GCController::gcPrologue(v8::Isolate* isolate, v8::GCType type, v8::GCCal
lbackFlags flags) |
268 { | 270 { |
269 if (isMainThread()) | 271 if (isMainThread()) |
270 ScriptForbiddenScope::enter(); | 272 ScriptForbiddenScope::enter(); |
271 | 273 |
| 274 // Attribute garbage collection to the all frames instead of a specific |
| 275 // frame. |
| 276 if (BlameContext* blameContext = Platform::current()->topLevelBlameContext()
) |
| 277 blameContext->Enter(); |
| 278 |
272 // TODO(haraken): A GC callback is not allowed to re-enter V8. This means | 279 // TODO(haraken): A GC callback is not allowed to re-enter V8. This means |
273 // that it's unsafe to run Oilpan's GC in the GC callback because it may | 280 // that it's unsafe to run Oilpan's GC in the GC callback because it may |
274 // run finalizers that call into V8. To avoid the risk, we should post | 281 // run finalizers that call into V8. To avoid the risk, we should post |
275 // a task to schedule the Oilpan's GC. | 282 // a task to schedule the Oilpan's GC. |
276 // (In practice, there is no finalizer that calls into V8 and thus is safe.) | 283 // (In practice, there is no finalizer that calls into V8 and thus is safe.) |
277 | 284 |
278 v8::HandleScope scope(isolate); | 285 v8::HandleScope scope(isolate); |
279 switch (type) { | 286 switch (type) { |
280 case v8::kGCTypeScavenge: | 287 case v8::kGCTypeScavenge: |
281 if (ThreadState::current()) | 288 if (ThreadState::current()) |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
326 case v8::kGCTypeProcessWeakCallbacks: | 333 case v8::kGCTypeProcessWeakCallbacks: |
327 TRACE_EVENT_END1("devtools.timeline,v8", "MajorGC", "usedHeapSizeAfter",
usedHeapSize(isolate)); | 334 TRACE_EVENT_END1("devtools.timeline,v8", "MajorGC", "usedHeapSizeAfter",
usedHeapSize(isolate)); |
328 break; | 335 break; |
329 default: | 336 default: |
330 ASSERT_NOT_REACHED(); | 337 ASSERT_NOT_REACHED(); |
331 } | 338 } |
332 | 339 |
333 if (isMainThread()) | 340 if (isMainThread()) |
334 ScriptForbiddenScope::exit(); | 341 ScriptForbiddenScope::exit(); |
335 | 342 |
| 343 if (BlameContext* blameContext = Platform::current()->topLevelBlameContext()
) |
| 344 blameContext->Leave(); |
| 345 |
336 // v8::kGCCallbackFlagForced forces a Blink heap garbage collection | 346 // v8::kGCCallbackFlagForced forces a Blink heap garbage collection |
337 // when a garbage collection was forced from V8. This is either used | 347 // when a garbage collection was forced from V8. This is either used |
338 // for tests that force GCs from JavaScript to verify that objects die | 348 // for tests that force GCs from JavaScript to verify that objects die |
339 // when expected. | 349 // when expected. |
340 if (flags & v8::kGCCallbackFlagForced) { | 350 if (flags & v8::kGCCallbackFlagForced) { |
341 // This single GC is not enough for two reasons: | 351 // This single GC is not enough for two reasons: |
342 // (1) The GC is not precise because the GC scans on-stack pointers co
nservatively. | 352 // (1) The GC is not precise because the GC scans on-stack pointers co
nservatively. |
343 // (2) One GC is not enough to break a chain of persistent handles. It
's possible that | 353 // (2) One GC is not enough to break a chain of persistent handles. It
's possible that |
344 // some heap allocated objects own objects that contain persistent
handles | 354 // some heap allocated objects own objects that contain persistent
handles |
345 // pointing to other heap allocated objects. To break the chain, w
e need multiple GCs. | 355 // pointing to other heap allocated objects. To break the chain, w
e need multiple GCs. |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
493 DEFINE_THREAD_SAFE_STATIC_LOCAL(CustomCountHistogram, scanPendingActivityHis
togram, new CustomCountHistogram("Blink.ScanPendingActivityDuration", 1, 1000, 5
0)); | 503 DEFINE_THREAD_SAFE_STATIC_LOCAL(CustomCountHistogram, scanPendingActivityHis
togram, new CustomCountHistogram("Blink.ScanPendingActivityDuration", 1, 1000, 5
0)); |
494 double startTime = WTF::currentTimeMS(); | 504 double startTime = WTF::currentTimeMS(); |
495 v8::HandleScope scope(isolate); | 505 v8::HandleScope scope(isolate); |
496 PendingActivityVisitor visitor(isolate, executionContext); | 506 PendingActivityVisitor visitor(isolate, executionContext); |
497 toIsolate(executionContext)->VisitHandlesWithClassIds(&visitor); | 507 toIsolate(executionContext)->VisitHandlesWithClassIds(&visitor); |
498 scanPendingActivityHistogram.count(static_cast<int>(WTF::currentTimeMS() - s
tartTime)); | 508 scanPendingActivityHistogram.count(static_cast<int>(WTF::currentTimeMS() - s
tartTime)); |
499 return visitor.pendingActivityFound(); | 509 return visitor.pendingActivityFound(); |
500 } | 510 } |
501 | 511 |
502 } // namespace blink | 512 } // namespace blink |
OLD | NEW |