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 1944 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1955 } | 1955 } |
1956 | 1956 |
1957 void Heap::flushHeapDoesNotContainCache() | 1957 void Heap::flushHeapDoesNotContainCache() |
1958 { | 1958 { |
1959 s_heapDoesNotContainCache->flush(); | 1959 s_heapDoesNotContainCache->flush(); |
1960 } | 1960 } |
1961 | 1961 |
1962 void Heap::init() | 1962 void Heap::init() |
1963 { | 1963 { |
1964 ThreadState::init(); | 1964 ThreadState::init(); |
1965 s_markingStack = new CallbackStack(); | 1965 s_markingVisitor = new MarkingVisitor<Visitor::GlobalMarking>(); |
1966 s_postMarkingCallbackStack = new CallbackStack(); | |
1967 s_weakCallbackStack = new CallbackStack(); | |
1968 s_ephemeronStack = new CallbackStack(); | |
1969 s_heapDoesNotContainCache = new HeapDoesNotContainCache(); | 1966 s_heapDoesNotContainCache = new HeapDoesNotContainCache(); |
1970 s_markingVisitor = new MarkingVisitor<Visitor::GlobalMarking>(); | |
1971 s_freePagePool = new FreePagePool(); | 1967 s_freePagePool = new FreePagePool(); |
1972 s_orphanedPagePool = new OrphanedPagePool(); | 1968 s_orphanedPagePool = new OrphanedPagePool(); |
1973 s_allocatedObjectSize = 0; | |
1974 s_allocatedSpace = 0; | |
1975 s_markedObjectSize = 0; | |
1976 s_estimatedMarkingTimePerByte = 0.0; | |
1977 | 1969 |
1978 GCInfoTable::init(); | 1970 GCInfoTable::init(); |
1979 } | 1971 } |
1980 | 1972 |
1981 void Heap::shutdown() | 1973 void Heap::shutdown() |
1982 { | 1974 { |
1983 s_shutdownCalled = true; | 1975 s_shutdownCalled = true; |
1984 ThreadState::shutdownHeapIfNecessary(); | 1976 ThreadState::shutdownHeapIfNecessary(); |
1985 } | 1977 } |
1986 | 1978 |
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2252 double timeStamp = WTF::currentTimeMS(); | 2244 double timeStamp = WTF::currentTimeMS(); |
2253 #if ENABLE(GC_PROFILING) | 2245 #if ENABLE(GC_PROFILING) |
2254 static_cast<MarkingVisitor<Visitor::GlobalMarking>*>(s_markingVisitor)->obje
ctGraph().clear(); | 2246 static_cast<MarkingVisitor<Visitor::GlobalMarking>*>(s_markingVisitor)->obje
ctGraph().clear(); |
2255 #endif | 2247 #endif |
2256 | 2248 |
2257 // Disallow allocation during garbage collection (but not during the | 2249 // Disallow allocation during garbage collection (but not during the |
2258 // finalization that happens when the gcScope is torn down). | 2250 // finalization that happens when the gcScope is torn down). |
2259 ThreadState::NoAllocationScope noAllocationScope(state); | 2251 ThreadState::NoAllocationScope noAllocationScope(state); |
2260 | 2252 |
2261 preGC(); | 2253 preGC(); |
| 2254 Heap::ensureCallbackStacks(); |
2262 StackFrameDepth::configureStackLimit(); | 2255 StackFrameDepth::configureStackLimit(); |
2263 ASSERT(StackFrameDepth::isSafeToRecurse()); | 2256 ASSERT(StackFrameDepth::isSafeToRecurse()); |
2264 | 2257 |
2265 size_t totalObjectSize = Heap::allocatedObjectSize() + Heap::markedObjectSiz
e(); | 2258 size_t totalObjectSize = Heap::allocatedObjectSize() + Heap::markedObjectSiz
e(); |
2266 Heap::resetHeapCounters(); | 2259 Heap::resetHeapCounters(); |
2267 | 2260 |
2268 // 1. Trace persistent roots. | 2261 // 1. Trace persistent roots. |
2269 ThreadState::visitPersistentRoots(s_markingVisitor); | 2262 ThreadState::visitPersistentRoots(s_markingVisitor); |
2270 | 2263 |
2271 // 2. Trace objects reachable from the persistent roots including | 2264 // 2. Trace objects reachable from the persistent roots including |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2313 void Heap::collectGarbageForTerminatingThread(ThreadState* state) | 2306 void Heap::collectGarbageForTerminatingThread(ThreadState* state) |
2314 { | 2307 { |
2315 // We explicitly do not enter a safepoint while doing thread specific | 2308 // We explicitly do not enter a safepoint while doing thread specific |
2316 // garbage collection since we don't want to allow a global GC at the | 2309 // garbage collection since we don't want to allow a global GC at the |
2317 // same time as a thread local GC. | 2310 // same time as a thread local GC. |
2318 { | 2311 { |
2319 MarkingVisitor<Visitor::ThreadLocalMarking> markingVisitor; | 2312 MarkingVisitor<Visitor::ThreadLocalMarking> markingVisitor; |
2320 ThreadState::NoAllocationScope noAllocationScope(state); | 2313 ThreadState::NoAllocationScope noAllocationScope(state); |
2321 | 2314 |
2322 state->preGC(); | 2315 state->preGC(); |
| 2316 Heap::ensureCallbackStacks(); |
2323 StackFrameDepth::configureStackLimit(); | 2317 StackFrameDepth::configureStackLimit(); |
2324 ASSERT(StackFrameDepth::isSafeToRecurse()); | 2318 ASSERT(StackFrameDepth::isSafeToRecurse()); |
2325 | 2319 |
2326 // 1. Trace the thread local persistent roots. For thread local GCs we | 2320 // 1. Trace the thread local persistent roots. For thread local GCs we |
2327 // don't trace the stack (ie. no conservative scanning) since this is | 2321 // don't trace the stack (ie. no conservative scanning) since this is |
2328 // only called during thread shutdown where there should be no objects | 2322 // only called during thread shutdown where there should be no objects |
2329 // on the stack. | 2323 // on the stack. |
2330 // We also assume that orphaned pages have no objects reachable from | 2324 // We also assume that orphaned pages have no objects reachable from |
2331 // persistent handles on other threads or CrossThreadPersistents. The | 2325 // persistent handles on other threads or CrossThreadPersistents. The |
2332 // only cases where this could happen is if a subsequent conservative | 2326 // only cases where this could happen is if a subsequent conservative |
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2667 | 2661 |
2668 void Heap::resetHeapCounters() | 2662 void Heap::resetHeapCounters() |
2669 { | 2663 { |
2670 ASSERT(ThreadState::current()->isInGC()); | 2664 ASSERT(ThreadState::current()->isInGC()); |
2671 | 2665 |
2672 s_allocatedObjectSize = 0; | 2666 s_allocatedObjectSize = 0; |
2673 s_markedObjectSize = 0; | 2667 s_markedObjectSize = 0; |
2674 s_externalObjectSizeAtLastGC = WTF::Partitions::totalSizeOfCommittedPages(); | 2668 s_externalObjectSizeAtLastGC = WTF::Partitions::totalSizeOfCommittedPages(); |
2675 } | 2669 } |
2676 | 2670 |
| 2671 void Heap::ensureCallbackStacks() |
| 2672 { |
| 2673 if (s_markingStack) |
| 2674 return; |
| 2675 |
| 2676 s_markingStack = new CallbackStack(CallbackStack::MarkingStackBlockSize); |
| 2677 s_postMarkingCallbackStack = new CallbackStack(CallbackStack::PostMarkingSta
ckBlockSize); |
| 2678 s_weakCallbackStack = new CallbackStack(CallbackStack::WeakCallbackStackBloc
kSize); |
| 2679 s_ephemeronStack = new CallbackStack(CallbackStack::EphemeronCallbackStackBl
ockSize); |
| 2680 } |
| 2681 |
2677 Visitor* Heap::s_markingVisitor; | 2682 Visitor* Heap::s_markingVisitor; |
2678 CallbackStack* Heap::s_markingStack; | 2683 CallbackStack* Heap::s_markingStack = nullptr; |
2679 CallbackStack* Heap::s_postMarkingCallbackStack; | 2684 CallbackStack* Heap::s_postMarkingCallbackStack = nullptr; |
2680 CallbackStack* Heap::s_weakCallbackStack; | 2685 CallbackStack* Heap::s_weakCallbackStack = nullptr; |
2681 CallbackStack* Heap::s_ephemeronStack; | 2686 CallbackStack* Heap::s_ephemeronStack = nullptr; |
2682 HeapDoesNotContainCache* Heap::s_heapDoesNotContainCache; | 2687 HeapDoesNotContainCache* Heap::s_heapDoesNotContainCache; |
2683 bool Heap::s_shutdownCalled = false; | 2688 bool Heap::s_shutdownCalled = false; |
2684 bool Heap::s_lastGCWasConservative = false; | 2689 bool Heap::s_lastGCWasConservative = false; |
2685 FreePagePool* Heap::s_freePagePool; | 2690 FreePagePool* Heap::s_freePagePool; |
2686 OrphanedPagePool* Heap::s_orphanedPagePool; | 2691 OrphanedPagePool* Heap::s_orphanedPagePool; |
2687 Heap::RegionTree* Heap::s_regionTree = nullptr; | 2692 Heap::RegionTree* Heap::s_regionTree = nullptr; |
2688 size_t Heap::s_allocatedObjectSize = 0; | 2693 size_t Heap::s_allocatedObjectSize = 0; |
2689 size_t Heap::s_allocatedSpace = 0; | 2694 size_t Heap::s_allocatedSpace = 0; |
2690 size_t Heap::s_markedObjectSize = 0; | 2695 size_t Heap::s_markedObjectSize = 0; |
2691 // We don't want to use 0 KB for the initial value because it may end up | 2696 // We don't want to use 0 KB for the initial value because it may end up |
2692 // triggering the first GC of some thread too prematurely. | 2697 // triggering the first GC of some thread too prematurely. |
2693 size_t Heap::s_estimatedLiveObjectSize = 512 * 1024; | 2698 size_t Heap::s_estimatedLiveObjectSize = 512 * 1024; |
2694 size_t Heap::s_externalObjectSizeAtLastGC = 0; | 2699 size_t Heap::s_externalObjectSizeAtLastGC = 0; |
2695 double Heap::s_estimatedMarkingTimePerByte = 0.0; | 2700 double Heap::s_estimatedMarkingTimePerByte = 0.0; |
2696 | 2701 |
2697 } // namespace blink | 2702 } // namespace blink |
OLD | NEW |