OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 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 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
371 // Disallow allocation during weak processing. | 371 // Disallow allocation during weak processing. |
372 // It would be technically safe to allow allocations, but it is unsafe | 372 // It would be technically safe to allow allocations, but it is unsafe |
373 // to mutate an object graph in a way in which a dead object gets | 373 // to mutate an object graph in a way in which a dead object gets |
374 // resurrected or mutate a HashTable (because HashTable's weak processing | 374 // resurrected or mutate a HashTable (because HashTable's weak processing |
375 // assumes that the HashTable hasn't been mutated since the latest marking). | 375 // assumes that the HashTable hasn't been mutated since the latest marking). |
376 // Due to the complexity, we just forbid allocations. | 376 // Due to the complexity, we just forbid allocations. |
377 NoAllocationScope noAllocationScope(this); | 377 NoAllocationScope noAllocationScope(this); |
378 | 378 |
379 GCForbiddenScope gcForbiddenScope(this); | 379 GCForbiddenScope gcForbiddenScope(this); |
380 std::unique_ptr<Visitor> visitor = | 380 std::unique_ptr<Visitor> visitor = |
381 Visitor::create(this, VisitorMarkingMode::WeakProcessing); | 381 Visitor::create(this, Visitor::WeakProcessing); |
382 | 382 |
383 // Perform thread-specific weak processing. | 383 // Perform thread-specific weak processing. |
384 while (popAndInvokeThreadLocalWeakCallback(visitor.get())) { | 384 while (popAndInvokeThreadLocalWeakCallback(visitor.get())) { |
385 } | 385 } |
386 | 386 |
387 m_threadLocalWeakCallbackStack->decommit(); | 387 m_threadLocalWeakCallbackStack->decommit(); |
388 | 388 |
389 if (isMainThread()) { | 389 if (isMainThread()) { |
390 double timeForThreadLocalWeakProcessing = WTF::currentTimeMS() - startTime; | 390 double timeForThreadLocalWeakProcessing = WTF::currentTimeMS() - startTime; |
391 DEFINE_STATIC_LOCAL( | 391 DEFINE_STATIC_LOCAL( |
(...skipping 1180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1572 | 1572 |
1573 // Resume all parked threads upon leaving this scope. | 1573 // Resume all parked threads upon leaving this scope. |
1574 ParkThreadsScope parkThreadsScope(this); | 1574 ParkThreadsScope parkThreadsScope(this); |
1575 | 1575 |
1576 // Try to park the other threads. If we're unable to, bail out of the GC. | 1576 // Try to park the other threads. If we're unable to, bail out of the GC. |
1577 if (!parkThreadsScope.parkThreads()) | 1577 if (!parkThreadsScope.parkThreads()) |
1578 return; | 1578 return; |
1579 | 1579 |
1580 std::unique_ptr<Visitor> visitor; | 1580 std::unique_ptr<Visitor> visitor; |
1581 if (gcType == BlinkGC::TakeSnapshot) { | 1581 if (gcType == BlinkGC::TakeSnapshot) { |
1582 visitor = Visitor::create(this, VisitorMarkingMode::SnapshotMarking); | 1582 visitor = Visitor::create(this, Visitor::SnapshotMarking); |
1583 } else { | 1583 } else { |
1584 DCHECK(gcType == BlinkGC::GCWithSweep || | 1584 DCHECK(gcType == BlinkGC::GCWithSweep || |
1585 gcType == BlinkGC::GCWithoutSweep); | 1585 gcType == BlinkGC::GCWithoutSweep); |
1586 if (heap().compaction()->shouldCompact(this, gcType, reason)) { | 1586 if (heap().compaction()->shouldCompact(this, gcType, reason)) { |
1587 heap().compaction()->initialize(this); | 1587 heap().compaction()->initialize(this); |
1588 visitor = Visitor::create( | 1588 visitor = Visitor::create(this, Visitor::GlobalMarkingWithCompaction); |
1589 this, VisitorMarkingMode::GlobalMarkingWithCompaction); | |
1590 } else { | 1589 } else { |
1591 visitor = Visitor::create(this, VisitorMarkingMode::GlobalMarking); | 1590 visitor = Visitor::create(this, Visitor::GlobalMarking); |
1592 } | 1591 } |
1593 } | 1592 } |
1594 | 1593 |
1595 ScriptForbiddenIfMainThreadScope scriptForbidden; | 1594 ScriptForbiddenIfMainThreadScope scriptForbidden; |
1596 | 1595 |
1597 TRACE_EVENT2("blink_gc,devtools.timeline", "BlinkGCMarking", "lazySweeping", | 1596 TRACE_EVENT2("blink_gc,devtools.timeline", "BlinkGCMarking", "lazySweeping", |
1598 gcType == BlinkGC::GCWithoutSweep, "gcReason", | 1597 gcType == BlinkGC::GCWithoutSweep, "gcReason", |
1599 gcReasonString(reason)); | 1598 gcReasonString(reason)); |
1600 double startTime = WTF::currentTimeMS(); | 1599 double startTime = WTF::currentTimeMS(); |
1601 | 1600 |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1685 collectGarbage(BlinkGC::NoHeapPointersOnStack, BlinkGC::GCWithSweep, | 1684 collectGarbage(BlinkGC::NoHeapPointersOnStack, BlinkGC::GCWithSweep, |
1686 BlinkGC::ForcedGC); | 1685 BlinkGC::ForcedGC); |
1687 size_t liveObjects = heap().heapStats().markedObjectSize(); | 1686 size_t liveObjects = heap().heapStats().markedObjectSize(); |
1688 if (liveObjects == previousLiveObjects) | 1687 if (liveObjects == previousLiveObjects) |
1689 break; | 1688 break; |
1690 previousLiveObjects = liveObjects; | 1689 previousLiveObjects = liveObjects; |
1691 } | 1690 } |
1692 } | 1691 } |
1693 | 1692 |
1694 } // namespace blink | 1693 } // namespace blink |
OLD | NEW |