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