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

Unified Diff: runtime/vm/gc_marker.cc

Issue 2191313002: VM: Fix assertion checking number of active concurrent markers. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 5 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/gc_marker.cc
diff --git a/runtime/vm/gc_marker.cc b/runtime/vm/gc_marker.cc
index 319716ee0d5c758f717bc1769f4bbad9aedec88c..7ea64d6168fec374d69eb9f804f024c701f2a563 100644
--- a/runtime/vm/gc_marker.cc
+++ b/runtime/vm/gc_marker.cc
@@ -610,8 +610,13 @@ class MarkTask : public ThreadPool::Task {
} while (true);
// Wait for all markers to stop.
barrier_->Sync();
+#if defined(DEBUG)
ASSERT(AtomicOperations::LoadRelaxed(num_busy_) == 0);
-
+ // Caveat: must not allow any marker to continue past the barrier
+ // before we checked num_busy, otherwise one of them might rush
+ // ahead and increment it.
+ barrier_->Sync();
+#endif
// Check if we have any pending properties with marked keys.
// Those might have been marked by another marker.
more_to_mark = visitor.ProcessPendingWeakProperties();
@@ -626,7 +631,7 @@ class MarkTask : public ThreadPool::Task {
// between all markers and the main thread.
barrier_->Sync();
if (!more_to_mark && (AtomicOperations::LoadRelaxed(num_busy_) > 0)) {
- // All markers continue to marker as long as any single marker has
+ // All markers continue to mark as long as any single marker has
// some work to do.
AtomicOperations::FetchAndIncrement(num_busy_);
more_to_mark = true;
@@ -747,6 +752,13 @@ void GCMarker::MarkObjects(Isolate* isolate,
do {
// Wait for all markers to stop.
barrier.Sync();
+#if defined(DEBUG)
+ ASSERT(AtomicOperations::LoadRelaxed(&num_busy) == 0);
+ // Caveat: must not allow any marker to continue past the barrier
+ // before we checked num_busy, otherwise one of them might rush
+ // ahead and increment it.
+ barrier.Sync();
+#endif
// Wait for all markers to go through weak properties and verify
// that there are no more objects to mark.
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698