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