OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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 #ifndef V8_HEAP_GC_IDLE_TIME_HANDLER_H_ | 5 #ifndef V8_HEAP_GC_IDLE_TIME_HANDLER_H_ |
6 #define V8_HEAP_GC_IDLE_TIME_HANDLER_H_ | 6 #define V8_HEAP_GC_IDLE_TIME_HANDLER_H_ |
7 | 7 |
8 #include "src/globals.h" | 8 #include "src/globals.h" |
9 | 9 |
10 namespace v8 { | 10 namespace v8 { |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 int contexts_disposed; | 125 int contexts_disposed; |
126 size_t size_of_objects; | 126 size_t size_of_objects; |
127 bool incremental_marking_stopped; | 127 bool incremental_marking_stopped; |
128 bool can_start_incremental_marking; | 128 bool can_start_incremental_marking; |
129 bool sweeping_in_progress; | 129 bool sweeping_in_progress; |
130 size_t mark_compact_speed_in_bytes_per_ms; | 130 size_t mark_compact_speed_in_bytes_per_ms; |
131 size_t incremental_marking_speed_in_bytes_per_ms; | 131 size_t incremental_marking_speed_in_bytes_per_ms; |
132 size_t scavenge_speed_in_bytes_per_ms; | 132 size_t scavenge_speed_in_bytes_per_ms; |
133 size_t available_new_space_memory; | 133 size_t available_new_space_memory; |
134 size_t new_space_capacity; | 134 size_t new_space_capacity; |
| 135 size_t new_space_allocation_throughput_in_bytes_per_ms; |
135 }; | 136 }; |
136 | 137 |
137 GCIdleTimeHandler() | 138 GCIdleTimeHandler() |
138 : mark_compacts_since_idle_round_started_(0), | 139 : mark_compacts_since_idle_round_started_(0), |
139 scavenges_since_last_idle_round_(0) {} | 140 scavenges_since_last_idle_round_(0) {} |
140 | 141 |
141 GCIdleTimeAction Compute(size_t idle_time_in_ms, HeapState heap_state); | 142 GCIdleTimeAction Compute(size_t idle_time_in_ms, HeapState heap_state); |
142 | 143 |
143 void NotifyIdleMarkCompact() { | 144 void NotifyIdleMarkCompact() { |
144 if (mark_compacts_since_idle_round_started_ < kMaxMarkCompactsInIdleRound) { | 145 if (mark_compacts_since_idle_round_started_ < kMaxMarkCompactsInIdleRound) { |
145 ++mark_compacts_since_idle_round_started_; | 146 ++mark_compacts_since_idle_round_started_; |
146 if (mark_compacts_since_idle_round_started_ == | 147 if (mark_compacts_since_idle_round_started_ == |
147 kMaxMarkCompactsInIdleRound) { | 148 kMaxMarkCompactsInIdleRound) { |
148 scavenges_since_last_idle_round_ = 0; | 149 scavenges_since_last_idle_round_ = 0; |
149 } | 150 } |
150 } | 151 } |
151 } | 152 } |
152 | 153 |
153 void NotifyScavenge() { ++scavenges_since_last_idle_round_; } | 154 void NotifyScavenge() { ++scavenges_since_last_idle_round_; } |
154 | 155 |
155 static size_t EstimateMarkingStepSize(size_t idle_time_in_ms, | 156 static size_t EstimateMarkingStepSize(size_t idle_time_in_ms, |
156 size_t marking_speed_in_bytes_per_ms); | 157 size_t marking_speed_in_bytes_per_ms); |
157 | 158 |
158 static size_t EstimateMarkCompactTime( | 159 static size_t EstimateMarkCompactTime( |
159 size_t size_of_objects, size_t mark_compact_speed_in_bytes_per_ms); | 160 size_t size_of_objects, size_t mark_compact_speed_in_bytes_per_ms); |
160 | 161 |
161 static size_t EstimateScavengeTime(size_t new_space_size, | 162 static size_t EstimateScavengeTime(size_t new_space_size, |
162 size_t scavenger_speed_in_bytes_per_ms); | 163 size_t scavenger_speed_in_bytes_per_ms); |
163 | 164 |
| 165 static bool ScavangeMayHappenSoon( |
| 166 size_t available_new_space_memory, |
| 167 size_t new_space_allocation_throughput_in_bytes_per_ms); |
| 168 |
164 private: | 169 private: |
165 void StartIdleRound() { mark_compacts_since_idle_round_started_ = 0; } | 170 void StartIdleRound() { mark_compacts_since_idle_round_started_ = 0; } |
166 bool IsMarkCompactIdleRoundFinished() { | 171 bool IsMarkCompactIdleRoundFinished() { |
167 return mark_compacts_since_idle_round_started_ == | 172 return mark_compacts_since_idle_round_started_ == |
168 kMaxMarkCompactsInIdleRound; | 173 kMaxMarkCompactsInIdleRound; |
169 } | 174 } |
170 bool EnoughGarbageSinceLastIdleRound() { | 175 bool EnoughGarbageSinceLastIdleRound() { |
171 return scavenges_since_last_idle_round_ >= kIdleScavengeThreshold; | 176 return scavenges_since_last_idle_round_ >= kIdleScavengeThreshold; |
172 } | 177 } |
173 | 178 |
174 int mark_compacts_since_idle_round_started_; | 179 int mark_compacts_since_idle_round_started_; |
175 int scavenges_since_last_idle_round_; | 180 int scavenges_since_last_idle_round_; |
176 | 181 |
177 DISALLOW_COPY_AND_ASSIGN(GCIdleTimeHandler); | 182 DISALLOW_COPY_AND_ASSIGN(GCIdleTimeHandler); |
178 }; | 183 }; |
179 | 184 |
180 } // namespace internal | 185 } // namespace internal |
181 } // namespace v8 | 186 } // namespace v8 |
182 | 187 |
183 #endif // V8_HEAP_GC_IDLE_TIME_HANDLER_H_ | 188 #endif // V8_HEAP_GC_IDLE_TIME_HANDLER_H_ |
OLD | NEW |