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