| 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 769 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 780 IncrementalMarking::set_should_hurry(false); | 780 IncrementalMarking::set_should_hurry(false); |
| 781 ResetStepCounters(); | 781 ResetStepCounters(); |
| 782 PatchIncrementalMarkingRecordWriteStubs(heap_, | 782 PatchIncrementalMarkingRecordWriteStubs(heap_, |
| 783 RecordWriteStub::STORE_BUFFER_ONLY); | 783 RecordWriteStub::STORE_BUFFER_ONLY); |
| 784 DeactivateIncrementalWriteBarrier(); | 784 DeactivateIncrementalWriteBarrier(); |
| 785 DCHECK(heap_->mark_compact_collector()->marking_deque()->IsEmpty()); | 785 DCHECK(heap_->mark_compact_collector()->marking_deque()->IsEmpty()); |
| 786 heap_->isolate()->stack_guard()->ClearGC(); | 786 heap_->isolate()->stack_guard()->ClearGC(); |
| 787 } | 787 } |
| 788 | 788 |
| 789 | 789 |
| 790 void IncrementalMarking::OverApproximateWeakClosure() { | 790 void IncrementalMarking::OverApproximateWeakClosure(CompletionAction action) { |
| 791 DCHECK(FLAG_overapproximate_weak_closure); | 791 DCHECK(FLAG_overapproximate_weak_closure); |
| 792 DCHECK(!weak_closure_was_overapproximated_); | 792 DCHECK(!weak_closure_was_overapproximated_); |
| 793 if (FLAG_trace_incremental_marking) { | 793 if (FLAG_trace_incremental_marking) { |
| 794 PrintF("[IncrementalMarking] requesting weak closure overapproximation.\n"); | 794 PrintF("[IncrementalMarking] requesting weak closure overapproximation.\n"); |
| 795 } | 795 } |
| 796 request_type_ = OVERAPPROXIMATION; | 796 request_type_ = OVERAPPROXIMATION; |
| 797 heap_->isolate()->stack_guard()->RequestGC(); | 797 if (action == GC_VIA_STACK_GUARD) { |
| 798 heap_->isolate()->stack_guard()->RequestGC(); |
| 799 } |
| 798 } | 800 } |
| 799 | 801 |
| 800 | 802 |
| 801 void IncrementalMarking::MarkingComplete(CompletionAction action) { | 803 void IncrementalMarking::MarkingComplete(CompletionAction action) { |
| 802 state_ = COMPLETE; | 804 state_ = COMPLETE; |
| 803 // We will set the stack guard to request a GC now. This will mean the rest | 805 // We will set the stack guard to request a GC now. This will mean the rest |
| 804 // of the GC gets performed as soon as possible (we can't do a GC here in a | 806 // of the GC gets performed as soon as possible (we can't do a GC here in a |
| 805 // record-write context). If a few things get allocated between now and then | 807 // record-write context). If a few things get allocated between now and then |
| 806 // that shouldn't make us do a scavenge and keep being incremental, so we set | 808 // that shouldn't make us do a scavenge and keep being incremental, so we set |
| 807 // the should-hurry flag to indicate that there can't be much work left to do. | 809 // the should-hurry flag to indicate that there can't be much work left to do. |
| 808 set_should_hurry(true); | 810 set_should_hurry(true); |
| 809 if (FLAG_trace_incremental_marking) { | 811 if (FLAG_trace_incremental_marking) { |
| 810 PrintF("[IncrementalMarking] Complete (normal).\n"); | 812 PrintF("[IncrementalMarking] Complete (normal).\n"); |
| 811 } | 813 } |
| 814 request_type_ = COMPLETE_MARKING; |
| 812 if (action == GC_VIA_STACK_GUARD) { | 815 if (action == GC_VIA_STACK_GUARD) { |
| 813 request_type_ = COMPLETE_MARKING; | |
| 814 heap_->isolate()->stack_guard()->RequestGC(); | 816 heap_->isolate()->stack_guard()->RequestGC(); |
| 815 } | 817 } |
| 816 } | 818 } |
| 817 | 819 |
| 818 | 820 |
| 819 void IncrementalMarking::Epilogue() { | 821 void IncrementalMarking::Epilogue() { |
| 820 was_activated_ = false; | 822 was_activated_ = false; |
| 821 weak_closure_was_overapproximated_ = false; | 823 weak_closure_was_overapproximated_ = false; |
| 822 } | 824 } |
| 823 | 825 |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 956 if (!heap_->mark_compact_collector()->sweeping_in_progress()) { | 958 if (!heap_->mark_compact_collector()->sweeping_in_progress()) { |
| 957 bytes_scanned_ = 0; | 959 bytes_scanned_ = 0; |
| 958 StartMarking(PREVENT_COMPACTION); | 960 StartMarking(PREVENT_COMPACTION); |
| 959 } | 961 } |
| 960 } else if (state_ == MARKING) { | 962 } else if (state_ == MARKING) { |
| 961 bytes_processed = ProcessMarkingDeque(bytes_to_process); | 963 bytes_processed = ProcessMarkingDeque(bytes_to_process); |
| 962 if (heap_->mark_compact_collector()->marking_deque()->IsEmpty()) { | 964 if (heap_->mark_compact_collector()->marking_deque()->IsEmpty()) { |
| 963 if (completion == FORCE_COMPLETION || | 965 if (completion == FORCE_COMPLETION || |
| 964 IsIdleMarkingDelayCounterLimitReached()) { | 966 IsIdleMarkingDelayCounterLimitReached()) { |
| 965 if (FLAG_overapproximate_weak_closure && | 967 if (FLAG_overapproximate_weak_closure && |
| 966 !weak_closure_was_overapproximated_ && | 968 !weak_closure_was_overapproximated_) { |
| 967 action == GC_VIA_STACK_GUARD) { | 969 OverApproximateWeakClosure(action); |
| 968 OverApproximateWeakClosure(); | |
| 969 } else { | 970 } else { |
| 970 MarkingComplete(action); | 971 MarkingComplete(action); |
| 971 } | 972 } |
| 972 } else { | 973 } else { |
| 973 IncrementIdleMarkingDelayCounter(); | 974 IncrementIdleMarkingDelayCounter(); |
| 974 } | 975 } |
| 975 } | 976 } |
| 976 } | 977 } |
| 977 | 978 |
| 978 steps_count_++; | 979 steps_count_++; |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1018 void IncrementalMarking::IncrementIdleMarkingDelayCounter() { | 1019 void IncrementalMarking::IncrementIdleMarkingDelayCounter() { |
| 1019 idle_marking_delay_counter_++; | 1020 idle_marking_delay_counter_++; |
| 1020 } | 1021 } |
| 1021 | 1022 |
| 1022 | 1023 |
| 1023 void IncrementalMarking::ClearIdleMarkingDelayCounter() { | 1024 void IncrementalMarking::ClearIdleMarkingDelayCounter() { |
| 1024 idle_marking_delay_counter_ = 0; | 1025 idle_marking_delay_counter_ = 0; |
| 1025 } | 1026 } |
| 1026 } | 1027 } |
| 1027 } // namespace v8::internal | 1028 } // namespace v8::internal |
| OLD | NEW |