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

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

Issue 2599283002: Reland "[heap] Ensure progress when incrementally marking wrappers" (Closed)
Patch Set: Fix: Make toggle a IM global to avoid only advancing wrappers 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/incremental-marking.h ('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 14 matching lines...) Expand all
25 initial_old_generation_size_(0), 25 initial_old_generation_size_(0),
26 bytes_marked_ahead_of_schedule_(0), 26 bytes_marked_ahead_of_schedule_(0),
27 unscanned_bytes_of_large_object_(0), 27 unscanned_bytes_of_large_object_(0),
28 idle_marking_delay_counter_(0), 28 idle_marking_delay_counter_(0),
29 incremental_marking_finalization_rounds_(0), 29 incremental_marking_finalization_rounds_(0),
30 is_compacting_(false), 30 is_compacting_(false),
31 should_hurry_(false), 31 should_hurry_(false),
32 was_activated_(false), 32 was_activated_(false),
33 black_allocation_(false), 33 black_allocation_(false),
34 finalize_marking_completed_(false), 34 finalize_marking_completed_(false),
35 trace_wrappers_toggle_(false),
35 request_type_(NONE), 36 request_type_(NONE),
36 new_generation_observer_(*this, kAllocatedThreshold), 37 new_generation_observer_(*this, kAllocatedThreshold),
37 old_generation_observer_(*this, kAllocatedThreshold) {} 38 old_generation_observer_(*this, kAllocatedThreshold) {}
38 39
39 bool IncrementalMarking::BaseRecordWrite(HeapObject* obj, Object* value) { 40 bool IncrementalMarking::BaseRecordWrite(HeapObject* obj, Object* value) {
40 HeapObject* value_heap_obj = HeapObject::cast(value); 41 HeapObject* value_heap_obj = HeapObject::cast(value);
41 MarkBit value_bit = ObjectMarking::MarkBitFrom(value_heap_obj); 42 MarkBit value_bit = ObjectMarking::MarkBitFrom(value_heap_obj);
42 DCHECK(!Marking::IsImpossible(value_bit)); 43 DCHECK(!Marking::IsImpossible(value_bit));
43 44
44 MarkBit obj_bit = ObjectMarking::MarkBitFrom(obj); 45 MarkBit obj_bit = ObjectMarking::MarkBitFrom(obj);
(...skipping 986 matching lines...) Expand 10 before | Expand all | Expand 10 after
1031 heap_->isolate()->counters()->gc_incremental_marking()); 1032 heap_->isolate()->counters()->gc_incremental_marking());
1032 TRACE_EVENT0("v8", "V8.GCIncrementalMarking"); 1033 TRACE_EVENT0("v8", "V8.GCIncrementalMarking");
1033 TRACE_GC(heap_->tracer(), GCTracer::Scope::MC_INCREMENTAL); 1034 TRACE_GC(heap_->tracer(), GCTracer::Scope::MC_INCREMENTAL);
1034 DCHECK(!IsStopped()); 1035 DCHECK(!IsStopped());
1035 1036
1036 double remaining_time_in_ms = 0.0; 1037 double remaining_time_in_ms = 0.0;
1037 intptr_t step_size_in_bytes = GCIdleTimeHandler::EstimateMarkingStepSize( 1038 intptr_t step_size_in_bytes = GCIdleTimeHandler::EstimateMarkingStepSize(
1038 kStepSizeInMs, 1039 kStepSizeInMs,
1039 heap()->tracer()->IncrementalMarkingSpeedInBytesPerMillisecond()); 1040 heap()->tracer()->IncrementalMarkingSpeedInBytesPerMillisecond());
1040 1041
1042 const bool incremental_wrapper_tracing =
1043 state_ == MARKING && FLAG_incremental_marking_wrappers &&
1044 heap_->local_embedder_heap_tracer()->InUse();
1041 do { 1045 do {
1042 Step(step_size_in_bytes, completion_action, force_completion, step_origin); 1046 if (incremental_wrapper_tracing && trace_wrappers_toggle_) {
1047 TRACE_GC(heap()->tracer(),
1048 GCTracer::Scope::MC_INCREMENTAL_WRAPPER_TRACING);
1049 const double wrapper_deadline =
1050 heap_->MonotonicallyIncreasingTimeInMs() + kStepSizeInMs;
1051 if (!heap_->local_embedder_heap_tracer()
1052 ->ShouldFinalizeIncrementalMarking()) {
1053 heap_->local_embedder_heap_tracer()->Trace(
1054 wrapper_deadline, EmbedderHeapTracer::AdvanceTracingActions(
1055 EmbedderHeapTracer::ForceCompletionAction::
1056 DO_NOT_FORCE_COMPLETION));
1057 }
1058 } else {
1059 Step(step_size_in_bytes, completion_action, force_completion,
1060 step_origin);
1061 }
1062 trace_wrappers_toggle_ = !trace_wrappers_toggle_;
1043 remaining_time_in_ms = 1063 remaining_time_in_ms =
1044 deadline_in_ms - heap()->MonotonicallyIncreasingTimeInMs(); 1064 deadline_in_ms - heap()->MonotonicallyIncreasingTimeInMs();
1045 } while (remaining_time_in_ms >= kStepSizeInMs && !IsComplete() && 1065 } while (remaining_time_in_ms >= kStepSizeInMs && !IsComplete() &&
1046 !heap()->mark_compact_collector()->marking_deque()->IsEmpty()); 1066 !heap()->mark_compact_collector()->marking_deque()->IsEmpty());
1047 return remaining_time_in_ms; 1067 return remaining_time_in_ms;
1048 } 1068 }
1049 1069
1050 1070
1051 void IncrementalMarking::FinalizeSweeping() { 1071 void IncrementalMarking::FinalizeSweeping() {
1052 DCHECK(state_ == SWEEPING); 1072 DCHECK(state_ == SWEEPING);
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
1131 StepOrigin step_origin) { 1151 StepOrigin step_origin) {
1132 double start = heap_->MonotonicallyIncreasingTimeInMs(); 1152 double start = heap_->MonotonicallyIncreasingTimeInMs();
1133 1153
1134 if (state_ == SWEEPING) { 1154 if (state_ == SWEEPING) {
1135 TRACE_GC(heap_->tracer(), GCTracer::Scope::MC_INCREMENTAL_SWEEPING); 1155 TRACE_GC(heap_->tracer(), GCTracer::Scope::MC_INCREMENTAL_SWEEPING);
1136 FinalizeSweeping(); 1156 FinalizeSweeping();
1137 } 1157 }
1138 1158
1139 size_t bytes_processed = 0; 1159 size_t bytes_processed = 0;
1140 if (state_ == MARKING) { 1160 if (state_ == MARKING) {
1141 const bool incremental_wrapper_tracing = 1161 bytes_processed = ProcessMarkingDeque(bytes_to_process);
1142 FLAG_incremental_marking_wrappers && 1162 if (step_origin == StepOrigin::kTask) {
1143 heap_->local_embedder_heap_tracer()->InUse(); 1163 bytes_marked_ahead_of_schedule_ += bytes_processed;
1144 const bool process_wrappers =
1145 incremental_wrapper_tracing &&
1146 (heap_->local_embedder_heap_tracer()
1147 ->RequiresImmediateWrapperProcessing() ||
1148 heap_->mark_compact_collector()->marking_deque()->IsEmpty());
1149 bool wrapper_work_left = incremental_wrapper_tracing;
1150 if (!process_wrappers) {
1151 bytes_processed = ProcessMarkingDeque(bytes_to_process);
1152 if (step_origin == StepOrigin::kTask) {
1153 bytes_marked_ahead_of_schedule_ += bytes_processed;
1154 }
1155 } else {
1156 const double wrapper_deadline =
1157 heap_->MonotonicallyIncreasingTimeInMs() + kStepSizeInMs;
1158 TRACE_GC(heap()->tracer(),
1159 GCTracer::Scope::MC_INCREMENTAL_WRAPPER_TRACING);
1160 wrapper_work_left = heap_->local_embedder_heap_tracer()->Trace(
1161 wrapper_deadline, EmbedderHeapTracer::AdvanceTracingActions(
1162 EmbedderHeapTracer::ForceCompletionAction::
1163 DO_NOT_FORCE_COMPLETION));
1164 } 1164 }
1165 1165
1166 if (heap_->mark_compact_collector()->marking_deque()->IsEmpty() && 1166 if (heap_->mark_compact_collector()->marking_deque()->IsEmpty()) {
1167 !wrapper_work_left) { 1167 if (heap_->local_embedder_heap_tracer()
1168 if (completion == FORCE_COMPLETION || 1168 ->ShouldFinalizeIncrementalMarking()) {
1169 IsIdleMarkingDelayCounterLimitReached()) { 1169 if (completion == FORCE_COMPLETION ||
1170 if (!finalize_marking_completed_) { 1170 IsIdleMarkingDelayCounterLimitReached()) {
1171 FinalizeMarking(action); 1171 if (!finalize_marking_completed_) {
1172 FinalizeMarking(action);
1173 } else {
1174 MarkingComplete(action);
1175 }
1172 } else { 1176 } else {
1173 MarkingComplete(action); 1177 IncrementIdleMarkingDelayCounter();
1174 } 1178 }
1175 } else { 1179 } else {
1176 IncrementIdleMarkingDelayCounter(); 1180 heap_->local_embedder_heap_tracer()->NotifyV8MarkingDequeWasEmpty();
1177 } 1181 }
1178 } 1182 }
1179 } 1183 }
1180 1184
1181 double end = heap_->MonotonicallyIncreasingTimeInMs(); 1185 double end = heap_->MonotonicallyIncreasingTimeInMs();
1182 double duration = (end - start); 1186 double duration = (end - start);
1183 // Note that we report zero bytes here when sweeping was in progress or 1187 // Note that we report zero bytes here when sweeping was in progress or
1184 // when we just started incremental marking. In these cases we did not 1188 // when we just started incremental marking. In these cases we did not
1185 // process the marking deque. 1189 // process the marking deque.
1186 heap_->tracer()->AddIncrementalMarkingStep(duration, bytes_processed); 1190 heap_->tracer()->AddIncrementalMarkingStep(duration, bytes_processed);
(...skipping 16 matching lines...) Expand all
1203 idle_marking_delay_counter_++; 1207 idle_marking_delay_counter_++;
1204 } 1208 }
1205 1209
1206 1210
1207 void IncrementalMarking::ClearIdleMarkingDelayCounter() { 1211 void IncrementalMarking::ClearIdleMarkingDelayCounter() {
1208 idle_marking_delay_counter_ = 0; 1212 idle_marking_delay_counter_ = 0;
1209 } 1213 }
1210 1214
1211 } // namespace internal 1215 } // namespace internal
1212 } // namespace v8 1216 } // namespace v8
OLDNEW
« no previous file with comments | « src/heap/incremental-marking.h ('k') | src/heap/mark-compact.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698