| 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 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 349 // This single GC is not enough for two reasons: | 349 // This single GC is not enough for two reasons: |
| 350 // (1) The GC is not precise because the GC scans on-stack pointers co
nservatively. | 350 // (1) The GC is not precise because the GC scans on-stack pointers co
nservatively. |
| 351 // (2) One GC is not enough to break a chain of persistent handles. It
's possible that | 351 // (2) One GC is not enough to break a chain of persistent handles. It
's possible that |
| 352 // some heap allocated objects own objects that contain persistent
handles | 352 // some heap allocated objects own objects that contain persistent
handles |
| 353 // pointing to other heap allocated objects. To break the chain, w
e need multiple GCs. | 353 // pointing to other heap allocated objects. To break the chain, w
e need multiple GCs. |
| 354 // | 354 // |
| 355 // Regarding (1), we force a precise GC at the end of the current event
loop. So if you want | 355 // Regarding (1), we force a precise GC at the end of the current event
loop. So if you want |
| 356 // to collect all garbage, you need to wait until the next event loop. | 356 // to collect all garbage, you need to wait until the next event loop. |
| 357 // Regarding (2), it would be OK in practice to trigger only one GC per
gcEpilogue, because | 357 // Regarding (2), it would be OK in practice to trigger only one GC per
gcEpilogue, because |
| 358 // GCController.collectAll() forces multiple V8's GC. | 358 // GCController.collectAll() forces multiple V8's GC. |
| 359 ThreadHeap::collectGarbage(BlinkGC::HeapPointersOnStack, BlinkGC::GCWith
Sweep, BlinkGC::ForcedGC); | 359 Heap::collectGarbage(BlinkGC::HeapPointersOnStack, BlinkGC::GCWithSweep,
BlinkGC::ForcedGC); |
| 360 | 360 |
| 361 // Forces a precise GC at the end of the current event loop. | 361 // Forces a precise GC at the end of the current event loop. |
| 362 if (ThreadState::current()) { | 362 if (ThreadState::current()) { |
| 363 RELEASE_ASSERT(!ThreadState::current()->isInGC()); | 363 RELEASE_ASSERT(!ThreadState::current()->isInGC()); |
| 364 ThreadState::current()->setGCState(ThreadState::FullGCScheduled); | 364 ThreadState::current()->setGCState(ThreadState::FullGCScheduled); |
| 365 } | 365 } |
| 366 } | 366 } |
| 367 | 367 |
| 368 // v8::kGCCallbackFlagCollectAllAvailableGarbage is used when V8 handles | 368 // v8::kGCCallbackFlagCollectAllAvailableGarbage is used when V8 handles |
| 369 // low memory notifications. | 369 // low memory notifications. |
| 370 if (flags & v8::kGCCallbackFlagCollectAllAvailableGarbage) { | 370 if (flags & v8::kGCCallbackFlagCollectAllAvailableGarbage) { |
| 371 // This single GC is not enough. See the above comment. | 371 // This single GC is not enough. See the above comment. |
| 372 ThreadHeap::collectGarbage(BlinkGC::HeapPointersOnStack, BlinkGC::GCWith
Sweep, BlinkGC::ForcedGC); | 372 Heap::collectGarbage(BlinkGC::HeapPointersOnStack, BlinkGC::GCWithSweep,
BlinkGC::ForcedGC); |
| 373 | 373 |
| 374 // Do not force a precise GC at the end of the current event loop. | 374 // Do not force a precise GC at the end of the current event loop. |
| 375 // According to UMA stats, the collection rate of the precise GC | 375 // According to UMA stats, the collection rate of the precise GC |
| 376 // scheduled at the end of the low memory handling is extremely low, | 376 // scheduled at the end of the low memory handling is extremely low, |
| 377 // because the above conservative GC is sufficient for collecting | 377 // because the above conservative GC is sufficient for collecting |
| 378 // most objects. So we intentionally don't schedule a precise GC here. | 378 // most objects. So we intentionally don't schedule a precise GC here. |
| 379 } | 379 } |
| 380 | 380 |
| 381 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "Update
Counters", TRACE_EVENT_SCOPE_THREAD, "data", InspectorUpdateCountersEvent::data(
)); | 381 TRACE_EVENT_INSTANT1(TRACE_DISABLED_BY_DEFAULT("devtools.timeline"), "Update
Counters", TRACE_EVENT_SCOPE_THREAD, "data", InspectorUpdateCountersEvent::data(
)); |
| 382 } | 382 } |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 480 DEFINE_THREAD_SAFE_STATIC_LOCAL(CustomCountHistogram, scanPendingActivityHis
togram, new CustomCountHistogram("Blink.ScanPendingActivityDuration", 1, 1000, 5
0)); | 480 DEFINE_THREAD_SAFE_STATIC_LOCAL(CustomCountHistogram, scanPendingActivityHis
togram, new CustomCountHistogram("Blink.ScanPendingActivityDuration", 1, 1000, 5
0)); |
| 481 double startTime = WTF::currentTimeMS(); | 481 double startTime = WTF::currentTimeMS(); |
| 482 v8::HandleScope scope(isolate); | 482 v8::HandleScope scope(isolate); |
| 483 PendingActivityVisitor visitor(isolate, executionContext); | 483 PendingActivityVisitor visitor(isolate, executionContext); |
| 484 toIsolate(executionContext)->VisitHandlesWithClassIds(&visitor); | 484 toIsolate(executionContext)->VisitHandlesWithClassIds(&visitor); |
| 485 scanPendingActivityHistogram.count(static_cast<int>(WTF::currentTimeMS() - s
tartTime)); | 485 scanPendingActivityHistogram.count(static_cast<int>(WTF::currentTimeMS() - s
tartTime)); |
| 486 return visitor.pendingActivityFound(); | 486 return visitor.pendingActivityFound(); |
| 487 } | 487 } |
| 488 | 488 |
| 489 } // namespace blink | 489 } // namespace blink |
| OLD | NEW |