| 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/incremental-marking.h" | 5 #include "src/heap/incremental-marking.h" |
| 6 | 6 |
| 7 #include "src/code-stubs.h" | 7 #include "src/code-stubs.h" |
| 8 #include "src/compilation-cache.h" | 8 #include "src/compilation-cache.h" |
| 9 #include "src/conversions.h" | 9 #include "src/conversions.h" |
| 10 #include "src/heap/gc-idle-time-handler.h" | 10 #include "src/heap/gc-idle-time-handler.h" |
| (...skipping 631 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 642 &visitor, &MarkCompactCollector::IsUnmarkedHeapObjectWithHeap); | 642 &visitor, &MarkCompactCollector::IsUnmarkedHeapObjectWithHeap); |
| 643 heap_->isolate()->global_handles()->RemoveImplicitRefGroups(); | 643 heap_->isolate()->global_handles()->RemoveImplicitRefGroups(); |
| 644 heap_->isolate()->global_handles()->RemoveObjectGroups(); | 644 heap_->isolate()->global_handles()->RemoveObjectGroups(); |
| 645 } | 645 } |
| 646 | 646 |
| 647 | 647 |
| 648 void IncrementalMarking::ProcessWeakCells() { | 648 void IncrementalMarking::ProcessWeakCells() { |
| 649 DCHECK(!finalize_marking_completed_); | 649 DCHECK(!finalize_marking_completed_); |
| 650 DCHECK(IsMarking()); | 650 DCHECK(IsMarking()); |
| 651 | 651 |
| 652 Object* the_hole_value = heap()->the_hole_value(); |
| 652 Object* weak_cell_obj = heap()->encountered_weak_cells(); | 653 Object* weak_cell_obj = heap()->encountered_weak_cells(); |
| 653 Object* weak_cell_head = Smi::FromInt(0); | 654 Object* weak_cell_head = Smi::FromInt(0); |
| 654 WeakCell* prev_weak_cell_obj = NULL; | 655 WeakCell* prev_weak_cell_obj = NULL; |
| 655 while (weak_cell_obj != Smi::FromInt(0)) { | 656 while (weak_cell_obj != Smi::FromInt(0)) { |
| 656 WeakCell* weak_cell = reinterpret_cast<WeakCell*>(weak_cell_obj); | 657 WeakCell* weak_cell = reinterpret_cast<WeakCell*>(weak_cell_obj); |
| 657 // We do not insert cleared weak cells into the list, so the value | 658 // We do not insert cleared weak cells into the list, so the value |
| 658 // cannot be a Smi here. | 659 // cannot be a Smi here. |
| 659 HeapObject* value = HeapObject::cast(weak_cell->value()); | 660 HeapObject* value = HeapObject::cast(weak_cell->value()); |
| 660 // Remove weak cells with live objects from the list, they do not need | 661 // Remove weak cells with live objects from the list, they do not need |
| 661 // clearing. | 662 // clearing. |
| 662 if (MarkCompactCollector::IsMarked(value)) { | 663 if (MarkCompactCollector::IsMarked(value)) { |
| 663 // Record slot, if value is pointing to an evacuation candidate. | 664 // Record slot, if value is pointing to an evacuation candidate. |
| 664 Object** slot = HeapObject::RawField(weak_cell, WeakCell::kValueOffset); | 665 Object** slot = HeapObject::RawField(weak_cell, WeakCell::kValueOffset); |
| 665 heap_->mark_compact_collector()->RecordSlot(weak_cell, slot, *slot); | 666 heap_->mark_compact_collector()->RecordSlot(weak_cell, slot, *slot); |
| 666 // Remove entry somewhere after top. | 667 // Remove entry somewhere after top. |
| 667 if (prev_weak_cell_obj != NULL) { | 668 if (prev_weak_cell_obj != NULL) { |
| 668 prev_weak_cell_obj->set_next(weak_cell->next()); | 669 prev_weak_cell_obj->set_next(weak_cell->next()); |
| 669 } | 670 } |
| 670 weak_cell_obj = weak_cell->next(); | 671 weak_cell_obj = weak_cell->next(); |
| 671 weak_cell->clear_next(heap()); | 672 weak_cell->clear_next(the_hole_value); |
| 672 } else { | 673 } else { |
| 673 if (weak_cell_head == Smi::FromInt(0)) { | 674 if (weak_cell_head == Smi::FromInt(0)) { |
| 674 weak_cell_head = weak_cell; | 675 weak_cell_head = weak_cell; |
| 675 } | 676 } |
| 676 prev_weak_cell_obj = weak_cell; | 677 prev_weak_cell_obj = weak_cell; |
| 677 weak_cell_obj = weak_cell->next(); | 678 weak_cell_obj = weak_cell->next(); |
| 678 } | 679 } |
| 679 } | 680 } |
| 680 // Top may have changed. | 681 // Top may have changed. |
| 681 heap()->set_encountered_weak_cells(weak_cell_head); | 682 heap()->set_encountered_weak_cells(weak_cell_head); |
| (...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1203 void IncrementalMarking::IncrementIdleMarkingDelayCounter() { | 1204 void IncrementalMarking::IncrementIdleMarkingDelayCounter() { |
| 1204 idle_marking_delay_counter_++; | 1205 idle_marking_delay_counter_++; |
| 1205 } | 1206 } |
| 1206 | 1207 |
| 1207 | 1208 |
| 1208 void IncrementalMarking::ClearIdleMarkingDelayCounter() { | 1209 void IncrementalMarking::ClearIdleMarkingDelayCounter() { |
| 1209 idle_marking_delay_counter_ = 0; | 1210 idle_marking_delay_counter_ = 0; |
| 1210 } | 1211 } |
| 1211 } // namespace internal | 1212 } // namespace internal |
| 1212 } // namespace v8 | 1213 } // namespace v8 |
| OLD | NEW |