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

Unified Diff: runtime/vm/pages.cc

Issue 1292353004: Safepointing in GC (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: More git cleanup. 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
« no previous file with comments | « runtime/vm/gc_sweeper.cc ('k') | runtime/vm/scavenger.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/pages.cc
diff --git a/runtime/vm/pages.cc b/runtime/vm/pages.cc
index f45c5b04a95f5715b7f77d3ab3e2ccd2571e8ffe..79ea761468f0af3acdf39517e0b8662c296803c7 100644
--- a/runtime/vm/pages.cc
+++ b/runtime/vm/pages.cc
@@ -11,6 +11,7 @@
#include "vm/lockers.h"
#include "vm/object.h"
#include "vm/os_thread.h"
+#include "vm/thread_registry.h"
#include "vm/verified_memory.h"
#include "vm/virtual_memory.h"
@@ -767,6 +768,12 @@ void PageSpace::MarkSweep(bool invoke_api_callbacks) {
}
set_tasks(1);
}
+ // Ensure that all threads for this isolate are at a safepoint (either stopped
+ // or in native code). If two threads are racing at this point, the loser
+ // will continue with its collection after waiting for the winner to complete.
+ // TODO(koda): Consider moving SafepointThreads into allocation failure/retry
+ // logic to avoid needless collections.
+ isolate->thread_registry()->SafepointThreads();
// Perform various cleanup that relies on no tasks interfering.
isolate->class_table()->FreeOldTables();
@@ -907,6 +914,8 @@ void PageSpace::MarkSweep(bool invoke_api_callbacks) {
freelist_[HeapPage::kExecutable].Print();
}
+ isolate->thread_registry()->ResumeAllThreads();
+
// Done, reset the task count.
{
MonitorLocker ml(tasks_lock());
« no previous file with comments | « runtime/vm/gc_sweeper.cc ('k') | runtime/vm/scavenger.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698