Commit 1dcf534c authored by zhengxing.li's avatar zhengxing.li Committed by Commit bot

X87: [turbofan] Better and more sane support for tail calls

    port ff283f7d (r31987)

    original commit message:
    * Limit triggering of tail calls to explicit use of a new inline runtime
      function %_TailCall. %_TailCall works just like %_Call except for using
      tail-calling mechanics (currently only in TF).
    * Remove hack that recognized some specific usages of %_Call and converted them
      into tail calls.
    * Support tail calls for all calls where the number of callee stack parameters
      is less than or equal to the number of caller stack parameters.
    * Use the gap resolver to swizzle parameters and registers to tail calls.

BUG=

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

Cr-Commit-Position: refs/heads/master@{#32001}
parent 34b7b21d
......@@ -330,13 +330,20 @@ class OutOfLineRecordWrite final : public OutOfLineCode {
} while (false)
void CodeGenerator::AssembleDeconstructActivationRecord() {
void CodeGenerator::AssembleDeconstructActivationRecord(int stack_param_delta) {
CallDescriptor* descriptor = linkage()->GetIncomingDescriptor();
int stack_slots = frame()->GetSpillSlotCount();
if (descriptor->IsJSFunctionCall() || stack_slots > 0) {
__ mov(esp, ebp);
__ pop(ebp);
}
if (stack_param_delta < 0) {
int offset = -(stack_param_delta + 1) * kPointerSize;
__ pop(Operand(esp, offset));
if (offset != 0) {
__ add(esp, Immediate(offset));
}
}
}
......@@ -372,7 +379,8 @@ void CodeGenerator::AssembleArchInstruction(Instruction* instr) {
break;
}
case kArchTailCallCodeObject: {
AssembleDeconstructActivationRecord();
int stack_param_delta = i.InputInt32(instr->InputCount() - 1);
AssembleDeconstructActivationRecord(stack_param_delta);
if (HasImmediateInput(instr, 0)) {
Handle<Code> code = Handle<Code>::cast(i.InputHeapObject(0));
__ jmp(code, RelocInfo::CODE_TARGET);
......@@ -415,7 +423,8 @@ void CodeGenerator::AssembleArchInstruction(Instruction* instr) {
__ cmp(esi, FieldOperand(func, JSFunction::kContextOffset));
__ Assert(equal, kWrongFunctionContext);
}
AssembleDeconstructActivationRecord();
int stack_param_delta = i.InputInt32(instr->InputCount() - 1);
AssembleDeconstructActivationRecord(stack_param_delta);
__ jmp(FieldOperand(func, JSFunction::kCodeEntryOffset));
break;
}
......
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