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/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #include "src/heap/incremental-marking.h" | 7 #include "src/heap/incremental-marking.h" |
8 | 8 |
9 #include "src/code-stubs.h" | 9 #include "src/code-stubs.h" |
10 #include "src/compilation-cache.h" | 10 #include "src/compilation-cache.h" |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 MarkBit mark_bit = Marking::MarkBitFrom(HeapObject::cast(obj)); | 128 MarkBit mark_bit = Marking::MarkBitFrom(HeapObject::cast(obj)); |
129 if (Marking::IsBlack(mark_bit)) { | 129 if (Marking::IsBlack(mark_bit)) { |
130 MemoryChunk::IncrementLiveBytesFromGC(heap_obj->address(), | 130 MemoryChunk::IncrementLiveBytesFromGC(heap_obj->address(), |
131 -heap_obj->Size()); | 131 -heap_obj->Size()); |
132 } | 132 } |
133 Marking::AnyToGrey(mark_bit); | 133 Marking::AnyToGrey(mark_bit); |
134 } | 134 } |
135 } | 135 } |
136 | 136 |
137 | 137 |
138 static inline void MarkBlackOrKeepGrey(HeapObject* heap_object, | |
139 MarkBit mark_bit, int size) { | |
140 DCHECK(!Marking::IsImpossible(mark_bit)); | |
141 if (mark_bit.Get()) return; | |
142 mark_bit.Set(); | |
143 MemoryChunk::IncrementLiveBytesFromGC(heap_object->address(), size); | |
144 DCHECK(Marking::IsBlack(mark_bit)); | |
145 } | |
146 | |
147 | |
148 static inline void MarkBlackOrKeepBlack(HeapObject* heap_object, | 138 static inline void MarkBlackOrKeepBlack(HeapObject* heap_object, |
149 MarkBit mark_bit, int size) { | 139 MarkBit mark_bit, int size) { |
150 DCHECK(!Marking::IsImpossible(mark_bit)); | 140 DCHECK(!Marking::IsImpossible(mark_bit)); |
151 if (Marking::IsBlack(mark_bit)) return; | 141 if (Marking::IsBlack(mark_bit)) return; |
152 Marking::MarkBlack(mark_bit); | 142 Marking::MarkBlack(mark_bit); |
153 MemoryChunk::IncrementLiveBytesFromGC(heap_object->address(), size); | 143 MemoryChunk::IncrementLiveBytesFromGC(heap_object->address(), size); |
154 DCHECK(Marking::IsBlack(mark_bit)); | 144 DCHECK(Marking::IsBlack(mark_bit)); |
155 } | 145 } |
156 | 146 |
157 | 147 |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
349 NewSpace* space) { | 339 NewSpace* space) { |
350 NewSpacePageIterator it(space); | 340 NewSpacePageIterator it(space); |
351 while (it.has_next()) { | 341 while (it.has_next()) { |
352 NewSpacePage* p = it.next(); | 342 NewSpacePage* p = it.next(); |
353 SetNewSpacePageFlags(p, false); | 343 SetNewSpacePageFlags(p, false); |
354 } | 344 } |
355 } | 345 } |
356 | 346 |
357 | 347 |
358 void IncrementalMarking::DeactivateIncrementalWriteBarrier() { | 348 void IncrementalMarking::DeactivateIncrementalWriteBarrier() { |
359 DeactivateIncrementalWriteBarrierForSpace(heap_->old_pointer_space()); | 349 DeactivateIncrementalWriteBarrierForSpace(heap_->old_space()); |
360 DeactivateIncrementalWriteBarrierForSpace(heap_->old_data_space()); | |
361 DeactivateIncrementalWriteBarrierForSpace(heap_->cell_space()); | 350 DeactivateIncrementalWriteBarrierForSpace(heap_->cell_space()); |
362 DeactivateIncrementalWriteBarrierForSpace(heap_->map_space()); | 351 DeactivateIncrementalWriteBarrierForSpace(heap_->map_space()); |
363 DeactivateIncrementalWriteBarrierForSpace(heap_->code_space()); | 352 DeactivateIncrementalWriteBarrierForSpace(heap_->code_space()); |
364 DeactivateIncrementalWriteBarrierForSpace(heap_->new_space()); | 353 DeactivateIncrementalWriteBarrierForSpace(heap_->new_space()); |
365 | 354 |
366 LargePage* lop = heap_->lo_space()->first_page(); | 355 LargePage* lop = heap_->lo_space()->first_page(); |
367 while (lop->is_valid()) { | 356 while (lop->is_valid()) { |
368 SetOldSpacePageFlags(lop, false, false); | 357 SetOldSpacePageFlags(lop, false, false); |
369 lop = lop->next_page(); | 358 lop = lop->next_page(); |
370 } | 359 } |
(...skipping 12 matching lines...) Expand all Loading... |
383 void IncrementalMarking::ActivateIncrementalWriteBarrier(NewSpace* space) { | 372 void IncrementalMarking::ActivateIncrementalWriteBarrier(NewSpace* space) { |
384 NewSpacePageIterator it(space->ToSpaceStart(), space->ToSpaceEnd()); | 373 NewSpacePageIterator it(space->ToSpaceStart(), space->ToSpaceEnd()); |
385 while (it.has_next()) { | 374 while (it.has_next()) { |
386 NewSpacePage* p = it.next(); | 375 NewSpacePage* p = it.next(); |
387 SetNewSpacePageFlags(p, true); | 376 SetNewSpacePageFlags(p, true); |
388 } | 377 } |
389 } | 378 } |
390 | 379 |
391 | 380 |
392 void IncrementalMarking::ActivateIncrementalWriteBarrier() { | 381 void IncrementalMarking::ActivateIncrementalWriteBarrier() { |
393 ActivateIncrementalWriteBarrier(heap_->old_pointer_space()); | 382 ActivateIncrementalWriteBarrier(heap_->old_space()); |
394 ActivateIncrementalWriteBarrier(heap_->old_data_space()); | |
395 ActivateIncrementalWriteBarrier(heap_->cell_space()); | 383 ActivateIncrementalWriteBarrier(heap_->cell_space()); |
396 ActivateIncrementalWriteBarrier(heap_->map_space()); | 384 ActivateIncrementalWriteBarrier(heap_->map_space()); |
397 ActivateIncrementalWriteBarrier(heap_->code_space()); | 385 ActivateIncrementalWriteBarrier(heap_->code_space()); |
398 ActivateIncrementalWriteBarrier(heap_->new_space()); | 386 ActivateIncrementalWriteBarrier(heap_->new_space()); |
399 | 387 |
400 LargePage* lop = heap_->lo_space()->first_page(); | 388 LargePage* lop = heap_->lo_space()->first_page(); |
401 while (lop->is_valid()) { | 389 while (lop->is_valid()) { |
402 SetOldSpacePageFlags(lop, true, is_compacting_); | 390 SetOldSpacePageFlags(lop, true, is_compacting_); |
403 lop = lop->next_page(); | 391 lop = lop->next_page(); |
404 } | 392 } |
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
647 (obj->IsFiller() && Marking::IsWhite(mark_bit)) || | 635 (obj->IsFiller() && Marking::IsWhite(mark_bit)) || |
648 (chunk->IsFlagSet(MemoryChunk::HAS_PROGRESS_BAR) && | 636 (chunk->IsFlagSet(MemoryChunk::HAS_PROGRESS_BAR) && |
649 Marking::IsBlack(mark_bit))); | 637 Marking::IsBlack(mark_bit))); |
650 #endif | 638 #endif |
651 MarkBlackOrKeepBlack(obj, mark_bit, size); | 639 MarkBlackOrKeepBlack(obj, mark_bit, size); |
652 } | 640 } |
653 | 641 |
654 | 642 |
655 void IncrementalMarking::MarkObject(Heap* heap, HeapObject* obj) { | 643 void IncrementalMarking::MarkObject(Heap* heap, HeapObject* obj) { |
656 MarkBit mark_bit = Marking::MarkBitFrom(obj); | 644 MarkBit mark_bit = Marking::MarkBitFrom(obj); |
657 if (mark_bit.data_only()) { | 645 if (Marking::IsWhite(mark_bit)) { |
658 MarkBlackOrKeepGrey(obj, mark_bit, obj->Size()); | |
659 } else if (Marking::IsWhite(mark_bit)) { | |
660 heap->incremental_marking()->WhiteToGreyAndPush(obj, mark_bit); | 646 heap->incremental_marking()->WhiteToGreyAndPush(obj, mark_bit); |
661 } | 647 } |
662 } | 648 } |
663 | 649 |
664 | 650 |
665 intptr_t IncrementalMarking::ProcessMarkingDeque(intptr_t bytes_to_process) { | 651 intptr_t IncrementalMarking::ProcessMarkingDeque(intptr_t bytes_to_process) { |
666 intptr_t bytes_processed = 0; | 652 intptr_t bytes_processed = 0; |
667 Map* filler_map = heap_->one_pointer_filler_map(); | 653 Map* filler_map = heap_->one_pointer_filler_map(); |
668 MarkingDeque* marking_deque = | 654 MarkingDeque* marking_deque = |
669 heap_->mark_compact_collector()->marking_deque(); | 655 heap_->mark_compact_collector()->marking_deque(); |
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1025 void IncrementalMarking::IncrementIdleMarkingDelayCounter() { | 1011 void IncrementalMarking::IncrementIdleMarkingDelayCounter() { |
1026 idle_marking_delay_counter_++; | 1012 idle_marking_delay_counter_++; |
1027 } | 1013 } |
1028 | 1014 |
1029 | 1015 |
1030 void IncrementalMarking::ClearIdleMarkingDelayCounter() { | 1016 void IncrementalMarking::ClearIdleMarkingDelayCounter() { |
1031 idle_marking_delay_counter_ = 0; | 1017 idle_marking_delay_counter_ = 0; |
1032 } | 1018 } |
1033 } | 1019 } |
1034 } // namespace v8::internal | 1020 } // namespace v8::internal |
OLD | NEW |