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/incremental-marking.h" | 7 #include "src/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/objects-visiting.h" | 12 #include "src/objects-visiting.h" |
13 #include "src/objects-visiting-inl.h" | 13 #include "src/objects-visiting-inl.h" |
14 | 14 |
15 namespace v8 { | 15 namespace v8 { |
16 namespace internal { | 16 namespace internal { |
17 | 17 |
18 | 18 |
19 IncrementalMarking::IncrementalMarking(Heap* heap) | 19 IncrementalMarking::IncrementalMarking(Heap* heap) |
20 : heap_(heap), | 20 : heap_(heap), |
21 state_(STOPPED), | 21 state_(STOPPED), |
22 marking_deque_memory_(NULL), | 22 marking_deque_memory_(NULL), |
23 marking_deque_memory_committed_(false), | 23 marking_deque_memory_committed_(false), |
24 steps_count_(0), | 24 steps_count_(0), |
25 steps_took_(0), | |
26 longest_step_(0.0), | |
27 old_generation_space_available_at_start_of_incremental_(0), | 25 old_generation_space_available_at_start_of_incremental_(0), |
28 old_generation_space_used_at_start_of_incremental_(0), | 26 old_generation_space_used_at_start_of_incremental_(0), |
29 steps_count_since_last_gc_(0), | |
30 steps_took_since_last_gc_(0), | |
31 should_hurry_(false), | 27 should_hurry_(false), |
32 marking_speed_(0), | 28 marking_speed_(0), |
33 allocated_(0), | 29 allocated_(0), |
34 no_marking_scope_depth_(0), | 30 no_marking_scope_depth_(0), |
35 unscanned_bytes_of_large_object_(0) {} | 31 unscanned_bytes_of_large_object_(0) {} |
36 | 32 |
37 | 33 |
38 void IncrementalMarking::TearDown() { | 34 void IncrementalMarking::TearDown() { |
39 delete marking_deque_memory_; | 35 delete marking_deque_memory_; |
40 } | 36 } |
(...skipping 610 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
651 MarkBit mark_bit = Marking::MarkBitFrom(obj); | 647 MarkBit mark_bit = Marking::MarkBitFrom(obj); |
652 MemoryChunk* chunk = MemoryChunk::FromAddress(obj->address()); | 648 MemoryChunk* chunk = MemoryChunk::FromAddress(obj->address()); |
653 ASSERT(Marking::IsGrey(mark_bit) || | 649 ASSERT(Marking::IsGrey(mark_bit) || |
654 (obj->IsFiller() && Marking::IsWhite(mark_bit)) || | 650 (obj->IsFiller() && Marking::IsWhite(mark_bit)) || |
655 (chunk->IsFlagSet(MemoryChunk::HAS_PROGRESS_BAR) && | 651 (chunk->IsFlagSet(MemoryChunk::HAS_PROGRESS_BAR) && |
656 Marking::IsBlack(mark_bit))); | 652 Marking::IsBlack(mark_bit))); |
657 #endif | 653 #endif |
658 } | 654 } |
659 } | 655 } |
660 marking_deque_.set_top(new_top); | 656 marking_deque_.set_top(new_top); |
661 | |
662 steps_took_since_last_gc_ = 0; | |
663 steps_count_since_last_gc_ = 0; | |
664 } | 657 } |
665 | 658 |
666 | 659 |
667 void IncrementalMarking::VisitObject(Map* map, HeapObject* obj, int size) { | 660 void IncrementalMarking::VisitObject(Map* map, HeapObject* obj, int size) { |
668 MarkBit map_mark_bit = Marking::MarkBitFrom(map); | 661 MarkBit map_mark_bit = Marking::MarkBitFrom(map); |
669 if (Marking::IsWhite(map_mark_bit)) { | 662 if (Marking::IsWhite(map_mark_bit)) { |
670 WhiteToGreyAndPush(map, map_mark_bit); | 663 WhiteToGreyAndPush(map, map_mark_bit); |
671 } | 664 } |
672 | 665 |
673 IncrementalMarkingMarkingVisitor::IterateBody(map, obj); | 666 IncrementalMarkingMarkingVisitor::IterateBody(map, obj); |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
888 if (!heap_->mark_compact_collector()->sweeping_in_progress()) { | 881 if (!heap_->mark_compact_collector()->sweeping_in_progress()) { |
889 bytes_scanned_ = 0; | 882 bytes_scanned_ = 0; |
890 StartMarking(PREVENT_COMPACTION); | 883 StartMarking(PREVENT_COMPACTION); |
891 } | 884 } |
892 } else if (state_ == MARKING) { | 885 } else if (state_ == MARKING) { |
893 ProcessMarkingDeque(bytes_to_process); | 886 ProcessMarkingDeque(bytes_to_process); |
894 if (marking_deque_.IsEmpty()) MarkingComplete(action); | 887 if (marking_deque_.IsEmpty()) MarkingComplete(action); |
895 } | 888 } |
896 | 889 |
897 steps_count_++; | 890 steps_count_++; |
898 steps_count_since_last_gc_++; | |
899 | 891 |
900 bool speed_up = false; | 892 bool speed_up = false; |
901 | 893 |
902 if ((steps_count_ % kMarkingSpeedAccellerationInterval) == 0) { | 894 if ((steps_count_ % kMarkingSpeedAccellerationInterval) == 0) { |
903 if (FLAG_trace_gc) { | 895 if (FLAG_trace_gc) { |
904 PrintPID("Speed up marking after %d steps\n", | 896 PrintPID("Speed up marking after %d steps\n", |
905 static_cast<int>(kMarkingSpeedAccellerationInterval)); | 897 static_cast<int>(kMarkingSpeedAccellerationInterval)); |
906 } | 898 } |
907 speed_up = true; | 899 speed_up = true; |
908 } | 900 } |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
957 if (FLAG_trace_gc) { | 949 if (FLAG_trace_gc) { |
958 PrintPID("Marking speed increased to %d\n", marking_speed_); | 950 PrintPID("Marking speed increased to %d\n", marking_speed_); |
959 } | 951 } |
960 } | 952 } |
961 } | 953 } |
962 | 954 |
963 if (FLAG_trace_incremental_marking || FLAG_trace_gc || | 955 if (FLAG_trace_incremental_marking || FLAG_trace_gc || |
964 FLAG_print_cumulative_gc_stat) { | 956 FLAG_print_cumulative_gc_stat) { |
965 double end = base::OS::TimeCurrentMillis(); | 957 double end = base::OS::TimeCurrentMillis(); |
966 double delta = (end - start); | 958 double delta = (end - start); |
967 longest_step_ = Max(longest_step_, delta); | 959 heap_->tracer()->AddIncrementalMarkingStep(delta); |
968 steps_took_ += delta; | |
969 steps_took_since_last_gc_ += delta; | |
970 heap_->AddMarkingTime(delta); | 960 heap_->AddMarkingTime(delta); |
971 } | 961 } |
972 } | 962 } |
973 | 963 |
974 | 964 |
975 void IncrementalMarking::ResetStepCounters() { | 965 void IncrementalMarking::ResetStepCounters() { |
976 steps_count_ = 0; | 966 steps_count_ = 0; |
977 steps_took_ = 0; | |
978 longest_step_ = 0.0; | |
979 old_generation_space_available_at_start_of_incremental_ = | 967 old_generation_space_available_at_start_of_incremental_ = |
980 SpaceLeftInOldSpace(); | 968 SpaceLeftInOldSpace(); |
981 old_generation_space_used_at_start_of_incremental_ = | 969 old_generation_space_used_at_start_of_incremental_ = |
982 heap_->PromotedTotalSize(); | 970 heap_->PromotedTotalSize(); |
983 steps_count_since_last_gc_ = 0; | |
984 steps_took_since_last_gc_ = 0; | |
985 bytes_rescanned_ = 0; | 971 bytes_rescanned_ = 0; |
986 marking_speed_ = kInitialMarkingSpeed; | 972 marking_speed_ = kInitialMarkingSpeed; |
987 bytes_scanned_ = 0; | 973 bytes_scanned_ = 0; |
988 write_barriers_invoked_since_last_step_ = 0; | 974 write_barriers_invoked_since_last_step_ = 0; |
989 } | 975 } |
990 | 976 |
991 | 977 |
992 int64_t IncrementalMarking::SpaceLeftInOldSpace() { | 978 int64_t IncrementalMarking::SpaceLeftInOldSpace() { |
993 return heap_->MaxOldGenerationSize() - heap_->PromotedSpaceSizeOfObjects(); | 979 return heap_->MaxOldGenerationSize() - heap_->PromotedSpaceSizeOfObjects(); |
994 } | 980 } |
995 | 981 |
996 } } // namespace v8::internal | 982 } } // namespace v8::internal |
OLD | NEW |