| Index: runtime/vm/compiler.cc
 | 
| diff --git a/runtime/vm/compiler.cc b/runtime/vm/compiler.cc
 | 
| index 74795062b1ef56e71e69b289926e3e98ca2a5909..3ce18f89e3ec5d94364f1c8c7e91788cf8633228 100644
 | 
| --- a/runtime/vm/compiler.cc
 | 
| +++ b/runtime/vm/compiler.cc
 | 
| @@ -1058,14 +1058,13 @@ bool CompileParsedFunctionHelper::Compile(CompilationPipeline* pipeline) {
 | 
|            // instruction object, since the creation of instruction object
 | 
|            // changes code page access permissions (makes them temporary not
 | 
|            // executable).
 | 
| -          isolate()->thread_registry()->SafepointThreads();
 | 
|            {
 | 
| +            SafepointOperationScope safepoint_scope(thread());
 | 
|              // Do not Garbage collect during this stage and instead allow the
 | 
|              // heap to grow.
 | 
|              NoHeapGrowthControlScope no_growth_control;
 | 
|              FinalizeCompilation(&assembler, &graph_compiler, flow_graph);
 | 
|            }
 | 
| -          isolate()->thread_registry()->ResumeAllThreads();
 | 
|            if (isolate()->heap()->NeedsGarbageCollection()) {
 | 
|              isolate()->heap()->CollectAllGarbage();
 | 
|            }
 | 
| @@ -1899,9 +1898,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;
 | 
| 
 |