| 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 4752 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4763 | 4763 |
| 4764 | 4764 |
| 4765 void Heap::ReduceNewSpaceSize() { | 4765 void Heap::ReduceNewSpaceSize() { |
| 4766 if (!FLAG_predictable && HasLowAllocationRate()) { | 4766 if (!FLAG_predictable && HasLowAllocationRate()) { |
| 4767 new_space_.Shrink(); | 4767 new_space_.Shrink(); |
| 4768 UncommitFromSpace(); | 4768 UncommitFromSpace(); |
| 4769 } | 4769 } |
| 4770 } | 4770 } |
| 4771 | 4771 |
| 4772 | 4772 |
| 4773 bool Heap::TryFinalizeIdleIncrementalMarking( | 4773 bool Heap::TryFinalizeIdleIncrementalMarking(double idle_time_in_ms) { |
| 4774 double idle_time_in_ms, size_t size_of_objects, | 4774 size_t size_of_objects = static_cast<size_t>(SizeOfObjects()); |
| 4775 size_t final_incremental_mark_compact_speed_in_bytes_per_ms) { | 4775 size_t final_incremental_mark_compact_speed_in_bytes_per_ms = |
| 4776 static_cast<size_t>( |
| 4777 tracer()->FinalIncrementalMarkCompactSpeedInBytesPerMillisecond()); |
| 4776 if (FLAG_overapproximate_weak_closure && | 4778 if (FLAG_overapproximate_weak_closure && |
| 4777 (incremental_marking()->IsReadyToOverApproximateWeakClosure() || | 4779 (incremental_marking()->IsReadyToOverApproximateWeakClosure() || |
| 4778 (!incremental_marking()->weak_closure_was_overapproximated() && | 4780 (!incremental_marking()->weak_closure_was_overapproximated() && |
| 4779 mark_compact_collector_.marking_deque()->IsEmpty() && | 4781 mark_compact_collector_.marking_deque()->IsEmpty() && |
| 4780 gc_idle_time_handler_.ShouldDoOverApproximateWeakClosure( | 4782 gc_idle_time_handler_.ShouldDoOverApproximateWeakClosure( |
| 4781 static_cast<size_t>(idle_time_in_ms))))) { | 4783 static_cast<size_t>(idle_time_in_ms))))) { |
| 4782 OverApproximateWeakClosure( | 4784 OverApproximateWeakClosure( |
| 4783 "Idle notification: overapproximate weak closure"); | 4785 "Idle notification: overapproximate weak closure"); |
| 4784 return true; | 4786 return true; |
| 4785 } else if (incremental_marking()->IsComplete() || | 4787 } else if (incremental_marking()->IsComplete() || |
| 4786 (mark_compact_collector_.marking_deque()->IsEmpty() && | 4788 (mark_compact_collector_.marking_deque()->IsEmpty() && |
| 4787 gc_idle_time_handler_.ShouldDoFinalIncrementalMarkCompact( | 4789 gc_idle_time_handler_.ShouldDoFinalIncrementalMarkCompact( |
| 4788 static_cast<size_t>(idle_time_in_ms), size_of_objects, | 4790 static_cast<size_t>(idle_time_in_ms), size_of_objects, |
| 4789 final_incremental_mark_compact_speed_in_bytes_per_ms))) { | 4791 final_incremental_mark_compact_speed_in_bytes_per_ms))) { |
| 4790 CollectAllGarbage(kNoGCFlags, "idle notification: finalize incremental"); | 4792 CollectAllGarbage(kNoGCFlags, "idle notification: finalize incremental"); |
| 4791 return true; | 4793 return true; |
| 4792 } | 4794 } |
| 4793 return false; | 4795 return false; |
| 4794 } | 4796 } |
| 4795 | 4797 |
| 4796 | 4798 |
| 4797 GCIdleTimeHandler::HeapState Heap::ComputeHeapState() { | 4799 GCIdleTimeHandler::HeapState Heap::ComputeHeapState() { |
| 4798 GCIdleTimeHandler::HeapState heap_state; | 4800 GCIdleTimeHandler::HeapState heap_state; |
| 4799 heap_state.contexts_disposed = contexts_disposed_; | 4801 heap_state.contexts_disposed = contexts_disposed_; |
| 4800 heap_state.contexts_disposal_rate = | 4802 heap_state.contexts_disposal_rate = |
| 4801 tracer()->ContextDisposalRateInMilliseconds(); | 4803 tracer()->ContextDisposalRateInMilliseconds(); |
| 4802 heap_state.size_of_objects = static_cast<size_t>(SizeOfObjects()); | |
| 4803 heap_state.incremental_marking_stopped = incremental_marking()->IsStopped(); | 4804 heap_state.incremental_marking_stopped = incremental_marking()->IsStopped(); |
| 4804 heap_state.sweeping_in_progress = | |
| 4805 mark_compact_collector()->sweeping_in_progress(); | |
| 4806 heap_state.sweeping_completed = | |
| 4807 mark_compact_collector()->IsSweepingCompleted(); | |
| 4808 heap_state.mark_compact_speed_in_bytes_per_ms = | 4805 heap_state.mark_compact_speed_in_bytes_per_ms = |
| 4809 static_cast<size_t>(tracer()->MarkCompactSpeedInBytesPerMillisecond()); | 4806 static_cast<size_t>(tracer()->MarkCompactSpeedInBytesPerMillisecond()); |
| 4810 heap_state.incremental_marking_speed_in_bytes_per_ms = static_cast<size_t>( | |
| 4811 tracer()->IncrementalMarkingSpeedInBytesPerMillisecond()); | |
| 4812 heap_state.final_incremental_mark_compact_speed_in_bytes_per_ms = | |
| 4813 static_cast<size_t>( | |
| 4814 tracer()->FinalIncrementalMarkCompactSpeedInBytesPerMillisecond()); | |
| 4815 heap_state.scavenge_speed_in_bytes_per_ms = | 4807 heap_state.scavenge_speed_in_bytes_per_ms = |
| 4816 static_cast<size_t>(tracer()->ScavengeSpeedInBytesPerMillisecond()); | 4808 static_cast<size_t>(tracer()->ScavengeSpeedInBytesPerMillisecond()); |
| 4817 heap_state.used_new_space_size = new_space_.Size(); | 4809 heap_state.used_new_space_size = new_space_.Size(); |
| 4818 heap_state.new_space_capacity = new_space_.Capacity(); | 4810 heap_state.new_space_capacity = new_space_.Capacity(); |
| 4819 heap_state.new_space_allocation_throughput_in_bytes_per_ms = | 4811 heap_state.new_space_allocation_throughput_in_bytes_per_ms = |
| 4820 tracer()->NewSpaceAllocationThroughputInBytesPerMillisecond(); | 4812 tracer()->NewSpaceAllocationThroughputInBytesPerMillisecond(); |
| 4821 return heap_state; | 4813 return heap_state; |
| 4822 } | 4814 } |
| 4823 | 4815 |
| 4824 | 4816 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 4849 | 4841 |
| 4850 | 4842 |
| 4851 bool Heap::PerformIdleTimeAction(GCIdleTimeAction action, | 4843 bool Heap::PerformIdleTimeAction(GCIdleTimeAction action, |
| 4852 GCIdleTimeHandler::HeapState heap_state, | 4844 GCIdleTimeHandler::HeapState heap_state, |
| 4853 double deadline_in_ms) { | 4845 double deadline_in_ms) { |
| 4854 bool result = false; | 4846 bool result = false; |
| 4855 switch (action.type) { | 4847 switch (action.type) { |
| 4856 case DONE: | 4848 case DONE: |
| 4857 result = true; | 4849 result = true; |
| 4858 break; | 4850 break; |
| 4859 case DO_INCREMENTAL_MARKING: { | 4851 case DO_INCREMENTAL_STEP: { |
| 4860 const double remaining_idle_time_in_ms = | 4852 if (incremental_marking()->IsIncrementalMarkingTaskPending() || |
| 4861 AdvanceIncrementalMarking(action.parameter, deadline_in_ms, | 4853 IncrementalMarkingTask::Step(this, deadline_in_ms) == |
| 4862 IncrementalMarking::NoForcedStepActions()); | 4854 IncrementalMarkingTask::kDone) { |
| 4863 if (remaining_idle_time_in_ms > 0.0) { | 4855 result = true; |
| 4864 action.additional_work = TryFinalizeIdleIncrementalMarking( | |
| 4865 remaining_idle_time_in_ms, heap_state.size_of_objects, | |
| 4866 heap_state.final_incremental_mark_compact_speed_in_bytes_per_ms); | |
| 4867 } | 4856 } |
| 4868 break; | 4857 break; |
| 4869 } | 4858 } |
| 4870 case DO_FULL_GC: { | 4859 case DO_FULL_GC: { |
| 4871 DCHECK(contexts_disposed_ > 0); | 4860 DCHECK(contexts_disposed_ > 0); |
| 4872 HistogramTimerScope scope(isolate_->counters()->gc_context()); | 4861 HistogramTimerScope scope(isolate_->counters()->gc_context()); |
| 4873 CollectAllGarbage(kNoGCFlags, "idle notification: contexts disposed"); | 4862 CollectAllGarbage(kNoGCFlags, "idle notification: contexts disposed"); |
| 4874 break; | 4863 break; |
| 4875 } | 4864 } |
| 4876 case DO_SCAVENGE: | 4865 case DO_SCAVENGE: |
| 4877 CollectGarbage(NEW_SPACE, "idle notification: scavenge"); | 4866 CollectGarbage(NEW_SPACE, "idle notification: scavenge"); |
| 4878 break; | 4867 break; |
| 4879 case DO_FINALIZE_SWEEPING: | |
| 4880 mark_compact_collector()->EnsureSweepingCompleted(); | |
| 4881 break; | |
| 4882 case DO_NOTHING: | 4868 case DO_NOTHING: |
| 4883 break; | 4869 break; |
| 4884 } | 4870 } |
| 4885 | 4871 |
| 4886 return result; | 4872 return result; |
| 4887 } | 4873 } |
| 4888 | 4874 |
| 4889 | 4875 |
| 4890 void Heap::IdleNotificationEpilogue(GCIdleTimeAction action, | 4876 void Heap::IdleNotificationEpilogue(GCIdleTimeAction action, |
| 4891 GCIdleTimeHandler::HeapState heap_state, | 4877 GCIdleTimeHandler::HeapState heap_state, |
| (...skipping 2009 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6901 *object_type = "CODE_TYPE"; \ | 6887 *object_type = "CODE_TYPE"; \ |
| 6902 *object_sub_type = "CODE_AGE/" #name; \ | 6888 *object_sub_type = "CODE_AGE/" #name; \ |
| 6903 return true; | 6889 return true; |
| 6904 CODE_AGE_LIST_COMPLETE(COMPARE_AND_RETURN_NAME) | 6890 CODE_AGE_LIST_COMPLETE(COMPARE_AND_RETURN_NAME) |
| 6905 #undef COMPARE_AND_RETURN_NAME | 6891 #undef COMPARE_AND_RETURN_NAME |
| 6906 } | 6892 } |
| 6907 return false; | 6893 return false; |
| 6908 } | 6894 } |
| 6909 } // namespace internal | 6895 } // namespace internal |
| 6910 } // namespace v8 | 6896 } // namespace v8 |
| OLD | NEW |