Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(299)

Side by Side Diff: src/heap/heap.cc

Issue 1273483002: GC: Refactor public incremental marking interface in heap (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Add reason parameter to StartIncrementalMarking Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 751 matching lines...) Expand 10 before | Expand all | Expand 10 after
762 } 762 }
763 // We must not compact the weak fixed list here, as we may be in the middle 763 // We must not compact the weak fixed list here, as we may be in the middle
764 // of writing to it, when the GC triggered. Instead, we reset the root value. 764 // of writing to it, when the GC triggered. Instead, we reset the root value.
765 set_weak_stack_trace_list(Smi::FromInt(0)); 765 set_weak_stack_trace_list(Smi::FromInt(0));
766 } 766 }
767 767
768 768
769 void Heap::HandleGCRequest() { 769 void Heap::HandleGCRequest() {
770 if (incremental_marking()->request_type() == 770 if (incremental_marking()->request_type() ==
771 IncrementalMarking::COMPLETE_MARKING) { 771 IncrementalMarking::COMPLETE_MARKING) {
772 CollectAllGarbage(Heap::kNoGCFlags, "GC interrupt"); 772 CollectAllGarbage(Heap::kNoGCFlags, "GC interrupt",
773 incremental_marking()->CallbackFlags());
773 return; 774 return;
774 } 775 }
775 DCHECK(FLAG_overapproximate_weak_closure); 776 DCHECK(FLAG_overapproximate_weak_closure);
776 if (!incremental_marking()->weak_closure_was_overapproximated()) { 777 if (!incremental_marking()->weak_closure_was_overapproximated()) {
777 OverApproximateWeakClosure("GC interrupt"); 778 OverApproximateWeakClosure("GC interrupt");
778 } 779 }
779 } 780 }
780 781
781 782
782 void Heap::OverApproximateWeakClosure(const char* gc_reason) { 783 void Heap::OverApproximateWeakClosure(const char* gc_reason) {
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
999 set_retained_maps(ArrayList::cast(empty_fixed_array())); 1000 set_retained_maps(ArrayList::cast(empty_fixed_array()));
1000 tracer()->AddContextDisposalTime(base::OS::TimeCurrentMillis()); 1001 tracer()->AddContextDisposalTime(base::OS::TimeCurrentMillis());
1001 MemoryReducer::Event event; 1002 MemoryReducer::Event event;
1002 event.type = MemoryReducer::kContextDisposed; 1003 event.type = MemoryReducer::kContextDisposed;
1003 event.time_ms = MonotonicallyIncreasingTimeInMs(); 1004 event.time_ms = MonotonicallyIncreasingTimeInMs();
1004 memory_reducer_.NotifyContextDisposed(event); 1005 memory_reducer_.NotifyContextDisposed(event);
1005 return ++contexts_disposed_; 1006 return ++contexts_disposed_;
1006 } 1007 }
1007 1008
1008 1009
1010 void Heap::StartIncrementalMarking(int gc_flags,
1011 const GCCallbackFlags gc_callback_flags,
1012 const char* reason) {
1013 incremental_marking()->Start(gc_flags, gc_callback_flags, reason);
1014 }
1015
1016
1009 void Heap::StartIdleIncrementalMarking() { 1017 void Heap::StartIdleIncrementalMarking() {
1010 gc_idle_time_handler_.ResetNoProgressCounter(); 1018 gc_idle_time_handler_.ResetNoProgressCounter();
1011 incremental_marking()->Start(kReduceMemoryFootprintMask); 1019 StartIncrementalMarking(kReduceMemoryFootprintMask, kNoGCCallbackFlags,
1020 "idle");
1012 } 1021 }
1013 1022
1014 1023
1015 void Heap::MoveElements(FixedArray* array, int dst_index, int src_index, 1024 void Heap::MoveElements(FixedArray* array, int dst_index, int src_index,
1016 int len) { 1025 int len) {
1017 if (len == 0) return; 1026 if (len == 0) return;
1018 1027
1019 DCHECK(array->map() != fixed_cow_array_map()); 1028 DCHECK(array->map() != fixed_cow_array_map());
1020 Object** dst_objects = array->data_start() + dst_index; 1029 Object** dst_objects = array->data_start() + dst_index;
1021 MemMove(dst_objects, array->data_start() + src_index, len * kPointerSize); 1030 MemMove(dst_objects, array->data_start() + src_index, len * kPointerSize);
(...skipping 3761 matching lines...) Expand 10 before | Expand all | Expand 10 after
4783 heap_state.used_new_space_size = new_space_.Size(); 4792 heap_state.used_new_space_size = new_space_.Size();
4784 heap_state.new_space_capacity = new_space_.Capacity(); 4793 heap_state.new_space_capacity = new_space_.Capacity();
4785 heap_state.new_space_allocation_throughput_in_bytes_per_ms = 4794 heap_state.new_space_allocation_throughput_in_bytes_per_ms =
4786 tracer()->NewSpaceAllocationThroughputInBytesPerMillisecond(); 4795 tracer()->NewSpaceAllocationThroughputInBytesPerMillisecond();
4787 return heap_state; 4796 return heap_state;
4788 } 4797 }
4789 4798
4790 4799
4791 double Heap::AdvanceIncrementalMarking( 4800 double Heap::AdvanceIncrementalMarking(
4792 intptr_t step_size_in_bytes, double deadline_in_ms, 4801 intptr_t step_size_in_bytes, double deadline_in_ms,
4793 IncrementalMarking::ForceCompletionAction completion) { 4802 IncrementalMarking::StepActions step_actions) {
4794 DCHECK(!incremental_marking()->IsStopped()); 4803 DCHECK(!incremental_marking()->IsStopped());
4804
4805 if (step_size_in_bytes == 0) {
4806 GCIdleTimeHandler::HeapState heap_state = ComputeHeapState();
Hannes Payer (out of office) 2015/08/04 15:05:59 You don't need the heap_state for that. Just call
Michael Lippautz 2015/08/04 15:53:06 Done.
4807 step_size_in_bytes = GCIdleTimeHandler::EstimateMarkingStepSize(
4808 static_cast<size_t>(GCIdleTimeHandler::kIncrementalMarkingStepTimeInMs),
4809 heap_state.incremental_marking_speed_in_bytes_per_ms);
4810 }
4811
4795 double remaining_time_in_ms = 0.0; 4812 double remaining_time_in_ms = 0.0;
4796 do { 4813 do {
4797 incremental_marking()->Step(step_size_in_bytes, 4814 incremental_marking()->Step(
4798 IncrementalMarking::NO_GC_VIA_STACK_GUARD, 4815 step_size_in_bytes, step_actions.completion_action,
4799 IncrementalMarking::FORCE_MARKING, completion); 4816 step_actions.force_marking, step_actions.force_completion);
4800 remaining_time_in_ms = deadline_in_ms - MonotonicallyIncreasingTimeInMs(); 4817 remaining_time_in_ms = deadline_in_ms - MonotonicallyIncreasingTimeInMs();
4801 } while (remaining_time_in_ms >= 4818 } while (remaining_time_in_ms >=
4802 2.0 * GCIdleTimeHandler::kIncrementalMarkingStepTimeInMs && 4819 2.0 * GCIdleTimeHandler::kIncrementalMarkingStepTimeInMs &&
4803 !incremental_marking()->IsComplete() && 4820 !incremental_marking()->IsComplete() &&
4804 !mark_compact_collector_.marking_deque()->IsEmpty()); 4821 !mark_compact_collector_.marking_deque()->IsEmpty());
4805 return remaining_time_in_ms; 4822 return remaining_time_in_ms;
4806 } 4823 }
4807 4824
4808 4825
4809 bool Heap::PerformIdleTimeAction(GCIdleTimeAction action, 4826 bool Heap::PerformIdleTimeAction(GCIdleTimeAction action,
4810 GCIdleTimeHandler::HeapState heap_state, 4827 GCIdleTimeHandler::HeapState heap_state,
4811 double deadline_in_ms) { 4828 double deadline_in_ms) {
4812 bool result = false; 4829 bool result = false;
4813 switch (action.type) { 4830 switch (action.type) {
4814 case DONE: 4831 case DONE:
4815 result = true; 4832 result = true;
4816 break; 4833 break;
4817 case DO_INCREMENTAL_MARKING: { 4834 case DO_INCREMENTAL_MARKING: {
4818 const double remaining_idle_time_in_ms = AdvanceIncrementalMarking( 4835 const double remaining_idle_time_in_ms =
4819 action.parameter, deadline_in_ms, 4836 AdvanceIncrementalMarking(action.parameter, deadline_in_ms,
4820 IncrementalMarking::DO_NOT_FORCE_COMPLETION); 4837 IncrementalMarking::NoForcedStepActions());
4821 if (remaining_idle_time_in_ms > 0.0) { 4838 if (remaining_idle_time_in_ms > 0.0) {
4822 action.additional_work = TryFinalizeIdleIncrementalMarking( 4839 action.additional_work = TryFinalizeIdleIncrementalMarking(
4823 remaining_idle_time_in_ms, heap_state.size_of_objects, 4840 remaining_idle_time_in_ms, heap_state.size_of_objects,
4824 heap_state.final_incremental_mark_compact_speed_in_bytes_per_ms); 4841 heap_state.final_incremental_mark_compact_speed_in_bytes_per_ms);
4825 } 4842 }
4826 break; 4843 break;
4827 } 4844 }
4828 case DO_FULL_GC: { 4845 case DO_FULL_GC: {
4829 DCHECK(contexts_disposed_ > 0); 4846 DCHECK(contexts_disposed_ > 0);
4830 HistogramTimerScope scope(isolate_->counters()->gc_context()); 4847 HistogramTimerScope scope(isolate_->counters()->gc_context());
(...skipping 2031 matching lines...) Expand 10 before | Expand all | Expand 10 after
6862 *object_type = "CODE_TYPE"; \ 6879 *object_type = "CODE_TYPE"; \
6863 *object_sub_type = "CODE_AGE/" #name; \ 6880 *object_sub_type = "CODE_AGE/" #name; \
6864 return true; 6881 return true;
6865 CODE_AGE_LIST_COMPLETE(COMPARE_AND_RETURN_NAME) 6882 CODE_AGE_LIST_COMPLETE(COMPARE_AND_RETURN_NAME)
6866 #undef COMPARE_AND_RETURN_NAME 6883 #undef COMPARE_AND_RETURN_NAME
6867 } 6884 }
6868 return false; 6885 return false;
6869 } 6886 }
6870 } // namespace internal 6887 } // namespace internal
6871 } // namespace v8 6888 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698