Commit 1d1557d8 authored by mbrandy's avatar mbrandy Committed by Commit bot

PPC: [turbofan]: Implement tail calls with more callee than caller parameters

Port c6d310da

Original commit message:
    * Adds a PrepareForTailCall instruction that bumps the stack in the case that
      the number of parameters passed to the callee causes the stack to exceed the
      calleer's frame size.
    * Uses the gap resolver to move the saved caller return address and frame
      pointer to the approprate location in the tail-called frame.

R=danno@chromium.org, joransiu@ca.ibm.com, jyan@ca.ibm.com, michael_dawson@ca.ibm.com
BUG=v8:4076
LOG=n

Review URL: https://codereview.chromium.org/1460183003

Cr-Commit-Position: refs/heads/master@{#32183}
parent 07b50849
...@@ -606,14 +606,28 @@ Condition FlagsConditionToCondition(FlagsCondition condition) { ...@@ -606,14 +606,28 @@ Condition FlagsConditionToCondition(FlagsCondition condition) {
void CodeGenerator::AssembleDeconstructActivationRecord(int stack_param_delta) { void CodeGenerator::AssembleDeconstructActivationRecord(int stack_param_delta) {
int sp_slot_delta = TailCallFrameStackSlotDelta(stack_param_delta);
if (sp_slot_delta > 0) {
__ Add(sp, sp, sp_slot_delta * kPointerSize, r0);
}
CallDescriptor* descriptor = linkage()->GetIncomingDescriptor(); CallDescriptor* descriptor = linkage()->GetIncomingDescriptor();
int stack_slots = frame()->GetSpillSlotCount(); int spill_slots = frame()->GetSpillSlotCount();
int sp_delta = bool has_frame = descriptor->IsJSFunctionCall() || spill_slots > 0;
(stack_param_delta < 0) ? -stack_param_delta * kPointerSize : 0; if (has_frame) {
if (descriptor->IsJSFunctionCall() || stack_slots > 0) { if (FLAG_enable_embedded_constant_pool) {
__ LeaveFrame(StackFrame::MANUAL, sp_delta); __ Pop(r0, fp, kConstantPoolRegister);
} else if (sp_delta) { } else {
__ Add(sp, sp, sp_delta, r0); __ Pop(r0, fp);
}
__ mtlr(r0);
}
}
void CodeGenerator::AssemblePrepareTailCall(int stack_param_delta) {
int sp_slot_delta = TailCallFrameStackSlotDelta(stack_param_delta);
if (sp_slot_delta < 0) {
__ Add(sp, sp, sp_slot_delta * kPointerSize, r0);
} }
} }
...@@ -703,6 +717,9 @@ void CodeGenerator::AssembleArchInstruction(Instruction* instr) { ...@@ -703,6 +717,9 @@ void CodeGenerator::AssembleArchInstruction(Instruction* instr) {
__ PrepareCallCFunction(num_parameters, kScratchReg); __ PrepareCallCFunction(num_parameters, kScratchReg);
break; break;
} }
case kArchPrepareTailCall:
AssemblePrepareTailCall(i.InputInt32(instr->InputCount() - 1));
break;
case kArchCallCFunction: { case kArchCallCFunction: {
int const num_parameters = MiscField::decode(instr->opcode()); int const num_parameters = MiscField::decode(instr->opcode());
if (instr->InputAt(0)->IsImmediate()) { if (instr->InputAt(0)->IsImmediate()) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment