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 2457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2468 #endif | 2468 #endif |
2469 | 2469 |
2470 // Disallow allocation during garbage collection (but not during the | 2470 // Disallow allocation during garbage collection (but not during the |
2471 // finalization that happens when the gcScope is torn down). | 2471 // finalization that happens when the gcScope is torn down). |
2472 ThreadState::NoAllocationScope noAllocationScope(state); | 2472 ThreadState::NoAllocationScope noAllocationScope(state); |
2473 | 2473 |
2474 preGC(); | 2474 preGC(); |
2475 s_markingVisitor->configureEagerTraceLimit(); | 2475 s_markingVisitor->configureEagerTraceLimit(); |
2476 ASSERT(s_markingVisitor->canTraceEagerly()); | 2476 ASSERT(s_markingVisitor->canTraceEagerly()); |
2477 | 2477 |
2478 Heap::resetMarkedObjectSize(); | 2478 Heap::resetHeapCounters(); |
2479 Heap::resetAllocatedObjectSize(); | |
2480 | 2479 |
2481 // 1. Trace persistent roots. | 2480 // 1. Trace persistent roots. |
2482 ThreadState::visitPersistentRoots(s_markingVisitor); | 2481 ThreadState::visitPersistentRoots(s_markingVisitor); |
2483 | 2482 |
2484 // 2. Trace objects reachable from the persistent roots including | 2483 // 2. Trace objects reachable from the persistent roots including |
2485 // ephemerons. | 2484 // ephemerons. |
2486 processMarkingStack(s_markingVisitor); | 2485 processMarkingStack(s_markingVisitor); |
2487 | 2486 |
2488 // 3. Trace objects reachable from the stack. We do this independent of the | 2487 // 3. Trace objects reachable from the stack. We do this independent of the |
2489 // given stackState since other threads might have a different stack state. | 2488 // given stackState since other threads might have a different stack state. |
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2833 add(current->m_left, context); | 2832 add(current->m_left, context); |
2834 current->m_left = nullptr; | 2833 current->m_left = nullptr; |
2835 } | 2834 } |
2836 if (current->m_right) { | 2835 if (current->m_right) { |
2837 add(current->m_right, context); | 2836 add(current->m_right, context); |
2838 current->m_right = nullptr; | 2837 current->m_right = nullptr; |
2839 } | 2838 } |
2840 delete current; | 2839 delete current; |
2841 } | 2840 } |
2842 | 2841 |
| 2842 void Heap::resetHeapCounters() |
| 2843 { |
| 2844 ASSERT(ThreadState::current()->isInGC()); |
| 2845 |
| 2846 s_allocatedObjectSize = 0; |
| 2847 s_markedObjectSize = 0; |
| 2848 |
| 2849 // Similarly, reset the amount of externally allocated memory. |
| 2850 s_externallyAllocatedBytes = 0; |
| 2851 s_externallyAllocatedBytesAlive = 0; |
| 2852 |
| 2853 s_requestedUrgentGC = false; |
| 2854 } |
| 2855 |
| 2856 void Heap::requestUrgentGC() |
| 2857 { |
| 2858 // The urgent-gc flag will be considered the next time an out-of-line |
| 2859 // allocation is made. Bump allocations from the current block will |
| 2860 // go ahead until it can no longer service an allocation request. |
| 2861 // |
| 2862 // FIXME: if that delays urgently needed GCs for too long, consider |
| 2863 // flushing out per-heap "allocation points" to trigger the GC |
| 2864 // right away. |
| 2865 releaseStore(&s_requestedUrgentGC, 1); |
| 2866 } |
| 2867 |
2843 Visitor* Heap::s_markingVisitor; | 2868 Visitor* Heap::s_markingVisitor; |
2844 CallbackStack* Heap::s_markingStack; | 2869 CallbackStack* Heap::s_markingStack; |
2845 CallbackStack* Heap::s_postMarkingCallbackStack; | 2870 CallbackStack* Heap::s_postMarkingCallbackStack; |
2846 CallbackStack* Heap::s_weakCallbackStack; | 2871 CallbackStack* Heap::s_weakCallbackStack; |
2847 CallbackStack* Heap::s_ephemeronStack; | 2872 CallbackStack* Heap::s_ephemeronStack; |
2848 HeapDoesNotContainCache* Heap::s_heapDoesNotContainCache; | 2873 HeapDoesNotContainCache* Heap::s_heapDoesNotContainCache; |
2849 bool Heap::s_shutdownCalled = false; | 2874 bool Heap::s_shutdownCalled = false; |
2850 bool Heap::s_lastGCWasConservative = false; | 2875 bool Heap::s_lastGCWasConservative = false; |
2851 FreePagePool* Heap::s_freePagePool; | 2876 FreePagePool* Heap::s_freePagePool; |
2852 OrphanedPagePool* Heap::s_orphanedPagePool; | 2877 OrphanedPagePool* Heap::s_orphanedPagePool; |
2853 Heap::RegionTree* Heap::s_regionTree = nullptr; | 2878 Heap::RegionTree* Heap::s_regionTree = nullptr; |
2854 size_t Heap::s_allocatedObjectSize = 0; | 2879 size_t Heap::s_allocatedObjectSize = 0; |
2855 size_t Heap::s_allocatedSpace = 0; | 2880 size_t Heap::s_allocatedSpace = 0; |
2856 size_t Heap::s_markedObjectSize = 0; | 2881 size_t Heap::s_markedObjectSize = 0; |
2857 | 2882 |
| 2883 size_t Heap::s_externallyAllocatedBytes = 0; |
| 2884 size_t Heap::s_externallyAllocatedBytesAlive = 0; |
| 2885 unsigned Heap::s_requestedUrgentGC = false; |
| 2886 |
2858 } // namespace blink | 2887 } // namespace blink |
OLD | NEW |