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

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

Issue 1477023003: Refactor the Heap into ThreadHeap to prepare for per thread heaps Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 // This single GC is not enough for two reasons: 340 // 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. 341 // (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 342 // (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 343 // 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. 344 // pointing to other heap allocated objects. To break the chain, w e need multiple GCs.
345 // 345 //
346 // Regarding (1), we force a precise GC at the end of the current event loop. So if you want 346 // Regarding (1), we force a precise GC at the end of the current event loop. So if you want
347 // to collect all garbage, you need to wait until the next event loop. 347 // to collect all garbage, you need to wait until the next event loop.
348 // Regarding (2), it would be OK in practice to trigger only one GC per gcEpilogue, because 348 // Regarding (2), it would be OK in practice to trigger only one GC per gcEpilogue, because
349 // GCController.collectAll() forces multiple V8's GC. 349 // GCController.collectAll() forces multiple V8's GC.
350 Heap::collectGarbage(BlinkGC::HeapPointersOnStack, BlinkGC::GCWithSweep, BlinkGC::ForcedGC); 350 ThreadHeap::collectGarbage(BlinkGC::HeapPointersOnStack, BlinkGC::GCWith Sweep, BlinkGC::ForcedGC);
351 351
352 // Forces a precise GC at the end of the current event loop. 352 // Forces a precise GC at the end of the current event loop.
353 if (ThreadState::current()) { 353 if (ThreadState::current()) {
354 RELEASE_ASSERT(!ThreadState::current()->isInGC()); 354 RELEASE_ASSERT(!ThreadState::current()->isInGC());
355 ThreadState::current()->setGCState(ThreadState::FullGCScheduled); 355 ThreadState::current()->setGCState(ThreadState::FullGCScheduled);
356 } 356 }
357 } 357 }
358 358
359 // v8::kGCCallbackFlagCollectAllAvailableGarbage is used when V8 handles 359 // v8::kGCCallbackFlagCollectAllAvailableGarbage is used when V8 handles
360 // low memory notifications. 360 // low memory notifications.
361 if (flags & v8::kGCCallbackFlagCollectAllAvailableGarbage) { 361 if (flags & v8::kGCCallbackFlagCollectAllAvailableGarbage) {
362 // This single GC is not enough. See the above comment. 362 // This single GC is not enough. See the above comment.
363 Heap::collectGarbage(BlinkGC::HeapPointersOnStack, BlinkGC::GCWithSweep, BlinkGC::ForcedGC); 363 ThreadHeap::collectGarbage(BlinkGC::HeapPointersOnStack, BlinkGC::GCWith Sweep, BlinkGC::ForcedGC);
364 364
365 // Do not force a precise GC at the end of the current event loop. 365 // Do not force a precise GC at the end of the current event loop.
366 // According to UMA stats, the collection rate of the precise GC 366 // According to UMA stats, the collection rate of the precise GC
367 // scheduled at the end of the low memory handling is extremely low, 367 // scheduled at the end of the low memory handling is extremely low,
368 // because the above conservative GC is sufficient for collecting 368 // because the above conservative GC is sufficient for collecting
369 // most objects. So we intentionally don't schedule a precise GC here. 369 // most objects. So we intentionally don't schedule a precise GC here.
370 } 370 }
371 371
372 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "Update Counters", TRACE_EVENT_SCOPE_THREAD, "data", InspectorUpdateCountersEvent::data( )); 372 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "Update Counters", TRACE_EVENT_SCOPE_THREAD, "data", InspectorUpdateCountersEvent::data( ));
373 } 373 }
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
488 488
489 DEFINE_THREAD_SAFE_STATIC_LOCAL(CustomCountHistogram, scanPendingActivityHis togram, new CustomCountHistogram("Blink.ScanPendingActivityDuration", 1, 1000, 5 0)); 489 DEFINE_THREAD_SAFE_STATIC_LOCAL(CustomCountHistogram, scanPendingActivityHis togram, new CustomCountHistogram("Blink.ScanPendingActivityDuration", 1, 1000, 5 0));
490 double startTime = WTF::currentTimeMS(); 490 double startTime = WTF::currentTimeMS();
491 PendingActivityVisitor visitor(executionContext); 491 PendingActivityVisitor visitor(executionContext);
492 toIsolate(executionContext)->VisitHandlesWithClassIds(&visitor); 492 toIsolate(executionContext)->VisitHandlesWithClassIds(&visitor);
493 scanPendingActivityHistogram.count(static_cast<int>(WTF::currentTimeMS() - s tartTime)); 493 scanPendingActivityHistogram.count(static_cast<int>(WTF::currentTimeMS() - s tartTime));
494 return visitor.pendingActivityFound(); 494 return visitor.pendingActivityFound();
495 } 495 }
496 496
497 } // namespace blink 497 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698