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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 dump_allocations_hash_countdown_(FLAG_dump_allocations_digest_at_alloc), | 102 dump_allocations_hash_countdown_(FLAG_dump_allocations_digest_at_alloc), |
103 ms_count_(0), | 103 ms_count_(0), |
104 gc_count_(0), | 104 gc_count_(0), |
105 remembered_unmapped_pages_index_(0), | 105 remembered_unmapped_pages_index_(0), |
106 unflattened_strings_length_(0), | 106 unflattened_strings_length_(0), |
107 #ifdef DEBUG | 107 #ifdef DEBUG |
108 allocation_timeout_(0), | 108 allocation_timeout_(0), |
109 #endif // DEBUG | 109 #endif // DEBUG |
110 old_generation_allocation_limit_(initial_old_generation_size_), | 110 old_generation_allocation_limit_(initial_old_generation_size_), |
111 old_gen_exhausted_(false), | 111 old_gen_exhausted_(false), |
| 112 optimize_for_memory_usage_(false), |
112 inline_allocation_disabled_(false), | 113 inline_allocation_disabled_(false), |
113 store_buffer_rebuilder_(store_buffer()), | 114 store_buffer_rebuilder_(store_buffer()), |
114 hidden_string_(NULL), | 115 hidden_string_(NULL), |
115 gc_safe_size_of_old_object_(NULL), | 116 gc_safe_size_of_old_object_(NULL), |
116 total_regexp_code_generated_(0), | 117 total_regexp_code_generated_(0), |
117 tracer_(this), | 118 tracer_(this), |
118 new_space_high_promotion_mode_active_(false), | 119 new_space_high_promotion_mode_active_(false), |
119 gathering_lifetime_feedback_(0), | 120 gathering_lifetime_feedback_(0), |
120 high_survival_rate_period_length_(0), | 121 high_survival_rate_period_length_(0), |
121 promoted_objects_size_(0), | 122 promoted_objects_size_(0), |
(...skipping 4838 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4960 | 4961 |
4961 void Heap::CheckAndNotifyBackgroundIdleNotification(double idle_time_in_ms, | 4962 void Heap::CheckAndNotifyBackgroundIdleNotification(double idle_time_in_ms, |
4962 double now_ms) { | 4963 double now_ms) { |
4963 if (idle_time_in_ms >= GCIdleTimeHandler::kMinBackgroundIdleTime) { | 4964 if (idle_time_in_ms >= GCIdleTimeHandler::kMinBackgroundIdleTime) { |
4964 MemoryReducer::Event event; | 4965 MemoryReducer::Event event; |
4965 event.type = MemoryReducer::kBackgroundIdleNotification; | 4966 event.type = MemoryReducer::kBackgroundIdleNotification; |
4966 event.time_ms = now_ms; | 4967 event.time_ms = now_ms; |
4967 event.can_start_incremental_gc = incremental_marking()->IsStopped() && | 4968 event.can_start_incremental_gc = incremental_marking()->IsStopped() && |
4968 incremental_marking()->CanBeActivated(); | 4969 incremental_marking()->CanBeActivated(); |
4969 memory_reducer_.NotifyBackgroundIdleNotification(event); | 4970 memory_reducer_.NotifyBackgroundIdleNotification(event); |
| 4971 optimize_for_memory_usage_ = true; |
| 4972 } else { |
| 4973 optimize_for_memory_usage_ = false; |
4970 } | 4974 } |
4971 } | 4975 } |
4972 | 4976 |
4973 | 4977 |
4974 double Heap::MonotonicallyIncreasingTimeInMs() { | 4978 double Heap::MonotonicallyIncreasingTimeInMs() { |
4975 return V8::GetCurrentPlatform()->MonotonicallyIncreasingTime() * | 4979 return V8::GetCurrentPlatform()->MonotonicallyIncreasingTime() * |
4976 static_cast<double>(base::Time::kMillisecondsPerSecond); | 4980 static_cast<double>(base::Time::kMillisecondsPerSecond); |
4977 } | 4981 } |
4978 | 4982 |
4979 | 4983 |
(...skipping 640 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5620 limit = Max(limit, old_gen_size + kMinimumOldGenerationAllocationLimit); | 5624 limit = Max(limit, old_gen_size + kMinimumOldGenerationAllocationLimit); |
5621 limit += new_space_.Capacity(); | 5625 limit += new_space_.Capacity(); |
5622 intptr_t halfway_to_the_max = (old_gen_size + max_old_generation_size_) / 2; | 5626 intptr_t halfway_to_the_max = (old_gen_size + max_old_generation_size_) / 2; |
5623 return Min(limit, halfway_to_the_max); | 5627 return Min(limit, halfway_to_the_max); |
5624 } | 5628 } |
5625 | 5629 |
5626 | 5630 |
5627 void Heap::SetOldGenerationAllocationLimit(intptr_t old_gen_size, | 5631 void Heap::SetOldGenerationAllocationLimit(intptr_t old_gen_size, |
5628 double gc_speed, | 5632 double gc_speed, |
5629 double mutator_speed) { | 5633 double mutator_speed) { |
| 5634 const double kConservativeHeapGrowingFactor = 1.3; |
| 5635 |
5630 double factor = HeapGrowingFactor(gc_speed, mutator_speed); | 5636 double factor = HeapGrowingFactor(gc_speed, mutator_speed); |
5631 | 5637 |
5632 if (FLAG_trace_gc_verbose) { | 5638 if (FLAG_trace_gc_verbose) { |
5633 PrintIsolate(isolate_, | 5639 PrintIsolate(isolate_, |
5634 "Heap growing factor %.1f based on mu=%.3f, speed_ratio=%.f " | 5640 "Heap growing factor %.1f based on mu=%.3f, speed_ratio=%.f " |
5635 "(gc=%.f, mutator=%.f)\n", | 5641 "(gc=%.f, mutator=%.f)\n", |
5636 factor, kTargetMutatorUtilization, gc_speed / mutator_speed, | 5642 factor, kTargetMutatorUtilization, gc_speed / mutator_speed, |
5637 gc_speed, mutator_speed); | 5643 gc_speed, mutator_speed); |
5638 } | 5644 } |
5639 | 5645 |
5640 // We set the old generation growing factor to 2 to grow the heap slower on | 5646 // We set the old generation growing factor to 2 to grow the heap slower on |
5641 // memory-constrained devices. | 5647 // memory-constrained devices. |
5642 if (max_old_generation_size_ <= kMaxOldSpaceSizeMediumMemoryDevice || | 5648 if (max_old_generation_size_ <= kMaxOldSpaceSizeMediumMemoryDevice || |
5643 FLAG_optimize_for_size) { | 5649 FLAG_optimize_for_size) { |
5644 factor = Min(factor, kMaxHeapGrowingFactorMemoryConstrained); | 5650 factor = Min(factor, kMaxHeapGrowingFactorMemoryConstrained); |
5645 } | 5651 } |
5646 | 5652 |
| 5653 if (memory_reducer_.ShouldGrowHeapSlowly() || optimize_for_memory_usage_) { |
| 5654 factor = Min(factor, kConservativeHeapGrowingFactor); |
| 5655 } |
| 5656 |
5647 if (FLAG_stress_compaction || | 5657 if (FLAG_stress_compaction || |
5648 mark_compact_collector()->reduce_memory_footprint_) { | 5658 mark_compact_collector()->reduce_memory_footprint_) { |
5649 factor = kMinHeapGrowingFactor; | 5659 factor = kMinHeapGrowingFactor; |
5650 } | 5660 } |
5651 | 5661 |
5652 old_generation_allocation_limit_ = | 5662 old_generation_allocation_limit_ = |
5653 CalculateOldGenerationAllocationLimit(factor, old_gen_size); | 5663 CalculateOldGenerationAllocationLimit(factor, old_gen_size); |
5654 | 5664 |
5655 if (FLAG_trace_gc_verbose) { | 5665 if (FLAG_trace_gc_verbose) { |
5656 PrintIsolate(isolate_, "Grow: old size: %" V8_PTR_PREFIX | 5666 PrintIsolate(isolate_, "Grow: old size: %" V8_PTR_PREFIX |
(...skipping 1239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6896 *object_type = "CODE_TYPE"; \ | 6906 *object_type = "CODE_TYPE"; \ |
6897 *object_sub_type = "CODE_AGE/" #name; \ | 6907 *object_sub_type = "CODE_AGE/" #name; \ |
6898 return true; | 6908 return true; |
6899 CODE_AGE_LIST_COMPLETE(COMPARE_AND_RETURN_NAME) | 6909 CODE_AGE_LIST_COMPLETE(COMPARE_AND_RETURN_NAME) |
6900 #undef COMPARE_AND_RETURN_NAME | 6910 #undef COMPARE_AND_RETURN_NAME |
6901 } | 6911 } |
6902 return false; | 6912 return false; |
6903 } | 6913 } |
6904 } // namespace internal | 6914 } // namespace internal |
6905 } // namespace v8 | 6915 } // namespace v8 |
OLD | NEW |