| 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 #ifndef V8_OBJECTS_VISITING_INL_H_ | 5 #ifndef V8_OBJECTS_VISITING_INL_H_ |
| 6 #define V8_OBJECTS_VISITING_INL_H_ | 6 #define V8_OBJECTS_VISITING_INL_H_ |
| 7 | 7 |
| 8 #include "src/heap/array-buffer-tracker.h" | 8 #include "src/heap/array-buffer-tracker.h" |
| 9 #include "src/heap/objects-visiting.h" | 9 #include "src/heap/objects-visiting.h" |
| 10 #include "src/ic/ic-state.h" | 10 #include "src/ic/ic-state.h" |
| (...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 347 | 347 |
| 348 template <typename StaticVisitor> | 348 template <typename StaticVisitor> |
| 349 void StaticMarkingVisitor<StaticVisitor>::VisitWeakCell(Map* map, | 349 void StaticMarkingVisitor<StaticVisitor>::VisitWeakCell(Map* map, |
| 350 HeapObject* object) { | 350 HeapObject* object) { |
| 351 Heap* heap = map->GetHeap(); | 351 Heap* heap = map->GetHeap(); |
| 352 WeakCell* weak_cell = reinterpret_cast<WeakCell*>(object); | 352 WeakCell* weak_cell = reinterpret_cast<WeakCell*>(object); |
| 353 // Enqueue weak cell in linked list of encountered weak collections. | 353 // Enqueue weak cell in linked list of encountered weak collections. |
| 354 // We can ignore weak cells with cleared values because they will always | 354 // We can ignore weak cells with cleared values because they will always |
| 355 // contain smi zero. | 355 // contain smi zero. |
| 356 if (weak_cell->next_cleared() && !weak_cell->cleared()) { | 356 if (weak_cell->next_cleared() && !weak_cell->cleared()) { |
| 357 weak_cell->set_next(heap->encountered_weak_cells(), | 357 HeapObject* value = HeapObject::cast(weak_cell->value()); |
| 358 UPDATE_WEAK_WRITE_BARRIER); | 358 if (MarkCompactCollector::IsMarked(value)) { |
| 359 heap->set_encountered_weak_cells(weak_cell); | 359 // Weak cells with live values are directly processed here to reduce |
| 360 // the processing time of weak cells during the main GC pause. |
| 361 Object** slot = HeapObject::RawField(weak_cell, WeakCell::kValueOffset); |
| 362 map->GetHeap()->mark_compact_collector()->RecordSlot(weak_cell, slot, |
| 363 *slot); |
| 364 } else { |
| 365 // If we do not know about liveness of values of weak cells, we have to |
| 366 // process them when we know the liveness of the whole transitive |
| 367 // closure. |
| 368 weak_cell->set_next(heap->encountered_weak_cells(), |
| 369 UPDATE_WEAK_WRITE_BARRIER); |
| 370 heap->set_encountered_weak_cells(weak_cell); |
| 371 } |
| 360 } | 372 } |
| 361 } | 373 } |
| 362 | 374 |
| 363 | 375 |
| 364 template <typename StaticVisitor> | 376 template <typename StaticVisitor> |
| 365 void StaticMarkingVisitor<StaticVisitor>::VisitAllocationSite( | 377 void StaticMarkingVisitor<StaticVisitor>::VisitAllocationSite( |
| 366 Map* map, HeapObject* object) { | 378 Map* map, HeapObject* object) { |
| 367 Heap* heap = map->GetHeap(); | 379 Heap* heap = map->GetHeap(); |
| 368 | 380 |
| 369 StaticVisitor::VisitPointers( | 381 StaticVisitor::VisitPointers( |
| (...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 887 | 899 |
| 888 RelocIterator it(this, mode_mask); | 900 RelocIterator it(this, mode_mask); |
| 889 for (; !it.done(); it.next()) { | 901 for (; !it.done(); it.next()) { |
| 890 it.rinfo()->template Visit<StaticVisitor>(heap); | 902 it.rinfo()->template Visit<StaticVisitor>(heap); |
| 891 } | 903 } |
| 892 } | 904 } |
| 893 } | 905 } |
| 894 } // namespace v8::internal | 906 } // namespace v8::internal |
| 895 | 907 |
| 896 #endif // V8_OBJECTS_VISITING_INL_H_ | 908 #endif // V8_OBJECTS_VISITING_INL_H_ |
| OLD | NEW |