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/accessors.h" | 7 #include "src/accessors.h" |
8 #include "src/api.h" | 8 #include "src/api.h" |
9 #include "src/base/bits.h" | 9 #include "src/base/bits.h" |
10 #include "src/base/once.h" | 10 #include "src/base/once.h" |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 idle_old_generation_allocation_limit_( | 110 idle_old_generation_allocation_limit_( |
111 kMinimumOldGenerationAllocationLimit), | 111 kMinimumOldGenerationAllocationLimit), |
112 old_gen_exhausted_(false), | 112 old_gen_exhausted_(false), |
113 inline_allocation_disabled_(false), | 113 inline_allocation_disabled_(false), |
114 store_buffer_rebuilder_(store_buffer()), | 114 store_buffer_rebuilder_(store_buffer()), |
115 hidden_string_(NULL), | 115 hidden_string_(NULL), |
116 gc_safe_size_of_old_object_(NULL), | 116 gc_safe_size_of_old_object_(NULL), |
117 total_regexp_code_generated_(0), | 117 total_regexp_code_generated_(0), |
118 tracer_(this), | 118 tracer_(this), |
119 new_space_high_promotion_mode_active_(false), | 119 new_space_high_promotion_mode_active_(false), |
| 120 gathering_lifetime_feedback_(0), |
120 high_survival_rate_period_length_(0), | 121 high_survival_rate_period_length_(0), |
121 promoted_objects_size_(0), | 122 promoted_objects_size_(0), |
122 low_survival_rate_period_length_(0), | 123 low_survival_rate_period_length_(0), |
123 survival_rate_(0), | 124 survival_rate_(0), |
124 promotion_ratio_(0), | 125 promotion_ratio_(0), |
125 semi_space_copied_object_size_(0), | 126 semi_space_copied_object_size_(0), |
126 previous_semi_space_copied_object_size_(0), | 127 previous_semi_space_copied_object_size_(0), |
127 semi_space_copied_rate_(0), | 128 semi_space_copied_rate_(0), |
128 nodes_died_in_new_space_(0), | 129 nodes_died_in_new_space_(0), |
129 nodes_copied_in_new_space_(0), | 130 nodes_copied_in_new_space_(0), |
(...skipping 1116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1246 old_generation_size_at_last_gc_ = PromotedSpaceSizeOfObjects(); | 1247 old_generation_size_at_last_gc_ = PromotedSpaceSizeOfObjects(); |
1247 } else { | 1248 } else { |
1248 Scavenge(); | 1249 Scavenge(); |
1249 } | 1250 } |
1250 | 1251 |
1251 bool deopted = ProcessPretenuringFeedback(); | 1252 bool deopted = ProcessPretenuringFeedback(); |
1252 UpdateSurvivalStatistics(start_new_space_size); | 1253 UpdateSurvivalStatistics(start_new_space_size); |
1253 | 1254 |
1254 // When pretenuring is collecting new feedback, we do not shrink the new space | 1255 // When pretenuring is collecting new feedback, we do not shrink the new space |
1255 // right away. | 1256 // right away. |
1256 if (!deopted) { | 1257 if (deopted) { |
| 1258 RecordDeoptForPretenuring(); |
| 1259 } else { |
1257 ConfigureNewGenerationSize(); | 1260 ConfigureNewGenerationSize(); |
1258 } | 1261 } |
1259 ConfigureInitialOldGenerationSize(); | 1262 ConfigureInitialOldGenerationSize(); |
1260 | 1263 |
1261 isolate_->counters()->objs_since_last_young()->Set(0); | 1264 isolate_->counters()->objs_since_last_young()->Set(0); |
1262 | 1265 |
1263 if (collector != SCAVENGER) { | 1266 if (collector != SCAVENGER) { |
1264 // Callbacks that fire after this point might trigger nested GCs and | 1267 // Callbacks that fire after this point might trigger nested GCs and |
1265 // restart incremental marking, the assertion can't be moved down. | 1268 // restart incremental marking, the assertion can't be moved down. |
1266 DCHECK(incremental_marking()->IsStopped()); | 1269 DCHECK(incremental_marking()->IsStopped()); |
(...skipping 1361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2628 old_generation_allocation_limit_ = | 2631 old_generation_allocation_limit_ = |
2629 Max(kMinimumOldGenerationAllocationLimit, | 2632 Max(kMinimumOldGenerationAllocationLimit, |
2630 static_cast<intptr_t>( | 2633 static_cast<intptr_t>( |
2631 static_cast<double>(old_generation_allocation_limit_) * | 2634 static_cast<double>(old_generation_allocation_limit_) * |
2632 (tracer()->AverageSurvivalRatio() / 100))); | 2635 (tracer()->AverageSurvivalRatio() / 100))); |
2633 } | 2636 } |
2634 } | 2637 } |
2635 | 2638 |
2636 | 2639 |
2637 void Heap::ConfigureNewGenerationSize() { | 2640 void Heap::ConfigureNewGenerationSize() { |
| 2641 bool still_gathering_lifetime_data = gathering_lifetime_feedback_ != 0; |
| 2642 if (gathering_lifetime_feedback_ != 0) gathering_lifetime_feedback_--; |
2638 if (!new_space_high_promotion_mode_active_ && | 2643 if (!new_space_high_promotion_mode_active_ && |
2639 new_space_.TotalCapacity() == new_space_.MaximumCapacity() && | 2644 new_space_.TotalCapacity() == new_space_.MaximumCapacity() && |
2640 IsStableOrIncreasingSurvivalTrend() && IsHighSurvivalRate()) { | 2645 IsStableOrIncreasingSurvivalTrend() && IsHighSurvivalRate()) { |
2641 // Stable high survival rates even though young generation is at | 2646 // Stable high survival rates even though young generation is at |
2642 // maximum capacity indicates that most objects will be promoted. | 2647 // maximum capacity indicates that most objects will be promoted. |
2643 // To decrease scavenger pauses and final mark-sweep pauses, we | 2648 // To decrease scavenger pauses and final mark-sweep pauses, we |
2644 // have to limit maximal capacity of the young generation. | 2649 // have to limit maximal capacity of the young generation. |
2645 new_space_high_promotion_mode_active_ = true; | 2650 if (still_gathering_lifetime_data) { |
2646 if (FLAG_trace_gc) { | 2651 if (FLAG_trace_gc) { |
2647 PrintPID("Limited new space size due to high promotion rate: %d MB\n", | 2652 PrintPID( |
2648 new_space_.InitialTotalCapacity() / MB); | 2653 "Postpone entering high promotion mode as optimized pretenuring " |
| 2654 "code is still being generated\n"); |
| 2655 } |
| 2656 } else { |
| 2657 new_space_high_promotion_mode_active_ = true; |
| 2658 if (FLAG_trace_gc) { |
| 2659 PrintPID("Limited new space size due to high promotion rate: %d MB\n", |
| 2660 new_space_.InitialTotalCapacity() / MB); |
| 2661 } |
2649 } | 2662 } |
2650 } else if (new_space_high_promotion_mode_active_ && | 2663 } else if (new_space_high_promotion_mode_active_ && |
2651 IsStableOrDecreasingSurvivalTrend() && IsLowSurvivalRate()) { | 2664 IsStableOrDecreasingSurvivalTrend() && IsLowSurvivalRate()) { |
2652 // Decreasing low survival rates might indicate that the above high | 2665 // Decreasing low survival rates might indicate that the above high |
2653 // promotion mode is over and we should allow the young generation | 2666 // promotion mode is over and we should allow the young generation |
2654 // to grow again. | 2667 // to grow again. |
2655 new_space_high_promotion_mode_active_ = false; | 2668 new_space_high_promotion_mode_active_ = false; |
2656 if (FLAG_trace_gc) { | 2669 if (FLAG_trace_gc) { |
2657 PrintPID("Unlimited new space size due to low promotion rate: %d MB\n", | 2670 PrintPID("Unlimited new space size due to low promotion rate: %d MB\n", |
2658 new_space_.MaximumCapacity() / MB); | 2671 new_space_.MaximumCapacity() / MB); |
(...skipping 4189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6848 *object_type = "CODE_TYPE"; \ | 6861 *object_type = "CODE_TYPE"; \ |
6849 *object_sub_type = "CODE_AGE/" #name; \ | 6862 *object_sub_type = "CODE_AGE/" #name; \ |
6850 return true; | 6863 return true; |
6851 CODE_AGE_LIST_COMPLETE(COMPARE_AND_RETURN_NAME) | 6864 CODE_AGE_LIST_COMPLETE(COMPARE_AND_RETURN_NAME) |
6852 #undef COMPARE_AND_RETURN_NAME | 6865 #undef COMPARE_AND_RETURN_NAME |
6853 } | 6866 } |
6854 return false; | 6867 return false; |
6855 } | 6868 } |
6856 } // namespace internal | 6869 } // namespace internal |
6857 } // namespace v8 | 6870 } // namespace v8 |
OLD | NEW |