Chromium Code Reviews| Index: src/runtime.cc |
| diff --git a/src/runtime.cc b/src/runtime.cc |
| index ed3527fa9202cb9977101725598cec30b3af1bba..3445fee65a3dc47b50221da1277fd91b7f69f2fa 100644 |
| --- a/src/runtime.cc |
| +++ b/src/runtime.cc |
| @@ -8188,9 +8188,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_LazyRecompile) { |
| return function->code(); |
| } |
| function->shared()->code()->set_profiler_ticks(0); |
| - if (JSFunction::CompileOptimized(function, |
| - BailoutId::None(), |
| - CLEAR_EXCEPTION)) { |
| + if (JSFunction::CompileOptimized(function, CLEAR_EXCEPTION)) { |
| return function->code(); |
| } |
| if (FLAG_trace_opt) { |
| @@ -8283,8 +8281,6 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_NotifyDeoptimized) { |
| RUNTIME_ASSERT(frame->function()->IsJSFunction()); |
| Handle<JSFunction> function(frame->function(), isolate); |
| Handle<Code> optimized_code(function->code()); |
| - RUNTIME_ASSERT((type != Deoptimizer::EAGER && |
| - type != Deoptimizer::SOFT) || function->IsOptimized()); |
| // Avoid doing too much work when running with --always-opt and keep |
| // the optimized code around. |
| @@ -8488,6 +8484,7 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_CompileForOnStackReplacement) { |
| } |
| BailoutId ast_id = BailoutId::None(); |
| + Handle<Code> osr_code = Handle<Code>::null(); |
| if (succeeded) { |
| // The top JS function is this one, the PC is somewhere in the |
| // unoptimized code. |
| @@ -8523,26 +8520,26 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_CompileForOnStackReplacement) { |
| PrintF("]\n"); |
| } |
| - // Try to compile the optimized code. A true return value from |
| - // CompileOptimized means that compilation succeeded, not necessarily |
| - // that optimization succeeded. |
| - if (JSFunction::CompileOptimized(function, ast_id, CLEAR_EXCEPTION) && |
| - function->IsOptimized()) { |
| + // Try to compile the function for OSR. A non-null return value indicates |
| + // the compilation succeeded for the given AST id. |
| + osr_code = JSFunction::CompileOsr(function, ast_id, CLEAR_EXCEPTION); |
| + |
| + if (!osr_code.is_null() && |
| + osr_code->kind() == Code::OPTIMIZED_FUNCTION) { |
| DeoptimizationInputData* data = DeoptimizationInputData::cast( |
| - function->code()->deoptimization_data()); |
| - if (data->OsrPcOffset()->value() >= 0) { |
| + osr_code->deoptimization_data()); |
| + if (data->OsrPcOffset()->value() >= 0 |
| + && BailoutId(data->OsrAstId()->value()) == ast_id) { |
| if (FLAG_trace_osr) { |
| PrintF("[on-stack replacement offset %d in optimized code]\n", |
| data->OsrPcOffset()->value()); |
| } |
| - ASSERT(BailoutId(data->OsrAstId()->value()) == ast_id); |
| } else { |
| - // We may never generate the desired OSR entry if we emit an |
| - // early deoptimize. |
| - succeeded = false; |
| + // The code we got back did not match our OSR compile request. |
| + osr_code = Handle<Code>::null(); |
| } |
| } else { |
| - succeeded = false; |
| + osr_code = Handle<Code>::null(); |
| } |
| } |
| @@ -8559,18 +8556,9 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_CompileForOnStackReplacement) { |
| *interrupt_code, |
| *replacement_code); |
| - // If the optimization attempt succeeded, return the AST id tagged as a |
| - // smi. This tells the builtin that we need to translate the unoptimized |
| - // frame to an optimized one. |
| - if (succeeded) { |
| - ASSERT(function->code()->kind() == Code::OPTIMIZED_FUNCTION); |
| - return Smi::FromInt(ast_id.ToInt()); |
| - } else { |
| - if (function->IsMarkedForLazyRecompilation()) { |
| - function->ReplaceCode(function->shared()->code()); |
| - } |
| - return Smi::FromInt(-1); |
| - } |
| + // Return the code object to the calling builtin. If non-null, the builtin |
| + // will jump directly to its OSR entrypoint. |
| + return osr_code.is_null() ? NULL: *osr_code; |
|
Michael Starzinger
2013/07/31 14:55:50
nit: Missing white-space in front of the colon.
|
| } |