| 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 550 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 561 if (FLAG_cleanup_code_caches_at_gc) { | 561 if (FLAG_cleanup_code_caches_at_gc) { |
| 562 // We will mark cache black with a separate pass | 562 // We will mark cache black with a separate pass |
| 563 // when we finish marking. | 563 // when we finish marking. |
| 564 MarkObjectGreyDoNotEnqueue(heap_->polymorphic_code_cache()); | 564 MarkObjectGreyDoNotEnqueue(heap_->polymorphic_code_cache()); |
| 565 } | 565 } |
| 566 | 566 |
| 567 // Mark strong roots grey. | 567 // Mark strong roots grey. |
| 568 IncrementalMarkingRootMarkingVisitor visitor(this); | 568 IncrementalMarkingRootMarkingVisitor visitor(this); |
| 569 heap_->IterateStrongRoots(&visitor, VISIT_ONLY_STRONG); | 569 heap_->IterateStrongRoots(&visitor, VISIT_ONLY_STRONG); |
| 570 | 570 |
| 571 if (FLAG_black_allocation) { | 571 if (FLAG_black_allocation && !heap()->ShouldReduceMemory()) { |
| 572 StartBlackAllocation(); | 572 StartBlackAllocation(); |
| 573 } | 573 } |
| 574 | 574 |
| 575 // Ready to start incremental marking. | 575 // Ready to start incremental marking. |
| 576 if (FLAG_trace_incremental_marking) { | 576 if (FLAG_trace_incremental_marking) { |
| 577 PrintF("[IncrementalMarking] Running\n"); | 577 PrintF("[IncrementalMarking] Running\n"); |
| 578 } | 578 } |
| 579 } | 579 } |
| 580 | 580 |
| 581 void IncrementalMarking::StartBlackAllocation() { | 581 void IncrementalMarking::StartBlackAllocation() { |
| 582 DCHECK(FLAG_black_allocation); | 582 DCHECK(FLAG_black_allocation); |
| 583 DCHECK(IsMarking()); | 583 DCHECK(IsMarking()); |
| 584 black_allocation_ = true; | 584 black_allocation_ = true; |
| 585 OldSpace* old_space = heap()->old_space(); | 585 OldSpace* old_space = heap()->old_space(); |
| 586 old_space->EmptyAllocationInfo(); | 586 old_space->EmptyAllocationInfo(); |
| 587 old_space->free_list()->Reset(); | 587 old_space->free_list()->Reset(); |
| 588 if (FLAG_trace_incremental_marking) { | 588 if (FLAG_trace_incremental_marking) { |
| 589 PrintF("[IncrementalMarking] Black allocation started\n"); | 589 PrintF("[IncrementalMarking] Black allocation started\n"); |
| 590 } | 590 } |
| 591 } | 591 } |
| 592 | 592 |
| 593 void IncrementalMarking::FinishBlackAllocation() { | 593 void IncrementalMarking::FinishBlackAllocation() { |
| 594 black_allocation_ = false; | 594 if (black_allocation_) { |
| 595 if (FLAG_trace_incremental_marking) { | 595 black_allocation_ = false; |
| 596 PrintF("[IncrementalMarking] Black allocation finished\n"); | 596 if (FLAG_trace_incremental_marking) { |
| 597 PrintF("[IncrementalMarking] Black allocation finished\n"); |
| 598 } |
| 597 } | 599 } |
| 598 } | 600 } |
| 599 | 601 |
| 600 void IncrementalMarking::MarkRoots() { | 602 void IncrementalMarking::MarkRoots() { |
| 601 DCHECK(!finalize_marking_completed_); | 603 DCHECK(!finalize_marking_completed_); |
| 602 DCHECK(IsMarking()); | 604 DCHECK(IsMarking()); |
| 603 | 605 |
| 604 IncrementalMarkingRootMarkingVisitor visitor(this); | 606 IncrementalMarkingRootMarkingVisitor visitor(this); |
| 605 heap_->IterateStrongRoots(&visitor, VISIT_ONLY_STRONG); | 607 heap_->IterateStrongRoots(&visitor, VISIT_ONLY_STRONG); |
| 606 } | 608 } |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 760 static_cast<int>(delta), incremental_marking_finalization_rounds_, | 762 static_cast<int>(delta), incremental_marking_finalization_rounds_, |
| 761 marking_progress); | 763 marking_progress); |
| 762 } | 764 } |
| 763 | 765 |
| 764 ++incremental_marking_finalization_rounds_; | 766 ++incremental_marking_finalization_rounds_; |
| 765 if ((incremental_marking_finalization_rounds_ >= | 767 if ((incremental_marking_finalization_rounds_ >= |
| 766 FLAG_max_incremental_marking_finalization_rounds) || | 768 FLAG_max_incremental_marking_finalization_rounds) || |
| 767 (marking_progress < | 769 (marking_progress < |
| 768 FLAG_min_progress_during_incremental_marking_finalization)) { | 770 FLAG_min_progress_during_incremental_marking_finalization)) { |
| 769 finalize_marking_completed_ = true; | 771 finalize_marking_completed_ = true; |
| 772 |
| 773 // If black allocation was not enabled earlier, start black allocation |
| 774 // here. |
| 775 if (FLAG_black_allocation && !black_allocation_) { |
| 776 StartBlackAllocation(); |
| 777 } |
| 770 } | 778 } |
| 771 } | 779 } |
| 772 | 780 |
| 773 | 781 |
| 774 void IncrementalMarking::UpdateMarkingDequeAfterScavenge() { | 782 void IncrementalMarking::UpdateMarkingDequeAfterScavenge() { |
| 775 if (!IsMarking()) return; | 783 if (!IsMarking()) return; |
| 776 | 784 |
| 777 MarkingDeque* marking_deque = | 785 MarkingDeque* marking_deque = |
| 778 heap_->mark_compact_collector()->marking_deque(); | 786 heap_->mark_compact_collector()->marking_deque(); |
| 779 int current = marking_deque->bottom(); | 787 int current = marking_deque->bottom(); |
| (...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1244 void IncrementalMarking::IncrementIdleMarkingDelayCounter() { | 1252 void IncrementalMarking::IncrementIdleMarkingDelayCounter() { |
| 1245 idle_marking_delay_counter_++; | 1253 idle_marking_delay_counter_++; |
| 1246 } | 1254 } |
| 1247 | 1255 |
| 1248 | 1256 |
| 1249 void IncrementalMarking::ClearIdleMarkingDelayCounter() { | 1257 void IncrementalMarking::ClearIdleMarkingDelayCounter() { |
| 1250 idle_marking_delay_counter_ = 0; | 1258 idle_marking_delay_counter_ = 0; |
| 1251 } | 1259 } |
| 1252 } // namespace internal | 1260 } // namespace internal |
| 1253 } // namespace v8 | 1261 } // namespace v8 |
| OLD | NEW |