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 764 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
775 // If concurrent unmapping tasks are still running, we should wait for | 775 // If concurrent unmapping tasks are still running, we should wait for |
776 // them here. | 776 // them here. |
777 heap()->WaitUntilUnmappingOfFreeChunksCompleted(); | 777 heap()->WaitUntilUnmappingOfFreeChunksCompleted(); |
778 | 778 |
779 // Clear marking bits if incremental marking is aborted. | 779 // Clear marking bits if incremental marking is aborted. |
780 if (was_marked_incrementally_ && heap_->ShouldAbortIncrementalMarking()) { | 780 if (was_marked_incrementally_ && heap_->ShouldAbortIncrementalMarking()) { |
781 heap()->incremental_marking()->Stop(); | 781 heap()->incremental_marking()->Stop(); |
782 ClearMarkbits(); | 782 ClearMarkbits(); |
783 AbortWeakCollections(); | 783 AbortWeakCollections(); |
784 AbortWeakCells(); | 784 AbortWeakCells(); |
785 AbortTransitionArrays(); | |
785 AbortCompaction(); | 786 AbortCompaction(); |
786 was_marked_incrementally_ = false; | 787 was_marked_incrementally_ = false; |
787 } | 788 } |
788 | 789 |
789 // Don't start compaction if we are in the middle of incremental | 790 // Don't start compaction if we are in the middle of incremental |
790 // marking cycle. We did not collect any slots. | 791 // marking cycle. We did not collect any slots. |
791 if (!FLAG_never_compact && !was_marked_incrementally_) { | 792 if (!FLAG_never_compact && !was_marked_incrementally_) { |
792 StartCompaction(NON_INCREMENTAL_COMPACTION); | 793 StartCompaction(NON_INCREMENTAL_COMPACTION); |
793 } | 794 } |
794 | 795 |
(...skipping 1406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2201 // Process weak cells before MarkCodeForDeoptimization and | 2202 // Process weak cells before MarkCodeForDeoptimization and |
2202 // ClearNonLiveReferences so that weak cells in dependent code arrays are | 2203 // ClearNonLiveReferences so that weak cells in dependent code arrays are |
2203 // cleared or contain only live code objects. | 2204 // cleared or contain only live code objects. |
2204 ProcessAndClearWeakCells(); | 2205 ProcessAndClearWeakCells(); |
2205 | 2206 |
2206 MarkDependentCodeListForDeoptimization(dependent_code_list); | 2207 MarkDependentCodeListForDeoptimization(dependent_code_list); |
2207 | 2208 |
2208 ClearNonLiveReferences(); | 2209 ClearNonLiveReferences(); |
2209 | 2210 |
2210 ClearWeakCollections(); | 2211 ClearWeakCollections(); |
2211 | |
2212 heap_->set_encountered_weak_cells(Smi::FromInt(0)); | |
2213 } | 2212 } |
2214 | 2213 |
2215 | 2214 |
2216 void MarkCompactCollector::ClearNonLiveReferences() { | 2215 void MarkCompactCollector::ClearNonLiveReferences() { |
2217 GCTracer::Scope gc_scope(heap()->tracer(), | 2216 GCTracer::Scope gc_scope(heap()->tracer(), |
2218 GCTracer::Scope::MC_NONLIVEREFERENCES); | 2217 GCTracer::Scope::MC_NONLIVEREFERENCES); |
2218 | |
2219 ProcessAndClearTransitionArrays(); | |
2220 | |
2219 // Iterate over the map space, setting map transitions that go from | 2221 // Iterate over the map space, setting map transitions that go from |
2220 // a marked map to an unmarked map to null transitions. This action | 2222 // a marked map to an unmarked map to null transitions. This action |
2221 // is carried out only on maps of JSObjects and related subtypes. | 2223 // is carried out only on maps of JSObjects and related subtypes. |
2222 HeapObjectIterator map_iterator(heap()->map_space()); | 2224 HeapObjectIterator map_iterator(heap()->map_space()); |
2223 for (HeapObject* obj = map_iterator.Next(); obj != NULL; | 2225 for (HeapObject* obj = map_iterator.Next(); obj != NULL; |
2224 obj = map_iterator.Next()) { | 2226 obj = map_iterator.Next()) { |
2225 Map* map = Map::cast(obj); | 2227 Map* map = Map::cast(obj); |
2226 if (!map->CanTransition()) continue; | 2228 if (!map->CanTransition()) continue; |
2227 MarkBit map_mark = Marking::MarkBitFrom(map); | 2229 MarkBit map_mark = Marking::MarkBitFrom(map); |
2228 if (Marking::IsWhite(map_mark)) { | 2230 if (Marking::IsWhite(map_mark)) { |
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2526 Object* weak_cell_obj = heap()->encountered_weak_cells(); | 2528 Object* weak_cell_obj = heap()->encountered_weak_cells(); |
2527 while (weak_cell_obj != Smi::FromInt(0)) { | 2529 while (weak_cell_obj != Smi::FromInt(0)) { |
2528 WeakCell* weak_cell = reinterpret_cast<WeakCell*>(weak_cell_obj); | 2530 WeakCell* weak_cell = reinterpret_cast<WeakCell*>(weak_cell_obj); |
2529 weak_cell_obj = weak_cell->next(); | 2531 weak_cell_obj = weak_cell->next(); |
2530 weak_cell->clear_next(heap()); | 2532 weak_cell->clear_next(heap()); |
2531 } | 2533 } |
2532 heap()->set_encountered_weak_cells(Smi::FromInt(0)); | 2534 heap()->set_encountered_weak_cells(Smi::FromInt(0)); |
2533 } | 2535 } |
2534 | 2536 |
2535 | 2537 |
2538 void MarkCompactCollector::ProcessAndClearTransitionArrays() { | |
2539 HeapObject* undefined = heap()->undefined_value(); | |
2540 Object* obj = heap()->encountered_transition_arrays(); | |
2541 while (obj != Smi::FromInt(0)) { | |
2542 TransitionArray* array = reinterpret_cast<TransitionArray*>(obj); | |
Michael Lippautz
2015/11/27 14:27:28
Let's use TransitionArray::cast()
ulan
2015/11/27 14:43:45
Done.
| |
2543 // TODO(ulan): move logic from ClearMapTransitions here. | |
2544 obj = array->next_link(); | |
2545 array->set_next_link(undefined, SKIP_WRITE_BARRIER); | |
2546 } | |
2547 heap()->set_encountered_transition_arrays(Smi::FromInt(0)); | |
2548 } | |
2549 | |
2550 | |
2551 void MarkCompactCollector::AbortTransitionArrays() { | |
2552 HeapObject* undefined = heap()->undefined_value(); | |
2553 Object* obj = heap()->encountered_transition_arrays(); | |
2554 while (obj != Smi::FromInt(0)) { | |
2555 TransitionArray* array = reinterpret_cast<TransitionArray*>(obj); | |
Michael Lippautz
2015/11/27 14:27:28
Let's use TransitionArray::cast()
ulan
2015/11/27 14:43:45
Done.
| |
2556 obj = array->next_link(); | |
2557 array->set_next_link(undefined, SKIP_WRITE_BARRIER); | |
2558 } | |
2559 heap()->set_encountered_transition_arrays(Smi::FromInt(0)); | |
2560 } | |
2561 | |
2562 | |
2536 void MarkCompactCollector::RecordMigratedSlot( | 2563 void MarkCompactCollector::RecordMigratedSlot( |
2537 Object* value, Address slot, SlotsBuffer** evacuation_slots_buffer) { | 2564 Object* value, Address slot, SlotsBuffer** evacuation_slots_buffer) { |
2538 // When parallel compaction is in progress, store and slots buffer entries | 2565 // When parallel compaction is in progress, store and slots buffer entries |
2539 // require synchronization. | 2566 // require synchronization. |
2540 if (heap_->InNewSpace(value)) { | 2567 if (heap_->InNewSpace(value)) { |
2541 if (compaction_in_progress_) { | 2568 if (compaction_in_progress_) { |
2542 heap_->store_buffer()->MarkSynchronized(slot); | 2569 heap_->store_buffer()->MarkSynchronized(slot); |
2543 } else { | 2570 } else { |
2544 heap_->store_buffer()->Mark(slot); | 2571 heap_->store_buffer()->Mark(slot); |
2545 } | 2572 } |
(...skipping 1560 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4106 MarkBit mark_bit = Marking::MarkBitFrom(host); | 4133 MarkBit mark_bit = Marking::MarkBitFrom(host); |
4107 if (Marking::IsBlack(mark_bit)) { | 4134 if (Marking::IsBlack(mark_bit)) { |
4108 RelocInfo rinfo(pc, RelocInfo::CODE_TARGET, 0, host); | 4135 RelocInfo rinfo(pc, RelocInfo::CODE_TARGET, 0, host); |
4109 RecordRelocSlot(&rinfo, target); | 4136 RecordRelocSlot(&rinfo, target); |
4110 } | 4137 } |
4111 } | 4138 } |
4112 } | 4139 } |
4113 | 4140 |
4114 } // namespace internal | 4141 } // namespace internal |
4115 } // namespace v8 | 4142 } // namespace v8 |
OLD | NEW |