Index: src/compiler/instruction-selector.cc |
diff --git a/src/compiler/instruction-selector.cc b/src/compiler/instruction-selector.cc |
index eac5571e9c4b8ae1424aab36d9690efb941a5db0..49a5894e43684415d66f03092e5b3e6842afc1a5 100644 |
--- a/src/compiler/instruction-selector.cc |
+++ b/src/compiler/instruction-selector.cc |
@@ -375,7 +375,9 @@ struct CallBuffer { |
// InstructionSelector::VisitCall platform independent instead. |
void InstructionSelector::InitializeCallBuffer(Node* call, CallBuffer* buffer, |
bool call_code_immediate, |
- bool call_address_immediate) { |
+ bool call_address_immediate, |
+ bool call_tail, |
+ int stack_param_delta) { |
OperandGenerator g(this); |
DCHECK_LE(call->op()->ValueOutputCount(), |
static_cast<int>(buffer->descriptor->ReturnCount())); |
@@ -482,10 +484,15 @@ void InstructionSelector::InitializeCallBuffer(Node* call, CallBuffer* buffer, |
DCHECK(iter != call->inputs().end()); |
DCHECK((*iter)->op()->opcode() != IrOpcode::kFrameState); |
if (index == 0) continue; // The first argument (callee) is already done. |
+ |
+ LinkageLocation location = buffer->descriptor->GetInputLocation(index); |
+ if (call_tail) { |
+ location = LinkageLocation::ConvertToTailCallerLocation( |
+ buffer->descriptor->GetInputLocation(index), stack_param_delta); |
Jarin
2015/11/12 13:45:12
Replace 'buffer->descriptor->GetInputLocation(inde
danno
2015/11/13 10:04:17
Done.
|
+ } |
InstructionOperand op = |
- g.UseLocation(*iter, buffer->descriptor->GetInputLocation(index), |
- buffer->descriptor->GetInputType(index)); |
- if (UnallocatedOperand::cast(op).HasFixedSlotPolicy()) { |
+ g.UseLocation(*iter, location, buffer->descriptor->GetInputType(index)); |
+ if (UnallocatedOperand::cast(op).HasFixedSlotPolicy() && !call_tail) { |
int stack_index = -UnallocatedOperand::cast(op).fixed_slot_index() - 1; |
if (static_cast<size_t>(stack_index) >= buffer->pushed_nodes.size()) { |
buffer->pushed_nodes.resize(stack_index + 1, NULL); |
@@ -1166,7 +1173,7 @@ void InstructionSelector::VisitCall(Node* node, BasicBlock* handler) { |
// the code object in a register if there are multiple uses of it. |
// Improve constant pool and the heuristics in the register allocator |
// for where to emit constants. |
- InitializeCallBuffer(node, &buffer, true, true); |
+ InitializeCallBuffer(node, &buffer, true, true, false); |
Jarin
2015/11/12 13:45:12
Hmm, the bool parameters are getting a bit out of
danno
2015/11/13 10:04:17
Done.
|
EmitPrepareArguments(&(buffer.pushed_nodes), descriptor, node); |
@@ -1219,11 +1226,14 @@ void InstructionSelector::VisitTailCall(Node* node) { |
// TODO(turbofan): Relax restriction for stack parameters. |
- if (linkage()->GetIncomingDescriptor()->CanTailCall(node)) { |
+ int stack_param_delta = 0; |
+ if (linkage()->GetIncomingDescriptor()->CanTailCall(node, |
+ &stack_param_delta)) { |
CallBuffer buffer(zone(), descriptor, nullptr); |
// Compute InstructionOperands for inputs and outputs. |
- InitializeCallBuffer(node, &buffer, true, IsTailCallAddressImmediate()); |
+ InitializeCallBuffer(node, &buffer, true, IsTailCallAddressImmediate(), |
+ true, stack_param_delta); |
// Select the appropriate opcode based on the call type. |
InstructionCode opcode; |
@@ -1240,6 +1250,8 @@ void InstructionSelector::VisitTailCall(Node* node) { |
} |
opcode |= MiscField::encode(descriptor->flags()); |
+ buffer.instruction_args.push_back(g.TempImmediate(stack_param_delta)); |
+ |
// Emit the tailcall instruction. |
Emit(opcode, 0, nullptr, buffer.instruction_args.size(), |
&buffer.instruction_args.front()); |
@@ -1253,7 +1265,8 @@ void InstructionSelector::VisitTailCall(Node* node) { |
CallBuffer buffer(zone(), descriptor, frame_state_descriptor); |
// Compute InstructionOperands for inputs and outputs. |
- InitializeCallBuffer(node, &buffer, true, IsTailCallAddressImmediate()); |
+ InitializeCallBuffer(node, &buffer, true, IsTailCallAddressImmediate(), |
+ false); |
EmitPrepareArguments(&(buffer.pushed_nodes), descriptor, node); |