| 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;
|
|
|