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 461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
472 // Disallow allocation during weak processing. | 472 // Disallow allocation during weak processing. |
473 // It would be technically safe to allow allocations, but it is unsafe | 473 // It would be technically safe to allow allocations, but it is unsafe |
474 // to mutate an object graph in a way in which a dead object gets | 474 // to mutate an object graph in a way in which a dead object gets |
475 // resurrected or mutate a HashTable (because HashTable's weak processing | 475 // resurrected or mutate a HashTable (because HashTable's weak processing |
476 // assumes that the HashTable hasn't been mutated since the latest marking). | 476 // assumes that the HashTable hasn't been mutated since the latest marking). |
477 // Due to the complexity, we just forbid allocations. | 477 // Due to the complexity, we just forbid allocations. |
478 NoAllocationScope noAllocationScope(this); | 478 NoAllocationScope noAllocationScope(this); |
479 | 479 |
480 GCForbiddenScope gcForbiddenScope(this); | 480 GCForbiddenScope gcForbiddenScope(this); |
481 std::unique_ptr<Visitor> visitor = | 481 std::unique_ptr<Visitor> visitor = |
482 Visitor::create(this, Visitor::WeakProcessing); | 482 Visitor::create(this, VisitorMarkingMode::WeakProcessing); |
483 | 483 |
484 // Perform thread-specific weak processing. | 484 // Perform thread-specific weak processing. |
485 while (popAndInvokeThreadLocalWeakCallback(visitor.get())) { | 485 while (popAndInvokeThreadLocalWeakCallback(visitor.get())) { |
486 } | 486 } |
487 | 487 |
488 m_threadLocalWeakCallbackStack->decommit(); | 488 m_threadLocalWeakCallbackStack->decommit(); |
489 | 489 |
490 if (isMainThread()) { | 490 if (isMainThread()) { |
491 double timeForThreadLocalWeakProcessing = WTF::currentTimeMS() - startTime; | 491 double timeForThreadLocalWeakProcessing = WTF::currentTimeMS() - startTime; |
492 DEFINE_STATIC_LOCAL( | 492 DEFINE_STATIC_LOCAL( |
(...skipping 1197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1690 | 1690 |
1691 // Resume all parked threads upon leaving this scope. | 1691 // Resume all parked threads upon leaving this scope. |
1692 ParkThreadsScope parkThreadsScope(this); | 1692 ParkThreadsScope parkThreadsScope(this); |
1693 | 1693 |
1694 // Try to park the other threads. If we're unable to, bail out of the GC. | 1694 // Try to park the other threads. If we're unable to, bail out of the GC. |
1695 if (!parkThreadsScope.parkThreads()) | 1695 if (!parkThreadsScope.parkThreads()) |
1696 return; | 1696 return; |
1697 | 1697 |
1698 std::unique_ptr<Visitor> visitor; | 1698 std::unique_ptr<Visitor> visitor; |
1699 if (gcType == BlinkGC::TakeSnapshot) { | 1699 if (gcType == BlinkGC::TakeSnapshot) { |
1700 visitor = Visitor::create(this, Visitor::SnapshotMarking); | 1700 visitor = Visitor::create(this, VisitorMarkingMode::SnapshotMarking); |
1701 } else { | 1701 } else { |
1702 DCHECK(gcType == BlinkGC::GCWithSweep || gcType == BlinkGC::GCWithoutSweep); | 1702 DCHECK(gcType == BlinkGC::GCWithSweep || gcType == BlinkGC::GCWithoutSweep); |
1703 if (heap().compaction()->shouldCompact(this, gcType, reason)) { | 1703 if (heap().compaction()->shouldCompact(this, gcType, reason)) { |
1704 heap().compaction()->initialize(this); | 1704 heap().compaction()->initialize(this); |
1705 visitor = Visitor::create(this, Visitor::GlobalMarkingWithCompaction); | 1705 visitor = Visitor::create( |
| 1706 this, VisitorMarkingMode::GlobalMarkingWithCompaction); |
1706 } else { | 1707 } else { |
1707 visitor = Visitor::create(this, Visitor::GlobalMarking); | 1708 visitor = Visitor::create(this, VisitorMarkingMode::GlobalMarking); |
1708 } | 1709 } |
1709 } | 1710 } |
1710 | 1711 |
1711 ScriptForbiddenIfMainThreadScope scriptForbidden; | 1712 ScriptForbiddenIfMainThreadScope scriptForbidden; |
1712 | 1713 |
1713 TRACE_EVENT2("blink_gc,devtools.timeline", "BlinkGCMarking", "lazySweeping", | 1714 TRACE_EVENT2("blink_gc,devtools.timeline", "BlinkGCMarking", "lazySweeping", |
1714 gcType == BlinkGC::GCWithoutSweep, "gcReason", | 1715 gcType == BlinkGC::GCWithoutSweep, "gcReason", |
1715 gcReasonString(reason)); | 1716 gcReasonString(reason)); |
1716 double startTime = WTF::currentTimeMS(); | 1717 double startTime = WTF::currentTimeMS(); |
1717 | 1718 |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1803 } | 1804 } |
1804 | 1805 |
1805 void ThreadState::collectGarbageForTerminatingThread() { | 1806 void ThreadState::collectGarbageForTerminatingThread() { |
1806 { | 1807 { |
1807 // A thread-specific termination GC must not allow other global GCs to go | 1808 // A thread-specific termination GC must not allow other global GCs to go |
1808 // ahead while it is running, hence the termination GC does not enter a | 1809 // ahead while it is running, hence the termination GC does not enter a |
1809 // safepoint. VisitorScope will not enter also a safepoint scope for | 1810 // safepoint. VisitorScope will not enter also a safepoint scope for |
1810 // ThreadTerminationGC. | 1811 // ThreadTerminationGC. |
1811 GCForbiddenScope gcForbiddenScope(this); | 1812 GCForbiddenScope gcForbiddenScope(this); |
1812 std::unique_ptr<Visitor> visitor = | 1813 std::unique_ptr<Visitor> visitor = |
1813 Visitor::create(this, Visitor::ThreadLocalMarking); | 1814 Visitor::create(this, VisitorMarkingMode::ThreadLocalMarking); |
1814 | 1815 |
1815 NoAllocationScope noAllocationScope(this); | 1816 NoAllocationScope noAllocationScope(this); |
1816 | 1817 |
1817 heap().commitCallbackStacks(); | 1818 heap().commitCallbackStacks(); |
1818 preGC(); | 1819 preGC(); |
1819 | 1820 |
1820 // 1. Trace the thread local persistent roots. For thread local GCs we | 1821 // 1. Trace the thread local persistent roots. For thread local GCs we |
1821 // don't trace the stack (ie. no conservative scanning) since this is | 1822 // don't trace the stack (ie. no conservative scanning) since this is |
1822 // only called during thread shutdown where there should be no objects | 1823 // only called during thread shutdown where there should be no objects |
1823 // on the stack. | 1824 // on the stack. |
(...skipping 25 matching lines...) Expand all Loading... |
1849 collectGarbage(BlinkGC::NoHeapPointersOnStack, BlinkGC::GCWithSweep, | 1850 collectGarbage(BlinkGC::NoHeapPointersOnStack, BlinkGC::GCWithSweep, |
1850 BlinkGC::ForcedGC); | 1851 BlinkGC::ForcedGC); |
1851 size_t liveObjects = heap().heapStats().markedObjectSize(); | 1852 size_t liveObjects = heap().heapStats().markedObjectSize(); |
1852 if (liveObjects == previousLiveObjects) | 1853 if (liveObjects == previousLiveObjects) |
1853 break; | 1854 break; |
1854 previousLiveObjects = liveObjects; | 1855 previousLiveObjects = liveObjects; |
1855 } | 1856 } |
1856 } | 1857 } |
1857 | 1858 |
1858 } // namespace blink | 1859 } // namespace blink |
OLD | NEW |