| 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/once.h" | 9 #include "src/base/once.h" |
| 10 #include "src/base/utils/random-number-generator.h" | 10 #include "src/base/utils/random-number-generator.h" |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 | 46 |
| 47 namespace v8 { | 47 namespace v8 { |
| 48 namespace internal { | 48 namespace internal { |
| 49 | 49 |
| 50 | 50 |
| 51 Heap::Heap() | 51 Heap::Heap() |
| 52 : amount_of_external_allocated_memory_(0), | 52 : amount_of_external_allocated_memory_(0), |
| 53 amount_of_external_allocated_memory_at_last_global_gc_(0), | 53 amount_of_external_allocated_memory_at_last_global_gc_(0), |
| 54 isolate_(NULL), | 54 isolate_(NULL), |
| 55 code_range_size_(0), | 55 code_range_size_(0), |
| 56 // semispace_size_ should be a power of 2 and old_generation_size_ should be | 56 // semispace_size_ should be a power of 2 and old_generation_size_ should |
| 57 // a multiple of Page::kPageSize. | 57 // be a multiple of Page::kPageSize. |
| 58 reserved_semispace_size_(8 * (kPointerSize / 4) * MB), | 58 reserved_semispace_size_(8 * (kPointerSize / 4) * MB), |
| 59 max_semi_space_size_(8 * (kPointerSize / 4) * MB), | 59 max_semi_space_size_(8 * (kPointerSize / 4) * MB), |
| 60 initial_semispace_size_(Page::kPageSize), | 60 initial_semispace_size_(Page::kPageSize), |
| 61 max_old_generation_size_(700ul * (kPointerSize / 4) * MB), | 61 max_old_generation_size_(700ul * (kPointerSize / 4) * MB), |
| 62 max_executable_size_(256ul * (kPointerSize / 4) * MB), | 62 max_executable_size_(256ul * (kPointerSize / 4) * MB), |
| 63 // Variables set based on semispace_size_ and old_generation_size_ in | 63 // Variables set based on semispace_size_ and old_generation_size_ in |
| 64 // ConfigureHeap. | 64 // ConfigureHeap. |
| 65 // Will be 4 * reserved_semispace_size_ to ensure that young | 65 // Will be 4 * reserved_semispace_size_ to ensure that young |
| 66 // generation can be aligned to its size. | 66 // generation can be aligned to its size. |
| 67 maximum_committed_(0), | 67 maximum_committed_(0), |
| 68 survived_since_last_expansion_(0), | 68 survived_since_last_expansion_(0), |
| 69 sweep_generation_(0), | 69 sweep_generation_(0), |
| 70 always_allocate_scope_depth_(0), | 70 always_allocate_scope_depth_(0), |
| 71 contexts_disposed_(0), | 71 contexts_disposed_(0), |
| 72 global_ic_age_(0), | 72 global_ic_age_(0), |
| 73 flush_monomorphic_ics_(false), | 73 flush_monomorphic_ics_(false), |
| 74 scan_on_scavenge_pages_(0), | 74 scan_on_scavenge_pages_(0), |
| 75 new_space_(this), | 75 new_space_(this), |
| 76 old_pointer_space_(NULL), | 76 old_pointer_space_(NULL), |
| (...skipping 4184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4261 const int kMinHintForIncrementalMarking = 10; | 4261 const int kMinHintForIncrementalMarking = 10; |
| 4262 // Minimal hint that allows to do full GC. | 4262 // Minimal hint that allows to do full GC. |
| 4263 const int kMinHintForFullGC = 100; | 4263 const int kMinHintForFullGC = 100; |
| 4264 intptr_t size_factor = Min(Max(hint, 20), kMaxHint) / 4; | 4264 intptr_t size_factor = Min(Max(hint, 20), kMaxHint) / 4; |
| 4265 // The size factor is in range [5..250]. The numbers here are chosen from | 4265 // The size factor is in range [5..250]. The numbers here are chosen from |
| 4266 // experiments. If you changes them, make sure to test with | 4266 // experiments. If you changes them, make sure to test with |
| 4267 // chrome/performance_ui_tests --gtest_filter="GeneralMixMemoryTest.* | 4267 // chrome/performance_ui_tests --gtest_filter="GeneralMixMemoryTest.* |
| 4268 intptr_t step_size = | 4268 intptr_t step_size = |
| 4269 size_factor * IncrementalMarking::kAllocatedThreshold; | 4269 size_factor * IncrementalMarking::kAllocatedThreshold; |
| 4270 | 4270 |
| 4271 isolate()->counters()->gc_idle_time_allotted_in_ms()->AddSample(hint); |
| 4271 HistogramTimerScope idle_notification_scope( | 4272 HistogramTimerScope idle_notification_scope( |
| 4272 isolate_->counters()->gc_idle_notification()); | 4273 isolate_->counters()->gc_idle_notification()); |
| 4273 | 4274 |
| 4274 if (contexts_disposed_ > 0) { | 4275 if (contexts_disposed_ > 0) { |
| 4275 contexts_disposed_ = 0; | 4276 contexts_disposed_ = 0; |
| 4276 int mark_sweep_time = Min(TimeMarkSweepWouldTakeInMs(), 1000); | 4277 int mark_sweep_time = Min(TimeMarkSweepWouldTakeInMs(), 1000); |
| 4277 if (hint >= mark_sweep_time && !FLAG_expose_gc && | 4278 if (hint >= mark_sweep_time && !FLAG_expose_gc && |
| 4278 incremental_marking()->IsStopped()) { | 4279 incremental_marking()->IsStopped()) { |
| 4279 HistogramTimerScope scope(isolate_->counters()->gc_context()); | 4280 HistogramTimerScope scope(isolate_->counters()->gc_context()); |
| 4280 CollectAllGarbage(kReduceMemoryFootprintMask, | 4281 CollectAllGarbage(kReduceMemoryFootprintMask, |
| (...skipping 2169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6450 static_cast<int>(object_sizes_last_time_[index])); | 6451 static_cast<int>(object_sizes_last_time_[index])); |
| 6451 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT) | 6452 CODE_AGE_LIST_COMPLETE(ADJUST_LAST_TIME_OBJECT_COUNT) |
| 6452 #undef ADJUST_LAST_TIME_OBJECT_COUNT | 6453 #undef ADJUST_LAST_TIME_OBJECT_COUNT |
| 6453 | 6454 |
| 6454 MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); | 6455 MemCopy(object_counts_last_time_, object_counts_, sizeof(object_counts_)); |
| 6455 MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); | 6456 MemCopy(object_sizes_last_time_, object_sizes_, sizeof(object_sizes_)); |
| 6456 ClearObjectStats(); | 6457 ClearObjectStats(); |
| 6457 } | 6458 } |
| 6458 | 6459 |
| 6459 } } // namespace v8::internal | 6460 } } // namespace v8::internal |
| OLD | NEW |