| 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/heap/heap.h" | 5 #include "src/heap/heap.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/ast/context-slot-cache.h" | 9 #include "src/ast/context-slot-cache.h" |
| 10 #include "src/base/bits.h" | 10 #include "src/base/bits.h" |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 ms_count_(0), | 108 ms_count_(0), |
| 109 gc_count_(0), | 109 gc_count_(0), |
| 110 remembered_unmapped_pages_index_(0), | 110 remembered_unmapped_pages_index_(0), |
| 111 #ifdef DEBUG | 111 #ifdef DEBUG |
| 112 allocation_timeout_(0), | 112 allocation_timeout_(0), |
| 113 #endif // DEBUG | 113 #endif // DEBUG |
| 114 old_generation_allocation_limit_(initial_old_generation_size_), | 114 old_generation_allocation_limit_(initial_old_generation_size_), |
| 115 inline_allocation_disabled_(false), | 115 inline_allocation_disabled_(false), |
| 116 total_regexp_code_generated_(0), | 116 total_regexp_code_generated_(0), |
| 117 tracer_(nullptr), | 117 tracer_(nullptr), |
| 118 high_survival_rate_period_length_(0), | |
| 119 promoted_objects_size_(0), | 118 promoted_objects_size_(0), |
| 120 promotion_ratio_(0), | 119 promotion_ratio_(0), |
| 121 semi_space_copied_object_size_(0), | 120 semi_space_copied_object_size_(0), |
| 122 previous_semi_space_copied_object_size_(0), | 121 previous_semi_space_copied_object_size_(0), |
| 123 semi_space_copied_rate_(0), | 122 semi_space_copied_rate_(0), |
| 124 nodes_died_in_new_space_(0), | 123 nodes_died_in_new_space_(0), |
| 125 nodes_copied_in_new_space_(0), | 124 nodes_copied_in_new_space_(0), |
| 126 nodes_promoted_(0), | 125 nodes_promoted_(0), |
| 127 maximum_size_scavenges_(0), | 126 maximum_size_scavenges_(0), |
| 128 last_idle_notification_time_(0.0), | 127 last_idle_notification_time_(0.0), |
| 129 last_gc_time_(0.0), | 128 last_gc_time_(0.0), |
| 130 scavenge_collector_(nullptr), | 129 scavenge_collector_(nullptr), |
| 131 mark_compact_collector_(nullptr), | 130 mark_compact_collector_(nullptr), |
| 132 memory_allocator_(nullptr), | 131 memory_allocator_(nullptr), |
| 133 store_buffer_(nullptr), | 132 store_buffer_(nullptr), |
| 134 incremental_marking_(nullptr), | 133 incremental_marking_(nullptr), |
| 135 gc_idle_time_handler_(nullptr), | 134 gc_idle_time_handler_(nullptr), |
| 136 memory_reducer_(nullptr), | 135 memory_reducer_(nullptr), |
| 137 live_object_stats_(nullptr), | 136 live_object_stats_(nullptr), |
| 138 dead_object_stats_(nullptr), | 137 dead_object_stats_(nullptr), |
| 139 scavenge_job_(nullptr), | 138 scavenge_job_(nullptr), |
| 140 idle_scavenge_observer_(nullptr), | 139 idle_scavenge_observer_(nullptr), |
| 141 full_codegen_bytes_generated_(0), | 140 full_codegen_bytes_generated_(0), |
| 142 crankshaft_codegen_bytes_generated_(0), | 141 crankshaft_codegen_bytes_generated_(0), |
| 143 new_space_allocation_counter_(0), | 142 new_space_allocation_counter_(0), |
| 144 old_generation_allocation_counter_(0), | 143 old_generation_allocation_counter_at_last_gc_(0), |
| 145 old_generation_size_at_last_gc_(0), | 144 old_generation_size_at_last_gc_(0), |
| 146 gcs_since_last_deopt_(0), | 145 gcs_since_last_deopt_(0), |
| 147 global_pretenuring_feedback_(nullptr), | 146 global_pretenuring_feedback_(nullptr), |
| 148 ring_buffer_full_(false), | 147 ring_buffer_full_(false), |
| 149 ring_buffer_end_(0), | 148 ring_buffer_end_(0), |
| 150 promotion_queue_(this), | 149 promotion_queue_(this), |
| 151 configured_(false), | 150 configured_(false), |
| 152 current_gc_flags_(Heap::kNoGCFlags), | 151 current_gc_flags_(Heap::kNoGCFlags), |
| 153 current_gc_callback_flags_(GCCallbackFlags::kNoGCCallbackFlags), | 152 current_gc_callback_flags_(GCCallbackFlags::kNoGCCallbackFlags), |
| 154 external_string_table_(this), | 153 external_string_table_(this), |
| (...skipping 1108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1263 } else { | 1262 } else { |
| 1264 promotion_rate_ = 0; | 1263 promotion_rate_ = 0; |
| 1265 } | 1264 } |
| 1266 | 1265 |
| 1267 semi_space_copied_rate_ = | 1266 semi_space_copied_rate_ = |
| 1268 (static_cast<double>(semi_space_copied_object_size_) / | 1267 (static_cast<double>(semi_space_copied_object_size_) / |
| 1269 static_cast<double>(start_new_space_size) * 100); | 1268 static_cast<double>(start_new_space_size) * 100); |
| 1270 | 1269 |
| 1271 double survival_rate = promotion_ratio_ + semi_space_copied_rate_; | 1270 double survival_rate = promotion_ratio_ + semi_space_copied_rate_; |
| 1272 tracer()->AddSurvivalRatio(survival_rate); | 1271 tracer()->AddSurvivalRatio(survival_rate); |
| 1273 if (survival_rate > kYoungSurvivalRateHighThreshold) { | |
| 1274 high_survival_rate_period_length_++; | |
| 1275 } else { | |
| 1276 high_survival_rate_period_length_ = 0; | |
| 1277 } | |
| 1278 } | 1272 } |
| 1279 | 1273 |
| 1280 bool Heap::PerformGarbageCollection( | 1274 bool Heap::PerformGarbageCollection( |
| 1281 GarbageCollector collector, const v8::GCCallbackFlags gc_callback_flags) { | 1275 GarbageCollector collector, const v8::GCCallbackFlags gc_callback_flags) { |
| 1282 int freed_global_handles = 0; | 1276 int freed_global_handles = 0; |
| 1283 | 1277 |
| 1284 if (collector != SCAVENGER) { | 1278 if (collector != SCAVENGER) { |
| 1285 PROFILE(isolate_, CodeMovingGCEvent()); | 1279 PROFILE(isolate_, CodeMovingGCEvent()); |
| 1286 } | 1280 } |
| 1287 | 1281 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 1304 VMState<EXTERNAL> state(isolate_); | 1298 VMState<EXTERNAL> state(isolate_); |
| 1305 HandleScope handle_scope(isolate_); | 1299 HandleScope handle_scope(isolate_); |
| 1306 CallGCPrologueCallbacks(gc_type, kNoGCCallbackFlags); | 1300 CallGCPrologueCallbacks(gc_type, kNoGCCallbackFlags); |
| 1307 } | 1301 } |
| 1308 } | 1302 } |
| 1309 | 1303 |
| 1310 EnsureFromSpaceIsCommitted(); | 1304 EnsureFromSpaceIsCommitted(); |
| 1311 | 1305 |
| 1312 int start_new_space_size = Heap::new_space()->SizeAsInt(); | 1306 int start_new_space_size = Heap::new_space()->SizeAsInt(); |
| 1313 | 1307 |
| 1314 if (IsHighSurvivalRate()) { | |
| 1315 // We speed up the incremental marker if it is running so that it | |
| 1316 // does not fall behind the rate of promotion, which would cause a | |
| 1317 // constantly growing old space. | |
| 1318 incremental_marking()->NotifyOfHighPromotionRate(); | |
| 1319 } | |
| 1320 | |
| 1321 { | 1308 { |
| 1322 Heap::PretenuringScope pretenuring_scope(this); | 1309 Heap::PretenuringScope pretenuring_scope(this); |
| 1323 | 1310 |
| 1324 if (collector == MARK_COMPACTOR) { | 1311 if (collector == MARK_COMPACTOR) { |
| 1325 UpdateOldGenerationAllocationCounter(); | 1312 UpdateOldGenerationAllocationCounter(); |
| 1326 // Perform mark-sweep with optional compaction. | 1313 // Perform mark-sweep with optional compaction. |
| 1327 MarkCompact(); | 1314 MarkCompact(); |
| 1328 old_generation_size_configured_ = true; | 1315 old_generation_size_configured_ = true; |
| 1329 // This should be updated before PostGarbageCollectionProcessing, which | 1316 // This should be updated before PostGarbageCollectionProcessing, which |
| 1330 // can cause another GC. Take into account the objects promoted during GC. | 1317 // can cause another GC. Take into account the objects promoted during GC. |
| 1331 old_generation_allocation_counter_ += | 1318 old_generation_allocation_counter_at_last_gc_ += |
| 1332 static_cast<size_t>(promoted_objects_size_); | 1319 static_cast<size_t>(promoted_objects_size_); |
| 1333 old_generation_size_at_last_gc_ = PromotedSpaceSizeOfObjects(); | 1320 old_generation_size_at_last_gc_ = PromotedSpaceSizeOfObjects(); |
| 1334 } else { | 1321 } else { |
| 1335 Scavenge(); | 1322 Scavenge(); |
| 1336 } | 1323 } |
| 1337 | 1324 |
| 1338 ProcessPretenuringFeedback(); | 1325 ProcessPretenuringFeedback(); |
| 1339 } | 1326 } |
| 1340 | 1327 |
| 1341 UpdateSurvivalStatistics(start_new_space_size); | 1328 UpdateSurvivalStatistics(start_new_space_size); |
| (...skipping 5142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6484 } | 6471 } |
| 6485 | 6472 |
| 6486 | 6473 |
| 6487 // static | 6474 // static |
| 6488 int Heap::GetStaticVisitorIdForMap(Map* map) { | 6475 int Heap::GetStaticVisitorIdForMap(Map* map) { |
| 6489 return StaticVisitorBase::GetVisitorId(map); | 6476 return StaticVisitorBase::GetVisitorId(map); |
| 6490 } | 6477 } |
| 6491 | 6478 |
| 6492 } // namespace internal | 6479 } // namespace internal |
| 6493 } // namespace v8 | 6480 } // namespace v8 |
| OLD | NEW |