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

Side by Side Diff: src/heap/incremental-marking.cc

Issue 2591383004: Reland "[heap] Ensure progress when incrementally marking wrappers" (Closed)
Patch Set: Remove unused method Created 3 years, 12 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
« no previous file with comments | « src/heap/heap.cc ('k') | src/heap/mark-compact.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/heap/incremental-marking.h" 5 #include "src/heap/incremental-marking.h"
6 6
7 #include "src/code-stubs.h" 7 #include "src/code-stubs.h"
8 #include "src/compilation-cache.h" 8 #include "src/compilation-cache.h"
9 #include "src/conversions.h" 9 #include "src/conversions.h"
10 #include "src/heap/gc-idle-time-handler.h" 10 #include "src/heap/gc-idle-time-handler.h"
(...skipping 1016 matching lines...) Expand 10 before | Expand all | Expand 10 after
1027 double IncrementalMarking::AdvanceIncrementalMarking( 1027 double IncrementalMarking::AdvanceIncrementalMarking(
1028 double deadline_in_ms, CompletionAction completion_action, 1028 double deadline_in_ms, CompletionAction completion_action,
1029 ForceCompletionAction force_completion, StepOrigin step_origin) { 1029 ForceCompletionAction force_completion, StepOrigin step_origin) {
1030 DCHECK(!IsStopped()); 1030 DCHECK(!IsStopped());
1031 1031
1032 double remaining_time_in_ms = 0.0; 1032 double remaining_time_in_ms = 0.0;
1033 intptr_t step_size_in_bytes = GCIdleTimeHandler::EstimateMarkingStepSize( 1033 intptr_t step_size_in_bytes = GCIdleTimeHandler::EstimateMarkingStepSize(
1034 kStepSizeInMs, 1034 kStepSizeInMs,
1035 heap()->tracer()->IncrementalMarkingSpeedInBytesPerMillisecond()); 1035 heap()->tracer()->IncrementalMarkingSpeedInBytesPerMillisecond());
1036 1036
1037 const bool incremental_wrapper_tracing =
1038 state_ == MARKING && FLAG_incremental_marking_wrappers &&
1039 heap_->local_embedder_heap_tracer()->InUse();
1040 bool trace_wrappers_toggle = true;
1037 do { 1041 do {
1038 Step(step_size_in_bytes, completion_action, force_completion, step_origin); 1042 if (incremental_wrapper_tracing && trace_wrappers_toggle) {
1043 TRACE_GC(heap()->tracer(),
1044 GCTracer::Scope::MC_INCREMENTAL_WRAPPER_TRACING);
1045 const double wrapper_deadline =
1046 heap_->MonotonicallyIncreasingTimeInMs() + kStepSizeInMs;
1047 if (!heap_->local_embedder_heap_tracer()
1048 ->ShouldFinalizeIncrementalMarking()) {
1049 heap_->local_embedder_heap_tracer()->Trace(
1050 wrapper_deadline, EmbedderHeapTracer::AdvanceTracingActions(
1051 EmbedderHeapTracer::ForceCompletionAction::
1052 DO_NOT_FORCE_COMPLETION));
1053 }
1054 } else {
1055 Step(step_size_in_bytes, completion_action, force_completion,
1056 step_origin);
1057 }
1058 trace_wrappers_toggle = !trace_wrappers_toggle;
1039 remaining_time_in_ms = 1059 remaining_time_in_ms =
1040 deadline_in_ms - heap()->MonotonicallyIncreasingTimeInMs(); 1060 deadline_in_ms - heap()->MonotonicallyIncreasingTimeInMs();
1041 } while (remaining_time_in_ms >= kStepSizeInMs && !IsComplete() && 1061 } while (remaining_time_in_ms >= kStepSizeInMs && !IsComplete() &&
1042 !heap()->mark_compact_collector()->marking_deque()->IsEmpty()); 1062 !heap()->mark_compact_collector()->marking_deque()->IsEmpty());
1043 return remaining_time_in_ms; 1063 return remaining_time_in_ms;
1044 } 1064 }
1045 1065
1046 1066
1047 void IncrementalMarking::FinalizeSweeping() { 1067 void IncrementalMarking::FinalizeSweeping() {
1048 DCHECK(state_ == SWEEPING); 1068 DCHECK(state_ == SWEEPING);
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
1127 TRACE_GC(heap_->tracer(), GCTracer::Scope::MC_INCREMENTAL); 1147 TRACE_GC(heap_->tracer(), GCTracer::Scope::MC_INCREMENTAL);
1128 double start = heap_->MonotonicallyIncreasingTimeInMs(); 1148 double start = heap_->MonotonicallyIncreasingTimeInMs();
1129 1149
1130 if (state_ == SWEEPING) { 1150 if (state_ == SWEEPING) {
1131 TRACE_GC(heap_->tracer(), GCTracer::Scope::MC_INCREMENTAL_SWEEPING); 1151 TRACE_GC(heap_->tracer(), GCTracer::Scope::MC_INCREMENTAL_SWEEPING);
1132 FinalizeSweeping(); 1152 FinalizeSweeping();
1133 } 1153 }
1134 1154
1135 size_t bytes_processed = 0; 1155 size_t bytes_processed = 0;
1136 if (state_ == MARKING) { 1156 if (state_ == MARKING) {
1137 const bool incremental_wrapper_tracing = 1157 bytes_processed = ProcessMarkingDeque(bytes_to_process);
1138 FLAG_incremental_marking_wrappers && 1158 if (step_origin == StepOrigin::kTask) {
1139 heap_->local_embedder_heap_tracer()->InUse(); 1159 bytes_marked_ahead_of_schedule_ += bytes_processed;
1140 const bool process_wrappers =
1141 incremental_wrapper_tracing &&
1142 (heap_->local_embedder_heap_tracer()
1143 ->RequiresImmediateWrapperProcessing() ||
1144 heap_->mark_compact_collector()->marking_deque()->IsEmpty());
1145 bool wrapper_work_left = incremental_wrapper_tracing;
1146 if (!process_wrappers) {
1147 bytes_processed = ProcessMarkingDeque(bytes_to_process);
1148 if (step_origin == StepOrigin::kTask) {
1149 bytes_marked_ahead_of_schedule_ += bytes_processed;
1150 }
1151 } else {
1152 const double wrapper_deadline =
1153 heap_->MonotonicallyIncreasingTimeInMs() + kStepSizeInMs;
1154 TRACE_GC(heap()->tracer(),
1155 GCTracer::Scope::MC_INCREMENTAL_WRAPPER_TRACING);
1156 wrapper_work_left = heap_->local_embedder_heap_tracer()->Trace(
1157 wrapper_deadline, EmbedderHeapTracer::AdvanceTracingActions(
1158 EmbedderHeapTracer::ForceCompletionAction::
1159 DO_NOT_FORCE_COMPLETION));
1160 } 1160 }
1161 1161
1162 if (heap_->mark_compact_collector()->marking_deque()->IsEmpty() && 1162 if (heap_->mark_compact_collector()->marking_deque()->IsEmpty()) {
1163 !wrapper_work_left) { 1163 if (heap_->local_embedder_heap_tracer()
1164 if (completion == FORCE_COMPLETION || 1164 ->ShouldFinalizeIncrementalMarking()) {
1165 IsIdleMarkingDelayCounterLimitReached()) { 1165 if (completion == FORCE_COMPLETION ||
1166 if (!finalize_marking_completed_) { 1166 IsIdleMarkingDelayCounterLimitReached()) {
1167 FinalizeMarking(action); 1167 if (!finalize_marking_completed_) {
1168 FinalizeMarking(action);
1169 } else {
1170 MarkingComplete(action);
1171 }
1168 } else { 1172 } else {
1169 MarkingComplete(action); 1173 IncrementIdleMarkingDelayCounter();
1170 } 1174 }
1171 } else { 1175 } else {
1172 IncrementIdleMarkingDelayCounter(); 1176 heap_->local_embedder_heap_tracer()->NotifyV8MarkingDequeWasEmpty();
1173 } 1177 }
1174 } 1178 }
1175 } 1179 }
1176 1180
1177 double end = heap_->MonotonicallyIncreasingTimeInMs(); 1181 double end = heap_->MonotonicallyIncreasingTimeInMs();
1178 double duration = (end - start); 1182 double duration = (end - start);
1179 // Note that we report zero bytes here when sweeping was in progress or 1183 // Note that we report zero bytes here when sweeping was in progress or
1180 // when we just started incremental marking. In these cases we did not 1184 // when we just started incremental marking. In these cases we did not
1181 // process the marking deque. 1185 // process the marking deque.
1182 heap_->tracer()->AddIncrementalMarkingStep(duration, bytes_processed); 1186 heap_->tracer()->AddIncrementalMarkingStep(duration, bytes_processed);
(...skipping 16 matching lines...) Expand all
1199 idle_marking_delay_counter_++; 1203 idle_marking_delay_counter_++;
1200 } 1204 }
1201 1205
1202 1206
1203 void IncrementalMarking::ClearIdleMarkingDelayCounter() { 1207 void IncrementalMarking::ClearIdleMarkingDelayCounter() {
1204 idle_marking_delay_counter_ = 0; 1208 idle_marking_delay_counter_ = 0;
1205 } 1209 }
1206 1210
1207 } // namespace internal 1211 } // namespace internal
1208 } // namespace v8 1212 } // namespace v8
OLDNEW
« no previous file with comments | « src/heap/heap.cc ('k') | src/heap/mark-compact.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698