| 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 1678 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1689 heap().m_lastGCReason = reason; | 1689 heap().m_lastGCReason = reason; |
| 1690 | 1690 |
| 1691 ThreadHeap::reportMemoryUsageHistogram(); | 1691 ThreadHeap::reportMemoryUsageHistogram(); |
| 1692 WTF::Partitions::reportMemoryUsageHistogram(); | 1692 WTF::Partitions::reportMemoryUsageHistogram(); |
| 1693 } | 1693 } |
| 1694 | 1694 |
| 1695 heap().postGC(gcType); | 1695 heap().postGC(gcType); |
| 1696 heap().decommitCallbackStacks(); | 1696 heap().decommitCallbackStacks(); |
| 1697 } | 1697 } |
| 1698 | 1698 |
| 1699 void ThreadState::collectGarbageForTerminatingThread() { | |
| 1700 // A thread-specific termination GC must not allow other global GCs to go | |
| 1701 // ahead while it is running, hence the termination GC does not enter a | |
| 1702 // safepoint. VisitorScope will not enter also a safepoint scope for | |
| 1703 // ThreadTerminationGC. | |
| 1704 GCForbiddenScope gcForbiddenScope(this); | |
| 1705 | |
| 1706 { | |
| 1707 std::unique_ptr<Visitor> visitor = | |
| 1708 Visitor::create(this, VisitorMarkingMode::ThreadLocalMarking); | |
| 1709 | |
| 1710 NoAllocationScope noAllocationScope(this); | |
| 1711 | |
| 1712 heap().commitCallbackStacks(); | |
| 1713 preGC(); | |
| 1714 | |
| 1715 // 1. Trace the thread local persistent roots. For thread local GCs we | |
| 1716 // don't trace the stack (ie. no conservative scanning) since this is | |
| 1717 // only called during thread shutdown where there should be no objects | |
| 1718 // on the stack. | |
| 1719 // We also assume that orphaned pages have no objects reachable from | |
| 1720 // persistent handles on other threads or CrossThreadPersistents. The | |
| 1721 // only cases where this could happen is if a subsequent conservative | |
| 1722 // global GC finds a "pointer" on the stack or due to a programming | |
| 1723 // error where an object has a dangling cross-thread pointer to an | |
| 1724 // object on this heap. | |
| 1725 visitPersistents(visitor.get()); | |
| 1726 | |
| 1727 // 2. Trace objects reachable from the thread's persistent roots | |
| 1728 // including ephemerons. | |
| 1729 heap().processMarkingStack(visitor.get()); | |
| 1730 | |
| 1731 heap().postMarkingProcessing(visitor.get()); | |
| 1732 heap().globalWeakProcessing(visitor.get()); | |
| 1733 } | |
| 1734 | |
| 1735 postGC(BlinkGC::GCWithSweep); | |
| 1736 heap().decommitCallbackStacks(); | |
| 1737 } | |
| 1738 | |
| 1739 void ThreadState::collectAllGarbage() { | 1699 void ThreadState::collectAllGarbage() { |
| 1740 // We need to run multiple GCs to collect a chain of persistent handles. | 1700 // We need to run multiple GCs to collect a chain of persistent handles. |
| 1741 size_t previousLiveObjects = 0; | 1701 size_t previousLiveObjects = 0; |
| 1742 for (int i = 0; i < 5; ++i) { | 1702 for (int i = 0; i < 5; ++i) { |
| 1743 collectGarbage(BlinkGC::NoHeapPointersOnStack, BlinkGC::GCWithSweep, | 1703 collectGarbage(BlinkGC::NoHeapPointersOnStack, BlinkGC::GCWithSweep, |
| 1744 BlinkGC::ForcedGC); | 1704 BlinkGC::ForcedGC); |
| 1745 size_t liveObjects = heap().heapStats().markedObjectSize(); | 1705 size_t liveObjects = heap().heapStats().markedObjectSize(); |
| 1746 if (liveObjects == previousLiveObjects) | 1706 if (liveObjects == previousLiveObjects) |
| 1747 break; | 1707 break; |
| 1748 previousLiveObjects = liveObjects; | 1708 previousLiveObjects = liveObjects; |
| 1749 } | 1709 } |
| 1750 } | 1710 } |
| 1751 | 1711 |
| 1752 } // namespace blink | 1712 } // namespace blink |
| OLD | NEW |