| 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 2124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2135 ProcessTopOptimizedFrame(&root_visitor); | 2135 ProcessTopOptimizedFrame(&root_visitor); |
| 2136 } | 2136 } |
| 2137 | 2137 |
| 2138 { | 2138 { |
| 2139 GCTracer::Scope gc_scope(heap()->tracer(), | 2139 GCTracer::Scope gc_scope(heap()->tracer(), |
| 2140 GCTracer::Scope::MC_MARK_WEAK_CLOSURE); | 2140 GCTracer::Scope::MC_MARK_WEAK_CLOSURE); |
| 2141 | 2141 |
| 2142 // The objects reachable from the roots are marked, yet unreachable | 2142 // The objects reachable from the roots are marked, yet unreachable |
| 2143 // objects are unmarked. Mark objects reachable due to host | 2143 // objects are unmarked. Mark objects reachable due to host |
| 2144 // application specific logic or through Harmony weak maps. | 2144 // application specific logic or through Harmony weak maps. |
| 2145 ProcessEphemeralMarking(&root_visitor, false); | 2145 { |
| 2146 GCTracer::Scope gc_scope(heap()->tracer(), |
| 2147 GCTracer::Scope::MC_MARK_WEAK_CLOSURE_EPHEMERAL); |
| 2148 ProcessEphemeralMarking(&root_visitor, false); |
| 2149 ProcessMarkingDeque(); |
| 2150 } |
| 2146 | 2151 |
| 2147 // The objects reachable from the roots, weak maps or object groups | 2152 // The objects reachable from the roots, weak maps or object groups |
| 2148 // are marked. Objects pointed to only by weak global handles cannot be | 2153 // are marked. Objects pointed to only by weak global handles cannot be |
| 2149 // immediately reclaimed. Instead, we have to mark them as pending and mark | 2154 // immediately reclaimed. Instead, we have to mark them as pending and mark |
| 2150 // objects reachable from them. | 2155 // objects reachable from them. |
| 2151 // | 2156 // |
| 2152 // First we identify nonlive weak handles and mark them as pending | 2157 // First we identify nonlive weak handles and mark them as pending |
| 2153 // destruction. | 2158 // destruction. |
| 2154 heap()->isolate()->global_handles()->IdentifyWeakHandles( | 2159 { |
| 2155 &IsUnmarkedHeapObject); | 2160 GCTracer::Scope gc_scope( |
| 2161 heap()->tracer(), GCTracer::Scope::MC_MARK_WEAK_CLOSURE_WEAK_HANDLES); |
| 2162 heap()->isolate()->global_handles()->IdentifyWeakHandles( |
| 2163 &IsUnmarkedHeapObject); |
| 2164 ProcessMarkingDeque(); |
| 2165 } |
| 2156 // Then we mark the objects. | 2166 // Then we mark the objects. |
| 2157 heap()->isolate()->global_handles()->IterateWeakRoots(&root_visitor); | 2167 |
| 2158 ProcessMarkingDeque(); | 2168 { |
| 2169 GCTracer::Scope gc_scope( |
| 2170 heap()->tracer(), GCTracer::Scope::MC_MARK_WEAK_CLOSURE_WEAK_ROOTS); |
| 2171 heap()->isolate()->global_handles()->IterateWeakRoots(&root_visitor); |
| 2172 ProcessMarkingDeque(); |
| 2173 } |
| 2159 | 2174 |
| 2160 // Repeat Harmony weak maps marking to mark unmarked objects reachable from | 2175 // Repeat Harmony weak maps marking to mark unmarked objects reachable from |
| 2161 // the weak roots we just marked as pending destruction. | 2176 // the weak roots we just marked as pending destruction. |
| 2162 // | 2177 // |
| 2163 // We only process harmony collections, as all object groups have been fully | 2178 // We only process harmony collections, as all object groups have been fully |
| 2164 // processed and no weakly reachable node can discover new objects groups. | 2179 // processed and no weakly reachable node can discover new objects groups. |
| 2165 ProcessEphemeralMarking(&root_visitor, true); | 2180 { |
| 2181 GCTracer::Scope gc_scope(heap()->tracer(), |
| 2182 GCTracer::Scope::MC_MARK_WEAK_CLOSURE_HARMONY); |
| 2183 ProcessEphemeralMarking(&root_visitor, true); |
| 2184 ProcessMarkingDeque(); |
| 2185 } |
| 2166 } | 2186 } |
| 2167 | 2187 |
| 2168 if (FLAG_print_cumulative_gc_stat) { | 2188 if (FLAG_print_cumulative_gc_stat) { |
| 2169 heap_->tracer()->AddMarkingTime(heap_->MonotonicallyIncreasingTimeInMs() - | 2189 heap_->tracer()->AddMarkingTime(heap_->MonotonicallyIncreasingTimeInMs() - |
| 2170 start_time); | 2190 start_time); |
| 2171 } | 2191 } |
| 2172 if (FLAG_track_gc_object_stats) { | 2192 if (FLAG_track_gc_object_stats) { |
| 2173 if (FLAG_trace_gc_object_stats) { | 2193 if (FLAG_trace_gc_object_stats) { |
| 2174 heap()->object_stats_->TraceObjectStats(); | 2194 heap()->object_stats_->TraceObjectStats(); |
| 2175 } | 2195 } |
| (...skipping 1633 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3809 MarkBit mark_bit = Marking::MarkBitFrom(host); | 3829 MarkBit mark_bit = Marking::MarkBitFrom(host); |
| 3810 if (Marking::IsBlack(mark_bit)) { | 3830 if (Marking::IsBlack(mark_bit)) { |
| 3811 RelocInfo rinfo(isolate(), pc, RelocInfo::CODE_TARGET, 0, host); | 3831 RelocInfo rinfo(isolate(), pc, RelocInfo::CODE_TARGET, 0, host); |
| 3812 RecordRelocSlot(host, &rinfo, target); | 3832 RecordRelocSlot(host, &rinfo, target); |
| 3813 } | 3833 } |
| 3814 } | 3834 } |
| 3815 } | 3835 } |
| 3816 | 3836 |
| 3817 } // namespace internal | 3837 } // namespace internal |
| 3818 } // namespace v8 | 3838 } // namespace v8 |
| OLD | NEW |