Index: src/builtins/arm/builtins-arm.cc |
diff --git a/src/builtins/arm/builtins-arm.cc b/src/builtins/arm/builtins-arm.cc |
index 2c9c9c0b0cde532b81ddf030d67cda4790728808..e0bb922ecc57953b8efbaaf15f49bd7add337dc0 100644 |
--- a/src/builtins/arm/builtins-arm.cc |
+++ b/src/builtins/arm/builtins-arm.cc |
@@ -1723,9 +1723,16 @@ void Builtins::Generate_HandleFastApiCall(MacroAssembler* masm) { |
__ TailCallRuntime(Runtime::kThrowIllegalInvocation); |
} |
-void Builtins::Generate_OnStackReplacement(MacroAssembler* masm) { |
+static void Generate_OnStackReplacementHelper(MacroAssembler* masm, |
+ bool has_handler_frame) { |
// Lookup the function in the JavaScript frame. |
- __ ldr(r0, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); |
+ if (has_handler_frame) { |
+ __ ldr(r0, MemOperand(fp, StandardFrameConstants::kCallerFPOffset)); |
+ __ ldr(r0, MemOperand(r0, JavaScriptFrameConstants::kFunctionOffset)); |
+ } else { |
+ __ ldr(r0, MemOperand(fp, JavaScriptFrameConstants::kFunctionOffset)); |
+ } |
+ |
{ |
FrameAndConstantPoolScope scope(masm, StackFrame::INTERNAL); |
// Pass function as argument. |
@@ -1733,7 +1740,7 @@ void Builtins::Generate_OnStackReplacement(MacroAssembler* masm) { |
__ CallRuntime(Runtime::kCompileForOnStackReplacement); |
} |
- // If the code object is null, just return to the unoptimized code. |
+ // If the code object is null, just return to the caller. |
Label skip; |
__ cmp(r0, Operand(Smi::FromInt(0))); |
__ b(ne, &skip); |
@@ -1741,6 +1748,12 @@ void Builtins::Generate_OnStackReplacement(MacroAssembler* masm) { |
__ bind(&skip); |
+ // Drop any potential handler frame that is be sitting on top of the actual |
+ // JavaScript frame. This is the case then OSR is triggered from bytecode. |
+ if (has_handler_frame) { |
+ __ LeaveFrame(StackFrame::STUB); |
+ } |
+ |
// Load deoptimization data from the code object. |
// <deopt_data> = <code>[#deoptimization_data_offset] |
__ ldr(r1, FieldMemOperand(r0, Code::kDeoptimizationDataOffset)); |
@@ -1767,6 +1780,14 @@ void Builtins::Generate_OnStackReplacement(MacroAssembler* masm) { |
} |
} |
+void Builtins::Generate_OnStackReplacement(MacroAssembler* masm) { |
+ Generate_OnStackReplacementHelper(masm, false); |
+} |
+ |
+void Builtins::Generate_InterpreterOnStackReplacement(MacroAssembler* masm) { |
+ Generate_OnStackReplacementHelper(masm, true); |
+} |
+ |
// static |
void Builtins::Generate_DatePrototype_GetField(MacroAssembler* masm, |
int field_index) { |