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 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 Marking::AnyToGrey(mark_bit); | 157 Marking::AnyToGrey(mark_bit); |
158 } | 158 } |
159 } | 159 } |
160 | 160 |
161 void IncrementalMarking::TransferMark(Heap* heap, Address old_start, | 161 void IncrementalMarking::TransferMark(Heap* heap, Address old_start, |
162 Address new_start) { | 162 Address new_start) { |
163 // This is only used when resizing an object. | 163 // This is only used when resizing an object. |
164 DCHECK(MemoryChunk::FromAddress(old_start) == | 164 DCHECK(MemoryChunk::FromAddress(old_start) == |
165 MemoryChunk::FromAddress(new_start)); | 165 MemoryChunk::FromAddress(new_start)); |
166 | 166 |
167 if (!heap->incremental_marking()->IsMarking() || | 167 if (!heap->incremental_marking()->IsMarking()) return; |
168 Page::FromAddress(old_start)->IsFlagSet(Page::BLACK_PAGE)) | |
169 return; | |
170 | 168 |
171 // If the mark doesn't move, we don't check the color of the object. | 169 // If the mark doesn't move, we don't check the color of the object. |
172 // It doesn't matter whether the object is black, since it hasn't changed | 170 // It doesn't matter whether the object is black, since it hasn't changed |
173 // size, so the adjustment to the live data count will be zero anyway. | 171 // size, so the adjustment to the live data count will be zero anyway. |
174 if (old_start == new_start) return; | 172 if (old_start == new_start) return; |
175 | 173 |
176 MarkBit new_mark_bit = ObjectMarking::MarkBitFrom(new_start); | 174 MarkBit new_mark_bit = ObjectMarking::MarkBitFrom(new_start); |
177 MarkBit old_mark_bit = ObjectMarking::MarkBitFrom(old_start); | 175 MarkBit old_mark_bit = ObjectMarking::MarkBitFrom(old_start); |
178 | 176 |
179 #ifdef DEBUG | 177 #ifdef DEBUG |
(...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
596 // Ready to start incremental marking. | 594 // Ready to start incremental marking. |
597 if (FLAG_trace_incremental_marking) { | 595 if (FLAG_trace_incremental_marking) { |
598 PrintF("[IncrementalMarking] Running\n"); | 596 PrintF("[IncrementalMarking] Running\n"); |
599 } | 597 } |
600 } | 598 } |
601 | 599 |
602 void IncrementalMarking::StartBlackAllocation() { | 600 void IncrementalMarking::StartBlackAllocation() { |
603 DCHECK(FLAG_black_allocation); | 601 DCHECK(FLAG_black_allocation); |
604 DCHECK(IsMarking()); | 602 DCHECK(IsMarking()); |
605 black_allocation_ = true; | 603 black_allocation_ = true; |
606 OldSpace* old_space = heap()->old_space(); | 604 heap()->old_space()->MarkAllocationInfoBlack(); |
607 old_space->EmptyAllocationInfo(); | 605 heap()->map_space()->MarkAllocationInfoBlack(); |
608 old_space->free_list()->Reset(); | 606 heap()->code_space()->MarkAllocationInfoBlack(); |
609 if (FLAG_trace_incremental_marking) { | 607 if (FLAG_trace_incremental_marking) { |
610 PrintF("[IncrementalMarking] Black allocation started\n"); | 608 PrintF("[IncrementalMarking] Black allocation started\n"); |
611 } | 609 } |
612 } | 610 } |
613 | 611 |
614 void IncrementalMarking::FinishBlackAllocation() { | 612 void IncrementalMarking::FinishBlackAllocation() { |
615 if (black_allocation_) { | 613 if (black_allocation_) { |
616 black_allocation_ = false; | 614 black_allocation_ = false; |
617 if (FLAG_trace_incremental_marking) { | 615 if (FLAG_trace_incremental_marking) { |
618 PrintF("[IncrementalMarking] Black allocation finished\n"); | 616 PrintF("[IncrementalMarking] Black allocation finished\n"); |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
826 // Only pointers to from space have to be updated. | 824 // Only pointers to from space have to be updated. |
827 if (heap_->InFromSpace(obj)) { | 825 if (heap_->InFromSpace(obj)) { |
828 MapWord map_word = obj->map_word(); | 826 MapWord map_word = obj->map_word(); |
829 // There may be objects on the marking deque that do not exist anymore, | 827 // There may be objects on the marking deque that do not exist anymore, |
830 // e.g. left trimmed objects or objects from the root set (frames). | 828 // e.g. left trimmed objects or objects from the root set (frames). |
831 // If these object are dead at scavenging time, their marking deque | 829 // If these object are dead at scavenging time, their marking deque |
832 // entries will not point to forwarding addresses. Hence, we can discard | 830 // entries will not point to forwarding addresses. Hence, we can discard |
833 // them. | 831 // them. |
834 if (map_word.IsForwardingAddress()) { | 832 if (map_word.IsForwardingAddress()) { |
835 HeapObject* dest = map_word.ToForwardingAddress(); | 833 HeapObject* dest = map_word.ToForwardingAddress(); |
836 if (Page::FromAddress(dest->address())->IsFlagSet(Page::BLACK_PAGE)) | 834 if (Marking::IsBlack(ObjectMarking::MarkBitFrom(dest->address()))) |
837 continue; | 835 continue; |
838 array[new_top] = dest; | 836 array[new_top] = dest; |
839 new_top = ((new_top + 1) & mask); | 837 new_top = ((new_top + 1) & mask); |
840 DCHECK(new_top != marking_deque->bottom()); | 838 DCHECK(new_top != marking_deque->bottom()); |
841 #ifdef DEBUG | 839 #ifdef DEBUG |
842 MarkBit mark_bit = ObjectMarking::MarkBitFrom(obj); | 840 MarkBit mark_bit = ObjectMarking::MarkBitFrom(obj); |
843 DCHECK(Marking::IsGrey(mark_bit) || | 841 DCHECK(Marking::IsGrey(mark_bit) || |
844 (obj->IsFiller() && Marking::IsWhite(mark_bit))); | 842 (obj->IsFiller() && Marking::IsWhite(mark_bit))); |
845 #endif | 843 #endif |
846 } | 844 } |
(...skipping 431 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1278 void IncrementalMarking::IncrementIdleMarkingDelayCounter() { | 1276 void IncrementalMarking::IncrementIdleMarkingDelayCounter() { |
1279 idle_marking_delay_counter_++; | 1277 idle_marking_delay_counter_++; |
1280 } | 1278 } |
1281 | 1279 |
1282 | 1280 |
1283 void IncrementalMarking::ClearIdleMarkingDelayCounter() { | 1281 void IncrementalMarking::ClearIdleMarkingDelayCounter() { |
1284 idle_marking_delay_counter_ = 0; | 1282 idle_marking_delay_counter_ = 0; |
1285 } | 1283 } |
1286 } // namespace internal | 1284 } // namespace internal |
1287 } // namespace v8 | 1285 } // namespace v8 |
OLD | NEW |