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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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/HTMLTemplateElement.h" | 47 #include "core/html/HTMLTemplateElement.h" |
48 #include "core/html/imports/HTMLImportsController.h" | 48 #include "core/html/imports/HTMLImportsController.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/Histogram.h" | 51 #include "platform/Histogram.h" |
52 #include "platform/TraceEvent.h" | 52 #include "platform/TraceEvent.h" |
| 53 #include "public/platform/Platform.h" |
| 54 #include "public/platform/WebBlameContext.h" |
53 #include "wtf/Partitions.h" | 55 #include "wtf/Partitions.h" |
54 #include "wtf/Vector.h" | 56 #include "wtf/Vector.h" |
55 #include <algorithm> | 57 #include <algorithm> |
56 | 58 |
57 namespace blink { | 59 namespace blink { |
58 | 60 |
59 // FIXME: This should use opaque GC roots. | 61 // FIXME: This should use opaque GC roots. |
60 static void addReferencesForNodeWithEventListeners(v8::Isolate* isolate, Node* n
ode, const v8::Persistent<v8::Object>& wrapper) | 62 static void addReferencesForNodeWithEventListeners(v8::Isolate* isolate, Node* n
ode, const v8::Persistent<v8::Object>& wrapper) |
61 { | 63 { |
62 ASSERT(node->hasEventListeners()); | 64 ASSERT(node->hasEventListeners()); |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
259 objectGroupingForMajorGC(isolate, constructRetainedObjectInfos); | 261 objectGroupingForMajorGC(isolate, constructRetainedObjectInfos); |
260 } | 262 } |
261 | 263 |
262 } // namespace | 264 } // namespace |
263 | 265 |
264 void V8GCController::gcPrologue(v8::Isolate* isolate, v8::GCType type, v8::GCCal
lbackFlags flags) | 266 void V8GCController::gcPrologue(v8::Isolate* isolate, v8::GCType type, v8::GCCal
lbackFlags flags) |
265 { | 267 { |
266 if (isMainThread()) | 268 if (isMainThread()) |
267 ScriptForbiddenScope::enter(); | 269 ScriptForbiddenScope::enter(); |
268 | 270 |
| 271 // Attribute garbage collection to the entire thread instead of a specific |
| 272 // frame. |
| 273 if (WebBlameContext* blameContext = Platform::current()->threadBlameContext(
)) |
| 274 blameContext->enter(); |
| 275 |
269 // TODO(haraken): A GC callback is not allowed to re-enter V8. This means | 276 // TODO(haraken): A GC callback is not allowed to re-enter V8. This means |
270 // that it's unsafe to run Oilpan's GC in the GC callback because it may | 277 // that it's unsafe to run Oilpan's GC in the GC callback because it may |
271 // run finalizers that call into V8. To avoid the risk, we should post | 278 // run finalizers that call into V8. To avoid the risk, we should post |
272 // a task to schedule the Oilpan's GC. | 279 // a task to schedule the Oilpan's GC. |
273 // (In practice, there is no finalizer that calls into V8 and thus is safe.) | 280 // (In practice, there is no finalizer that calls into V8 and thus is safe.) |
274 | 281 |
275 v8::HandleScope scope(isolate); | 282 v8::HandleScope scope(isolate); |
276 switch (type) { | 283 switch (type) { |
277 case v8::kGCTypeScavenge: | 284 case v8::kGCTypeScavenge: |
278 if (ThreadState::current()) | 285 if (ThreadState::current()) |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
323 case v8::kGCTypeProcessWeakCallbacks: | 330 case v8::kGCTypeProcessWeakCallbacks: |
324 TRACE_EVENT_END1("devtools.timeline,v8", "MajorGC", "usedHeapSizeAfter",
usedHeapSize(isolate)); | 331 TRACE_EVENT_END1("devtools.timeline,v8", "MajorGC", "usedHeapSizeAfter",
usedHeapSize(isolate)); |
325 break; | 332 break; |
326 default: | 333 default: |
327 ASSERT_NOT_REACHED(); | 334 ASSERT_NOT_REACHED(); |
328 } | 335 } |
329 | 336 |
330 if (isMainThread()) | 337 if (isMainThread()) |
331 ScriptForbiddenScope::exit(); | 338 ScriptForbiddenScope::exit(); |
332 | 339 |
| 340 if (WebBlameContext* blameContext = Platform::current()->threadBlameContext(
)) |
| 341 blameContext->leave(); |
| 342 |
333 // v8::kGCCallbackFlagForced forces a Blink heap garbage collection | 343 // v8::kGCCallbackFlagForced forces a Blink heap garbage collection |
334 // when a garbage collection was forced from V8. This is either used | 344 // when a garbage collection was forced from V8. This is either used |
335 // for tests that force GCs from JavaScript to verify that objects die | 345 // for tests that force GCs from JavaScript to verify that objects die |
336 // when expected, or when handling memory pressure notifications. | 346 // when expected, or when handling memory pressure notifications. |
337 if (flags & v8::kGCCallbackFlagForced) { | 347 if (flags & v8::kGCCallbackFlagForced) { |
338 // This single GC is not enough for two reasons: | 348 // This single GC is not enough for two reasons: |
339 // (1) The GC is not precise because the GC scans on-stack pointers co
nservatively. | 349 // (1) The GC is not precise because the GC scans on-stack pointers co
nservatively. |
340 // (2) One GC is not enough to break a chain of persistent handles. It
's possible that | 350 // (2) One GC is not enough to break a chain of persistent handles. It
's possible that |
341 // some heap allocated objects own objects that contain persistent
handles | 351 // some heap allocated objects own objects that contain persistent
handles |
342 // pointing to other heap allocated objects. To break the chain, w
e need multiple GCs. | 352 // pointing to other heap allocated objects. To break the chain, w
e need multiple GCs. |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
473 | 483 |
474 DEFINE_THREAD_SAFE_STATIC_LOCAL(CustomCountHistogram, scanPendingActivityHis
togram, new CustomCountHistogram("Blink.ScanPendingActivityDuration", 1, 1000, 5
0)); | 484 DEFINE_THREAD_SAFE_STATIC_LOCAL(CustomCountHistogram, scanPendingActivityHis
togram, new CustomCountHistogram("Blink.ScanPendingActivityDuration", 1, 1000, 5
0)); |
475 double startTime = WTF::currentTimeMS(); | 485 double startTime = WTF::currentTimeMS(); |
476 PendingActivityVisitor visitor(executionContext); | 486 PendingActivityVisitor visitor(executionContext); |
477 toIsolate(executionContext)->VisitHandlesWithClassIds(&visitor); | 487 toIsolate(executionContext)->VisitHandlesWithClassIds(&visitor); |
478 scanPendingActivityHistogram.count(static_cast<int>(WTF::currentTimeMS() - s
tartTime)); | 488 scanPendingActivityHistogram.count(static_cast<int>(WTF::currentTimeMS() - s
tartTime)); |
479 return visitor.pendingActivityFound(); | 489 return visitor.pendingActivityFound(); |
480 } | 490 } |
481 | 491 |
482 } // namespace blink | 492 } // namespace blink |
OLD | NEW |