| 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 2421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2432 #endif | 2432 #endif |
| 2433 | 2433 |
| 2434 // Disallow allocation during garbage collection (but not during the | 2434 // Disallow allocation during garbage collection (but not during the |
| 2435 // finalization that happens when the gcScope is torn down). | 2435 // finalization that happens when the gcScope is torn down). |
| 2436 ThreadState::NoAllocationScope noAllocationScope(state); | 2436 ThreadState::NoAllocationScope noAllocationScope(state); |
| 2437 | 2437 |
| 2438 preGC(); | 2438 preGC(); |
| 2439 s_markingVisitor->configureEagerTraceLimit(); | 2439 s_markingVisitor->configureEagerTraceLimit(); |
| 2440 ASSERT(s_markingVisitor->canTraceEagerly()); | 2440 ASSERT(s_markingVisitor->canTraceEagerly()); |
| 2441 | 2441 |
| 2442 Heap::resetMarkedObjectSize(); | 2442 Heap::resetHeapCounters(); |
| 2443 Heap::resetAllocatedObjectSize(); | |
| 2444 | 2443 |
| 2445 // 1. Trace persistent roots. | 2444 // 1. Trace persistent roots. |
| 2446 ThreadState::visitPersistentRoots(s_markingVisitor); | 2445 ThreadState::visitPersistentRoots(s_markingVisitor); |
| 2447 | 2446 |
| 2448 // 2. Trace objects reachable from the persistent roots including | 2447 // 2. Trace objects reachable from the persistent roots including |
| 2449 // ephemerons. | 2448 // ephemerons. |
| 2450 processMarkingStack(s_markingVisitor); | 2449 processMarkingStack(s_markingVisitor); |
| 2451 | 2450 |
| 2452 // 3. Trace objects reachable from the stack. We do this independent of the | 2451 // 3. Trace objects reachable from the stack. We do this independent of the |
| 2453 // given stackState since other threads might have a different stack state. | 2452 // given stackState since other threads might have a different stack state. |
| (...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2808 add(current->m_left, context); | 2807 add(current->m_left, context); |
| 2809 current->m_left = nullptr; | 2808 current->m_left = nullptr; |
| 2810 } | 2809 } |
| 2811 if (current->m_right) { | 2810 if (current->m_right) { |
| 2812 add(current->m_right, context); | 2811 add(current->m_right, context); |
| 2813 current->m_right = nullptr; | 2812 current->m_right = nullptr; |
| 2814 } | 2813 } |
| 2815 delete current; | 2814 delete current; |
| 2816 } | 2815 } |
| 2817 | 2816 |
| 2817 void Heap::resetHeapCounters() |
| 2818 { |
| 2819 ASSERT(ThreadState::current()->isInGC()); |
| 2820 |
| 2821 s_allocatedObjectSize = 0; |
| 2822 s_markedObjectSize = 0; |
| 2823 |
| 2824 // Similarly, reset the amount of externally allocated memory. |
| 2825 s_externallyAllocatedBytes = 0; |
| 2826 s_externallyAllocatedBytesAlive = 0; |
| 2827 |
| 2828 s_requestedUrgentGC = false; |
| 2829 } |
| 2830 |
| 2831 void Heap::requestUrgentGC() |
| 2832 { |
| 2833 // The urgent-gc flag will be considered the next time an out-of-line |
| 2834 // allocation is made. Bump allocations from the current block will |
| 2835 // go ahead until it can no longer service an allocation request. |
| 2836 // |
| 2837 // FIXME: if that delays urgently needed GCs for too long, consider |
| 2838 // flushing out per-heap "allocation points" to trigger the GC |
| 2839 // right away. |
| 2840 releaseStore(&s_requestedUrgentGC, 1); |
| 2841 } |
| 2842 |
| 2818 Visitor* Heap::s_markingVisitor; | 2843 Visitor* Heap::s_markingVisitor; |
| 2819 CallbackStack* Heap::s_markingStack; | 2844 CallbackStack* Heap::s_markingStack; |
| 2820 CallbackStack* Heap::s_postMarkingCallbackStack; | 2845 CallbackStack* Heap::s_postMarkingCallbackStack; |
| 2821 CallbackStack* Heap::s_weakCallbackStack; | 2846 CallbackStack* Heap::s_weakCallbackStack; |
| 2822 CallbackStack* Heap::s_ephemeronStack; | 2847 CallbackStack* Heap::s_ephemeronStack; |
| 2823 HeapDoesNotContainCache* Heap::s_heapDoesNotContainCache; | 2848 HeapDoesNotContainCache* Heap::s_heapDoesNotContainCache; |
| 2824 bool Heap::s_shutdownCalled = false; | 2849 bool Heap::s_shutdownCalled = false; |
| 2825 bool Heap::s_lastGCWasConservative = false; | 2850 bool Heap::s_lastGCWasConservative = false; |
| 2826 FreePagePool* Heap::s_freePagePool; | 2851 FreePagePool* Heap::s_freePagePool; |
| 2827 OrphanedPagePool* Heap::s_orphanedPagePool; | 2852 OrphanedPagePool* Heap::s_orphanedPagePool; |
| 2828 Heap::RegionTree* Heap::s_regionTree = nullptr; | 2853 Heap::RegionTree* Heap::s_regionTree = nullptr; |
| 2829 size_t Heap::s_allocatedObjectSize = 0; | 2854 size_t Heap::s_allocatedObjectSize = 0; |
| 2830 size_t Heap::s_allocatedSpace = 0; | 2855 size_t Heap::s_allocatedSpace = 0; |
| 2831 size_t Heap::s_markedObjectSize = 0; | 2856 size_t Heap::s_markedObjectSize = 0; |
| 2832 | 2857 |
| 2858 size_t Heap::s_externallyAllocatedBytes = 0; |
| 2859 size_t Heap::s_externallyAllocatedBytesAlive = 0; |
| 2860 unsigned Heap::s_requestedUrgentGC = false; |
| 2861 |
| 2833 } // namespace blink | 2862 } // namespace blink |
| OLD | NEW |