OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #include "src/heap/objects-visiting.h" | 7 #include "src/heap/objects-visiting.h" |
8 | 8 |
9 namespace v8 { | 9 namespace v8 { |
10 namespace internal { | 10 namespace internal { |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 if (head == undefined) { | 209 if (head == undefined) { |
210 // First element in the list. | 210 // First element in the list. |
211 head = retained; | 211 head = retained; |
212 } else { | 212 } else { |
213 // Subsequent elements in the list. | 213 // Subsequent elements in the list. |
214 DCHECK(tail != NULL); | 214 DCHECK(tail != NULL); |
215 WeakListVisitor<T>::SetWeakNext(tail, retained); | 215 WeakListVisitor<T>::SetWeakNext(tail, retained); |
216 if (record_slots) { | 216 if (record_slots) { |
217 Object** next_slot = | 217 Object** next_slot = |
218 HeapObject::RawField(tail, WeakListVisitor<T>::WeakNextOffset()); | 218 HeapObject::RawField(tail, WeakListVisitor<T>::WeakNextOffset()); |
219 collector->RecordSlot(next_slot, next_slot, retained); | 219 collector->RecordSlot(tail, next_slot, retained); |
220 } | 220 } |
221 } | 221 } |
222 // Retained object is new tail. | 222 // Retained object is new tail. |
223 DCHECK(!retained->IsUndefined()); | 223 DCHECK(!retained->IsUndefined()); |
224 candidate = reinterpret_cast<T*>(retained); | 224 candidate = reinterpret_cast<T*>(retained); |
225 tail = candidate; | 225 tail = candidate; |
226 | 226 |
227 // tail is a live object, visit it. | 227 // tail is a live object, visit it. |
228 WeakListVisitor<T>::VisitLiveObject(heap, tail, retainer); | 228 WeakListVisitor<T>::VisitLiveObject(heap, tail, retainer); |
229 | 229 |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
320 // Visit the weak list, removing dead intermediate elements. | 320 // Visit the weak list, removing dead intermediate elements. |
321 Object* list_head = VisitWeakList<T>(heap, context->get(index), retainer); | 321 Object* list_head = VisitWeakList<T>(heap, context->get(index), retainer); |
322 | 322 |
323 // Update the list head. | 323 // Update the list head. |
324 context->set(index, list_head, UPDATE_WRITE_BARRIER); | 324 context->set(index, list_head, UPDATE_WRITE_BARRIER); |
325 | 325 |
326 if (MustRecordSlots(heap)) { | 326 if (MustRecordSlots(heap)) { |
327 // Record the updated slot if necessary. | 327 // Record the updated slot if necessary. |
328 Object** head_slot = | 328 Object** head_slot = |
329 HeapObject::RawField(context, FixedArray::SizeFor(index)); | 329 HeapObject::RawField(context, FixedArray::SizeFor(index)); |
330 heap->mark_compact_collector()->RecordSlot(head_slot, head_slot, | 330 heap->mark_compact_collector()->RecordSlot(context, head_slot, list_head); |
331 list_head); | |
332 } | 331 } |
333 } | 332 } |
334 | 333 |
335 static void VisitPhantomObject(Heap* heap, Context* context) { | 334 static void VisitPhantomObject(Heap* heap, Context* context) { |
336 ClearWeakList<JSFunction>(heap, | 335 ClearWeakList<JSFunction>(heap, |
337 context->get(Context::OPTIMIZED_FUNCTIONS_LIST)); | 336 context->get(Context::OPTIMIZED_FUNCTIONS_LIST)); |
338 ClearWeakList<Code>(heap, context->get(Context::OPTIMIZED_CODE_LIST)); | 337 ClearWeakList<Code>(heap, context->get(Context::OPTIMIZED_CODE_LIST)); |
339 ClearWeakList<Code>(heap, context->get(Context::DEOPTIMIZED_CODE_LIST)); | 338 ClearWeakList<Code>(heap, context->get(Context::DEOPTIMIZED_CODE_LIST)); |
340 } | 339 } |
341 }; | 340 }; |
(...skipping 15 matching lines...) Expand all Loading... |
357 }; | 356 }; |
358 | 357 |
359 | 358 |
360 template Object* VisitWeakList<Context>(Heap* heap, Object* list, | 359 template Object* VisitWeakList<Context>(Heap* heap, Object* list, |
361 WeakObjectRetainer* retainer); | 360 WeakObjectRetainer* retainer); |
362 | 361 |
363 template Object* VisitWeakList<AllocationSite>(Heap* heap, Object* list, | 362 template Object* VisitWeakList<AllocationSite>(Heap* heap, Object* list, |
364 WeakObjectRetainer* retainer); | 363 WeakObjectRetainer* retainer); |
365 } // namespace internal | 364 } // namespace internal |
366 } // namespace v8 | 365 } // namespace v8 |
OLD | NEW |