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::NoForcedStepActions() { |
| 20 return StepActions(IncrementalMarking::NO_GC_VIA_STACK_GUARD, |
| 21 IncrementalMarking::DO_NOT_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(obj, slot, value); | 55 heap_->mark_compact_collector()->RecordSlot(obj, slot, value); |
44 } | 56 } |
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
451 Object* e = stubs->ValueAt(i); | 463 Object* e = stubs->ValueAt(i); |
452 if (e->IsCode()) { | 464 if (e->IsCode()) { |
453 RecordWriteStub::Patch(Code::cast(e), mode); | 465 RecordWriteStub::Patch(Code::cast(e), mode); |
454 } | 466 } |
455 } | 467 } |
456 } | 468 } |
457 } | 469 } |
458 } | 470 } |
459 | 471 |
460 | 472 |
461 void IncrementalMarking::Start(int mark_compact_flags) { | 473 void IncrementalMarking::Start(int mark_compact_flags, |
| 474 const GCCallbackFlags gc_callback_flags, |
| 475 const char* reason) { |
462 if (FLAG_trace_incremental_marking) { | 476 if (FLAG_trace_incremental_marking) { |
463 PrintF("[IncrementalMarking] Start\n"); | 477 PrintF("[IncrementalMarking] Start (%s)\n", |
| 478 (reason == nullptr) ? "unknown reason" : reason); |
464 } | 479 } |
465 DCHECK(FLAG_incremental_marking); | 480 DCHECK(FLAG_incremental_marking); |
466 DCHECK(FLAG_incremental_marking_steps); | 481 DCHECK(FLAG_incremental_marking_steps); |
467 DCHECK(state_ == STOPPED); | 482 DCHECK(state_ == STOPPED); |
468 DCHECK(heap_->gc_state() == Heap::NOT_IN_GC); | 483 DCHECK(heap_->gc_state() == Heap::NOT_IN_GC); |
469 DCHECK(!heap_->isolate()->serializer_enabled()); | 484 DCHECK(!heap_->isolate()->serializer_enabled()); |
470 | 485 |
471 ResetStepCounters(); | 486 ResetStepCounters(); |
472 | 487 |
| 488 gc_callback_flags_ = gc_callback_flags; |
473 was_activated_ = true; | 489 was_activated_ = true; |
474 | 490 |
475 if (!heap_->mark_compact_collector()->sweeping_in_progress()) { | 491 if (!heap_->mark_compact_collector()->sweeping_in_progress()) { |
476 heap_->mark_compact_collector()->SetFlags(mark_compact_flags); | 492 heap_->mark_compact_collector()->SetFlags(mark_compact_flags); |
477 StartMarking(); | 493 StartMarking(); |
478 heap_->mark_compact_collector()->SetFlags(Heap::kNoGCFlags); | 494 heap_->mark_compact_collector()->SetFlags(Heap::kNoGCFlags); |
479 } else { | 495 } else { |
480 if (FLAG_trace_incremental_marking) { | 496 if (FLAG_trace_incremental_marking) { |
481 PrintF("[IncrementalMarking] Start sweeping.\n"); | 497 PrintF("[IncrementalMarking] Start sweeping.\n"); |
482 } | 498 } |
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
805 | 821 |
806 void IncrementalMarking::Epilogue() { | 822 void IncrementalMarking::Epilogue() { |
807 was_activated_ = false; | 823 was_activated_ = false; |
808 weak_closure_was_overapproximated_ = false; | 824 weak_closure_was_overapproximated_ = false; |
809 weak_closure_approximation_rounds_ = 0; | 825 weak_closure_approximation_rounds_ = 0; |
810 } | 826 } |
811 | 827 |
812 | 828 |
813 void IncrementalMarking::OldSpaceStep(intptr_t allocated) { | 829 void IncrementalMarking::OldSpaceStep(intptr_t allocated) { |
814 if (IsStopped() && ShouldActivateEvenWithoutIdleNotification()) { | 830 if (IsStopped() && ShouldActivateEvenWithoutIdleNotification()) { |
815 Start(Heap::kNoGCFlags); | 831 Start(Heap::kNoGCFlags, kNoGCCallbackFlags, "old space step"); |
816 } else { | 832 } else { |
817 Step(allocated * kFastMarking / kInitialMarkingSpeed, GC_VIA_STACK_GUARD); | 833 Step(allocated * kFastMarking / kInitialMarkingSpeed, GC_VIA_STACK_GUARD); |
818 } | 834 } |
819 } | 835 } |
820 | 836 |
821 | 837 |
822 void IncrementalMarking::SpeedUp() { | 838 void IncrementalMarking::SpeedUp() { |
823 bool speed_up = false; | 839 bool speed_up = false; |
824 | 840 |
825 if ((steps_count_ % kMarkingSpeedAccellerationInterval) == 0) { | 841 if ((steps_count_ % kMarkingSpeedAccellerationInterval) == 0) { |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1009 void IncrementalMarking::IncrementIdleMarkingDelayCounter() { | 1025 void IncrementalMarking::IncrementIdleMarkingDelayCounter() { |
1010 idle_marking_delay_counter_++; | 1026 idle_marking_delay_counter_++; |
1011 } | 1027 } |
1012 | 1028 |
1013 | 1029 |
1014 void IncrementalMarking::ClearIdleMarkingDelayCounter() { | 1030 void IncrementalMarking::ClearIdleMarkingDelayCounter() { |
1015 idle_marking_delay_counter_ = 0; | 1031 idle_marking_delay_counter_ = 0; |
1016 } | 1032 } |
1017 } // namespace internal | 1033 } // namespace internal |
1018 } // namespace v8 | 1034 } // namespace v8 |
OLD | NEW |