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/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/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/WebBlameContext.h" |
54 #include "wtf/Partitions.h" | 55 #include "wtf/Partitions.h" |
55 #include "wtf/Vector.h" | 56 #include "wtf/Vector.h" |
56 #include <algorithm> | 57 #include <algorithm> |
57 | 58 |
58 namespace blink { | 59 namespace blink { |
59 | 60 |
60 // FIXME: This should use opaque GC roots. | 61 // FIXME: This should use opaque GC roots. |
61 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) |
62 { | 63 { |
63 ASSERT(node->hasEventListeners()); | 64 ASSERT(node->hasEventListeners()); |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
268 | 269 |
269 void gcPrologueForMajorGC(v8::Isolate* isolate, bool constructRetainedObjectInfo
s) | 270 void gcPrologueForMajorGC(v8::Isolate* isolate, bool constructRetainedObjectInfo
s) |
270 { | 271 { |
271 objectGroupingForMajorGC(isolate, constructRetainedObjectInfos); | 272 objectGroupingForMajorGC(isolate, constructRetainedObjectInfos); |
272 } | 273 } |
273 | 274 |
274 } // namespace | 275 } // namespace |
275 | 276 |
276 void V8GCController::gcPrologue(v8::Isolate* isolate, v8::GCType type, v8::GCCal
lbackFlags flags) | 277 void V8GCController::gcPrologue(v8::Isolate* isolate, v8::GCType type, v8::GCCal
lbackFlags flags) |
277 { | 278 { |
278 if (isMainThread()) | 279 if (isMainThread()) { |
279 ScriptForbiddenScope::enter(); | 280 ScriptForbiddenScope::enter(); |
| 281 // Attribute garbage collection to the entire thread instead of a specif
ic |
| 282 // frame. |
| 283 } |
| 284 |
| 285 if (WebBlameContext* blame_context = Platform::current()->threadBlameContext
()) |
| 286 blame_context->enter(); |
280 | 287 |
281 // TODO(haraken): A GC callback is not allowed to re-enter V8. This means | 288 // TODO(haraken): A GC callback is not allowed to re-enter V8. This means |
282 // that it's unsafe to run Oilpan's GC in the GC callback because it may | 289 // that it's unsafe to run Oilpan's GC in the GC callback because it may |
283 // run finalizers that call into V8. To avoid the risk, we should post | 290 // run finalizers that call into V8. To avoid the risk, we should post |
284 // a task to schedule the Oilpan's GC. | 291 // a task to schedule the Oilpan's GC. |
285 // (In practice, there is no finalizer that calls into V8 and thus is safe.) | 292 // (In practice, there is no finalizer that calls into V8 and thus is safe.) |
286 | 293 |
287 v8::HandleScope scope(isolate); | |
288 switch (type) { | 294 switch (type) { |
289 case v8::kGCTypeScavenge: | 295 case v8::kGCTypeScavenge: |
290 if (ThreadState::current()) | 296 if (ThreadState::current()) |
291 ThreadState::current()->willStartV8GC(BlinkGC::V8MinorGC); | 297 ThreadState::current()->willStartV8GC(BlinkGC::V8MinorGC); |
292 | 298 |
293 TRACE_EVENT_BEGIN1("devtools.timeline,v8", "MinorGC", "usedHeapSizeBefor
e", usedHeapSize(isolate)); | 299 TRACE_EVENT_BEGIN1("devtools.timeline,v8", "MinorGC", "usedHeapSizeBefor
e", usedHeapSize(isolate)); |
294 visitWeakHandlesForMinorGC(isolate); | 300 visitWeakHandlesForMinorGC(isolate); |
295 break; | 301 break; |
296 case v8::kGCTypeMarkSweepCompact: | 302 case v8::kGCTypeMarkSweepCompact: |
297 if (ThreadState::current()) | 303 if (ThreadState::current()) |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
332 case v8::kGCTypeIncrementalMarking: | 338 case v8::kGCTypeIncrementalMarking: |
333 TRACE_EVENT_END1("devtools.timeline,v8", "MajorGC", "usedHeapSizeAfter",
usedHeapSize(isolate)); | 339 TRACE_EVENT_END1("devtools.timeline,v8", "MajorGC", "usedHeapSizeAfter",
usedHeapSize(isolate)); |
334 break; | 340 break; |
335 case v8::kGCTypeProcessWeakCallbacks: | 341 case v8::kGCTypeProcessWeakCallbacks: |
336 TRACE_EVENT_END1("devtools.timeline,v8", "MajorGC", "usedHeapSizeAfter",
usedHeapSize(isolate)); | 342 TRACE_EVENT_END1("devtools.timeline,v8", "MajorGC", "usedHeapSizeAfter",
usedHeapSize(isolate)); |
337 break; | 343 break; |
338 default: | 344 default: |
339 ASSERT_NOT_REACHED(); | 345 ASSERT_NOT_REACHED(); |
340 } | 346 } |
341 | 347 |
342 if (isMainThread()) | 348 if (isMainThread()) { |
343 ScriptForbiddenScope::exit(); | 349 ScriptForbiddenScope::exit(); |
| 350 } |
| 351 |
| 352 if (WebBlameContext* blame_context = Platform::current()->threadBlameContext
()) |
| 353 blame_context->leave(); |
344 | 354 |
345 // v8::kGCCallbackFlagForced forces a Blink heap garbage collection | 355 // v8::kGCCallbackFlagForced forces a Blink heap garbage collection |
346 // when a garbage collection was forced from V8. This is either used | 356 // when a garbage collection was forced from V8. This is either used |
347 // for tests that force GCs from JavaScript to verify that objects die | 357 // for tests that force GCs from JavaScript to verify that objects die |
348 // when expected, or when handling memory pressure notifications. | 358 // when expected, or when handling memory pressure notifications. |
349 if (flags & v8::kGCCallbackFlagForced) { | 359 if (flags & v8::kGCCallbackFlagForced) { |
350 // This single GC is not enough for two reasons: | 360 // This single GC is not enough for two reasons: |
351 // (1) The GC is not precise because the GC scans on-stack pointers co
nservatively. | 361 // (1) The GC is not precise because the GC scans on-stack pointers co
nservatively. |
352 // (2) One GC is not enough to break a chain of persistent handles. It
's possible that | 362 // (2) One GC is not enough to break a chain of persistent handles. It
's possible that |
353 // some heap allocated objects own objects that contain persistent
handles | 363 // some heap allocated objects own objects that contain persistent
handles |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
485 | 495 |
486 DEFINE_THREAD_SAFE_STATIC_LOCAL(CustomCountHistogram, scanPendingActivityHis
togram, new CustomCountHistogram("Blink.ScanPendingActivityDuration", 1, 1000, 5
0)); | 496 DEFINE_THREAD_SAFE_STATIC_LOCAL(CustomCountHistogram, scanPendingActivityHis
togram, new CustomCountHistogram("Blink.ScanPendingActivityDuration", 1, 1000, 5
0)); |
487 double startTime = WTF::currentTimeMS(); | 497 double startTime = WTF::currentTimeMS(); |
488 PendingActivityVisitor visitor(executionContext); | 498 PendingActivityVisitor visitor(executionContext); |
489 toIsolate(executionContext)->VisitHandlesWithClassIds(&visitor); | 499 toIsolate(executionContext)->VisitHandlesWithClassIds(&visitor); |
490 scanPendingActivityHistogram.count(static_cast<int>(WTF::currentTimeMS() - s
tartTime)); | 500 scanPendingActivityHistogram.count(static_cast<int>(WTF::currentTimeMS() - s
tartTime)); |
491 return visitor.pendingActivityFound(); | 501 return visitor.pendingActivityFound(); |
492 } | 502 } |
493 | 503 |
494 } // namespace blink | 504 } // namespace blink |
OLD | NEW |