| 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 1255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1266 | 1266 |
| 1267 double gc_speed = tracer()->CombinedMarkCompactSpeedInBytesPerMillisecond(); | 1267 double gc_speed = tracer()->CombinedMarkCompactSpeedInBytesPerMillisecond(); |
| 1268 double mutator_speed = static_cast<double>( | 1268 double mutator_speed = static_cast<double>( |
| 1269 tracer() | 1269 tracer() |
| 1270 ->CurrentOldGenerationAllocationThroughputInBytesPerMillisecond()); | 1270 ->CurrentOldGenerationAllocationThroughputInBytesPerMillisecond()); |
| 1271 intptr_t old_gen_size = PromotedSpaceSizeOfObjects(); | 1271 intptr_t old_gen_size = PromotedSpaceSizeOfObjects(); |
| 1272 if (collector == MARK_COMPACTOR) { | 1272 if (collector == MARK_COMPACTOR) { |
| 1273 // Register the amount of external allocated memory. | 1273 // Register the amount of external allocated memory. |
| 1274 amount_of_external_allocated_memory_at_last_global_gc_ = | 1274 amount_of_external_allocated_memory_at_last_global_gc_ = |
| 1275 amount_of_external_allocated_memory_; | 1275 amount_of_external_allocated_memory_; |
| 1276 SetOldGenerationAllocationLimit(old_gen_size, gc_speed, mutator_speed, | 1276 SetOldGenerationAllocationLimit(old_gen_size, gc_speed, mutator_speed); |
| 1277 freed_global_handles); | |
| 1278 } else if (HasLowYoungGenerationAllocationRate() && | 1277 } else if (HasLowYoungGenerationAllocationRate() && |
| 1279 old_generation_size_configured_) { | 1278 old_generation_size_configured_) { |
| 1280 DampenOldGenerationAllocationLimit(old_gen_size, gc_speed, mutator_speed); | 1279 DampenOldGenerationAllocationLimit(old_gen_size, gc_speed, mutator_speed); |
| 1281 } | 1280 } |
| 1282 | 1281 |
| 1283 { | 1282 { |
| 1284 GCCallbacksScope scope(this); | 1283 GCCallbacksScope scope(this); |
| 1285 if (scope.CheckReenter()) { | 1284 if (scope.CheckReenter()) { |
| 1286 AllowHeapAllocation allow_allocation; | 1285 AllowHeapAllocation allow_allocation; |
| 1287 GCTracer::Scope scope(tracer(), GCTracer::Scope::EXTERNAL); | 1286 GCTracer::Scope scope(tracer(), GCTracer::Scope::EXTERNAL); |
| (...skipping 4287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5575 intptr_t limit = static_cast<intptr_t>(old_gen_size * factor); | 5574 intptr_t limit = static_cast<intptr_t>(old_gen_size * factor); |
| 5576 limit = Max(limit, old_gen_size + kMinimumOldGenerationAllocationLimit); | 5575 limit = Max(limit, old_gen_size + kMinimumOldGenerationAllocationLimit); |
| 5577 limit += new_space_.Capacity(); | 5576 limit += new_space_.Capacity(); |
| 5578 intptr_t halfway_to_the_max = (old_gen_size + max_old_generation_size_) / 2; | 5577 intptr_t halfway_to_the_max = (old_gen_size + max_old_generation_size_) / 2; |
| 5579 return Min(limit, halfway_to_the_max); | 5578 return Min(limit, halfway_to_the_max); |
| 5580 } | 5579 } |
| 5581 | 5580 |
| 5582 | 5581 |
| 5583 void Heap::SetOldGenerationAllocationLimit(intptr_t old_gen_size, | 5582 void Heap::SetOldGenerationAllocationLimit(intptr_t old_gen_size, |
| 5584 double gc_speed, | 5583 double gc_speed, |
| 5585 double mutator_speed, | 5584 double mutator_speed) { |
| 5586 int freed_global_handles) { | |
| 5587 const int kFreedGlobalHandlesThreshold = 700; | |
| 5588 const double kConservativeHeapGrowingFactor = 1.3; | 5585 const double kConservativeHeapGrowingFactor = 1.3; |
| 5589 | 5586 |
| 5590 double factor = HeapGrowingFactor(gc_speed, mutator_speed); | 5587 double factor = HeapGrowingFactor(gc_speed, mutator_speed); |
| 5591 | 5588 |
| 5592 if (FLAG_trace_gc_verbose) { | 5589 if (FLAG_trace_gc_verbose) { |
| 5593 PrintIsolate(isolate_, | 5590 PrintIsolate(isolate_, |
| 5594 "Heap growing factor %.1f based on mu=%.3f, speed_ratio=%.f " | 5591 "Heap growing factor %.1f based on mu=%.3f, speed_ratio=%.f " |
| 5595 "(gc=%.f, mutator=%.f)\n", | 5592 "(gc=%.f, mutator=%.f)\n", |
| 5596 factor, kTargetMutatorUtilization, gc_speed / mutator_speed, | 5593 factor, kTargetMutatorUtilization, gc_speed / mutator_speed, |
| 5597 gc_speed, mutator_speed); | 5594 gc_speed, mutator_speed); |
| 5598 } | 5595 } |
| 5599 | 5596 |
| 5600 // We set the old generation growing factor to 2 to grow the heap slower on | 5597 // We set the old generation growing factor to 2 to grow the heap slower on |
| 5601 // memory-constrained devices. | 5598 // memory-constrained devices. |
| 5602 if (max_old_generation_size_ <= kMaxOldSpaceSizeMediumMemoryDevice || | 5599 if (max_old_generation_size_ <= kMaxOldSpaceSizeMediumMemoryDevice || |
| 5603 FLAG_optimize_for_size) { | 5600 FLAG_optimize_for_size) { |
| 5604 factor = Min(factor, kMaxHeapGrowingFactorMemoryConstrained); | 5601 factor = Min(factor, kMaxHeapGrowingFactorMemoryConstrained); |
| 5605 } | 5602 } |
| 5606 | 5603 |
| 5607 if (freed_global_handles >= kFreedGlobalHandlesThreshold || | 5604 if (memory_reducer_.ShouldGrowHeapSlowly() || optimize_for_memory_usage_) { |
| 5608 memory_reducer_.ShouldGrowHeapSlowly() || optimize_for_memory_usage_) { | |
| 5609 factor = Min(factor, kConservativeHeapGrowingFactor); | 5605 factor = Min(factor, kConservativeHeapGrowingFactor); |
| 5610 } | 5606 } |
| 5611 | 5607 |
| 5612 if (FLAG_stress_compaction || | 5608 if (FLAG_stress_compaction || |
| 5613 mark_compact_collector()->reduce_memory_footprint_) { | 5609 mark_compact_collector()->reduce_memory_footprint_) { |
| 5614 factor = kMinHeapGrowingFactor; | 5610 factor = kMinHeapGrowingFactor; |
| 5615 } | 5611 } |
| 5616 | 5612 |
| 5617 old_generation_allocation_limit_ = | 5613 old_generation_allocation_limit_ = |
| 5618 CalculateOldGenerationAllocationLimit(factor, old_gen_size); | 5614 CalculateOldGenerationAllocationLimit(factor, old_gen_size); |
| (...skipping 1243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6862 *object_type = "CODE_TYPE"; \ | 6858 *object_type = "CODE_TYPE"; \ |
| 6863 *object_sub_type = "CODE_AGE/" #name; \ | 6859 *object_sub_type = "CODE_AGE/" #name; \ |
| 6864 return true; | 6860 return true; |
| 6865 CODE_AGE_LIST_COMPLETE(COMPARE_AND_RETURN_NAME) | 6861 CODE_AGE_LIST_COMPLETE(COMPARE_AND_RETURN_NAME) |
| 6866 #undef COMPARE_AND_RETURN_NAME | 6862 #undef COMPARE_AND_RETURN_NAME |
| 6867 } | 6863 } |
| 6868 return false; | 6864 return false; |
| 6869 } | 6865 } |
| 6870 } // namespace internal | 6866 } // namespace internal |
| 6871 } // namespace v8 | 6867 } // namespace v8 |
| OLD | NEW |