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/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 551 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
562 | 562 |
563 is_compacting_ = !FLAG_never_compact && | 563 is_compacting_ = !FLAG_never_compact && |
564 heap_->mark_compact_collector()->StartCompaction( | 564 heap_->mark_compact_collector()->StartCompaction( |
565 MarkCompactCollector::INCREMENTAL_COMPACTION); | 565 MarkCompactCollector::INCREMENTAL_COMPACTION); |
566 | 566 |
567 state_ = MARKING; | 567 state_ = MARKING; |
568 | 568 |
569 if (heap_->UsingEmbedderHeapTracer()) { | 569 if (heap_->UsingEmbedderHeapTracer()) { |
570 TRACE_GC(heap()->tracer(), | 570 TRACE_GC(heap()->tracer(), |
571 GCTracer::Scope::MC_INCREMENTAL_WRAPPER_PROLOGUE); | 571 GCTracer::Scope::MC_INCREMENTAL_WRAPPER_PROLOGUE); |
572 heap_->mark_compact_collector()->embedder_heap_tracer()->TracePrologue(); | 572 heap_->embedder_heap_tracer()->TracePrologue( |
| 573 heap_->embedder_reachable_reference_reporter()); |
573 } | 574 } |
574 | 575 |
575 RecordWriteStub::Mode mode = is_compacting_ | 576 RecordWriteStub::Mode mode = is_compacting_ |
576 ? RecordWriteStub::INCREMENTAL_COMPACTION | 577 ? RecordWriteStub::INCREMENTAL_COMPACTION |
577 : RecordWriteStub::INCREMENTAL; | 578 : RecordWriteStub::INCREMENTAL; |
578 | 579 |
579 PatchIncrementalMarkingRecordWriteStubs(heap_, mode); | 580 PatchIncrementalMarkingRecordWriteStubs(heap_, mode); |
580 | 581 |
581 heap_->mark_compact_collector()->EnsureMarkingDequeIsCommittedAndInitialize( | 582 heap_->mark_compact_collector()->EnsureMarkingDequeIsCommittedAndInitialize( |
582 MarkCompactCollector::kMaxMarkingDequeSize); | 583 MarkCompactCollector::kMaxMarkingDequeSize); |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
789 // Map retaining is needed for perfromance, not correctness, | 790 // Map retaining is needed for perfromance, not correctness, |
790 // so we can do it only once at the beginning of the finalization. | 791 // so we can do it only once at the beginning of the finalization. |
791 RetainMaps(); | 792 RetainMaps(); |
792 } | 793 } |
793 ProcessWeakCells(); | 794 ProcessWeakCells(); |
794 | 795 |
795 int marking_progress = | 796 int marking_progress = |
796 abs(old_marking_deque_top - | 797 abs(old_marking_deque_top - |
797 heap_->mark_compact_collector()->marking_deque()->top()); | 798 heap_->mark_compact_collector()->marking_deque()->top()); |
798 | 799 |
799 marking_progress += | 800 marking_progress += static_cast<int>(heap_->wrappers_to_trace()); |
800 static_cast<int>(heap_->mark_compact_collector()->wrappers_to_trace()); | |
801 | 801 |
802 double end = heap_->MonotonicallyIncreasingTimeInMs(); | 802 double end = heap_->MonotonicallyIncreasingTimeInMs(); |
803 double delta = end - start; | 803 double delta = end - start; |
804 heap_->tracer()->AddMarkingTime(delta); | 804 heap_->tracer()->AddMarkingTime(delta); |
805 if (FLAG_trace_incremental_marking) { | 805 if (FLAG_trace_incremental_marking) { |
806 heap()->isolate()->PrintWithTimestamp( | 806 heap()->isolate()->PrintWithTimestamp( |
807 "[IncrementalMarking] Finalize incrementally round %d, " | 807 "[IncrementalMarking] Finalize incrementally round %d, " |
808 "spent %d ms, marking progress %d.\n", | 808 "spent %d ms, marking progress %d.\n", |
809 static_cast<int>(delta), incremental_marking_finalization_rounds_, | 809 static_cast<int>(delta), incremental_marking_finalization_rounds_, |
810 marking_progress); | 810 marking_progress); |
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1219 TRACE_GC(heap_->tracer(), GCTracer::Scope::MC_INCREMENTAL_SWEEPING); | 1219 TRACE_GC(heap_->tracer(), GCTracer::Scope::MC_INCREMENTAL_SWEEPING); |
1220 FinalizeSweeping(); | 1220 FinalizeSweeping(); |
1221 } | 1221 } |
1222 | 1222 |
1223 intptr_t bytes_processed = 0; | 1223 intptr_t bytes_processed = 0; |
1224 if (state_ == MARKING) { | 1224 if (state_ == MARKING) { |
1225 const bool incremental_wrapper_tracing = | 1225 const bool incremental_wrapper_tracing = |
1226 FLAG_incremental_marking_wrappers && heap_->UsingEmbedderHeapTracer(); | 1226 FLAG_incremental_marking_wrappers && heap_->UsingEmbedderHeapTracer(); |
1227 const bool process_wrappers = | 1227 const bool process_wrappers = |
1228 incremental_wrapper_tracing && | 1228 incremental_wrapper_tracing && |
1229 (heap_->mark_compact_collector() | 1229 (heap_->RequiresImmediateWrapperProcessing() || |
1230 ->RequiresImmediateWrapperProcessing() || | |
1231 heap_->mark_compact_collector()->marking_deque()->IsEmpty()); | 1230 heap_->mark_compact_collector()->marking_deque()->IsEmpty()); |
1232 bool wrapper_work_left = incremental_wrapper_tracing; | 1231 bool wrapper_work_left = incremental_wrapper_tracing; |
1233 if (!process_wrappers) { | 1232 if (!process_wrappers) { |
1234 if (step_origin == StepOrigin::kV8 && | 1233 if (step_origin == StepOrigin::kV8 && |
1235 bytes_marked_ahead_of_schedule_ >= bytes_to_process) { | 1234 bytes_marked_ahead_of_schedule_ >= bytes_to_process) { |
1236 // Steps performed in tasks have put us ahead of schedule. | 1235 // Steps performed in tasks have put us ahead of schedule. |
1237 // We skip processing of marking dequeue here and thus | 1236 // We skip processing of marking dequeue here and thus |
1238 // shift marking time from inside V8 to standalone tasks. | 1237 // shift marking time from inside V8 to standalone tasks. |
1239 bytes_marked_ahead_of_schedule_ -= bytes_to_process; | 1238 bytes_marked_ahead_of_schedule_ -= bytes_to_process; |
1240 } else { | 1239 } else { |
1241 bytes_processed = ProcessMarkingDeque(bytes_to_process); | 1240 bytes_processed = ProcessMarkingDeque(bytes_to_process); |
1242 if (step_origin == StepOrigin::kTask) { | 1241 if (step_origin == StepOrigin::kTask) { |
1243 bytes_marked_ahead_of_schedule_ += bytes_processed; | 1242 bytes_marked_ahead_of_schedule_ += bytes_processed; |
1244 } | 1243 } |
1245 } | 1244 } |
1246 } else { | 1245 } else { |
1247 const double wrapper_deadline = | 1246 const double wrapper_deadline = |
1248 heap_->MonotonicallyIncreasingTimeInMs() + kStepSizeInMs; | 1247 heap_->MonotonicallyIncreasingTimeInMs() + kStepSizeInMs; |
1249 TRACE_GC(heap()->tracer(), | 1248 TRACE_GC(heap()->tracer(), |
1250 GCTracer::Scope::MC_INCREMENTAL_WRAPPER_TRACING); | 1249 GCTracer::Scope::MC_INCREMENTAL_WRAPPER_TRACING); |
1251 heap_->mark_compact_collector()->RegisterWrappersWithEmbedderHeapTracer(); | 1250 heap_->RegisterWrappersWithEmbedderHeapTracer(); |
1252 wrapper_work_left = | 1251 wrapper_work_left = heap_->embedder_heap_tracer()->AdvanceTracing( |
1253 heap_->mark_compact_collector() | 1252 wrapper_deadline, EmbedderHeapTracer::AdvanceTracingActions( |
1254 ->embedder_heap_tracer() | 1253 EmbedderHeapTracer::ForceCompletionAction:: |
1255 ->AdvanceTracing(wrapper_deadline, | 1254 DO_NOT_FORCE_COMPLETION)); |
1256 EmbedderHeapTracer::AdvanceTracingActions( | |
1257 EmbedderHeapTracer::ForceCompletionAction:: | |
1258 DO_NOT_FORCE_COMPLETION)); | |
1259 } | 1255 } |
1260 | 1256 |
1261 if (heap_->mark_compact_collector()->marking_deque()->IsEmpty() && | 1257 if (heap_->mark_compact_collector()->marking_deque()->IsEmpty() && |
1262 !wrapper_work_left) { | 1258 !wrapper_work_left) { |
1263 if (completion == FORCE_COMPLETION || | 1259 if (completion == FORCE_COMPLETION || |
1264 IsIdleMarkingDelayCounterLimitReached()) { | 1260 IsIdleMarkingDelayCounterLimitReached()) { |
1265 if (!finalize_marking_completed_) { | 1261 if (!finalize_marking_completed_) { |
1266 FinalizeMarking(action); | 1262 FinalizeMarking(action); |
1267 } else { | 1263 } else { |
1268 MarkingComplete(action); | 1264 MarkingComplete(action); |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1323 idle_marking_delay_counter_++; | 1319 idle_marking_delay_counter_++; |
1324 } | 1320 } |
1325 | 1321 |
1326 | 1322 |
1327 void IncrementalMarking::ClearIdleMarkingDelayCounter() { | 1323 void IncrementalMarking::ClearIdleMarkingDelayCounter() { |
1328 idle_marking_delay_counter_ = 0; | 1324 idle_marking_delay_counter_ = 0; |
1329 } | 1325 } |
1330 | 1326 |
1331 } // namespace internal | 1327 } // namespace internal |
1332 } // namespace v8 | 1328 } // namespace v8 |
OLD | NEW |