| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "src/heap/mark-compact.h" | 5 #include "src/heap/mark-compact.h" |
| 6 | 6 |
| 7 #include "src/base/atomicops.h" | 7 #include "src/base/atomicops.h" |
| 8 #include "src/base/bits.h" | 8 #include "src/base/bits.h" |
| 9 #include "src/base/sys-info.h" | 9 #include "src/base/sys-info.h" |
| 10 #include "src/code-stubs.h" | 10 #include "src/code-stubs.h" |
| (...skipping 2006 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2017 } | 2017 } |
| 2018 | 2018 |
| 2019 // Mark all objects reachable (transitively) from objects on the marking | 2019 // Mark all objects reachable (transitively) from objects on the marking |
| 2020 // stack including references only considered in the atomic marking pause. | 2020 // stack including references only considered in the atomic marking pause. |
| 2021 void MarkCompactCollector::ProcessEphemeralMarking( | 2021 void MarkCompactCollector::ProcessEphemeralMarking( |
| 2022 ObjectVisitor* visitor, bool only_process_harmony_weak_collections) { | 2022 ObjectVisitor* visitor, bool only_process_harmony_weak_collections) { |
| 2023 bool work_to_do = true; | 2023 bool work_to_do = true; |
| 2024 DCHECK(marking_deque_.IsEmpty() && !marking_deque_.overflowed()); | 2024 DCHECK(marking_deque_.IsEmpty() && !marking_deque_.overflowed()); |
| 2025 while (work_to_do) { | 2025 while (work_to_do) { |
| 2026 if (UsingEmbedderHeapTracer()) { | 2026 if (UsingEmbedderHeapTracer()) { |
| 2027 embedder_heap_tracer()->TraceWrappersFrom( | 2027 embedder_heap_tracer()->TraceWrappersFrom(wrappers_to_trace_); |
| 2028 reinterpret_cast<v8::Isolate*>(isolate()), wrappers_to_trace_); | |
| 2029 wrappers_to_trace_.clear(); | 2028 wrappers_to_trace_.clear(); |
| 2030 } else if (!only_process_harmony_weak_collections) { | 2029 } else if (!only_process_harmony_weak_collections) { |
| 2031 isolate()->global_handles()->IterateObjectGroups( | 2030 isolate()->global_handles()->IterateObjectGroups( |
| 2032 visitor, &IsUnmarkedHeapObjectWithHeap); | 2031 visitor, &IsUnmarkedHeapObjectWithHeap); |
| 2033 MarkImplicitRefGroups(&MarkCompactMarkingVisitor::MarkObject); | 2032 MarkImplicitRefGroups(&MarkCompactMarkingVisitor::MarkObject); |
| 2034 } | 2033 } |
| 2035 ProcessWeakCollections(); | 2034 ProcessWeakCollections(); |
| 2036 work_to_do = !marking_deque_.IsEmpty(); | 2035 work_to_do = !marking_deque_.IsEmpty(); |
| 2037 ProcessMarkingDeque(); | 2036 ProcessMarkingDeque(); |
| 2038 } | 2037 } |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2212 { | 2211 { |
| 2213 TRACE_GC(heap()->tracer(), GCTracer::Scope::MC_MARK_WEAK_CLOSURE); | 2212 TRACE_GC(heap()->tracer(), GCTracer::Scope::MC_MARK_WEAK_CLOSURE); |
| 2214 | 2213 |
| 2215 // The objects reachable from the roots are marked, yet unreachable | 2214 // The objects reachable from the roots are marked, yet unreachable |
| 2216 // objects are unmarked. Mark objects reachable due to host | 2215 // objects are unmarked. Mark objects reachable due to host |
| 2217 // application specific logic or through Harmony weak maps. | 2216 // application specific logic or through Harmony weak maps. |
| 2218 { | 2217 { |
| 2219 TRACE_GC(heap()->tracer(), | 2218 TRACE_GC(heap()->tracer(), |
| 2220 GCTracer::Scope::MC_MARK_WEAK_CLOSURE_EPHEMERAL); | 2219 GCTracer::Scope::MC_MARK_WEAK_CLOSURE_EPHEMERAL); |
| 2221 if (UsingEmbedderHeapTracer()) { | 2220 if (UsingEmbedderHeapTracer()) { |
| 2222 embedder_heap_tracer()->TracePrologue( | 2221 embedder_heap_tracer()->TracePrologue(); |
| 2223 reinterpret_cast<v8::Isolate*>(isolate())); | |
| 2224 } | 2222 } |
| 2225 ProcessEphemeralMarking(&root_visitor, false); | 2223 ProcessEphemeralMarking(&root_visitor, false); |
| 2226 ProcessMarkingDeque(); | 2224 ProcessMarkingDeque(); |
| 2227 } | 2225 } |
| 2228 | 2226 |
| 2229 // The objects reachable from the roots, weak maps or object groups | 2227 // The objects reachable from the roots, weak maps or object groups |
| 2230 // are marked. Objects pointed to only by weak global handles cannot be | 2228 // are marked. Objects pointed to only by weak global handles cannot be |
| 2231 // immediately reclaimed. Instead, we have to mark them as pending and mark | 2229 // immediately reclaimed. Instead, we have to mark them as pending and mark |
| 2232 // objects reachable from them. | 2230 // objects reachable from them. |
| 2233 // | 2231 // |
| (...skipping 18 matching lines...) Expand all Loading... |
| 2252 // Repeat Harmony weak maps marking to mark unmarked objects reachable from | 2250 // Repeat Harmony weak maps marking to mark unmarked objects reachable from |
| 2253 // the weak roots we just marked as pending destruction. | 2251 // the weak roots we just marked as pending destruction. |
| 2254 // | 2252 // |
| 2255 // We only process harmony collections, as all object groups have been fully | 2253 // We only process harmony collections, as all object groups have been fully |
| 2256 // processed and no weakly reachable node can discover new objects groups. | 2254 // processed and no weakly reachable node can discover new objects groups. |
| 2257 { | 2255 { |
| 2258 TRACE_GC(heap()->tracer(), GCTracer::Scope::MC_MARK_WEAK_CLOSURE_HARMONY); | 2256 TRACE_GC(heap()->tracer(), GCTracer::Scope::MC_MARK_WEAK_CLOSURE_HARMONY); |
| 2259 ProcessEphemeralMarking(&root_visitor, true); | 2257 ProcessEphemeralMarking(&root_visitor, true); |
| 2260 ProcessMarkingDeque(); | 2258 ProcessMarkingDeque(); |
| 2261 if (UsingEmbedderHeapTracer()) { | 2259 if (UsingEmbedderHeapTracer()) { |
| 2262 embedder_heap_tracer()->TraceEpilogue( | 2260 embedder_heap_tracer()->TraceEpilogue(); |
| 2263 reinterpret_cast<v8::Isolate*>(isolate())); | |
| 2264 } | 2261 } |
| 2265 } | 2262 } |
| 2266 } | 2263 } |
| 2267 | 2264 |
| 2268 if (FLAG_print_cumulative_gc_stat) { | 2265 if (FLAG_print_cumulative_gc_stat) { |
| 2269 heap_->tracer()->AddMarkingTime(heap_->MonotonicallyIncreasingTimeInMs() - | 2266 heap_->tracer()->AddMarkingTime(heap_->MonotonicallyIncreasingTimeInMs() - |
| 2270 start_time); | 2267 start_time); |
| 2271 } | 2268 } |
| 2272 if (FLAG_track_gc_object_stats) { | 2269 if (FLAG_track_gc_object_stats) { |
| 2273 if (FLAG_trace_gc_object_stats) { | 2270 if (FLAG_trace_gc_object_stats) { |
| (...skipping 1604 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3878 MarkBit mark_bit = Marking::MarkBitFrom(host); | 3875 MarkBit mark_bit = Marking::MarkBitFrom(host); |
| 3879 if (Marking::IsBlack(mark_bit)) { | 3876 if (Marking::IsBlack(mark_bit)) { |
| 3880 RelocInfo rinfo(isolate(), pc, RelocInfo::CODE_TARGET, 0, host); | 3877 RelocInfo rinfo(isolate(), pc, RelocInfo::CODE_TARGET, 0, host); |
| 3881 RecordRelocSlot(host, &rinfo, target); | 3878 RecordRelocSlot(host, &rinfo, target); |
| 3882 } | 3879 } |
| 3883 } | 3880 } |
| 3884 } | 3881 } |
| 3885 | 3882 |
| 3886 } // namespace internal | 3883 } // namespace internal |
| 3887 } // namespace v8 | 3884 } // namespace v8 |
| OLD | NEW |