| 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" |
| 11 #include "src/heap/gc-tracer.h" | 11 #include "src/heap/gc-tracer.h" |
| 12 #include "src/heap/mark-compact-inl.h" | 12 #include "src/heap/mark-compact-inl.h" |
| 13 #include "src/heap/objects-visiting.h" | 13 #include "src/heap/objects-visiting.h" |
| 14 #include "src/heap/objects-visiting-inl.h" | 14 #include "src/heap/objects-visiting-inl.h" |
| 15 #include "src/v8.h" | 15 #include "src/v8.h" |
| 16 | 16 |
| 17 namespace v8 { | 17 namespace v8 { |
| 18 namespace internal { | 18 namespace internal { |
| 19 | 19 |
| 20 IncrementalMarking::StepActions IncrementalMarking::IdleStepActions() { | 20 IncrementalMarking::StepActions IncrementalMarking::IdleStepActions() { |
| 21 return StepActions(IncrementalMarking::NO_GC_VIA_STACK_GUARD, | 21 return StepActions(IncrementalMarking::NO_GC_VIA_STACK_GUARD, |
| 22 IncrementalMarking::FORCE_MARKING, | 22 IncrementalMarking::FORCE_MARKING, |
| 23 IncrementalMarking::DO_NOT_FORCE_COMPLETION); | 23 IncrementalMarking::DO_NOT_FORCE_COMPLETION); |
| 24 } | 24 } |
| 25 | 25 |
| 26 | 26 |
| 27 IncrementalMarking::IncrementalMarking(Heap* heap) | 27 IncrementalMarking::IncrementalMarking(Heap* heap) |
| 28 : heap_(heap), | 28 : heap_(heap), |
| 29 observer_(*this, kAllocatedThreshold), | 29 observer_(*this, heap, kAllocatedThreshold), |
| 30 state_(STOPPED), | 30 state_(STOPPED), |
| 31 is_compacting_(false), | 31 is_compacting_(false), |
| 32 steps_count_(0), | 32 steps_count_(0), |
| 33 old_generation_space_available_at_start_of_incremental_(0), | 33 old_generation_space_available_at_start_of_incremental_(0), |
| 34 old_generation_space_used_at_start_of_incremental_(0), | 34 old_generation_space_used_at_start_of_incremental_(0), |
| 35 bytes_rescanned_(0), | 35 bytes_rescanned_(0), |
| 36 should_hurry_(false), | 36 should_hurry_(false), |
| 37 marking_speed_(0), | 37 marking_speed_(0), |
| 38 bytes_scanned_(0), | 38 bytes_scanned_(0), |
| 39 allocated_(0), | 39 allocated_(0), |
| (...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 534 | 534 |
| 535 if (!heap_->mark_compact_collector()->sweeping_in_progress()) { | 535 if (!heap_->mark_compact_collector()->sweeping_in_progress()) { |
| 536 StartMarking(); | 536 StartMarking(); |
| 537 } else { | 537 } else { |
| 538 if (FLAG_trace_incremental_marking) { | 538 if (FLAG_trace_incremental_marking) { |
| 539 PrintF("[IncrementalMarking] Start sweeping.\n"); | 539 PrintF("[IncrementalMarking] Start sweeping.\n"); |
| 540 } | 540 } |
| 541 state_ = SWEEPING; | 541 state_ = SWEEPING; |
| 542 } | 542 } |
| 543 | 543 |
| 544 heap_->new_space()->AddInlineAllocationObserver(&observer_); | 544 heap_->new_space()->AddAllocationObserver(&observer_); |
| 545 | 545 |
| 546 incremental_marking_job()->Start(heap_); | 546 incremental_marking_job()->Start(heap_); |
| 547 } | 547 } |
| 548 | 548 |
| 549 | 549 |
| 550 void IncrementalMarking::StartMarking() { | 550 void IncrementalMarking::StartMarking() { |
| 551 if (FLAG_trace_incremental_marking) { | 551 if (FLAG_trace_incremental_marking) { |
| 552 PrintF("[IncrementalMarking] Start marking\n"); | 552 PrintF("[IncrementalMarking] Start marking\n"); |
| 553 } | 553 } |
| 554 | 554 |
| (...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 932 } | 932 } |
| 933 } | 933 } |
| 934 | 934 |
| 935 | 935 |
| 936 void IncrementalMarking::Stop() { | 936 void IncrementalMarking::Stop() { |
| 937 if (IsStopped()) return; | 937 if (IsStopped()) return; |
| 938 if (FLAG_trace_incremental_marking) { | 938 if (FLAG_trace_incremental_marking) { |
| 939 PrintF("[IncrementalMarking] Stopping.\n"); | 939 PrintF("[IncrementalMarking] Stopping.\n"); |
| 940 } | 940 } |
| 941 | 941 |
| 942 heap_->new_space()->RemoveInlineAllocationObserver(&observer_); | 942 heap_->new_space()->RemoveAllocationObserver(&observer_); |
| 943 IncrementalMarking::set_should_hurry(false); | 943 IncrementalMarking::set_should_hurry(false); |
| 944 ResetStepCounters(); | 944 ResetStepCounters(); |
| 945 if (IsMarking()) { | 945 if (IsMarking()) { |
| 946 PatchIncrementalMarkingRecordWriteStubs(heap_, | 946 PatchIncrementalMarkingRecordWriteStubs(heap_, |
| 947 RecordWriteStub::STORE_BUFFER_ONLY); | 947 RecordWriteStub::STORE_BUFFER_ONLY); |
| 948 DeactivateIncrementalWriteBarrier(); | 948 DeactivateIncrementalWriteBarrier(); |
| 949 | 949 |
| 950 if (is_compacting_) { | 950 if (is_compacting_) { |
| 951 LargeObjectIterator it(heap_->lo_space()); | 951 LargeObjectIterator it(heap_->lo_space()); |
| 952 for (HeapObject* obj = it.Next(); obj != NULL; obj = it.Next()) { | 952 for (HeapObject* obj = it.Next(); obj != NULL; obj = it.Next()) { |
| 953 Page* p = Page::FromAddress(obj->address()); | 953 Page* p = Page::FromAddress(obj->address()); |
| 954 if (p->IsFlagSet(Page::RESCAN_ON_EVACUATION)) { | 954 if (p->IsFlagSet(Page::RESCAN_ON_EVACUATION)) { |
| 955 p->ClearFlag(Page::RESCAN_ON_EVACUATION); | 955 p->ClearFlag(Page::RESCAN_ON_EVACUATION); |
| 956 } | 956 } |
| 957 } | 957 } |
| 958 } | 958 } |
| 959 } | 959 } |
| 960 heap_->isolate()->stack_guard()->ClearGC(); | 960 heap_->isolate()->stack_guard()->ClearGC(); |
| 961 state_ = STOPPED; | 961 state_ = STOPPED; |
| 962 is_compacting_ = false; | 962 is_compacting_ = false; |
| 963 } | 963 } |
| 964 | 964 |
| 965 | 965 |
| 966 void IncrementalMarking::Finalize() { | 966 void IncrementalMarking::Finalize() { |
| 967 Hurry(); | 967 Hurry(); |
| 968 state_ = STOPPED; | 968 state_ = STOPPED; |
| 969 is_compacting_ = false; | 969 is_compacting_ = false; |
| 970 | 970 |
| 971 heap_->new_space()->RemoveInlineAllocationObserver(&observer_); | 971 heap_->new_space()->RemoveAllocationObserver(&observer_); |
| 972 IncrementalMarking::set_should_hurry(false); | 972 IncrementalMarking::set_should_hurry(false); |
| 973 ResetStepCounters(); | 973 ResetStepCounters(); |
| 974 PatchIncrementalMarkingRecordWriteStubs(heap_, | 974 PatchIncrementalMarkingRecordWriteStubs(heap_, |
| 975 RecordWriteStub::STORE_BUFFER_ONLY); | 975 RecordWriteStub::STORE_BUFFER_ONLY); |
| 976 DeactivateIncrementalWriteBarrier(); | 976 DeactivateIncrementalWriteBarrier(); |
| 977 DCHECK(heap_->mark_compact_collector()->marking_deque()->IsEmpty()); | 977 DCHECK(heap_->mark_compact_collector()->marking_deque()->IsEmpty()); |
| 978 heap_->isolate()->stack_guard()->ClearGC(); | 978 heap_->isolate()->stack_guard()->ClearGC(); |
| 979 } | 979 } |
| 980 | 980 |
| 981 | 981 |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1246 void IncrementalMarking::IncrementIdleMarkingDelayCounter() { | 1246 void IncrementalMarking::IncrementIdleMarkingDelayCounter() { |
| 1247 idle_marking_delay_counter_++; | 1247 idle_marking_delay_counter_++; |
| 1248 } | 1248 } |
| 1249 | 1249 |
| 1250 | 1250 |
| 1251 void IncrementalMarking::ClearIdleMarkingDelayCounter() { | 1251 void IncrementalMarking::ClearIdleMarkingDelayCounter() { |
| 1252 idle_marking_delay_counter_ = 0; | 1252 idle_marking_delay_counter_ = 0; |
| 1253 } | 1253 } |
| 1254 } // namespace internal | 1254 } // namespace internal |
| 1255 } // namespace v8 | 1255 } // namespace v8 |
| OLD | NEW |