 Chromium Code Reviews
 Chromium Code Reviews Issue 1844413002:
  Use EmbedderHeapTracer instead of object grouping when trace_embedder_heap flag is set  (Closed) 
  Base URL: https://chromium.googlesource.com/v8/v8.git@master
    
  
    Issue 1844413002:
  Use EmbedderHeapTracer instead of object grouping when trace_embedder_heap flag is set  (Closed) 
  Base URL: https://chromium.googlesource.com/v8/v8.git@master| 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 1943 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1954 // pointers. After: the marking stack is empty and there are no overflowed | 1954 // pointers. After: the marking stack is empty and there are no overflowed | 
| 1955 // objects in the heap. | 1955 // objects in the heap. | 
| 1956 void MarkCompactCollector::ProcessMarkingDeque() { | 1956 void MarkCompactCollector::ProcessMarkingDeque() { | 
| 1957 EmptyMarkingDeque(); | 1957 EmptyMarkingDeque(); | 
| 1958 while (marking_deque_.overflowed()) { | 1958 while (marking_deque_.overflowed()) { | 
| 1959 RefillMarkingDeque(); | 1959 RefillMarkingDeque(); | 
| 1960 EmptyMarkingDeque(); | 1960 EmptyMarkingDeque(); | 
| 1961 } | 1961 } | 
| 1962 } | 1962 } | 
| 1963 | 1963 | 
| 1964 | |
| 1965 // Mark all objects reachable (transitively) from objects on the marking | 1964 // Mark all objects reachable (transitively) from objects on the marking | 
| 1966 // stack including references only considered in the atomic marking pause. | 1965 // stack including references only considered in the atomic marking pause. | 
| 1967 void MarkCompactCollector::ProcessEphemeralMarking( | 1966 void MarkCompactCollector::ProcessEphemeralMarking( | 
| 1968 ObjectVisitor* visitor, bool only_process_harmony_weak_collections) { | 1967 ObjectVisitor* visitor, bool only_process_harmony_weak_collections) { | 
| 1969 bool work_to_do = true; | 1968 bool work_to_do = true; | 
| 1970 DCHECK(marking_deque_.IsEmpty() && !marking_deque_.overflowed()); | 1969 DCHECK(marking_deque_.IsEmpty() && !marking_deque_.overflowed()); | 
| 1971 while (work_to_do) { | 1970 while (work_to_do) { | 
| 1972 if (!only_process_harmony_weak_collections) { | 1971 if (heap()->UsingEmbedderHeapTracer()) { | 
| 1972 heap()->embedder_heap_tracer()->TraceWrappableFrom( | |
| 1973 reinterpret_cast<v8::Isolate*>(isolate()), wrappers_to_trace_); | |
| 1974 wrappers_to_trace_.clear(); | |
| 1975 } else if (!only_process_harmony_weak_collections) { | |
| 1973 isolate()->global_handles()->IterateObjectGroups( | 1976 isolate()->global_handles()->IterateObjectGroups( | 
| 1974 visitor, &IsUnmarkedHeapObjectWithHeap); | 1977 visitor, &IsUnmarkedHeapObjectWithHeap); | 
| 1975 MarkImplicitRefGroups(&MarkCompactMarkingVisitor::MarkObject); | 1978 MarkImplicitRefGroups(&MarkCompactMarkingVisitor::MarkObject); | 
| 1976 } | 1979 } | 
| 1977 ProcessWeakCollections(); | 1980 ProcessWeakCollections(); | 
| 1978 work_to_do = !marking_deque_.IsEmpty(); | 1981 work_to_do = !marking_deque_.IsEmpty(); | 
| 1979 ProcessMarkingDeque(); | 1982 ProcessMarkingDeque(); | 
| 1980 } | 1983 } | 
| 1981 } | 1984 } | 
| 1982 | 1985 | 
| 1983 | |
| 1984 void MarkCompactCollector::ProcessTopOptimizedFrame(ObjectVisitor* visitor) { | 1986 void MarkCompactCollector::ProcessTopOptimizedFrame(ObjectVisitor* visitor) { | 
| 1985 for (StackFrameIterator it(isolate(), isolate()->thread_local_top()); | 1987 for (StackFrameIterator it(isolate(), isolate()->thread_local_top()); | 
| 1986 !it.done(); it.Advance()) { | 1988 !it.done(); it.Advance()) { | 
| 1987 if (it.frame()->type() == StackFrame::JAVA_SCRIPT) { | 1989 if (it.frame()->type() == StackFrame::JAVA_SCRIPT) { | 
| 1988 return; | 1990 return; | 
| 1989 } | 1991 } | 
| 1990 if (it.frame()->type() == StackFrame::OPTIMIZED) { | 1992 if (it.frame()->type() == StackFrame::OPTIMIZED) { | 
| 1991 Code* code = it.frame()->LookupCode(); | 1993 Code* code = it.frame()->LookupCode(); | 
| 1992 if (!code->CanDeoptAt(it.frame()->pc())) { | 1994 if (!code->CanDeoptAt(it.frame()->pc())) { | 
| 1993 Code::BodyDescriptor::IterateBody(code, visitor); | 1995 Code::BodyDescriptor::IterateBody(code, visitor); | 
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2128 | 2130 | 
| 2129 { | 2131 { | 
| 2130 TRACE_GC(heap()->tracer(), GCTracer::Scope::MC_MARK_WEAK_CLOSURE); | 2132 TRACE_GC(heap()->tracer(), GCTracer::Scope::MC_MARK_WEAK_CLOSURE); | 
| 2131 | 2133 | 
| 2132 // The objects reachable from the roots are marked, yet unreachable | 2134 // The objects reachable from the roots are marked, yet unreachable | 
| 2133 // objects are unmarked. Mark objects reachable due to host | 2135 // objects are unmarked. Mark objects reachable due to host | 
| 2134 // application specific logic or through Harmony weak maps. | 2136 // application specific logic or through Harmony weak maps. | 
| 2135 { | 2137 { | 
| 2136 TRACE_GC(heap()->tracer(), | 2138 TRACE_GC(heap()->tracer(), | 
| 2137 GCTracer::Scope::MC_MARK_WEAK_CLOSURE_EPHEMERAL); | 2139 GCTracer::Scope::MC_MARK_WEAK_CLOSURE_EPHEMERAL); | 
| 2140 if (heap()->UsingEmbedderHeapTracer()) { | |
| 
Hannes Payer (out of office)
2016/04/07 20:38:31
This piece of code and the code below need separat
 
Marcel Hlopko
2016/04/08 08:08:10
Let's not make this method more complicated than i
 | |
| 2141 heap()->embedder_heap_tracer()->TraceRoots( | |
| 2142 reinterpret_cast<v8::Isolate*>(isolate())); | |
| 2143 } | |
| 2138 ProcessEphemeralMarking(&root_visitor, false); | 2144 ProcessEphemeralMarking(&root_visitor, false); | 
| 2139 ProcessMarkingDeque(); | 2145 ProcessMarkingDeque(); | 
| 2140 } | 2146 } | 
| 2141 | 2147 | 
| 2142 // The objects reachable from the roots, weak maps or object groups | 2148 // The objects reachable from the roots, weak maps or object groups | 
| 2143 // are marked. Objects pointed to only by weak global handles cannot be | 2149 // are marked. Objects pointed to only by weak global handles cannot be | 
| 2144 // immediately reclaimed. Instead, we have to mark them as pending and mark | 2150 // immediately reclaimed. Instead, we have to mark them as pending and mark | 
| 2145 // objects reachable from them. | 2151 // objects reachable from them. | 
| 2146 // | 2152 // | 
| 2147 // First we identify nonlive weak handles and mark them as pending | 2153 // First we identify nonlive weak handles and mark them as pending | 
| (...skipping 16 matching lines...) Expand all Loading... | |
| 2164 | 2170 | 
| 2165 // Repeat Harmony weak maps marking to mark unmarked objects reachable from | 2171 // Repeat Harmony weak maps marking to mark unmarked objects reachable from | 
| 2166 // the weak roots we just marked as pending destruction. | 2172 // the weak roots we just marked as pending destruction. | 
| 2167 // | 2173 // | 
| 2168 // We only process harmony collections, as all object groups have been fully | 2174 // We only process harmony collections, as all object groups have been fully | 
| 2169 // processed and no weakly reachable node can discover new objects groups. | 2175 // processed and no weakly reachable node can discover new objects groups. | 
| 2170 { | 2176 { | 
| 2171 TRACE_GC(heap()->tracer(), GCTracer::Scope::MC_MARK_WEAK_CLOSURE_HARMONY); | 2177 TRACE_GC(heap()->tracer(), GCTracer::Scope::MC_MARK_WEAK_CLOSURE_HARMONY); | 
| 2172 ProcessEphemeralMarking(&root_visitor, true); | 2178 ProcessEphemeralMarking(&root_visitor, true); | 
| 2173 ProcessMarkingDeque(); | 2179 ProcessMarkingDeque(); | 
| 2180 if (heap()->UsingEmbedderHeapTracer()) { | |
| 2181 heap()->embedder_heap_tracer()->ClearTracingMarks( | |
| 2182 reinterpret_cast<v8::Isolate*>(isolate())); | |
| 2183 } | |
| 2174 } | 2184 } | 
| 2175 } | 2185 } | 
| 2176 | 2186 | 
| 2177 if (FLAG_print_cumulative_gc_stat) { | 2187 if (FLAG_print_cumulative_gc_stat) { | 
| 2178 heap_->tracer()->AddMarkingTime(heap_->MonotonicallyIncreasingTimeInMs() - | 2188 heap_->tracer()->AddMarkingTime(heap_->MonotonicallyIncreasingTimeInMs() - | 
| 2179 start_time); | 2189 start_time); | 
| 2180 } | 2190 } | 
| 2181 if (FLAG_track_gc_object_stats) { | 2191 if (FLAG_track_gc_object_stats) { | 
| 2182 if (FLAG_trace_gc_object_stats) { | 2192 if (FLAG_trace_gc_object_stats) { | 
| 2183 heap()->object_stats_->TraceObjectStats(); | 2193 heap()->object_stats_->TraceObjectStats(); | 
| (...skipping 1622 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3806 MarkBit mark_bit = Marking::MarkBitFrom(host); | 3816 MarkBit mark_bit = Marking::MarkBitFrom(host); | 
| 3807 if (Marking::IsBlack(mark_bit)) { | 3817 if (Marking::IsBlack(mark_bit)) { | 
| 3808 RelocInfo rinfo(isolate(), pc, RelocInfo::CODE_TARGET, 0, host); | 3818 RelocInfo rinfo(isolate(), pc, RelocInfo::CODE_TARGET, 0, host); | 
| 3809 RecordRelocSlot(host, &rinfo, target); | 3819 RecordRelocSlot(host, &rinfo, target); | 
| 3810 } | 3820 } | 
| 3811 } | 3821 } | 
| 3812 } | 3822 } | 
| 3813 | 3823 | 
| 3814 } // namespace internal | 3824 } // namespace internal | 
| 3815 } // namespace v8 | 3825 } // namespace v8 | 
| OLD | NEW |