| 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" |
| 11 #include "src/conversions.h" | 11 #include "src/conversions.h" |
| 12 #include "src/heap/objects-visiting.h" | 12 #include "src/heap/objects-visiting.h" |
| 13 #include "src/heap/objects-visiting-inl.h" | 13 #include "src/heap/objects-visiting-inl.h" |
| 14 | 14 |
| 15 namespace v8 { | 15 namespace v8 { |
| 16 namespace internal { | 16 namespace internal { |
| 17 | 17 |
| 18 | 18 |
| 19 IncrementalMarking::StepActions IncrementalMarking::IdleStepActions() { |
| 20 return StepActions(IncrementalMarking::NO_GC_VIA_STACK_GUARD, |
| 21 IncrementalMarking::FORCE_MARKING, |
| 22 IncrementalMarking::DO_NOT_FORCE_COMPLETION); |
| 23 } |
| 24 |
| 25 |
| 19 IncrementalMarking::IncrementalMarking(Heap* heap) | 26 IncrementalMarking::IncrementalMarking(Heap* heap) |
| 20 : heap_(heap), | 27 : heap_(heap), |
| 21 state_(STOPPED), | 28 state_(STOPPED), |
| 29 is_compacting_(false), |
| 22 steps_count_(0), | 30 steps_count_(0), |
| 23 old_generation_space_available_at_start_of_incremental_(0), | 31 old_generation_space_available_at_start_of_incremental_(0), |
| 24 old_generation_space_used_at_start_of_incremental_(0), | 32 old_generation_space_used_at_start_of_incremental_(0), |
| 33 bytes_rescanned_(0), |
| 25 should_hurry_(false), | 34 should_hurry_(false), |
| 26 marking_speed_(0), | 35 marking_speed_(0), |
| 36 bytes_scanned_(0), |
| 27 allocated_(0), | 37 allocated_(0), |
| 38 write_barriers_invoked_since_last_step_(0), |
| 28 idle_marking_delay_counter_(0), | 39 idle_marking_delay_counter_(0), |
| 29 no_marking_scope_depth_(0), | 40 no_marking_scope_depth_(0), |
| 30 unscanned_bytes_of_large_object_(0), | 41 unscanned_bytes_of_large_object_(0), |
| 31 was_activated_(false), | 42 was_activated_(false), |
| 32 weak_closure_was_overapproximated_(false), | 43 weak_closure_was_overapproximated_(false), |
| 33 weak_closure_approximation_rounds_(0), | 44 weak_closure_approximation_rounds_(0), |
| 34 request_type_(COMPLETE_MARKING) {} | 45 request_type_(COMPLETE_MARKING), |
| 46 gc_callback_flags_(kNoGCCallbackFlags) {} |
| 35 | 47 |
| 36 | 48 |
| 37 void IncrementalMarking::RecordWriteSlow(HeapObject* obj, Object** slot, | 49 void IncrementalMarking::RecordWriteSlow(HeapObject* obj, Object** slot, |
| 38 Object* value) { | 50 Object* value) { |
| 39 if (BaseRecordWrite(obj, slot, value) && slot != NULL) { | 51 if (BaseRecordWrite(obj, slot, value) && slot != NULL) { |
| 40 MarkBit obj_bit = Marking::MarkBitFrom(obj); | 52 MarkBit obj_bit = Marking::MarkBitFrom(obj); |
| 41 if (Marking::IsBlack(obj_bit)) { | 53 if (Marking::IsBlack(obj_bit)) { |
| 42 // Object is not going to be rescanned we need to record the slot. | 54 // Object is not going to be rescanned we need to record the slot. |
| 43 heap_->mark_compact_collector()->RecordSlot(HeapObject::RawField(obj, 0), | 55 heap_->mark_compact_collector()->RecordSlot(HeapObject::RawField(obj, 0), |
| 44 slot, value); | 56 slot, value); |
| (...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 465 Object* e = stubs->ValueAt(i); | 477 Object* e = stubs->ValueAt(i); |
| 466 if (e->IsCode()) { | 478 if (e->IsCode()) { |
| 467 RecordWriteStub::Patch(Code::cast(e), mode); | 479 RecordWriteStub::Patch(Code::cast(e), mode); |
| 468 } | 480 } |
| 469 } | 481 } |
| 470 } | 482 } |
| 471 } | 483 } |
| 472 } | 484 } |
| 473 | 485 |
| 474 | 486 |
| 475 void IncrementalMarking::Start(int mark_compact_flags) { | 487 void IncrementalMarking::Start(int mark_compact_flags, |
| 488 const GCCallbackFlags gc_callback_flags, |
| 489 const char* reason) { |
| 476 if (FLAG_trace_incremental_marking) { | 490 if (FLAG_trace_incremental_marking) { |
| 477 PrintF("[IncrementalMarking] Start\n"); | 491 PrintF("[IncrementalMarking] Start (%s)\n", |
| 492 (reason == nullptr) ? "unknown reason" : reason); |
| 478 } | 493 } |
| 479 DCHECK(FLAG_incremental_marking); | 494 DCHECK(FLAG_incremental_marking); |
| 480 DCHECK(FLAG_incremental_marking_steps); | 495 DCHECK(FLAG_incremental_marking_steps); |
| 481 DCHECK(state_ == STOPPED); | 496 DCHECK(state_ == STOPPED); |
| 482 DCHECK(heap_->gc_state() == Heap::NOT_IN_GC); | 497 DCHECK(heap_->gc_state() == Heap::NOT_IN_GC); |
| 483 DCHECK(!heap_->isolate()->serializer_enabled()); | 498 DCHECK(!heap_->isolate()->serializer_enabled()); |
| 484 | 499 |
| 485 ResetStepCounters(); | 500 ResetStepCounters(); |
| 486 | 501 |
| 502 gc_callback_flags_ = gc_callback_flags; |
| 487 was_activated_ = true; | 503 was_activated_ = true; |
| 488 | 504 |
| 489 if (!heap_->mark_compact_collector()->sweeping_in_progress()) { | 505 if (!heap_->mark_compact_collector()->sweeping_in_progress()) { |
| 490 heap_->mark_compact_collector()->SetFlags(mark_compact_flags); | 506 heap_->mark_compact_collector()->SetFlags(mark_compact_flags); |
| 491 StartMarking(); | 507 StartMarking(); |
| 492 heap_->mark_compact_collector()->SetFlags(Heap::kNoGCFlags); | 508 heap_->mark_compact_collector()->SetFlags(Heap::kNoGCFlags); |
| 493 } else { | 509 } else { |
| 494 if (FLAG_trace_incremental_marking) { | 510 if (FLAG_trace_incremental_marking) { |
| 495 PrintF("[IncrementalMarking] Start sweeping.\n"); | 511 PrintF("[IncrementalMarking] Start sweeping.\n"); |
| 496 } | 512 } |
| (...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 819 | 835 |
| 820 void IncrementalMarking::Epilogue() { | 836 void IncrementalMarking::Epilogue() { |
| 821 was_activated_ = false; | 837 was_activated_ = false; |
| 822 weak_closure_was_overapproximated_ = false; | 838 weak_closure_was_overapproximated_ = false; |
| 823 weak_closure_approximation_rounds_ = 0; | 839 weak_closure_approximation_rounds_ = 0; |
| 824 } | 840 } |
| 825 | 841 |
| 826 | 842 |
| 827 void IncrementalMarking::OldSpaceStep(intptr_t allocated) { | 843 void IncrementalMarking::OldSpaceStep(intptr_t allocated) { |
| 828 if (IsStopped() && ShouldActivateEvenWithoutIdleNotification()) { | 844 if (IsStopped() && ShouldActivateEvenWithoutIdleNotification()) { |
| 829 Start(Heap::kNoGCFlags); | 845 Start(Heap::kNoGCFlags, kNoGCCallbackFlags, "old space step"); |
| 830 } else { | 846 } else { |
| 831 Step(allocated * kFastMarking / kInitialMarkingSpeed, GC_VIA_STACK_GUARD); | 847 Step(allocated * kFastMarking / kInitialMarkingSpeed, GC_VIA_STACK_GUARD); |
| 832 } | 848 } |
| 833 } | 849 } |
| 834 | 850 |
| 835 | 851 |
| 836 void IncrementalMarking::SpeedUp() { | 852 void IncrementalMarking::SpeedUp() { |
| 837 bool speed_up = false; | 853 bool speed_up = false; |
| 838 | 854 |
| 839 if ((steps_count_ % kMarkingSpeedAccellerationInterval) == 0) { | 855 if ((steps_count_ % kMarkingSpeedAccellerationInterval) == 0) { |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1023 void IncrementalMarking::IncrementIdleMarkingDelayCounter() { | 1039 void IncrementalMarking::IncrementIdleMarkingDelayCounter() { |
| 1024 idle_marking_delay_counter_++; | 1040 idle_marking_delay_counter_++; |
| 1025 } | 1041 } |
| 1026 | 1042 |
| 1027 | 1043 |
| 1028 void IncrementalMarking::ClearIdleMarkingDelayCounter() { | 1044 void IncrementalMarking::ClearIdleMarkingDelayCounter() { |
| 1029 idle_marking_delay_counter_ = 0; | 1045 idle_marking_delay_counter_ = 0; |
| 1030 } | 1046 } |
| 1031 } // namespace internal | 1047 } // namespace internal |
| 1032 } // namespace v8 | 1048 } // namespace v8 |
| OLD | NEW |