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 4594 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4605 static_cast<size_t>(idle_time_in_ms), size_of_objects, | 4605 static_cast<size_t>(idle_time_in_ms), size_of_objects, |
4606 final_incremental_mark_compact_speed_in_bytes_per_ms))) { | 4606 final_incremental_mark_compact_speed_in_bytes_per_ms))) { |
4607 CollectAllGarbage(kNoGCFlags, "idle notification: finalize incremental"); | 4607 CollectAllGarbage(kNoGCFlags, "idle notification: finalize incremental"); |
4608 gc_idle_time_handler_.NotifyIdleMarkCompact(); | 4608 gc_idle_time_handler_.NotifyIdleMarkCompact(); |
4609 return true; | 4609 return true; |
4610 } | 4610 } |
4611 return false; | 4611 return false; |
4612 } | 4612 } |
4613 | 4613 |
4614 | 4614 |
4615 GCIdleTimeHandler::HeapState Heap::ComputeHeapState(bool reduce_memory) { | 4615 GCIdleTimeHandler::HeapState Heap::ComputeHeapState() { |
4616 GCIdleTimeHandler::HeapState heap_state; | 4616 GCIdleTimeHandler::HeapState heap_state; |
4617 heap_state.contexts_disposed = contexts_disposed_; | 4617 heap_state.contexts_disposed = contexts_disposed_; |
4618 heap_state.contexts_disposal_rate = | 4618 heap_state.contexts_disposal_rate = |
4619 tracer()->ContextDisposalRateInMilliseconds(); | 4619 tracer()->ContextDisposalRateInMilliseconds(); |
4620 heap_state.size_of_objects = static_cast<size_t>(SizeOfObjects()); | 4620 heap_state.size_of_objects = static_cast<size_t>(SizeOfObjects()); |
4621 heap_state.incremental_marking_stopped = incremental_marking()->IsStopped(); | 4621 heap_state.incremental_marking_stopped = incremental_marking()->IsStopped(); |
4622 // TODO(ulan): Start incremental marking only for large heaps. | |
4623 intptr_t limit = old_generation_allocation_limit_; | |
4624 if (reduce_memory) { | |
4625 limit = idle_old_generation_allocation_limit_; | |
4626 } | |
4627 | |
4628 heap_state.can_start_incremental_marking = | |
4629 incremental_marking()->CanBeActivated() && | |
4630 HeapIsFullEnoughToStartIncrementalMarking(limit) && | |
4631 !mark_compact_collector()->sweeping_in_progress(); | |
4632 heap_state.sweeping_in_progress = | 4622 heap_state.sweeping_in_progress = |
4633 mark_compact_collector()->sweeping_in_progress(); | 4623 mark_compact_collector()->sweeping_in_progress(); |
4634 heap_state.sweeping_completed = | 4624 heap_state.sweeping_completed = |
4635 mark_compact_collector()->IsSweepingCompleted(); | 4625 mark_compact_collector()->IsSweepingCompleted(); |
4636 heap_state.mark_compact_speed_in_bytes_per_ms = | 4626 heap_state.mark_compact_speed_in_bytes_per_ms = |
4637 static_cast<size_t>(tracer()->MarkCompactSpeedInBytesPerMillisecond()); | 4627 static_cast<size_t>(tracer()->MarkCompactSpeedInBytesPerMillisecond()); |
4638 heap_state.incremental_marking_speed_in_bytes_per_ms = static_cast<size_t>( | 4628 heap_state.incremental_marking_speed_in_bytes_per_ms = static_cast<size_t>( |
4639 tracer()->IncrementalMarkingSpeedInBytesPerMillisecond()); | 4629 tracer()->IncrementalMarkingSpeedInBytesPerMillisecond()); |
4640 heap_state.final_incremental_mark_compact_speed_in_bytes_per_ms = | 4630 heap_state.final_incremental_mark_compact_speed_in_bytes_per_ms = |
4641 static_cast<size_t>( | 4631 static_cast<size_t>( |
4642 tracer()->FinalIncrementalMarkCompactSpeedInBytesPerMillisecond()); | 4632 tracer()->FinalIncrementalMarkCompactSpeedInBytesPerMillisecond()); |
4643 heap_state.scavenge_speed_in_bytes_per_ms = | 4633 heap_state.scavenge_speed_in_bytes_per_ms = |
4644 static_cast<size_t>(tracer()->ScavengeSpeedInBytesPerMillisecond()); | 4634 static_cast<size_t>(tracer()->ScavengeSpeedInBytesPerMillisecond()); |
4645 heap_state.used_new_space_size = new_space_.Size(); | 4635 heap_state.used_new_space_size = new_space_.Size(); |
4646 heap_state.new_space_capacity = new_space_.Capacity(); | 4636 heap_state.new_space_capacity = new_space_.Capacity(); |
4647 heap_state.new_space_allocation_throughput_in_bytes_per_ms = | 4637 heap_state.new_space_allocation_throughput_in_bytes_per_ms = |
4648 tracer()->NewSpaceAllocationThroughputInBytesPerMillisecond(); | 4638 tracer()->NewSpaceAllocationThroughputInBytesPerMillisecond(); |
4649 heap_state.current_new_space_allocation_throughput_in_bytes_per_ms = | 4639 heap_state.current_new_space_allocation_throughput_in_bytes_per_ms = |
4650 tracer()->CurrentNewSpaceAllocationThroughputInBytesPerMillisecond(); | 4640 tracer()->CurrentNewSpaceAllocationThroughputInBytesPerMillisecond(); |
4641 // TODO(ulan): Start incremental marking only for large heaps. | |
ulan
2015/05/22 12:04:13
We can remove the todo.
Hannes Payer (out of office)
2015/05/22 12:19:46
Done.
| |
4642 intptr_t limit = old_generation_allocation_limit_; | |
4643 if (HasLowAllocationRate( | |
4644 heap_state.current_new_space_allocation_throughput_in_bytes_per_ms)) { | |
4645 limit = idle_old_generation_allocation_limit_; | |
4646 } | |
4647 heap_state.can_start_incremental_marking = | |
4648 incremental_marking()->CanBeActivated() && | |
4649 HeapIsFullEnoughToStartIncrementalMarking(limit) && | |
4650 !mark_compact_collector()->sweeping_in_progress(); | |
4651 return heap_state; | 4651 return heap_state; |
4652 } | 4652 } |
4653 | 4653 |
4654 | 4654 |
4655 bool Heap::PerformIdleTimeAction(GCIdleTimeAction action, | 4655 bool Heap::PerformIdleTimeAction(GCIdleTimeAction action, |
4656 GCIdleTimeHandler::HeapState heap_state, | 4656 GCIdleTimeHandler::HeapState heap_state, |
4657 double deadline_in_ms, | 4657 double deadline_in_ms, |
4658 bool is_long_idle_notification) { | 4658 bool is_long_idle_notification) { |
4659 bool result = false; | 4659 bool result = false; |
4660 switch (action.type) { | 4660 switch (action.type) { |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4776 bool Heap::IdleNotification(int idle_time_in_ms) { | 4776 bool Heap::IdleNotification(int idle_time_in_ms) { |
4777 return IdleNotification( | 4777 return IdleNotification( |
4778 V8::GetCurrentPlatform()->MonotonicallyIncreasingTime() + | 4778 V8::GetCurrentPlatform()->MonotonicallyIncreasingTime() + |
4779 (static_cast<double>(idle_time_in_ms) / | 4779 (static_cast<double>(idle_time_in_ms) / |
4780 static_cast<double>(base::Time::kMillisecondsPerSecond))); | 4780 static_cast<double>(base::Time::kMillisecondsPerSecond))); |
4781 } | 4781 } |
4782 | 4782 |
4783 | 4783 |
4784 bool Heap::IdleNotification(double deadline_in_seconds) { | 4784 bool Heap::IdleNotification(double deadline_in_seconds) { |
4785 CHECK(HasBeenSetUp()); | 4785 CHECK(HasBeenSetUp()); |
4786 static const double kLastGCTimeTreshold = 1000; | |
4787 double deadline_in_ms = | 4786 double deadline_in_ms = |
4788 deadline_in_seconds * | 4787 deadline_in_seconds * |
4789 static_cast<double>(base::Time::kMillisecondsPerSecond); | 4788 static_cast<double>(base::Time::kMillisecondsPerSecond); |
4790 HistogramTimerScope idle_notification_scope( | 4789 HistogramTimerScope idle_notification_scope( |
4791 isolate_->counters()->gc_idle_notification()); | 4790 isolate_->counters()->gc_idle_notification()); |
4792 double start_ms = MonotonicallyIncreasingTimeInMs(); | 4791 double start_ms = MonotonicallyIncreasingTimeInMs(); |
4793 double idle_time_in_ms = deadline_in_ms - start_ms; | 4792 double idle_time_in_ms = deadline_in_ms - start_ms; |
4794 bool is_long_idle_notification = | 4793 bool is_long_idle_notification = |
4795 static_cast<size_t>(idle_time_in_ms) > | 4794 static_cast<size_t>(idle_time_in_ms) > |
4796 GCIdleTimeHandler::kMaxFrameRenderingIdleTime; | 4795 GCIdleTimeHandler::kMaxFrameRenderingIdleTime; |
4797 bool has_low_gc_activity = (start_ms - last_gc_time_) > kLastGCTimeTreshold; | |
4798 | 4796 |
4799 if (is_long_idle_notification) { | 4797 if (is_long_idle_notification) { |
4800 tracer()->SampleNewSpaceAllocation(start_ms, NewSpaceAllocationCounter()); | 4798 tracer()->SampleNewSpaceAllocation(start_ms, NewSpaceAllocationCounter()); |
4801 } | 4799 } |
4802 | 4800 |
4803 GCIdleTimeHandler::HeapState heap_state = | 4801 GCIdleTimeHandler::HeapState heap_state = ComputeHeapState(); |
4804 ComputeHeapState(is_long_idle_notification && has_low_gc_activity); | |
4805 | 4802 |
4806 GCIdleTimeAction action = | 4803 GCIdleTimeAction action = |
4807 gc_idle_time_handler_.Compute(idle_time_in_ms, heap_state); | 4804 gc_idle_time_handler_.Compute(idle_time_in_ms, heap_state); |
4808 | 4805 |
4809 bool result = PerformIdleTimeAction(action, heap_state, deadline_in_ms, | 4806 bool result = PerformIdleTimeAction(action, heap_state, deadline_in_ms, |
4810 is_long_idle_notification); | 4807 is_long_idle_notification); |
4811 | 4808 |
4812 IdleNotificationEpilogue(action, heap_state, start_ms, deadline_in_ms, | 4809 IdleNotificationEpilogue(action, heap_state, start_ms, deadline_in_ms, |
4813 is_long_idle_notification); | 4810 is_long_idle_notification); |
4814 return result; | 4811 return result; |
(...skipping 1785 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6600 *object_type = "CODE_TYPE"; \ | 6597 *object_type = "CODE_TYPE"; \ |
6601 *object_sub_type = "CODE_AGE/" #name; \ | 6598 *object_sub_type = "CODE_AGE/" #name; \ |
6602 return true; | 6599 return true; |
6603 CODE_AGE_LIST_COMPLETE(COMPARE_AND_RETURN_NAME) | 6600 CODE_AGE_LIST_COMPLETE(COMPARE_AND_RETURN_NAME) |
6604 #undef COMPARE_AND_RETURN_NAME | 6601 #undef COMPARE_AND_RETURN_NAME |
6605 } | 6602 } |
6606 return false; | 6603 return false; |
6607 } | 6604 } |
6608 } | 6605 } |
6609 } // namespace v8::internal | 6606 } // namespace v8::internal |
OLD | NEW |