| 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 551 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 562 | 562 |
| 563 if (!heap_->mark_compact_collector()->sweeping_in_progress()) { | 563 if (!heap_->mark_compact_collector()->sweeping_in_progress()) { |
| 564 StartMarking(); | 564 StartMarking(); |
| 565 } else { | 565 } else { |
| 566 if (FLAG_trace_incremental_marking) { | 566 if (FLAG_trace_incremental_marking) { |
| 567 PrintF("[IncrementalMarking] Start sweeping.\n"); | 567 PrintF("[IncrementalMarking] Start sweeping.\n"); |
| 568 } | 568 } |
| 569 state_ = SWEEPING; | 569 state_ = SWEEPING; |
| 570 } | 570 } |
| 571 | 571 |
| 572 heap_->LowerInlineAllocationLimit(kAllocatedThreshold); | 572 heap_->SetIncrementalMarkingStep(kAllocatedThreshold); |
| 573 incremental_marking_job()->Start(heap_); | 573 incremental_marking_job()->Start(heap_); |
| 574 } | 574 } |
| 575 | 575 |
| 576 | 576 |
| 577 void IncrementalMarking::StartMarking() { | 577 void IncrementalMarking::StartMarking() { |
| 578 if (FLAG_trace_incremental_marking) { | 578 if (FLAG_trace_incremental_marking) { |
| 579 PrintF("[IncrementalMarking] Start marking\n"); | 579 PrintF("[IncrementalMarking] Start marking\n"); |
| 580 } | 580 } |
| 581 | 581 |
| 582 is_compacting_ = !FLAG_never_compact && | 582 is_compacting_ = !FLAG_never_compact && |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 814 context = Context::cast(context)->get(Context::NEXT_CONTEXT_LINK); | 814 context = Context::cast(context)->get(Context::NEXT_CONTEXT_LINK); |
| 815 } | 815 } |
| 816 } | 816 } |
| 817 | 817 |
| 818 | 818 |
| 819 void IncrementalMarking::Stop() { | 819 void IncrementalMarking::Stop() { |
| 820 if (IsStopped()) return; | 820 if (IsStopped()) return; |
| 821 if (FLAG_trace_incremental_marking) { | 821 if (FLAG_trace_incremental_marking) { |
| 822 PrintF("[IncrementalMarking] Stopping.\n"); | 822 PrintF("[IncrementalMarking] Stopping.\n"); |
| 823 } | 823 } |
| 824 heap_->ResetInlineAllocationLimit(); | 824 heap_->SetIncrementalMarkingStep(0); |
| 825 IncrementalMarking::set_should_hurry(false); | 825 IncrementalMarking::set_should_hurry(false); |
| 826 ResetStepCounters(); | 826 ResetStepCounters(); |
| 827 if (IsMarking()) { | 827 if (IsMarking()) { |
| 828 PatchIncrementalMarkingRecordWriteStubs(heap_, | 828 PatchIncrementalMarkingRecordWriteStubs(heap_, |
| 829 RecordWriteStub::STORE_BUFFER_ONLY); | 829 RecordWriteStub::STORE_BUFFER_ONLY); |
| 830 DeactivateIncrementalWriteBarrier(); | 830 DeactivateIncrementalWriteBarrier(); |
| 831 | 831 |
| 832 if (is_compacting_) { | 832 if (is_compacting_) { |
| 833 LargeObjectIterator it(heap_->lo_space()); | 833 LargeObjectIterator it(heap_->lo_space()); |
| 834 for (HeapObject* obj = it.Next(); obj != NULL; obj = it.Next()) { | 834 for (HeapObject* obj = it.Next(); obj != NULL; obj = it.Next()) { |
| 835 Page* p = Page::FromAddress(obj->address()); | 835 Page* p = Page::FromAddress(obj->address()); |
| 836 if (p->IsFlagSet(Page::RESCAN_ON_EVACUATION)) { | 836 if (p->IsFlagSet(Page::RESCAN_ON_EVACUATION)) { |
| 837 p->ClearFlag(Page::RESCAN_ON_EVACUATION); | 837 p->ClearFlag(Page::RESCAN_ON_EVACUATION); |
| 838 } | 838 } |
| 839 } | 839 } |
| 840 } | 840 } |
| 841 } | 841 } |
| 842 heap_->isolate()->stack_guard()->ClearGC(); | 842 heap_->isolate()->stack_guard()->ClearGC(); |
| 843 state_ = STOPPED; | 843 state_ = STOPPED; |
| 844 is_compacting_ = false; | 844 is_compacting_ = false; |
| 845 } | 845 } |
| 846 | 846 |
| 847 | 847 |
| 848 void IncrementalMarking::Finalize() { | 848 void IncrementalMarking::Finalize() { |
| 849 Hurry(); | 849 Hurry(); |
| 850 state_ = STOPPED; | 850 state_ = STOPPED; |
| 851 is_compacting_ = false; | 851 is_compacting_ = false; |
| 852 heap_->ResetInlineAllocationLimit(); | 852 heap_->SetIncrementalMarkingStep(0); |
| 853 IncrementalMarking::set_should_hurry(false); | 853 IncrementalMarking::set_should_hurry(false); |
| 854 ResetStepCounters(); | 854 ResetStepCounters(); |
| 855 PatchIncrementalMarkingRecordWriteStubs(heap_, | 855 PatchIncrementalMarkingRecordWriteStubs(heap_, |
| 856 RecordWriteStub::STORE_BUFFER_ONLY); | 856 RecordWriteStub::STORE_BUFFER_ONLY); |
| 857 DeactivateIncrementalWriteBarrier(); | 857 DeactivateIncrementalWriteBarrier(); |
| 858 DCHECK(heap_->mark_compact_collector()->marking_deque()->IsEmpty()); | 858 DCHECK(heap_->mark_compact_collector()->marking_deque()->IsEmpty()); |
| 859 heap_->isolate()->stack_guard()->ClearGC(); | 859 heap_->isolate()->stack_guard()->ClearGC(); |
| 860 } | 860 } |
| 861 | 861 |
| 862 | 862 |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1127 void IncrementalMarking::IncrementIdleMarkingDelayCounter() { | 1127 void IncrementalMarking::IncrementIdleMarkingDelayCounter() { |
| 1128 idle_marking_delay_counter_++; | 1128 idle_marking_delay_counter_++; |
| 1129 } | 1129 } |
| 1130 | 1130 |
| 1131 | 1131 |
| 1132 void IncrementalMarking::ClearIdleMarkingDelayCounter() { | 1132 void IncrementalMarking::ClearIdleMarkingDelayCounter() { |
| 1133 idle_marking_delay_counter_ = 0; | 1133 idle_marking_delay_counter_ = 0; |
| 1134 } | 1134 } |
| 1135 } // namespace internal | 1135 } // namespace internal |
| 1136 } // namespace v8 | 1136 } // namespace v8 |
| OLD | NEW |