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 750 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
761 } | 761 } |
762 // We must not compact the weak fixed list here, as we may be in the middle | 762 // We must not compact the weak fixed list here, as we may be in the middle |
763 // of writing to it, when the GC triggered. Instead, we reset the root value. | 763 // of writing to it, when the GC triggered. Instead, we reset the root value. |
764 set_weak_stack_trace_list(Smi::FromInt(0)); | 764 set_weak_stack_trace_list(Smi::FromInt(0)); |
765 } | 765 } |
766 | 766 |
767 | 767 |
768 void Heap::HandleGCRequest() { | 768 void Heap::HandleGCRequest() { |
769 if (incremental_marking()->request_type() == | 769 if (incremental_marking()->request_type() == |
770 IncrementalMarking::COMPLETE_MARKING) { | 770 IncrementalMarking::COMPLETE_MARKING) { |
771 CollectAllGarbage(Heap::kNoGCFlags, "GC interrupt"); | 771 CollectAllGarbage(Heap::kNoGCFlags, "GC interrupt", |
| 772 incremental_marking()->CallbackFlags()); |
772 return; | 773 return; |
773 } | 774 } |
774 DCHECK(FLAG_overapproximate_weak_closure); | 775 DCHECK(FLAG_overapproximate_weak_closure); |
775 if (!incremental_marking()->weak_closure_was_overapproximated()) { | 776 if (!incremental_marking()->weak_closure_was_overapproximated()) { |
776 OverApproximateWeakClosure("GC interrupt"); | 777 OverApproximateWeakClosure("GC interrupt"); |
777 } | 778 } |
778 } | 779 } |
779 | 780 |
780 | 781 |
781 void Heap::OverApproximateWeakClosure(const char* gc_reason) { | 782 void Heap::OverApproximateWeakClosure(const char* gc_reason) { |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
998 set_retained_maps(ArrayList::cast(empty_fixed_array())); | 999 set_retained_maps(ArrayList::cast(empty_fixed_array())); |
999 tracer()->AddContextDisposalTime(base::OS::TimeCurrentMillis()); | 1000 tracer()->AddContextDisposalTime(base::OS::TimeCurrentMillis()); |
1000 MemoryReducer::Event event; | 1001 MemoryReducer::Event event; |
1001 event.type = MemoryReducer::kContextDisposed; | 1002 event.type = MemoryReducer::kContextDisposed; |
1002 event.time_ms = MonotonicallyIncreasingTimeInMs(); | 1003 event.time_ms = MonotonicallyIncreasingTimeInMs(); |
1003 memory_reducer_.NotifyContextDisposed(event); | 1004 memory_reducer_.NotifyContextDisposed(event); |
1004 return ++contexts_disposed_; | 1005 return ++contexts_disposed_; |
1005 } | 1006 } |
1006 | 1007 |
1007 | 1008 |
| 1009 void Heap::StartIncrementalMarking(int gc_flags, |
| 1010 const GCCallbackFlags gc_callback_flags) { |
| 1011 incremental_marking()->Start(gc_flags, gc_callback_flags); |
| 1012 } |
| 1013 |
| 1014 |
1008 void Heap::StartIdleIncrementalMarking() { | 1015 void Heap::StartIdleIncrementalMarking() { |
1009 gc_idle_time_handler_.ResetNoProgressCounter(); | 1016 gc_idle_time_handler_.ResetNoProgressCounter(); |
1010 incremental_marking()->Start(kReduceMemoryFootprintMask); | 1017 StartIncrementalMarking(kReduceMemoryFootprintMask, kNoGCCallbackFlags); |
1011 } | 1018 } |
1012 | 1019 |
1013 | 1020 |
1014 void Heap::MoveElements(FixedArray* array, int dst_index, int src_index, | 1021 void Heap::MoveElements(FixedArray* array, int dst_index, int src_index, |
1015 int len) { | 1022 int len) { |
1016 if (len == 0) return; | 1023 if (len == 0) return; |
1017 | 1024 |
1018 DCHECK(array->map() != fixed_cow_array_map()); | 1025 DCHECK(array->map() != fixed_cow_array_map()); |
1019 Object** dst_objects = array->data_start() + dst_index; | 1026 Object** dst_objects = array->data_start() + dst_index; |
1020 MemMove(dst_objects, array->data_start() + src_index, len * kPointerSize); | 1027 MemMove(dst_objects, array->data_start() + src_index, len * kPointerSize); |
(...skipping 3761 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4782 heap_state.used_new_space_size = new_space_.Size(); | 4789 heap_state.used_new_space_size = new_space_.Size(); |
4783 heap_state.new_space_capacity = new_space_.Capacity(); | 4790 heap_state.new_space_capacity = new_space_.Capacity(); |
4784 heap_state.new_space_allocation_throughput_in_bytes_per_ms = | 4791 heap_state.new_space_allocation_throughput_in_bytes_per_ms = |
4785 tracer()->NewSpaceAllocationThroughputInBytesPerMillisecond(); | 4792 tracer()->NewSpaceAllocationThroughputInBytesPerMillisecond(); |
4786 return heap_state; | 4793 return heap_state; |
4787 } | 4794 } |
4788 | 4795 |
4789 | 4796 |
4790 double Heap::AdvanceIncrementalMarking( | 4797 double Heap::AdvanceIncrementalMarking( |
4791 intptr_t step_size_in_bytes, double deadline_in_ms, | 4798 intptr_t step_size_in_bytes, double deadline_in_ms, |
4792 IncrementalMarking::ForceCompletionAction completion) { | 4799 IncrementalMarking::StepActions step_actions) { |
4793 DCHECK(!incremental_marking()->IsStopped()); | 4800 DCHECK(!incremental_marking()->IsStopped()); |
| 4801 |
| 4802 if (step_size_in_bytes == 0) { |
| 4803 GCIdleTimeHandler::HeapState heap_state = ComputeHeapState(); |
| 4804 size_t step_size_in_bytes = GCIdleTimeHandler::EstimateMarkingStepSize( |
| 4805 static_cast<size_t>(GCIdleTimeHandler::kIncrementalMarkingStepTimeInMs), |
| 4806 heap_state.incremental_marking_speed_in_bytes_per_ms); |
| 4807 } |
| 4808 |
4794 double remaining_time_in_ms = 0.0; | 4809 double remaining_time_in_ms = 0.0; |
4795 do { | 4810 do { |
4796 incremental_marking()->Step(step_size_in_bytes, | 4811 incremental_marking()->Step( |
4797 IncrementalMarking::NO_GC_VIA_STACK_GUARD, | 4812 step_size_in_bytes, step_actions.completion_action, |
4798 IncrementalMarking::FORCE_MARKING, completion); | 4813 step_actions.force_marking, step_actions.force_completion); |
4799 remaining_time_in_ms = deadline_in_ms - MonotonicallyIncreasingTimeInMs(); | 4814 remaining_time_in_ms = deadline_in_ms - MonotonicallyIncreasingTimeInMs(); |
4800 } while (remaining_time_in_ms >= | 4815 } while (remaining_time_in_ms >= |
4801 2.0 * GCIdleTimeHandler::kIncrementalMarkingStepTimeInMs && | 4816 2.0 * GCIdleTimeHandler::kIncrementalMarkingStepTimeInMs && |
4802 !incremental_marking()->IsComplete() && | 4817 !incremental_marking()->IsComplete() && |
4803 !mark_compact_collector_.marking_deque()->IsEmpty()); | 4818 !mark_compact_collector_.marking_deque()->IsEmpty()); |
4804 return remaining_time_in_ms; | 4819 return remaining_time_in_ms; |
4805 } | 4820 } |
4806 | 4821 |
4807 | 4822 |
4808 bool Heap::PerformIdleTimeAction(GCIdleTimeAction action, | 4823 bool Heap::PerformIdleTimeAction(GCIdleTimeAction action, |
4809 GCIdleTimeHandler::HeapState heap_state, | 4824 GCIdleTimeHandler::HeapState heap_state, |
4810 double deadline_in_ms) { | 4825 double deadline_in_ms) { |
4811 bool result = false; | 4826 bool result = false; |
4812 switch (action.type) { | 4827 switch (action.type) { |
4813 case DONE: | 4828 case DONE: |
4814 result = true; | 4829 result = true; |
4815 break; | 4830 break; |
4816 case DO_INCREMENTAL_MARKING: { | 4831 case DO_INCREMENTAL_MARKING: { |
4817 const double remaining_idle_time_in_ms = AdvanceIncrementalMarking( | 4832 const double remaining_idle_time_in_ms = AdvanceIncrementalMarking( |
4818 action.parameter, deadline_in_ms, | 4833 action.parameter, deadline_in_ms, IncrementalMarking::StepActions()); |
4819 IncrementalMarking::DO_NOT_FORCE_COMPLETION); | |
4820 if (remaining_idle_time_in_ms > 0.0) { | 4834 if (remaining_idle_time_in_ms > 0.0) { |
4821 action.additional_work = TryFinalizeIdleIncrementalMarking( | 4835 action.additional_work = TryFinalizeIdleIncrementalMarking( |
4822 remaining_idle_time_in_ms, heap_state.size_of_objects, | 4836 remaining_idle_time_in_ms, heap_state.size_of_objects, |
4823 heap_state.final_incremental_mark_compact_speed_in_bytes_per_ms); | 4837 heap_state.final_incremental_mark_compact_speed_in_bytes_per_ms); |
4824 } | 4838 } |
4825 break; | 4839 break; |
4826 } | 4840 } |
4827 case DO_FULL_GC: { | 4841 case DO_FULL_GC: { |
4828 DCHECK(contexts_disposed_ > 0); | 4842 DCHECK(contexts_disposed_ > 0); |
4829 HistogramTimerScope scope(isolate_->counters()->gc_context()); | 4843 HistogramTimerScope scope(isolate_->counters()->gc_context()); |
(...skipping 2028 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6858 *object_type = "CODE_TYPE"; \ | 6872 *object_type = "CODE_TYPE"; \ |
6859 *object_sub_type = "CODE_AGE/" #name; \ | 6873 *object_sub_type = "CODE_AGE/" #name; \ |
6860 return true; | 6874 return true; |
6861 CODE_AGE_LIST_COMPLETE(COMPARE_AND_RETURN_NAME) | 6875 CODE_AGE_LIST_COMPLETE(COMPARE_AND_RETURN_NAME) |
6862 #undef COMPARE_AND_RETURN_NAME | 6876 #undef COMPARE_AND_RETURN_NAME |
6863 } | 6877 } |
6864 return false; | 6878 return false; |
6865 } | 6879 } |
6866 } // namespace internal | 6880 } // namespace internal |
6867 } // namespace v8 | 6881 } // namespace v8 |
OLD | NEW |