| 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 #ifndef V8_HEAP_HEAP_H_ | 5 #ifndef V8_HEAP_HEAP_H_ |
| 6 #define V8_HEAP_HEAP_H_ | 6 #define V8_HEAP_HEAP_H_ |
| 7 | 7 |
| 8 #include <cmath> | 8 #include <cmath> |
| 9 #include <map> | 9 #include <map> |
| 10 | 10 |
| (...skipping 1365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1376 | 1376 |
| 1377 // This should be used only for testing. | 1377 // This should be used only for testing. |
| 1378 void set_old_generation_allocation_counter(size_t new_value) { | 1378 void set_old_generation_allocation_counter(size_t new_value) { |
| 1379 old_generation_allocation_counter_ = new_value; | 1379 old_generation_allocation_counter_ = new_value; |
| 1380 } | 1380 } |
| 1381 | 1381 |
| 1382 size_t PromotedSinceLastGC() { | 1382 size_t PromotedSinceLastGC() { |
| 1383 return PromotedSpaceSizeOfObjects() - old_generation_size_at_last_gc_; | 1383 return PromotedSpaceSizeOfObjects() - old_generation_size_at_last_gc_; |
| 1384 } | 1384 } |
| 1385 | 1385 |
| 1386 // Record the fact that we generated some optimized code since the last GC | |
| 1387 // which will pretenure some previously unpretenured allocation. | |
| 1388 void RecordDeoptForPretenuring() { gathering_lifetime_feedback_ = 2; } | |
| 1389 | |
| 1390 // Update GC statistics that are tracked on the Heap. | 1386 // Update GC statistics that are tracked on the Heap. |
| 1391 void UpdateCumulativeGCStatistics(double duration, double spent_in_mutator, | 1387 void UpdateCumulativeGCStatistics(double duration, double spent_in_mutator, |
| 1392 double marking_time); | 1388 double marking_time); |
| 1393 | 1389 |
| 1394 // Returns maximum GC pause. | 1390 // Returns maximum GC pause. |
| 1395 double get_max_gc_pause() { return max_gc_pause_; } | 1391 double get_max_gc_pause() { return max_gc_pause_; } |
| 1396 | 1392 |
| 1397 // Returns maximum size of objects alive after GC. | 1393 // Returns maximum size of objects alive after GC. |
| 1398 intptr_t get_max_alive_after_gc() { return max_alive_after_gc_; } | 1394 intptr_t get_max_alive_after_gc() { return max_alive_after_gc_; } |
| 1399 | 1395 |
| (...skipping 771 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2171 | 2167 |
| 2172 // Initializes the allocation sites scratchpad with undefined values. | 2168 // Initializes the allocation sites scratchpad with undefined values. |
| 2173 void InitializeAllocationSitesScratchpad(); | 2169 void InitializeAllocationSitesScratchpad(); |
| 2174 | 2170 |
| 2175 // Adds an allocation site to the scratchpad if there is space left. | 2171 // Adds an allocation site to the scratchpad if there is space left. |
| 2176 void AddAllocationSiteToScratchpad(AllocationSite* site, | 2172 void AddAllocationSiteToScratchpad(AllocationSite* site, |
| 2177 ScratchpadSlotMode mode); | 2173 ScratchpadSlotMode mode); |
| 2178 | 2174 |
| 2179 void UpdateSurvivalStatistics(int start_new_space_size); | 2175 void UpdateSurvivalStatistics(int start_new_space_size); |
| 2180 | 2176 |
| 2181 enum SurvivalRateTrend { INCREASING, STABLE, DECREASING, FLUCTUATING }; | |
| 2182 | |
| 2183 static const int kYoungSurvivalRateHighThreshold = 90; | 2177 static const int kYoungSurvivalRateHighThreshold = 90; |
| 2184 static const int kYoungSurvivalRateLowThreshold = 10; | |
| 2185 static const int kYoungSurvivalRateAllowedDeviation = 15; | 2178 static const int kYoungSurvivalRateAllowedDeviation = 15; |
| 2186 | 2179 |
| 2187 static const int kOldSurvivalRateLowThreshold = 10; | 2180 static const int kOldSurvivalRateLowThreshold = 10; |
| 2188 | 2181 |
| 2189 bool new_space_high_promotion_mode_active_; | |
| 2190 // If this is non-zero, then there is hope yet that the optimized code we | |
| 2191 // have generated will solve our high promotion rate problems, so we don't | |
| 2192 // need to go into high promotion mode just yet. | |
| 2193 int gathering_lifetime_feedback_; | |
| 2194 int high_survival_rate_period_length_; | 2182 int high_survival_rate_period_length_; |
| 2195 intptr_t promoted_objects_size_; | 2183 intptr_t promoted_objects_size_; |
| 2196 int low_survival_rate_period_length_; | |
| 2197 double survival_rate_; | |
| 2198 double promotion_ratio_; | 2184 double promotion_ratio_; |
| 2199 double promotion_rate_; | 2185 double promotion_rate_; |
| 2200 intptr_t semi_space_copied_object_size_; | 2186 intptr_t semi_space_copied_object_size_; |
| 2201 intptr_t previous_semi_space_copied_object_size_; | 2187 intptr_t previous_semi_space_copied_object_size_; |
| 2202 double semi_space_copied_rate_; | 2188 double semi_space_copied_rate_; |
| 2203 int nodes_died_in_new_space_; | 2189 int nodes_died_in_new_space_; |
| 2204 int nodes_copied_in_new_space_; | 2190 int nodes_copied_in_new_space_; |
| 2205 int nodes_promoted_; | 2191 int nodes_promoted_; |
| 2206 | 2192 |
| 2207 // This is the pretenuring trigger for allocation sites that are in maybe | 2193 // This is the pretenuring trigger for allocation sites that are in maybe |
| 2208 // tenure state. When we switched to the maximum new space size we deoptimize | 2194 // tenure state. When we switched to the maximum new space size we deoptimize |
| 2209 // the code that belongs to the allocation site and derive the lifetime | 2195 // the code that belongs to the allocation site and derive the lifetime |
| 2210 // of the allocation site. | 2196 // of the allocation site. |
| 2211 unsigned int maximum_size_scavenges_; | 2197 unsigned int maximum_size_scavenges_; |
| 2212 | 2198 |
| 2213 SurvivalRateTrend previous_survival_rate_trend_; | 2199 // TODO(hpayer): Allocation site pretenuring may make this method obsolete. |
| 2214 SurvivalRateTrend survival_rate_trend_; | 2200 // Re-visit incremental marking heuristics. |
| 2215 | |
| 2216 void set_survival_rate_trend(SurvivalRateTrend survival_rate_trend) { | |
| 2217 DCHECK(survival_rate_trend != FLUCTUATING); | |
| 2218 previous_survival_rate_trend_ = survival_rate_trend_; | |
| 2219 survival_rate_trend_ = survival_rate_trend; | |
| 2220 } | |
| 2221 | |
| 2222 SurvivalRateTrend survival_rate_trend() { | |
| 2223 if (survival_rate_trend_ == STABLE) { | |
| 2224 return STABLE; | |
| 2225 } else if (previous_survival_rate_trend_ == STABLE) { | |
| 2226 return survival_rate_trend_; | |
| 2227 } else if (survival_rate_trend_ != previous_survival_rate_trend_) { | |
| 2228 return FLUCTUATING; | |
| 2229 } else { | |
| 2230 return survival_rate_trend_; | |
| 2231 } | |
| 2232 } | |
| 2233 | |
| 2234 bool IsStableOrIncreasingSurvivalTrend() { | |
| 2235 switch (survival_rate_trend()) { | |
| 2236 case STABLE: | |
| 2237 case INCREASING: | |
| 2238 return true; | |
| 2239 default: | |
| 2240 return false; | |
| 2241 } | |
| 2242 } | |
| 2243 | |
| 2244 bool IsStableOrDecreasingSurvivalTrend() { | |
| 2245 switch (survival_rate_trend()) { | |
| 2246 case STABLE: | |
| 2247 case DECREASING: | |
| 2248 return true; | |
| 2249 default: | |
| 2250 return false; | |
| 2251 } | |
| 2252 } | |
| 2253 | |
| 2254 bool IsIncreasingSurvivalTrend() { | |
| 2255 return survival_rate_trend() == INCREASING; | |
| 2256 } | |
| 2257 | |
| 2258 bool IsLowSurvivalRate() { return low_survival_rate_period_length_ > 0; } | |
| 2259 | |
| 2260 bool IsHighSurvivalRate() { return high_survival_rate_period_length_ > 0; } | 2201 bool IsHighSurvivalRate() { return high_survival_rate_period_length_ > 0; } |
| 2261 | 2202 |
| 2262 void ConfigureInitialOldGenerationSize(); | 2203 void ConfigureInitialOldGenerationSize(); |
| 2263 | 2204 |
| 2264 void ConfigureNewGenerationSize(); | |
| 2265 | |
| 2266 void SelectScavengingVisitorsTable(); | 2205 void SelectScavengingVisitorsTable(); |
| 2267 | 2206 |
| 2268 bool HasLowYoungGenerationAllocationRate(); | 2207 bool HasLowYoungGenerationAllocationRate(); |
| 2269 bool HasLowOldGenerationAllocationRate(); | 2208 bool HasLowOldGenerationAllocationRate(); |
| 2270 | 2209 |
| 2271 void ReduceNewSpaceSize(); | 2210 void ReduceNewSpaceSize(); |
| 2272 | 2211 |
| 2273 bool TryFinalizeIdleIncrementalMarking( | 2212 bool TryFinalizeIdleIncrementalMarking( |
| 2274 double idle_time_in_ms, size_t size_of_objects, | 2213 double idle_time_in_ms, size_t size_of_objects, |
| 2275 size_t mark_compact_speed_in_bytes_per_ms); | 2214 size_t mark_compact_speed_in_bytes_per_ms); |
| (...skipping 596 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2872 DisallowHeapAllocation no_allocation; // i.e. no gc allowed. | 2811 DisallowHeapAllocation no_allocation; // i.e. no gc allowed. |
| 2873 | 2812 |
| 2874 private: | 2813 private: |
| 2875 DISALLOW_IMPLICIT_CONSTRUCTORS(PathTracer); | 2814 DISALLOW_IMPLICIT_CONSTRUCTORS(PathTracer); |
| 2876 }; | 2815 }; |
| 2877 #endif // DEBUG | 2816 #endif // DEBUG |
| 2878 } | 2817 } |
| 2879 } // namespace v8::internal | 2818 } // namespace v8::internal |
| 2880 | 2819 |
| 2881 #endif // V8_HEAP_HEAP_H_ | 2820 #endif // V8_HEAP_HEAP_H_ |
| OLD | NEW |