| Index: src/builtins/x87/builtins-x87.cc
|
| diff --git a/src/builtins/x87/builtins-x87.cc b/src/builtins/x87/builtins-x87.cc
|
| index 6b039111c948375df76367182390fea9497b2a99..ff5597b539e37d1d63453415d1389a7b5bed46f0 100644
|
| --- a/src/builtins/x87/builtins-x87.cc
|
| +++ b/src/builtins/x87/builtins-x87.cc
|
| @@ -2993,9 +2993,16 @@ void Builtins::Generate_HandleFastApiCall(MacroAssembler* masm) {
|
| }
|
| }
|
|
|
| -void Builtins::Generate_OnStackReplacement(MacroAssembler* masm) {
|
| +static void Generate_OnStackReplacementHelper(MacroAssembler* masm,
|
| + bool has_handler_frame) {
|
| // Lookup the function in the JavaScript frame.
|
| - __ mov(eax, Operand(ebp, JavaScriptFrameConstants::kFunctionOffset));
|
| + if (has_handler_frame) {
|
| + __ mov(eax, Operand(ebp, StandardFrameConstants::kCallerFPOffset));
|
| + __ mov(eax, Operand(eax, JavaScriptFrameConstants::kFunctionOffset));
|
| + } else {
|
| + __ mov(eax, Operand(ebp, JavaScriptFrameConstants::kFunctionOffset));
|
| + }
|
| +
|
| {
|
| FrameScope scope(masm, StackFrame::INTERNAL);
|
| // Pass function as argument.
|
| @@ -3004,13 +3011,19 @@ void Builtins::Generate_OnStackReplacement(MacroAssembler* masm) {
|
| }
|
|
|
| Label skip;
|
| - // If the code object is null, just return to the unoptimized code.
|
| + // If the code object is null, just return to the caller.
|
| __ cmp(eax, Immediate(0));
|
| __ j(not_equal, &skip, Label::kNear);
|
| __ ret(0);
|
|
|
| __ 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) {
|
| + __ leave();
|
| + }
|
| +
|
| // Load deoptimization data from the code object.
|
| __ mov(ebx, Operand(eax, Code::kDeoptimizationDataOffset - kHeapObjectTag));
|
|
|
| @@ -3030,6 +3043,14 @@ void Builtins::Generate_OnStackReplacement(MacroAssembler* masm) {
|
| __ ret(0);
|
| }
|
|
|
| +void Builtins::Generate_OnStackReplacement(MacroAssembler* masm) {
|
| + Generate_OnStackReplacementHelper(masm, false);
|
| +}
|
| +
|
| +void Builtins::Generate_InterpreterOnStackReplacement(MacroAssembler* masm) {
|
| + Generate_OnStackReplacementHelper(masm, true);
|
| +}
|
| +
|
| #undef __
|
| } // namespace internal
|
| } // namespace v8
|
|
|