Index: src/ia32/builtins-ia32.cc |
diff --git a/src/ia32/builtins-ia32.cc b/src/ia32/builtins-ia32.cc |
index c02726b3ed2a55823edc82c508d8075da40ffbf1..a617da71d367745f58356b55dbcd6ccdc3b32d15 100644 |
--- a/src/ia32/builtins-ia32.cc |
+++ b/src/ia32/builtins-ia32.cc |
@@ -1337,22 +1337,30 @@ void Builtins::Generate_OnStackReplacement(MacroAssembler* masm) { |
__ CallRuntime(Runtime::kCompileForOnStackReplacement, 1); |
} |
- // If the result was -1 it means that we couldn't optimize the |
- // function. Just return and continue in the unoptimized version. |
Label skip; |
- __ cmp(eax, Immediate(Smi::FromInt(-1))); |
+ // If the code object is null, just return to the unoptimized code. |
+ __ cmp(eax, Immediate(0)); |
__ j(not_equal, &skip, Label::kNear); |
__ ret(0); |
__ bind(&skip); |
- // Untag the AST id and push it on the stack. |
- __ SmiUntag(eax); |
- __ push(eax); |
- |
- // Generate the code for doing the frame-to-frame translation using |
- // the deoptimizer infrastructure. |
- Deoptimizer::EntryGenerator generator(masm, Deoptimizer::OSR); |
- generator.Generate(); |
+ |
+ // Load deoptimization data from the code object. |
+ __ mov(ebx, Operand(eax, Code::kDeoptimizationDataOffset - kHeapObjectTag)); |
+ |
+ // Load the OSR entrypoint offset from the deoptimization data. |
+ __ mov(ebx, Operand(ebx, FixedArray::OffsetOfElementAt( |
+ DeoptimizationInputData::kOsrPcOffsetIndex) - kHeapObjectTag)); |
+ __ SmiUntag(ebx); |
+ |
+ // Compute the target address = code_obj + header_size + osr_offset |
+ __ lea(eax, Operand(eax, ebx, times_1, Code::kHeaderSize - kHeapObjectTag)); |
+ |
+ // Overwrite the return address on the stack. |
+ __ mov(Operand(esp, 0), eax); |
+ |
+ // And "return" to the OSR entry point of the function. |
+ __ ret(0); |
} |