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 1307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1318 | 1318 |
1319 double gc_speed = tracer()->CombinedMarkCompactSpeedInBytesPerMillisecond(); | 1319 double gc_speed = tracer()->CombinedMarkCompactSpeedInBytesPerMillisecond(); |
1320 double mutator_speed = static_cast<double>( | 1320 double mutator_speed = static_cast<double>( |
1321 tracer() | 1321 tracer() |
1322 ->CurrentOldGenerationAllocationThroughputInBytesPerMillisecond()); | 1322 ->CurrentOldGenerationAllocationThroughputInBytesPerMillisecond()); |
1323 intptr_t old_gen_size = PromotedSpaceSizeOfObjects(); | 1323 intptr_t old_gen_size = PromotedSpaceSizeOfObjects(); |
1324 if (collector == MARK_COMPACTOR) { | 1324 if (collector == MARK_COMPACTOR) { |
1325 // Register the amount of external allocated memory. | 1325 // Register the amount of external allocated memory. |
1326 amount_of_external_allocated_memory_at_last_global_gc_ = | 1326 amount_of_external_allocated_memory_at_last_global_gc_ = |
1327 amount_of_external_allocated_memory_; | 1327 amount_of_external_allocated_memory_; |
1328 SetOldGenerationAllocationLimit(old_gen_size, gc_speed, mutator_speed); | 1328 SetOldGenerationAllocationLimit(old_gen_size, gc_speed, mutator_speed, |
1329 freed_global_handles); | |
1329 } else if (HasLowYoungGenerationAllocationRate() && | 1330 } else if (HasLowYoungGenerationAllocationRate() && |
1330 old_generation_size_configured_) { | 1331 old_generation_size_configured_) { |
1331 DampenOldGenerationAllocationLimit(old_gen_size, gc_speed, mutator_speed); | 1332 DampenOldGenerationAllocationLimit(old_gen_size, gc_speed, mutator_speed); |
1332 } | 1333 } |
1333 | 1334 |
1334 { | 1335 { |
1335 GCCallbacksScope scope(this); | 1336 GCCallbacksScope scope(this); |
1336 if (scope.CheckReenter()) { | 1337 if (scope.CheckReenter()) { |
1337 AllowHeapAllocation allow_allocation; | 1338 AllowHeapAllocation allow_allocation; |
1338 GCTracer::Scope scope(tracer(), GCTracer::Scope::EXTERNAL); | 1339 GCTracer::Scope scope(tracer(), GCTracer::Scope::EXTERNAL); |
(...skipping 4307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5646 intptr_t limit = static_cast<intptr_t>(old_gen_size * factor); | 5647 intptr_t limit = static_cast<intptr_t>(old_gen_size * factor); |
5647 limit = Max(limit, old_gen_size + kMinimumOldGenerationAllocationLimit); | 5648 limit = Max(limit, old_gen_size + kMinimumOldGenerationAllocationLimit); |
5648 limit += new_space_.Capacity(); | 5649 limit += new_space_.Capacity(); |
5649 intptr_t halfway_to_the_max = (old_gen_size + max_old_generation_size_) / 2; | 5650 intptr_t halfway_to_the_max = (old_gen_size + max_old_generation_size_) / 2; |
5650 return Min(limit, halfway_to_the_max); | 5651 return Min(limit, halfway_to_the_max); |
5651 } | 5652 } |
5652 | 5653 |
5653 | 5654 |
5654 void Heap::SetOldGenerationAllocationLimit(intptr_t old_gen_size, | 5655 void Heap::SetOldGenerationAllocationLimit(intptr_t old_gen_size, |
5655 double gc_speed, | 5656 double gc_speed, |
5656 double mutator_speed) { | 5657 double mutator_speed, |
5658 int freed_global_handles) { | |
5659 const int kFreedGlobalHandlesThreshold = 700; | |
ulan
2015/07/30 13:58:32
These numbers are from the old heap growing strate
| |
5660 const double kMaxHeapGrowingFactorForManyFreedGlobalHandles = 1.3; | |
5661 | |
5657 double factor = HeapGrowingFactor(gc_speed, mutator_speed); | 5662 double factor = HeapGrowingFactor(gc_speed, mutator_speed); |
5658 | 5663 |
5659 if (FLAG_trace_gc_verbose) { | 5664 if (FLAG_trace_gc_verbose) { |
5660 PrintIsolate(isolate_, | 5665 PrintIsolate(isolate_, |
5661 "Heap growing factor %.1f based on mu=%.3f, speed_ratio=%.f " | 5666 "Heap growing factor %.1f based on mu=%.3f, speed_ratio=%.f " |
5662 "(gc=%.f, mutator=%.f)\n", | 5667 "(gc=%.f, mutator=%.f)\n", |
5663 factor, kTargetMutatorUtilization, gc_speed / mutator_speed, | 5668 factor, kTargetMutatorUtilization, gc_speed / mutator_speed, |
5664 gc_speed, mutator_speed); | 5669 gc_speed, mutator_speed); |
5665 } | 5670 } |
5666 | 5671 |
5667 // We set the old generation growing factor to 2 to grow the heap slower on | 5672 // We set the old generation growing factor to 2 to grow the heap slower on |
5668 // memory-constrained devices. | 5673 // memory-constrained devices. |
5669 if (max_old_generation_size_ <= kMaxOldSpaceSizeMediumMemoryDevice || | 5674 if (max_old_generation_size_ <= kMaxOldSpaceSizeMediumMemoryDevice || |
5670 FLAG_optimize_for_size) { | 5675 FLAG_optimize_for_size) { |
5671 factor = Min(factor, kMaxHeapGrowingFactorMemoryConstrained); | 5676 factor = Min(factor, kMaxHeapGrowingFactorMemoryConstrained); |
5672 } | 5677 } |
5673 | 5678 |
5679 if (freed_global_handles >= kFreedGlobalHandlesThreshold) { | |
5680 factor = Min(factor, kMaxHeapGrowingFactorForManyFreedGlobalHandles); | |
5681 } | |
5682 | |
5674 if (FLAG_stress_compaction || | 5683 if (FLAG_stress_compaction || |
5675 mark_compact_collector()->reduce_memory_footprint_) { | 5684 mark_compact_collector()->reduce_memory_footprint_) { |
5676 factor = kMinHeapGrowingFactor; | 5685 factor = kMinHeapGrowingFactor; |
5677 } | 5686 } |
5678 | 5687 |
5679 old_generation_allocation_limit_ = | 5688 old_generation_allocation_limit_ = |
5680 CalculateOldGenerationAllocationLimit(factor, old_gen_size); | 5689 CalculateOldGenerationAllocationLimit(factor, old_gen_size); |
5681 | 5690 |
5682 if (FLAG_trace_gc_verbose) { | 5691 if (FLAG_trace_gc_verbose) { |
5683 PrintIsolate(isolate_, "Grow: old size: %" V8_PTR_PREFIX | 5692 PrintIsolate(isolate_, "Grow: old size: %" V8_PTR_PREFIX |
(...skipping 1240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6924 *object_type = "CODE_TYPE"; \ | 6933 *object_type = "CODE_TYPE"; \ |
6925 *object_sub_type = "CODE_AGE/" #name; \ | 6934 *object_sub_type = "CODE_AGE/" #name; \ |
6926 return true; | 6935 return true; |
6927 CODE_AGE_LIST_COMPLETE(COMPARE_AND_RETURN_NAME) | 6936 CODE_AGE_LIST_COMPLETE(COMPARE_AND_RETURN_NAME) |
6928 #undef COMPARE_AND_RETURN_NAME | 6937 #undef COMPARE_AND_RETURN_NAME |
6929 } | 6938 } |
6930 return false; | 6939 return false; |
6931 } | 6940 } |
6932 } // namespace internal | 6941 } // namespace internal |
6933 } // namespace v8 | 6942 } // namespace v8 |
OLD | NEW |