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

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

Issue 2576453002: [heap] Create a thin wrapper around wrapper tracing in V8 to avoid misuse (Closed)
Patch Set: Include 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 506 matching lines...) Expand 10 before | Expand all | Expand 10 after
517 if (FLAG_trace_incremental_marking) { 517 if (FLAG_trace_incremental_marking) {
518 heap()->isolate()->PrintWithTimestamp( 518 heap()->isolate()->PrintWithTimestamp(
519 "[IncrementalMarking] Start marking\n"); 519 "[IncrementalMarking] Start marking\n");
520 } 520 }
521 521
522 is_compacting_ = 522 is_compacting_ =
523 !FLAG_never_compact && heap_->mark_compact_collector()->StartCompaction(); 523 !FLAG_never_compact && heap_->mark_compact_collector()->StartCompaction();
524 524
525 state_ = MARKING; 525 state_ = MARKING;
526 526
527 if (heap_->UsingEmbedderHeapTracer()) { 527 {
528 TRACE_GC(heap()->tracer(), 528 TRACE_GC(heap()->tracer(),
529 GCTracer::Scope::MC_INCREMENTAL_WRAPPER_PROLOGUE); 529 GCTracer::Scope::MC_INCREMENTAL_WRAPPER_PROLOGUE);
530 heap_->embedder_heap_tracer()->TracePrologue(); 530 heap_->local_embedder_heap_tracer()->TracePrologue();
531 } 531 }
532 532
533 RecordWriteStub::Mode mode = is_compacting_ 533 RecordWriteStub::Mode mode = is_compacting_
534 ? RecordWriteStub::INCREMENTAL_COMPACTION 534 ? RecordWriteStub::INCREMENTAL_COMPACTION
535 : RecordWriteStub::INCREMENTAL; 535 : RecordWriteStub::INCREMENTAL;
536 536
537 PatchIncrementalMarkingRecordWriteStubs(heap_, mode); 537 PatchIncrementalMarkingRecordWriteStubs(heap_, mode);
538 538
539 heap_->mark_compact_collector()->marking_deque()->StartUsing(); 539 heap_->mark_compact_collector()->marking_deque()->StartUsing();
540 540
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
596 596
597 IncrementalMarkingRootMarkingVisitor visitor(this); 597 IncrementalMarkingRootMarkingVisitor visitor(this);
598 heap_->IterateStrongRoots(&visitor, VISIT_ONLY_STRONG); 598 heap_->IterateStrongRoots(&visitor, VISIT_ONLY_STRONG);
599 } 599 }
600 600
601 601
602 void IncrementalMarking::MarkObjectGroups() { 602 void IncrementalMarking::MarkObjectGroups() {
603 TRACE_GC(heap_->tracer(), 603 TRACE_GC(heap_->tracer(),
604 GCTracer::Scope::MC_INCREMENTAL_FINALIZE_OBJECT_GROUPING); 604 GCTracer::Scope::MC_INCREMENTAL_FINALIZE_OBJECT_GROUPING);
605 605
606 DCHECK(!heap_->UsingEmbedderHeapTracer()); 606 DCHECK(!heap_->local_embedder_heap_tracer()->InUse());
607 DCHECK(!finalize_marking_completed_); 607 DCHECK(!finalize_marking_completed_);
608 DCHECK(IsMarking()); 608 DCHECK(IsMarking());
609 609
610 IncrementalMarkingRootMarkingVisitor visitor(this); 610 IncrementalMarkingRootMarkingVisitor visitor(this);
611 heap_->mark_compact_collector()->MarkImplicitRefGroups(&MarkGrey); 611 heap_->mark_compact_collector()->MarkImplicitRefGroups(&MarkGrey);
612 heap_->isolate()->global_handles()->IterateObjectGroups( 612 heap_->isolate()->global_handles()->IterateObjectGroups(
613 &visitor, &MarkCompactCollector::IsUnmarkedHeapObjectWithHeap); 613 &visitor, &MarkCompactCollector::IsUnmarkedHeapObjectWithHeap);
614 heap_->isolate()->global_handles()->RemoveImplicitRefGroups(); 614 heap_->isolate()->global_handles()->RemoveImplicitRefGroups();
615 heap_->isolate()->global_handles()->RemoveObjectGroups(); 615 heap_->isolate()->global_handles()->RemoveObjectGroups();
616 } 616 }
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
729 heap_->mark_compact_collector()->marking_deque()->top(); 729 heap_->mark_compact_collector()->marking_deque()->top();
730 730
731 // After finishing incremental marking, we try to discover all unmarked 731 // After finishing incremental marking, we try to discover all unmarked
732 // objects to reduce the marking load in the final pause. 732 // objects to reduce the marking load in the final pause.
733 // 1) We scan and mark the roots again to find all changes to the root set. 733 // 1) We scan and mark the roots again to find all changes to the root set.
734 // 2) We mark the object groups. 734 // 2) We mark the object groups.
735 // 3) Age and retain maps embedded in optimized code. 735 // 3) Age and retain maps embedded in optimized code.
736 // 4) Remove weak cell with live values from the list of weak cells, they 736 // 4) Remove weak cell with live values from the list of weak cells, they
737 // do not need processing during GC. 737 // do not need processing during GC.
738 MarkRoots(); 738 MarkRoots();
739 if (!heap_->UsingEmbedderHeapTracer()) { 739 if (!heap_->local_embedder_heap_tracer()->InUse()) {
740 MarkObjectGroups(); 740 MarkObjectGroups();
741 } 741 }
742 if (incremental_marking_finalization_rounds_ == 0) { 742 if (incremental_marking_finalization_rounds_ == 0) {
743 // Map retaining is needed for perfromance, not correctness, 743 // Map retaining is needed for perfromance, not correctness,
744 // so we can do it only once at the beginning of the finalization. 744 // so we can do it only once at the beginning of the finalization.
745 RetainMaps(); 745 RetainMaps();
746 } 746 }
747 ProcessWeakCells(); 747 ProcessWeakCells();
748 748
749 int marking_progress = 749 int marking_progress =
750 abs(old_marking_deque_top - 750 abs(old_marking_deque_top -
751 heap_->mark_compact_collector()->marking_deque()->top()); 751 heap_->mark_compact_collector()->marking_deque()->top());
752 752
753 marking_progress += static_cast<int>(heap_->wrappers_to_trace()); 753 marking_progress += static_cast<int>(
754 heap_->local_embedder_heap_tracer()->NumberOfCachedWrappersToTrace());
754 755
755 double end = heap_->MonotonicallyIncreasingTimeInMs(); 756 double end = heap_->MonotonicallyIncreasingTimeInMs();
756 double delta = end - start; 757 double delta = end - start;
757 if (FLAG_trace_incremental_marking) { 758 if (FLAG_trace_incremental_marking) {
758 heap()->isolate()->PrintWithTimestamp( 759 heap()->isolate()->PrintWithTimestamp(
759 "[IncrementalMarking] Finalize incrementally round %d, " 760 "[IncrementalMarking] Finalize incrementally round %d, "
760 "spent %d ms, marking progress %d.\n", 761 "spent %d ms, marking progress %d.\n",
761 static_cast<int>(delta), incremental_marking_finalization_rounds_, 762 static_cast<int>(delta), incremental_marking_finalization_rounds_,
762 marking_progress); 763 marking_progress);
763 } 764 }
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after
1127 double start = heap_->MonotonicallyIncreasingTimeInMs(); 1128 double start = heap_->MonotonicallyIncreasingTimeInMs();
1128 1129
1129 if (state_ == SWEEPING) { 1130 if (state_ == SWEEPING) {
1130 TRACE_GC(heap_->tracer(), GCTracer::Scope::MC_INCREMENTAL_SWEEPING); 1131 TRACE_GC(heap_->tracer(), GCTracer::Scope::MC_INCREMENTAL_SWEEPING);
1131 FinalizeSweeping(); 1132 FinalizeSweeping();
1132 } 1133 }
1133 1134
1134 size_t bytes_processed = 0; 1135 size_t bytes_processed = 0;
1135 if (state_ == MARKING) { 1136 if (state_ == MARKING) {
1136 const bool incremental_wrapper_tracing = 1137 const bool incremental_wrapper_tracing =
1137 FLAG_incremental_marking_wrappers && heap_->UsingEmbedderHeapTracer(); 1138 FLAG_incremental_marking_wrappers &&
1139 heap_->local_embedder_heap_tracer()->InUse();
1138 const bool process_wrappers = 1140 const bool process_wrappers =
1139 incremental_wrapper_tracing && 1141 incremental_wrapper_tracing &&
1140 (heap_->RequiresImmediateWrapperProcessing() || 1142 (heap_->local_embedder_heap_tracer()
1143 ->RequiresImmediateWrapperProcessing() ||
1141 heap_->mark_compact_collector()->marking_deque()->IsEmpty()); 1144 heap_->mark_compact_collector()->marking_deque()->IsEmpty());
1142 bool wrapper_work_left = incremental_wrapper_tracing; 1145 bool wrapper_work_left = incremental_wrapper_tracing;
1143 if (!process_wrappers) { 1146 if (!process_wrappers) {
1144 bytes_processed = ProcessMarkingDeque(bytes_to_process); 1147 bytes_processed = ProcessMarkingDeque(bytes_to_process);
1145 if (step_origin == StepOrigin::kTask) { 1148 if (step_origin == StepOrigin::kTask) {
1146 bytes_marked_ahead_of_schedule_ += bytes_processed; 1149 bytes_marked_ahead_of_schedule_ += bytes_processed;
1147 } 1150 }
1148 } else { 1151 } else {
1149 const double wrapper_deadline = 1152 const double wrapper_deadline =
1150 heap_->MonotonicallyIncreasingTimeInMs() + kStepSizeInMs; 1153 heap_->MonotonicallyIncreasingTimeInMs() + kStepSizeInMs;
1151 TRACE_GC(heap()->tracer(), 1154 TRACE_GC(heap()->tracer(),
1152 GCTracer::Scope::MC_INCREMENTAL_WRAPPER_TRACING); 1155 GCTracer::Scope::MC_INCREMENTAL_WRAPPER_TRACING);
1153 heap_->RegisterWrappersWithEmbedderHeapTracer(); 1156 wrapper_work_left = heap_->local_embedder_heap_tracer()->Trace(
1154 wrapper_work_left = heap_->embedder_heap_tracer()->AdvanceTracing(
1155 wrapper_deadline, EmbedderHeapTracer::AdvanceTracingActions( 1157 wrapper_deadline, EmbedderHeapTracer::AdvanceTracingActions(
1156 EmbedderHeapTracer::ForceCompletionAction:: 1158 EmbedderHeapTracer::ForceCompletionAction::
1157 DO_NOT_FORCE_COMPLETION)); 1159 DO_NOT_FORCE_COMPLETION));
1158 } 1160 }
1159 1161
1160 if (heap_->mark_compact_collector()->marking_deque()->IsEmpty() && 1162 if (heap_->mark_compact_collector()->marking_deque()->IsEmpty() &&
1161 !wrapper_work_left) { 1163 !wrapper_work_left) {
1162 if (completion == FORCE_COMPLETION || 1164 if (completion == FORCE_COMPLETION ||
1163 IsIdleMarkingDelayCounterLimitReached()) { 1165 IsIdleMarkingDelayCounterLimitReached()) {
1164 if (!finalize_marking_completed_) { 1166 if (!finalize_marking_completed_) {
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1197 idle_marking_delay_counter_++; 1199 idle_marking_delay_counter_++;
1198 } 1200 }
1199 1201
1200 1202
1201 void IncrementalMarking::ClearIdleMarkingDelayCounter() { 1203 void IncrementalMarking::ClearIdleMarkingDelayCounter() {
1202 idle_marking_delay_counter_ = 0; 1204 idle_marking_delay_counter_ = 0;
1203 } 1205 }
1204 1206
1205 } // namespace internal 1207 } // namespace internal
1206 } // namespace v8 1208 } // 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