| 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 2105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2116 } | 2116 } |
| 2117 | 2117 |
| 2118 // Mark all objects reachable (transitively) from objects on the marking | 2118 // Mark all objects reachable (transitively) from objects on the marking |
| 2119 // stack including references only considered in the atomic marking pause. | 2119 // stack including references only considered in the atomic marking pause. |
| 2120 void MarkCompactCollector::ProcessEphemeralMarking( | 2120 void MarkCompactCollector::ProcessEphemeralMarking( |
| 2121 ObjectVisitor* visitor, bool only_process_harmony_weak_collections) { | 2121 ObjectVisitor* visitor, bool only_process_harmony_weak_collections) { |
| 2122 DCHECK(marking_deque_.IsEmpty() && !marking_deque_.overflowed()); | 2122 DCHECK(marking_deque_.IsEmpty() && !marking_deque_.overflowed()); |
| 2123 bool work_to_do = true; | 2123 bool work_to_do = true; |
| 2124 while (work_to_do) { | 2124 while (work_to_do) { |
| 2125 if (UsingEmbedderHeapTracer()) { | 2125 if (UsingEmbedderHeapTracer()) { |
| 2126 embedder_heap_tracer()->TraceWrappersFrom(wrappers_to_trace_); | 2126 RegisterWrappersWithEmbedderHeapTracer(); |
| 2127 wrappers_to_trace_.clear(); | 2127 embedder_heap_tracer()->AdvanceTracing( |
| 2128 0, EmbedderHeapTracer::AdvanceTracingActions( |
| 2129 EmbedderHeapTracer::ForceCompletionAction::FORCE_COMPLETION)); |
| 2128 } | 2130 } |
| 2129 if (!only_process_harmony_weak_collections) { | 2131 if (!only_process_harmony_weak_collections) { |
| 2130 isolate()->global_handles()->IterateObjectGroups( | 2132 isolate()->global_handles()->IterateObjectGroups( |
| 2131 visitor, &IsUnmarkedHeapObjectWithHeap); | 2133 visitor, &IsUnmarkedHeapObjectWithHeap); |
| 2132 MarkImplicitRefGroups(&MarkCompactMarkingVisitor::MarkObject); | 2134 MarkImplicitRefGroups(&MarkCompactMarkingVisitor::MarkObject); |
| 2133 } | 2135 } |
| 2134 ProcessWeakCollections(); | 2136 ProcessWeakCollections(); |
| 2135 work_to_do = !marking_deque_.IsEmpty(); | 2137 work_to_do = !marking_deque_.IsEmpty(); |
| 2136 ProcessMarkingDeque(); | 2138 ProcessMarkingDeque(); |
| 2137 } | 2139 } |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2234 top_ = bottom_ = 0xdecbad; | 2236 top_ = bottom_ = 0xdecbad; |
| 2235 in_use_ = false; | 2237 in_use_ = false; |
| 2236 } | 2238 } |
| 2237 | 2239 |
| 2238 void MarkCompactCollector::SetEmbedderHeapTracer(EmbedderHeapTracer* tracer) { | 2240 void MarkCompactCollector::SetEmbedderHeapTracer(EmbedderHeapTracer* tracer) { |
| 2239 DCHECK_NOT_NULL(tracer); | 2241 DCHECK_NOT_NULL(tracer); |
| 2240 CHECK_NULL(embedder_heap_tracer_); | 2242 CHECK_NULL(embedder_heap_tracer_); |
| 2241 embedder_heap_tracer_ = tracer; | 2243 embedder_heap_tracer_ = tracer; |
| 2242 } | 2244 } |
| 2243 | 2245 |
| 2246 void MarkCompactCollector::RegisterWrappersWithEmbedderHeapTracer() { |
| 2247 DCHECK(UsingEmbedderHeapTracer()); |
| 2248 if (wrappers_to_trace_.empty()) { |
| 2249 return; |
| 2250 } |
| 2251 embedder_heap_tracer()->RegisterV8References(wrappers_to_trace_); |
| 2252 wrappers_to_trace_.clear(); |
| 2253 } |
| 2254 |
| 2244 void MarkCompactCollector::TracePossibleWrapper(JSObject* js_object) { | 2255 void MarkCompactCollector::TracePossibleWrapper(JSObject* js_object) { |
| 2245 DCHECK(js_object->WasConstructedFromApiFunction()); | 2256 DCHECK(js_object->WasConstructedFromApiFunction()); |
| 2246 if (js_object->GetInternalFieldCount() >= 2 && | 2257 if (js_object->GetInternalFieldCount() >= 2 && |
| 2247 js_object->GetInternalField(0) && | 2258 js_object->GetInternalField(0) && |
| 2248 js_object->GetInternalField(0) != heap_->undefined_value() && | 2259 js_object->GetInternalField(0) != heap_->undefined_value() && |
| 2249 js_object->GetInternalField(1) != heap_->undefined_value()) { | 2260 js_object->GetInternalField(1) != heap_->undefined_value()) { |
| 2250 DCHECK(reinterpret_cast<intptr_t>(js_object->GetInternalField(0)) % 2 == 0); | 2261 DCHECK(reinterpret_cast<intptr_t>(js_object->GetInternalField(0)) % 2 == 0); |
| 2251 wrappers_to_trace().push_back(std::pair<void*, void*>( | 2262 wrappers_to_trace_.push_back(std::pair<void*, void*>( |
| 2252 reinterpret_cast<void*>(js_object->GetInternalField(0)), | 2263 reinterpret_cast<void*>(js_object->GetInternalField(0)), |
| 2253 reinterpret_cast<void*>(js_object->GetInternalField(1)))); | 2264 reinterpret_cast<void*>(js_object->GetInternalField(1)))); |
| 2254 } | 2265 } |
| 2255 } | 2266 } |
| 2256 | 2267 |
| 2257 void MarkCompactCollector::RegisterExternallyReferencedObject(Object** object) { | 2268 void MarkCompactCollector::RegisterExternallyReferencedObject(Object** object) { |
| 2258 DCHECK(in_use()); | 2269 DCHECK(in_use()); |
| 2259 HeapObject* heap_object = HeapObject::cast(*object); | 2270 HeapObject* heap_object = HeapObject::cast(*object); |
| 2260 DCHECK(heap_->Contains(heap_object)); | 2271 DCHECK(heap_->Contains(heap_object)); |
| 2261 MarkBit mark_bit = Marking::MarkBitFrom(heap_object); | 2272 MarkBit mark_bit = Marking::MarkBitFrom(heap_object); |
| (...skipping 1723 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3985 MarkBit mark_bit = Marking::MarkBitFrom(host); | 3996 MarkBit mark_bit = Marking::MarkBitFrom(host); |
| 3986 if (Marking::IsBlack(mark_bit)) { | 3997 if (Marking::IsBlack(mark_bit)) { |
| 3987 RelocInfo rinfo(isolate(), pc, RelocInfo::CODE_TARGET, 0, host); | 3998 RelocInfo rinfo(isolate(), pc, RelocInfo::CODE_TARGET, 0, host); |
| 3988 RecordRelocSlot(host, &rinfo, target); | 3999 RecordRelocSlot(host, &rinfo, target); |
| 3989 } | 4000 } |
| 3990 } | 4001 } |
| 3991 } | 4002 } |
| 3992 | 4003 |
| 3993 } // namespace internal | 4004 } // namespace internal |
| 3994 } // namespace v8 | 4005 } // namespace v8 |
| OLD | NEW |