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

Unified Diff: runtime/vm/thread_registry.cc

Issue 1292353004: Safepointing in GC (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Scavenger again. Created 5 years, 4 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
« runtime/vm/gc_sweeper.cc ('K') | « runtime/vm/thread_registry.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« runtime/vm/gc_sweeper.cc ('K') | « runtime/vm/thread_registry.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698