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

Unified Diff: runtime/vm/compiler.cc

Issue 1541073002: Implement safepointing of threads (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: self-review-comments Created 4 years, 11 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
Index: runtime/vm/compiler.cc
diff --git a/runtime/vm/compiler.cc b/runtime/vm/compiler.cc
index be9c996a8ee88a12f439c6bb3fbe4041a12f7223..074a44e8064f6852f4f55d9903327aa3e68e6fa7 100644
--- a/runtime/vm/compiler.cc
+++ b/runtime/vm/compiler.cc
@@ -1050,21 +1050,17 @@ bool CompileParsedFunctionHelper::Compile(CompilationPipeline* pipeline) {
compiler_timeline,
"FinalizeCompilation");
// This part of compilation must be at a safepoint.
- if (!thread()->IsMutatorThread()) {
+ if (thread()->IsMutatorThread()) {
+ FinalizeCompilation(&assembler, &graph_compiler, flow_graph);
+ } else {
// Stop mutator thread before creating the instruction object and
// installing code.
// Mutator thread may not run code while we are creating the
// instruction object, since the creation of instruction object
// changes code page access permissions (makes them temporary not
// executable).
- isolate()->thread_registry()->SafepointThreads();
- }
-
- FinalizeCompilation(&assembler, &graph_compiler, flow_graph);
-
- if (!thread()->IsMutatorThread()) {
- // Background compilation.
- isolate()->thread_registry()->ResumeAllThreads();
+ SafepointOperationScope safepoint_scope(thread());
+ FinalizeCompilation(&assembler, &graph_compiler, flow_graph);
}
}
// Mark that this isolate now has compiled code.
@@ -1894,9 +1890,7 @@ void BackgroundCompiler::Stop(BackgroundCompiler* task) {
{
MonitorLocker ml_done(done_monitor);
while (!(*task_done)) {
- // In case that the compiler is waiting for safepoint.
- Isolate::Current()->thread_registry()->CheckSafepoint();
- ml_done.Wait(1);
+ ml_done.WaitWithSafepointCheck(Thread::Current());
}
}
delete task_done;

Powered by Google App Engine
This is Rietveld 408576698