Index: src/execution.cc |
diff --git a/src/execution.cc b/src/execution.cc |
index b550415bfdea82e43cf1687c4573b424a3d3deb5..62a4cbef16e351b73c3a0f2a4eae9a5de589bd2f 100644 |
--- a/src/execution.cc |
+++ b/src/execution.cc |
@@ -713,43 +713,50 @@ void Execution::ProcessDebugMessages(Isolate* isolate, |
Object* StackGuard::HandleInterrupts() { |
- ExecutionAccess access(isolate_); |
- if (should_postpone_interrupts(access)) { |
- return isolate_->heap()->undefined_value(); |
- } |
+ bool has_api_interrupt = false; |
+ { |
+ ExecutionAccess access(isolate_); |
+ if (should_postpone_interrupts(access)) { |
+ return isolate_->heap()->undefined_value(); |
+ } |
- if (CheckAndClearInterrupt(API_INTERRUPT, access)) { |
- isolate_->InvokeApiInterruptCallback(); |
- } |
+ if (CheckAndClearInterrupt(GC_REQUEST, access)) { |
+ isolate_->heap()->CollectAllGarbage(Heap::kNoGCFlags, "GC interrupt"); |
+ } |
- if (CheckAndClearInterrupt(GC_REQUEST, access)) { |
- isolate_->heap()->CollectAllGarbage(Heap::kNoGCFlags, "GC interrupt"); |
- } |
+ if (CheckDebugBreak() || CheckDebugCommand()) { |
+ Execution::DebugBreakHelper(isolate_); |
+ } |
- if (CheckDebugBreak() || CheckDebugCommand()) { |
- Execution::DebugBreakHelper(isolate_); |
- } |
+ if (CheckAndClearInterrupt(TERMINATE_EXECUTION, access)) { |
+ return isolate_->TerminateExecution(); |
+ } |
- if (CheckAndClearInterrupt(TERMINATE_EXECUTION, access)) { |
- return isolate_->TerminateExecution(); |
- } |
+ if (CheckAndClearInterrupt(FULL_DEOPT, access)) { |
+ Deoptimizer::DeoptimizeAll(isolate_); |
+ } |
- if (CheckAndClearInterrupt(FULL_DEOPT, access)) { |
- Deoptimizer::DeoptimizeAll(isolate_); |
- } |
+ if (CheckAndClearInterrupt(DEOPT_MARKED_ALLOCATION_SITES, access)) { |
+ isolate_->heap()->DeoptMarkedAllocationSites(); |
+ } |
- if (CheckAndClearInterrupt(DEOPT_MARKED_ALLOCATION_SITES, access)) { |
- isolate_->heap()->DeoptMarkedAllocationSites(); |
+ if (CheckAndClearInterrupt(INSTALL_CODE, access)) { |
+ ASSERT(isolate_->concurrent_recompilation_enabled()); |
+ isolate_->optimizing_compiler_thread()->InstallOptimizedFunctions(); |
+ } |
+ |
+ has_api_interrupt = CheckAndClearInterrupt(API_INTERRUPT, access); |
+ |
+ isolate_->counters()->stack_interrupts()->Increment(); |
+ isolate_->counters()->runtime_profiler_ticks()->Increment(); |
+ isolate_->runtime_profiler()->OptimizeNow(); |
} |
- if (CheckAndClearInterrupt(INSTALL_CODE, access)) { |
- ASSERT(isolate_->concurrent_recompilation_enabled()); |
- isolate_->optimizing_compiler_thread()->InstallOptimizedFunctions(); |
+ if (has_api_interrupt) { |
+ // Callback must be invoked outside of ExecusionAccess lock. |
+ isolate_->InvokeApiInterruptCallback(); |
} |
- isolate_->counters()->stack_interrupts()->Increment(); |
- isolate_->counters()->runtime_profiler_ticks()->Increment(); |
- isolate_->runtime_profiler()->OptimizeNow(); |
return isolate_->heap()->undefined_value(); |
} |