Index: src/runtime/runtime-compiler.cc |
diff --git a/src/runtime/runtime-compiler.cc b/src/runtime/runtime-compiler.cc |
index 37484f379d4d87bebf5f9d2985c4d4b730d41f64..01ec73d427d8dec5a8ef53c791c4bbcbf8c316f9 100644 |
--- a/src/runtime/runtime-compiler.cc |
+++ b/src/runtime/runtime-compiler.cc |
@@ -361,7 +361,20 @@ RUNTIME_FUNCTION(Runtime_CompileForOnStackReplacement) { |
// match. Fix heuristics for reenabling optimizations! |
function->shared()->increment_deopt_count(); |
- if (!result->is_turbofanned()) { |
+ if (result->is_turbofanned()) { |
+ // When we're waiting for concurrent optimization, set to compile on |
+ // the next call - otherwise we'd run unoptimized once more |
+ // and potentially compile for OSR another time as well. |
+ if (function->IsMarkedForConcurrentOptimization()) { |
+ if (FLAG_trace_osr) { |
+ PrintF("[OSR - Re-marking "); |
+ function->PrintName(); |
+ PrintF(" for non-concurrent optimization]\n"); |
+ } |
+ function->ReplaceCode( |
+ isolate->builtins()->builtin(Builtins::kCompileOptimized)); |
+ } |
+ } else { |
// Crankshafted OSR code can be installed into the function. |
function->ReplaceCode(*result); |
} |