Index: runtime/vm/thread_registry.cc |
diff --git a/runtime/vm/thread_registry.cc b/runtime/vm/thread_registry.cc |
index 8ade009c6035e6762ee9f45b39b1ce2dcc00100c..000175fb2c824033cc62a117079b60a47a430d8d 100644 |
--- a/runtime/vm/thread_registry.cc |
+++ b/runtime/vm/thread_registry.cc |
@@ -9,7 +9,7 @@ |
namespace dart { |
-void ThreadRegistry::SafepointThreads() { |
+SafepointId ThreadRegistry::SafepointThreads() { |
MonitorLocker ml(monitor_); |
// First wait for any older rounds that are still in progress. |
while (in_rendezvous_) { |
@@ -20,7 +20,16 @@ void ThreadRegistry::SafepointThreads() { |
// Start a new round. |
in_rendezvous_ = true; |
++round_; // Overflows after 240+ years @ 10^9 safepoints per second. |
- remaining_ = CountScheduledLocked(); |
+ // Count the number of threads that should participate in this round. |
+ remaining_ = 0; |
+ for (int i = 0; i < entries_.length(); ++i) { |
+ const Entry& entry = entries_[i]; |
+ if (entry.scheduled) { |
+ // All threads that are running should participate. |
+ ASSERT(IsParticipant(entry.thread)); |
+ ++remaining_; |
+ } |
+ } |
Isolate* isolate = Isolate::Current(); |
// We only expect this method to be called from within the isolate itself. |
ASSERT(isolate->thread_registry() == this); |
@@ -33,6 +42,7 @@ void ThreadRegistry::SafepointThreads() { |
while (remaining_ > 0) { |
ml.Wait(Monitor::kNoTimeout); |
} |
+ return round_; |
} |
@@ -69,16 +79,4 @@ void ThreadRegistry::CheckSafepointLocked() { |
} |
} |
- |
-intptr_t ThreadRegistry::CountScheduledLocked() { |
- intptr_t count = 0; |
- for (int i = 0; i < entries_.length(); ++i) { |
- const Entry& entry = entries_[i]; |
- if (entry.scheduled) { |
- ++count; |
- } |
- } |
- return count; |
-} |
- |
} // namespace dart |