Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(76)

Side by Side Diff: third_party/WebKit/Source/bindings/core/v8/V8GCController.cpp

Issue 1447563002: Implement frame attribution (FrameBlamer) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Cleanup. Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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/BlameContext.h"
54 #include "public/platform/Platform.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 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 objectGroupingForMajorGC(isolate, constructRetainedObjectInfos); 263 objectGroupingForMajorGC(isolate, constructRetainedObjectInfos);
262 } 264 }
263 265
264 } // namespace 266 } // namespace
265 267
266 void V8GCController::gcPrologue(v8::Isolate* isolate, v8::GCType type, v8::GCCal lbackFlags flags) 268 void V8GCController::gcPrologue(v8::Isolate* isolate, v8::GCType type, v8::GCCal lbackFlags flags)
267 { 269 {
268 if (isMainThread()) 270 if (isMainThread())
269 ScriptForbiddenScope::enter(); 271 ScriptForbiddenScope::enter();
270 272
273 // Attribute garbage collection to the entire thread instead of a specific
274 // frame.
275 if (BlameContext* blameContext = Platform::current()->threadBlameContext())
276 blameContext->Enter();
277
271 // TODO(haraken): A GC callback is not allowed to re-enter V8. This means 278 // TODO(haraken): A GC callback is not allowed to re-enter V8. This means
272 // that it's unsafe to run Oilpan's GC in the GC callback because it may 279 // that it's unsafe to run Oilpan's GC in the GC callback because it may
273 // run finalizers that call into V8. To avoid the risk, we should post 280 // run finalizers that call into V8. To avoid the risk, we should post
274 // a task to schedule the Oilpan's GC. 281 // a task to schedule the Oilpan's GC.
275 // (In practice, there is no finalizer that calls into V8 and thus is safe.) 282 // (In practice, there is no finalizer that calls into V8 and thus is safe.)
276 283
277 v8::HandleScope scope(isolate); 284 v8::HandleScope scope(isolate);
278 switch (type) { 285 switch (type) {
279 case v8::kGCTypeScavenge: 286 case v8::kGCTypeScavenge:
280 if (ThreadState::current()) 287 if (ThreadState::current())
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 case v8::kGCTypeProcessWeakCallbacks: 332 case v8::kGCTypeProcessWeakCallbacks:
326 TRACE_EVENT_END1("devtools.timeline,v8", "MajorGC", "usedHeapSizeAfter", usedHeapSize(isolate)); 333 TRACE_EVENT_END1("devtools.timeline,v8", "MajorGC", "usedHeapSizeAfter", usedHeapSize(isolate));
327 break; 334 break;
328 default: 335 default:
329 ASSERT_NOT_REACHED(); 336 ASSERT_NOT_REACHED();
330 } 337 }
331 338
332 if (isMainThread()) 339 if (isMainThread())
333 ScriptForbiddenScope::exit(); 340 ScriptForbiddenScope::exit();
334 341
342 if (BlameContext* blameContext = Platform::current()->threadBlameContext())
343 blameContext->Leave();
344
335 // v8::kGCCallbackFlagForced forces a Blink heap garbage collection 345 // v8::kGCCallbackFlagForced forces a Blink heap garbage collection
336 // when a garbage collection was forced from V8. This is either used 346 // when a garbage collection was forced from V8. This is either used
337 // for tests that force GCs from JavaScript to verify that objects die 347 // for tests that force GCs from JavaScript to verify that objects die
338 // when expected. 348 // when expected.
339 if (flags & v8::kGCCallbackFlagForced) { 349 if (flags & v8::kGCCallbackFlagForced) {
340 // This single GC is not enough for two reasons: 350 // This single GC is not enough for two reasons:
341 // (1) The GC is not precise because the GC scans on-stack pointers co nservatively. 351 // (1) The GC is not precise because the GC scans on-stack pointers co nservatively.
342 // (2) One GC is not enough to break a chain of persistent handles. It 's possible that 352 // (2) One GC is not enough to break a chain of persistent handles. It 's possible that
343 // some heap allocated objects own objects that contain persistent handles 353 // some heap allocated objects own objects that contain persistent handles
344 // pointing to other heap allocated objects. To break the chain, w e need multiple GCs. 354 // pointing to other heap allocated objects. To break the chain, w e need multiple GCs.
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
488 498
489 DEFINE_THREAD_SAFE_STATIC_LOCAL(CustomCountHistogram, scanPendingActivityHis togram, new CustomCountHistogram("Blink.ScanPendingActivityDuration", 1, 1000, 5 0)); 499 DEFINE_THREAD_SAFE_STATIC_LOCAL(CustomCountHistogram, scanPendingActivityHis togram, new CustomCountHistogram("Blink.ScanPendingActivityDuration", 1, 1000, 5 0));
490 double startTime = WTF::currentTimeMS(); 500 double startTime = WTF::currentTimeMS();
491 PendingActivityVisitor visitor(executionContext); 501 PendingActivityVisitor visitor(executionContext);
492 toIsolate(executionContext)->VisitHandlesWithClassIds(&visitor); 502 toIsolate(executionContext)->VisitHandlesWithClassIds(&visitor);
493 scanPendingActivityHistogram.count(static_cast<int>(WTF::currentTimeMS() - s tartTime)); 503 scanPendingActivityHistogram.count(static_cast<int>(WTF::currentTimeMS() - s tartTime));
494 return visitor.pendingActivityFound(); 504 return visitor.pendingActivityFound();
495 } 505 }
496 506
497 } // namespace blink 507 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698