Index: src/runtime/runtime-compiler.cc |
diff --git a/src/runtime/runtime-compiler.cc b/src/runtime/runtime-compiler.cc |
index 6526dcff8bf3dad096bb6470e541fddcedc4b966..f132d986f5eb4f689c92ae340881df9d804bbbf3 100644 |
--- a/src/runtime/runtime-compiler.cc |
+++ b/src/runtime/runtime-compiler.cc |
@@ -301,8 +301,15 @@ RUNTIME_FUNCTION(Runtime_CompileForOnStackReplacement) { |
// match. Fix heuristics for reenabling optimizations! |
function->shared()->increment_deopt_count(); |
- // TODO(titzer): Do not install code into the function. |
- function->ReplaceCode(*result); |
+ if (result->is_turbofanned()) { |
+ // TurboFanned OSR code cannot be installed into the function. |
+ // But the function is obviously hot, so optimize it next time. |
+ function->ReplaceCode( |
+ isolate->builtins()->builtin(Builtins::kCompileOptimized)); |
+ } else { |
+ // Crankshafted OSR code can be installed into the function. |
+ function->ReplaceCode(*result); |
+ } |
return *result; |
} |
} |