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 5654 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5665 intptr_t halfway_to_the_max = (old_gen_size + max_old_generation_size_) / 2; | 5665 intptr_t halfway_to_the_max = (old_gen_size + max_old_generation_size_) / 2; |
5666 return Min(limit, halfway_to_the_max); | 5666 return Min(limit, halfway_to_the_max); |
5667 } | 5667 } |
5668 | 5668 |
5669 | 5669 |
5670 void Heap::SetOldGenerationAllocationLimit(intptr_t old_gen_size, | 5670 void Heap::SetOldGenerationAllocationLimit(intptr_t old_gen_size, |
5671 double gc_speed, | 5671 double gc_speed, |
5672 double mutator_speed, | 5672 double mutator_speed, |
5673 int freed_global_handles) { | 5673 int freed_global_handles) { |
5674 const int kFreedGlobalHandlesThreshold = 700; | 5674 const int kFreedGlobalHandlesThreshold = 700; |
5675 const double kMaxHeapGrowingFactorForManyFreedGlobalHandles = 1.3; | 5675 const double kConservativeHeapGrowingFactor = 1.3; |
5676 | 5676 |
5677 double factor = HeapGrowingFactor(gc_speed, mutator_speed); | 5677 double factor = HeapGrowingFactor(gc_speed, mutator_speed); |
5678 | 5678 |
5679 if (FLAG_trace_gc_verbose) { | 5679 if (FLAG_trace_gc_verbose) { |
5680 PrintIsolate(isolate_, | 5680 PrintIsolate(isolate_, |
5681 "Heap growing factor %.1f based on mu=%.3f, speed_ratio=%.f " | 5681 "Heap growing factor %.1f based on mu=%.3f, speed_ratio=%.f " |
5682 "(gc=%.f, mutator=%.f)\n", | 5682 "(gc=%.f, mutator=%.f)\n", |
5683 factor, kTargetMutatorUtilization, gc_speed / mutator_speed, | 5683 factor, kTargetMutatorUtilization, gc_speed / mutator_speed, |
5684 gc_speed, mutator_speed); | 5684 gc_speed, mutator_speed); |
5685 } | 5685 } |
5686 | 5686 |
5687 // We set the old generation growing factor to 2 to grow the heap slower on | 5687 // We set the old generation growing factor to 2 to grow the heap slower on |
5688 // memory-constrained devices. | 5688 // memory-constrained devices. |
5689 if (max_old_generation_size_ <= kMaxOldSpaceSizeMediumMemoryDevice || | 5689 if (max_old_generation_size_ <= kMaxOldSpaceSizeMediumMemoryDevice || |
5690 FLAG_optimize_for_size) { | 5690 FLAG_optimize_for_size) { |
5691 factor = Min(factor, kMaxHeapGrowingFactorMemoryConstrained); | 5691 factor = Min(factor, kMaxHeapGrowingFactorMemoryConstrained); |
5692 } | 5692 } |
5693 | 5693 |
5694 if (freed_global_handles >= kFreedGlobalHandlesThreshold) { | 5694 if (freed_global_handles >= kFreedGlobalHandlesThreshold || |
5695 factor = Min(factor, kMaxHeapGrowingFactorForManyFreedGlobalHandles); | 5695 memory_reducer_.ShouldGrowHeapSlowly()) { |
| 5696 factor = Min(factor, kConservativeHeapGrowingFactor); |
5696 } | 5697 } |
5697 | 5698 |
5698 if (FLAG_stress_compaction || | 5699 if (FLAG_stress_compaction || |
5699 mark_compact_collector()->reduce_memory_footprint_) { | 5700 mark_compact_collector()->reduce_memory_footprint_) { |
5700 factor = kMinHeapGrowingFactor; | 5701 factor = kMinHeapGrowingFactor; |
5701 } | 5702 } |
5702 | 5703 |
5703 old_generation_allocation_limit_ = | 5704 old_generation_allocation_limit_ = |
5704 CalculateOldGenerationAllocationLimit(factor, old_gen_size); | 5705 CalculateOldGenerationAllocationLimit(factor, old_gen_size); |
5705 | 5706 |
(...skipping 1242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6948 *object_type = "CODE_TYPE"; \ | 6949 *object_type = "CODE_TYPE"; \ |
6949 *object_sub_type = "CODE_AGE/" #name; \ | 6950 *object_sub_type = "CODE_AGE/" #name; \ |
6950 return true; | 6951 return true; |
6951 CODE_AGE_LIST_COMPLETE(COMPARE_AND_RETURN_NAME) | 6952 CODE_AGE_LIST_COMPLETE(COMPARE_AND_RETURN_NAME) |
6952 #undef COMPARE_AND_RETURN_NAME | 6953 #undef COMPARE_AND_RETURN_NAME |
6953 } | 6954 } |
6954 return false; | 6955 return false; |
6955 } | 6956 } |
6956 } // namespace internal | 6957 } // namespace internal |
6957 } // namespace v8 | 6958 } // namespace v8 |
OLD | NEW |