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

Unified Diff: src/heap/incremental-marking.cc

Issue 1428683002: [heap] Convert overapproximate weak closure phase into finalize incremental marking phase and revis… (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/heap/incremental-marking.h ('k') | test/cctest/cctest.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/heap/incremental-marking.cc
diff --git a/src/heap/incremental-marking.cc b/src/heap/incremental-marking.cc
index 3e5e6c0697cd505bf49880d407891ef8f938458a..99d0d45c9467a4ac4eaa1c140cb71a4a7312d1b1 100644
--- a/src/heap/incremental-marking.cc
+++ b/src/heap/incremental-marking.cc
@@ -42,8 +42,8 @@ IncrementalMarking::IncrementalMarking(Heap* heap)
no_marking_scope_depth_(0),
unscanned_bytes_of_large_object_(0),
was_activated_(false),
- weak_closure_was_overapproximated_(false),
- weak_closure_approximation_rounds_(0),
+ finalize_marking_completed_(false),
+ incremental_marking_finalization_rounds_(0),
request_type_(COMPLETE_MARKING) {}
@@ -623,33 +623,57 @@ void IncrementalMarking::StartMarking() {
}
-void IncrementalMarking::MarkObjectGroups() {
- DCHECK(FLAG_overapproximate_weak_closure);
- DCHECK(!weak_closure_was_overapproximated_);
+void IncrementalMarking::MarkRoots() {
+ DCHECK(FLAG_finalize_marking_incrementally);
+ DCHECK(!finalize_marking_completed_);
DCHECK(IsMarking());
- int old_marking_deque_top =
- heap_->mark_compact_collector()->marking_deque()->top();
+ IncrementalMarkingRootMarkingVisitor visitor(this);
+ heap_->IterateStrongRoots(&visitor, VISIT_ONLY_STRONG);
+}
- heap_->mark_compact_collector()->MarkImplicitRefGroups(&MarkObject);
+
+void IncrementalMarking::MarkObjectGroups() {
+ DCHECK(FLAG_finalize_marking_incrementally);
+ DCHECK(!finalize_marking_completed_);
+ DCHECK(IsMarking());
IncrementalMarkingRootMarkingVisitor visitor(this);
+ heap_->mark_compact_collector()->MarkImplicitRefGroups(&MarkObject);
heap_->isolate()->global_handles()->IterateObjectGroups(
&visitor, &MarkCompactCollector::IsUnmarkedHeapObjectWithHeap);
+ heap_->isolate()->global_handles()->RemoveImplicitRefGroups();
+ heap_->isolate()->global_handles()->RemoveObjectGroups();
+}
+
+
+void IncrementalMarking::FinalizeIncrementally() {
+ DCHECK(FLAG_finalize_marking_incrementally);
+ DCHECK(!finalize_marking_completed_);
+ DCHECK(IsMarking());
+
+ int old_marking_deque_top =
+ heap_->mark_compact_collector()->marking_deque()->top();
+
+ // After finishing incremental marking, we try to discover all unmarked
+ // objects to reduce the marking load in the final pause.
+ // 1) We scan and mark the roots again to find all changes to the root set.
+ // 2) We mark the object groups.
+ MarkRoots();
+ MarkObjectGroups();
int marking_progress =
abs(old_marking_deque_top -
- heap_->mark_compact_collector()->marking_deque()->top());
-
- ++weak_closure_approximation_rounds_;
- if ((weak_closure_approximation_rounds_ >=
- FLAG_max_object_groups_marking_rounds) ||
- (marking_progress < FLAG_min_progress_during_object_groups_marking)) {
- weak_closure_was_overapproximated_ = true;
+ heap_->mark_compact_collector()->marking_deque()->top()) /
+ kPointerSize;
+
+ ++incremental_marking_finalization_rounds_;
+ if ((incremental_marking_finalization_rounds_ >=
+ FLAG_max_incremental_marking_finalization_rounds) ||
+ (marking_progress <
+ FLAG_min_progress_during_incremental_marking_finalization)) {
+ finalize_marking_completed_ = true;
}
-
- heap_->isolate()->global_handles()->RemoveImplicitRefGroups();
- heap_->isolate()->global_handles()->RemoveObjectGroups();
}
@@ -860,13 +884,15 @@ void IncrementalMarking::Finalize() {
}
-void IncrementalMarking::OverApproximateWeakClosure(CompletionAction action) {
- DCHECK(FLAG_overapproximate_weak_closure);
- DCHECK(!weak_closure_was_overapproximated_);
+void IncrementalMarking::FinalizeMarking(CompletionAction action) {
+ DCHECK(FLAG_finalize_marking_incrementally);
+ DCHECK(!finalize_marking_completed_);
if (FLAG_trace_incremental_marking) {
- PrintF("[IncrementalMarking] requesting weak closure overapproximation.\n");
+ PrintF(
+ "[IncrementalMarking] requesting finalization of incremental "
+ "marking.\n");
}
- request_type_ = OVERAPPROXIMATION;
+ request_type_ = FINALIZATION;
if (action == GC_VIA_STACK_GUARD) {
heap_->isolate()->stack_guard()->RequestGC();
}
@@ -893,8 +919,8 @@ void IncrementalMarking::MarkingComplete(CompletionAction action) {
void IncrementalMarking::Epilogue() {
was_activated_ = false;
- weak_closure_was_overapproximated_ = false;
- weak_closure_approximation_rounds_ = 0;
+ finalize_marking_completed_ = false;
+ incremental_marking_finalization_rounds_ = 0;
}
@@ -1072,9 +1098,9 @@ intptr_t IncrementalMarking::Step(intptr_t allocated_bytes,
if (heap_->mark_compact_collector()->marking_deque()->IsEmpty()) {
if (completion == FORCE_COMPLETION ||
IsIdleMarkingDelayCounterLimitReached()) {
- if (FLAG_overapproximate_weak_closure &&
- !weak_closure_was_overapproximated_) {
- OverApproximateWeakClosure(action);
+ if (FLAG_finalize_marking_incrementally &&
+ !finalize_marking_completed_) {
+ FinalizeMarking(action);
} else {
MarkingComplete(action);
}
« no previous file with comments | « src/heap/incremental-marking.h ('k') | test/cctest/cctest.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698