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 1595 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1606 void Heap::flushHeapDoesNotContainCache() | 1606 void Heap::flushHeapDoesNotContainCache() |
1607 { | 1607 { |
1608 s_heapDoesNotContainCache->flush(); | 1608 s_heapDoesNotContainCache->flush(); |
1609 } | 1609 } |
1610 | 1610 |
1611 void Heap::init() | 1611 void Heap::init() |
1612 { | 1612 { |
1613 ThreadState::init(); | 1613 ThreadState::init(); |
1614 s_markingStack = new CallbackStack(); | 1614 s_markingStack = new CallbackStack(); |
1615 s_postMarkingCallbackStack = new CallbackStack(); | 1615 s_postMarkingCallbackStack = new CallbackStack(); |
1616 s_weakCallbackStack = new CallbackStack(); | 1616 s_globalWeakCallbackStack = new CallbackStack(); |
1617 s_ephemeronStack = new CallbackStack(); | 1617 s_ephemeronStack = new CallbackStack(); |
1618 s_heapDoesNotContainCache = new HeapDoesNotContainCache(); | 1618 s_heapDoesNotContainCache = new HeapDoesNotContainCache(); |
1619 s_markingVisitor = new MarkingVisitor<Visitor::GlobalMarking>(); | 1619 s_markingVisitor = new MarkingVisitor<Visitor::GlobalMarking>(); |
1620 s_freePagePool = new FreePagePool(); | 1620 s_freePagePool = new FreePagePool(); |
1621 s_orphanedPagePool = new OrphanedPagePool(); | 1621 s_orphanedPagePool = new OrphanedPagePool(); |
1622 s_allocatedObjectSize = 0; | 1622 s_allocatedObjectSize = 0; |
1623 s_allocatedSpace = 0; | 1623 s_allocatedSpace = 0; |
1624 s_markedObjectSize = 0; | 1624 s_markedObjectSize = 0; |
1625 s_estimatedMarkingTimePerByte = 0.0; | 1625 s_estimatedMarkingTimePerByte = 0.0; |
1626 | 1626 |
(...skipping 14 matching lines...) Expand all Loading... |
1641 | 1641 |
1642 ASSERT(!ThreadState::attachedThreads().size()); | 1642 ASSERT(!ThreadState::attachedThreads().size()); |
1643 delete s_markingVisitor; | 1643 delete s_markingVisitor; |
1644 s_markingVisitor = nullptr; | 1644 s_markingVisitor = nullptr; |
1645 delete s_heapDoesNotContainCache; | 1645 delete s_heapDoesNotContainCache; |
1646 s_heapDoesNotContainCache = nullptr; | 1646 s_heapDoesNotContainCache = nullptr; |
1647 delete s_freePagePool; | 1647 delete s_freePagePool; |
1648 s_freePagePool = nullptr; | 1648 s_freePagePool = nullptr; |
1649 delete s_orphanedPagePool; | 1649 delete s_orphanedPagePool; |
1650 s_orphanedPagePool = nullptr; | 1650 s_orphanedPagePool = nullptr; |
1651 delete s_weakCallbackStack; | 1651 delete s_globalWeakCallbackStack; |
1652 s_weakCallbackStack = nullptr; | 1652 s_globalWeakCallbackStack = nullptr; |
1653 delete s_postMarkingCallbackStack; | 1653 delete s_postMarkingCallbackStack; |
1654 s_postMarkingCallbackStack = nullptr; | 1654 s_postMarkingCallbackStack = nullptr; |
1655 delete s_markingStack; | 1655 delete s_markingStack; |
1656 s_markingStack = nullptr; | 1656 s_markingStack = nullptr; |
1657 delete s_ephemeronStack; | 1657 delete s_ephemeronStack; |
1658 s_ephemeronStack = nullptr; | 1658 s_ephemeronStack = nullptr; |
1659 delete s_regionTree; | 1659 delete s_regionTree; |
1660 s_regionTree = nullptr; | 1660 s_regionTree = nullptr; |
1661 GCInfoTable::shutdown(); | 1661 GCInfoTable::shutdown(); |
1662 ThreadState::shutdown(); | 1662 ThreadState::shutdown(); |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1787 | 1787 |
1788 bool Heap::popAndInvokePostMarkingCallback(Visitor* visitor) | 1788 bool Heap::popAndInvokePostMarkingCallback(Visitor* visitor) |
1789 { | 1789 { |
1790 if (CallbackStack::Item* item = s_postMarkingCallbackStack->pop()) { | 1790 if (CallbackStack::Item* item = s_postMarkingCallbackStack->pop()) { |
1791 item->call(visitor); | 1791 item->call(visitor); |
1792 return true; | 1792 return true; |
1793 } | 1793 } |
1794 return false; | 1794 return false; |
1795 } | 1795 } |
1796 | 1796 |
1797 void Heap::pushWeakCellPointerCallback(void** cell, WeakPointerCallback callback
) | 1797 void Heap::pushGlobalWeakCallback(void** cell, WeakPointerCallback callback) |
1798 { | 1798 { |
1799 ASSERT(!Heap::orphanedPagePool()->contains(cell)); | 1799 ASSERT(!Heap::orphanedPagePool()->contains(cell)); |
1800 CallbackStack::Item* slot = s_weakCallbackStack->allocateEntry(); | 1800 CallbackStack::Item* slot = s_globalWeakCallbackStack->allocateEntry(); |
1801 *slot = CallbackStack::Item(cell, callback); | 1801 *slot = CallbackStack::Item(cell, callback); |
1802 } | 1802 } |
1803 | 1803 |
1804 void Heap::pushWeakPointerCallback(void* closure, void* object, WeakPointerCallb
ack callback) | 1804 void Heap::pushThreadLocalWeakCallback(void* closure, void* object, WeakPointerC
allback callback) |
1805 { | 1805 { |
1806 BasePage* page = pageFromObject(object); | 1806 BasePage* page = pageFromObject(object); |
1807 ASSERT(!page->orphaned()); | 1807 ASSERT(!page->orphaned()); |
1808 ThreadState* state = page->heap()->threadState(); | 1808 ThreadState* state = page->heap()->threadState(); |
1809 state->pushWeakPointerCallback(closure, callback); | 1809 state->pushThreadLocalWeakCallback(closure, callback); |
1810 } | 1810 } |
1811 | 1811 |
1812 bool Heap::popAndInvokeWeakPointerCallback(Visitor* visitor) | 1812 bool Heap::popAndInvokeGlobalWeakCallback(Visitor* visitor) |
1813 { | 1813 { |
1814 // For weak processing we should never reach orphaned pages since orphaned | 1814 // For weak processing we should never reach orphaned pages since orphaned |
1815 // pages are not traced and thus objects on those pages are never be | 1815 // pages are not traced and thus objects on those pages are never be |
1816 // registered as objects on orphaned pages. We cannot assert this here | 1816 // registered as objects on orphaned pages. We cannot assert this here |
1817 // since we might have an off-heap collection. We assert it in | 1817 // since we might have an off-heap collection. We assert it in |
1818 // Heap::pushWeakPointerCallback. | 1818 // Heap::pushWeakPointerCallback. |
1819 if (CallbackStack::Item* item = s_weakCallbackStack->pop()) { | 1819 if (CallbackStack::Item* item = s_globalWeakCallbackStack->pop()) { |
1820 item->call(visitor); | 1820 item->call(visitor); |
1821 return true; | 1821 return true; |
1822 } | 1822 } |
1823 return false; | 1823 return false; |
1824 } | 1824 } |
1825 | 1825 |
1826 void Heap::registerWeakTable(void* table, EphemeronCallback iterationCallback, E
phemeronCallback iterationDoneCallback) | 1826 void Heap::registerWeakTable(void* table, EphemeronCallback iterationCallback, E
phemeronCallback iterationDoneCallback) |
1827 { | 1827 { |
1828 { | 1828 { |
1829 // Check that the ephemeron table being pushed onto the stack is not on | 1829 // Check that the ephemeron table being pushed onto the stack is not on |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2033 // Post-marking callbacks should not trace any objects and | 2033 // Post-marking callbacks should not trace any objects and |
2034 // therefore the marking stack should be empty after the | 2034 // therefore the marking stack should be empty after the |
2035 // post-marking callbacks. | 2035 // post-marking callbacks. |
2036 ASSERT(s_markingStack->isEmpty()); | 2036 ASSERT(s_markingStack->isEmpty()); |
2037 } | 2037 } |
2038 | 2038 |
2039 void Heap::globalWeakProcessing(Visitor* markingVisitor) | 2039 void Heap::globalWeakProcessing(Visitor* markingVisitor) |
2040 { | 2040 { |
2041 TRACE_EVENT0("blink_gc", "Heap::globalWeakProcessing"); | 2041 TRACE_EVENT0("blink_gc", "Heap::globalWeakProcessing"); |
2042 // Call weak callbacks on objects that may now be pointing to dead objects. | 2042 // Call weak callbacks on objects that may now be pointing to dead objects. |
2043 while (popAndInvokeWeakPointerCallback(markingVisitor)) { } | 2043 while (popAndInvokeGlobalWeakCallback(markingVisitor)) { } |
2044 | 2044 |
2045 // It is not permitted to trace pointers of live objects in the weak | 2045 // It is not permitted to trace pointers of live objects in the weak |
2046 // callback phase, so the marking stack should still be empty here. | 2046 // callback phase, so the marking stack should still be empty here. |
2047 ASSERT(s_markingStack->isEmpty()); | 2047 ASSERT(s_markingStack->isEmpty()); |
2048 } | 2048 } |
2049 | 2049 |
2050 void Heap::collectAllGarbage() | 2050 void Heap::collectAllGarbage() |
2051 { | 2051 { |
2052 // FIXME: Oilpan: we should perform a single GC and everything | 2052 // FIXME: Oilpan: we should perform a single GC and everything |
2053 // should die. Unfortunately it is not the case for all objects | 2053 // should die. Unfortunately it is not the case for all objects |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2209 ASSERT(ThreadState::current()->isInGC()); | 2209 ASSERT(ThreadState::current()->isInGC()); |
2210 | 2210 |
2211 s_allocatedObjectSize = 0; | 2211 s_allocatedObjectSize = 0; |
2212 s_markedObjectSize = 0; | 2212 s_markedObjectSize = 0; |
2213 s_externalObjectSizeAtLastGC = WTF::Partitions::totalSizeOfCommittedPages(); | 2213 s_externalObjectSizeAtLastGC = WTF::Partitions::totalSizeOfCommittedPages(); |
2214 } | 2214 } |
2215 | 2215 |
2216 Visitor* Heap::s_markingVisitor; | 2216 Visitor* Heap::s_markingVisitor; |
2217 CallbackStack* Heap::s_markingStack; | 2217 CallbackStack* Heap::s_markingStack; |
2218 CallbackStack* Heap::s_postMarkingCallbackStack; | 2218 CallbackStack* Heap::s_postMarkingCallbackStack; |
2219 CallbackStack* Heap::s_weakCallbackStack; | 2219 CallbackStack* Heap::s_globalWeakCallbackStack; |
2220 CallbackStack* Heap::s_ephemeronStack; | 2220 CallbackStack* Heap::s_ephemeronStack; |
2221 HeapDoesNotContainCache* Heap::s_heapDoesNotContainCache; | 2221 HeapDoesNotContainCache* Heap::s_heapDoesNotContainCache; |
2222 bool Heap::s_shutdownCalled = false; | 2222 bool Heap::s_shutdownCalled = false; |
2223 bool Heap::s_lastGCWasConservative = false; | 2223 bool Heap::s_lastGCWasConservative = false; |
2224 FreePagePool* Heap::s_freePagePool; | 2224 FreePagePool* Heap::s_freePagePool; |
2225 OrphanedPagePool* Heap::s_orphanedPagePool; | 2225 OrphanedPagePool* Heap::s_orphanedPagePool; |
2226 Heap::RegionTree* Heap::s_regionTree = nullptr; | 2226 Heap::RegionTree* Heap::s_regionTree = nullptr; |
2227 size_t Heap::s_allocatedObjectSize = 0; | 2227 size_t Heap::s_allocatedObjectSize = 0; |
2228 size_t Heap::s_allocatedSpace = 0; | 2228 size_t Heap::s_allocatedSpace = 0; |
2229 size_t Heap::s_markedObjectSize = 0; | 2229 size_t Heap::s_markedObjectSize = 0; |
2230 // We don't want to use 0 KB for the initial value because it may end up | 2230 // We don't want to use 0 KB for the initial value because it may end up |
2231 // triggering the first GC of some thread too prematurely. | 2231 // triggering the first GC of some thread too prematurely. |
2232 size_t Heap::s_estimatedLiveObjectSize = 512 * 1024; | 2232 size_t Heap::s_estimatedLiveObjectSize = 512 * 1024; |
2233 size_t Heap::s_externalObjectSizeAtLastGC = 0; | 2233 size_t Heap::s_externalObjectSizeAtLastGC = 0; |
2234 double Heap::s_estimatedMarkingTimePerByte = 0.0; | 2234 double Heap::s_estimatedMarkingTimePerByte = 0.0; |
2235 | 2235 |
2236 } // namespace blink | 2236 } // namespace blink |
OLD | NEW |