Index: src/compiler/instruction-selector.cc |
diff --git a/src/compiler/instruction-selector.cc b/src/compiler/instruction-selector.cc |
index 4200d0d93784f493e4216f3f776fe31d9e3b1817..eb286109f8e2092b3c08596f3f2a649a8de61303 100644 |
--- a/src/compiler/instruction-selector.cc |
+++ b/src/compiler/instruction-selector.cc |
@@ -507,6 +507,40 @@ void InstructionSelector::InitializeCallBuffer(Node* call, CallBuffer* buffer, |
} |
DCHECK_EQ(input_count, buffer->instruction_args.size() + pushed_count - |
buffer->frame_state_value_count()); |
+ if (call_tail && stack_param_delta != 0) { |
+ // For tail calls that change the size of their parameter list, move the |
+ // saved caller return address, parent frame pointer and parent constant |
+ // pool pointer to just above the parameters. |
+ |
+ // Return address |
+ LinkageLocation saved_return_location = |
+ LinkageLocation::ForSavedCallerReturnAddress(); |
+ InstructionOperand return_address = |
+ g.UsePointerLocation(LinkageLocation::ConvertToTailCallerLocation( |
+ saved_return_location, stack_param_delta), |
+ saved_return_location); |
+ buffer->instruction_args.push_back(return_address); |
+ |
+ // Parent frame pointer |
+ LinkageLocation saved_frame_location = |
+ LinkageLocation::ForSavedCallerFramePtr(); |
+ InstructionOperand saved_frame = |
+ g.UsePointerLocation(LinkageLocation::ConvertToTailCallerLocation( |
+ saved_frame_location, stack_param_delta), |
+ saved_frame_location); |
+ buffer->instruction_args.push_back(saved_frame); |
+ |
+ if (V8_EMBEDDED_CONSTANT_POOL) { |
+ // Constant pool pointer |
+ LinkageLocation saved_cp_location = |
+ LinkageLocation::ForSavedCallerConstantPool(); |
+ InstructionOperand saved_cp = |
+ g.UsePointerLocation(LinkageLocation::ConvertToTailCallerLocation( |
+ saved_cp_location, stack_param_delta), |
+ saved_cp_location); |
+ buffer->instruction_args.push_back(saved_cp); |
+ } |
+ } |
} |
@@ -1287,6 +1321,9 @@ void InstructionSelector::VisitTailCall(Node* node) { |
buffer.instruction_args.push_back(g.TempImmediate(stack_param_delta)); |
+ Emit(kArchPrepareTailCall, g.NoOutput(), |
+ g.TempImmediate(stack_param_delta)); |
+ |
// Emit the tailcall instruction. |
Emit(opcode, 0, nullptr, buffer.instruction_args.size(), |
&buffer.instruction_args.front()); |