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 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
350 NewSpace* space) { | 340 NewSpace* space) { |
351 NewSpacePageIterator it(space); | 341 NewSpacePageIterator it(space); |
352 while (it.has_next()) { | 342 while (it.has_next()) { |
353 NewSpacePage* p = it.next(); | 343 NewSpacePage* p = it.next(); |
354 SetNewSpacePageFlags(p, false); | 344 SetNewSpacePageFlags(p, false); |
355 } | 345 } |
356 } | 346 } |
357 | 347 |
358 | 348 |
359 void IncrementalMarking::DeactivateIncrementalWriteBarrier() { | 349 void IncrementalMarking::DeactivateIncrementalWriteBarrier() { |
360 DeactivateIncrementalWriteBarrierForSpace(heap_->old_pointer_space()); | 350 DeactivateIncrementalWriteBarrierForSpace(heap_->old_space()); |
361 DeactivateIncrementalWriteBarrierForSpace(heap_->old_data_space()); | |
362 DeactivateIncrementalWriteBarrierForSpace(heap_->cell_space()); | 351 DeactivateIncrementalWriteBarrierForSpace(heap_->cell_space()); |
363 DeactivateIncrementalWriteBarrierForSpace(heap_->property_cell_space()); | 352 DeactivateIncrementalWriteBarrierForSpace(heap_->property_cell_space()); |
364 DeactivateIncrementalWriteBarrierForSpace(heap_->map_space()); | 353 DeactivateIncrementalWriteBarrierForSpace(heap_->map_space()); |
365 DeactivateIncrementalWriteBarrierForSpace(heap_->code_space()); | 354 DeactivateIncrementalWriteBarrierForSpace(heap_->code_space()); |
366 DeactivateIncrementalWriteBarrierForSpace(heap_->new_space()); | 355 DeactivateIncrementalWriteBarrierForSpace(heap_->new_space()); |
367 | 356 |
368 LargePage* lop = heap_->lo_space()->first_page(); | 357 LargePage* lop = heap_->lo_space()->first_page(); |
369 while (lop->is_valid()) { | 358 while (lop->is_valid()) { |
370 SetOldSpacePageFlags(lop, false, false); | 359 SetOldSpacePageFlags(lop, false, false); |
371 lop = lop->next_page(); | 360 lop = lop->next_page(); |
(...skipping 13 matching lines...) Expand all Loading... |
385 void IncrementalMarking::ActivateIncrementalWriteBarrier(NewSpace* space) { | 374 void IncrementalMarking::ActivateIncrementalWriteBarrier(NewSpace* space) { |
386 NewSpacePageIterator it(space->ToSpaceStart(), space->ToSpaceEnd()); | 375 NewSpacePageIterator it(space->ToSpaceStart(), space->ToSpaceEnd()); |
387 while (it.has_next()) { | 376 while (it.has_next()) { |
388 NewSpacePage* p = it.next(); | 377 NewSpacePage* p = it.next(); |
389 SetNewSpacePageFlags(p, true); | 378 SetNewSpacePageFlags(p, true); |
390 } | 379 } |
391 } | 380 } |
392 | 381 |
393 | 382 |
394 void IncrementalMarking::ActivateIncrementalWriteBarrier() { | 383 void IncrementalMarking::ActivateIncrementalWriteBarrier() { |
395 ActivateIncrementalWriteBarrier(heap_->old_pointer_space()); | 384 ActivateIncrementalWriteBarrier(heap_->old_space()); |
396 ActivateIncrementalWriteBarrier(heap_->old_data_space()); | |
397 ActivateIncrementalWriteBarrier(heap_->cell_space()); | 385 ActivateIncrementalWriteBarrier(heap_->cell_space()); |
398 ActivateIncrementalWriteBarrier(heap_->property_cell_space()); | 386 ActivateIncrementalWriteBarrier(heap_->property_cell_space()); |
399 ActivateIncrementalWriteBarrier(heap_->map_space()); | 387 ActivateIncrementalWriteBarrier(heap_->map_space()); |
400 ActivateIncrementalWriteBarrier(heap_->code_space()); | 388 ActivateIncrementalWriteBarrier(heap_->code_space()); |
401 ActivateIncrementalWriteBarrier(heap_->new_space()); | 389 ActivateIncrementalWriteBarrier(heap_->new_space()); |
402 | 390 |
403 LargePage* lop = heap_->lo_space()->first_page(); | 391 LargePage* lop = heap_->lo_space()->first_page(); |
404 while (lop->is_valid()) { | 392 while (lop->is_valid()) { |
405 SetOldSpacePageFlags(lop, true, is_compacting_); | 393 SetOldSpacePageFlags(lop, true, is_compacting_); |
406 lop = lop->next_page(); | 394 lop = lop->next_page(); |
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
650 (obj->IsFiller() && Marking::IsWhite(mark_bit)) || | 638 (obj->IsFiller() && Marking::IsWhite(mark_bit)) || |
651 (chunk->IsFlagSet(MemoryChunk::HAS_PROGRESS_BAR) && | 639 (chunk->IsFlagSet(MemoryChunk::HAS_PROGRESS_BAR) && |
652 Marking::IsBlack(mark_bit))); | 640 Marking::IsBlack(mark_bit))); |
653 #endif | 641 #endif |
654 MarkBlackOrKeepBlack(obj, mark_bit, size); | 642 MarkBlackOrKeepBlack(obj, mark_bit, size); |
655 } | 643 } |
656 | 644 |
657 | 645 |
658 void IncrementalMarking::MarkObject(Heap* heap, HeapObject* obj) { | 646 void IncrementalMarking::MarkObject(Heap* heap, HeapObject* obj) { |
659 MarkBit mark_bit = Marking::MarkBitFrom(obj); | 647 MarkBit mark_bit = Marking::MarkBitFrom(obj); |
660 if (mark_bit.data_only()) { | 648 if (Marking::IsWhite(mark_bit)) { |
661 MarkBlackOrKeepGrey(obj, mark_bit, obj->Size()); | |
662 } else if (Marking::IsWhite(mark_bit)) { | |
663 heap->incremental_marking()->WhiteToGreyAndPush(obj, mark_bit); | 649 heap->incremental_marking()->WhiteToGreyAndPush(obj, mark_bit); |
664 } | 650 } |
665 } | 651 } |
666 | 652 |
667 | 653 |
668 intptr_t IncrementalMarking::ProcessMarkingDeque(intptr_t bytes_to_process) { | 654 intptr_t IncrementalMarking::ProcessMarkingDeque(intptr_t bytes_to_process) { |
669 intptr_t bytes_processed = 0; | 655 intptr_t bytes_processed = 0; |
670 Map* filler_map = heap_->one_pointer_filler_map(); | 656 Map* filler_map = heap_->one_pointer_filler_map(); |
671 MarkingDeque* marking_deque = | 657 MarkingDeque* marking_deque = |
672 heap_->mark_compact_collector()->marking_deque(); | 658 heap_->mark_compact_collector()->marking_deque(); |
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1030 void IncrementalMarking::IncrementIdleMarkingDelayCounter() { | 1016 void IncrementalMarking::IncrementIdleMarkingDelayCounter() { |
1031 idle_marking_delay_counter_++; | 1017 idle_marking_delay_counter_++; |
1032 } | 1018 } |
1033 | 1019 |
1034 | 1020 |
1035 void IncrementalMarking::ClearIdleMarkingDelayCounter() { | 1021 void IncrementalMarking::ClearIdleMarkingDelayCounter() { |
1036 idle_marking_delay_counter_ = 0; | 1022 idle_marking_delay_counter_ = 0; |
1037 } | 1023 } |
1038 } | 1024 } |
1039 } // namespace v8::internal | 1025 } // namespace v8::internal |
OLD | NEW |