| Index: src/compiler/x64/code-generator-x64.cc
|
| diff --git a/src/compiler/x64/code-generator-x64.cc b/src/compiler/x64/code-generator-x64.cc
|
| index 1c80ad85baa8fd6eb5eec196ea8e00fa17f47782..cbb8b6b628a1564c01bdbda169250cdb59918c27 100644
|
| --- a/src/compiler/x64/code-generator-x64.cc
|
| +++ b/src/compiler/x64/code-generator-x64.cc
|
| @@ -575,16 +575,37 @@ class OutOfLineRecordWrite final : public OutOfLineCode {
|
|
|
| void CodeGenerator::AssembleDeconstructActivationRecord(int stack_param_delta) {
|
| CallDescriptor* descriptor = linkage()->GetIncomingDescriptor();
|
| - int stack_slots = frame()->GetSpillSlotCount();
|
| - if (descriptor->IsJSFunctionCall() || stack_slots > 0) {
|
| - __ movq(rsp, rbp);
|
| + int spill_slots = frame()->GetSpillSlotCount();
|
| + bool has_frame = descriptor->IsJSFunctionCall() || spill_slots > 0;
|
| + if (has_frame) {
|
| + if (stack_param_delta != 0) {
|
| + int total_discarded_slots = frame()->GetTotalFrameSlotCount();
|
| + // Leave the PC and saved frame pointer on the stack.
|
| + total_discarded_slots -=
|
| + StandardFrameConstants::kFixedFrameSizeFromFp / kPointerSize;
|
| + // Discard only slots that won't be used by new parameters.
|
| + total_discarded_slots -= stack_param_delta;
|
| + if (total_discarded_slots > 0) {
|
| + __ addq(rsp, Immediate(total_discarded_slots * kPointerSize));
|
| + }
|
| + } else {
|
| + __ movq(rsp, rbp);
|
| + }
|
| __ popq(rbp);
|
| }
|
| - if (stack_param_delta < 0) {
|
| - int offset = -(stack_param_delta + 1) * kPointerSize;
|
| - __ popq(Operand(rsp, offset));
|
| - if (offset != 0) {
|
| - __ addq(rsp, Immediate(offset));
|
| +}
|
| +
|
| +
|
| +void CodeGenerator::AssemblePrepareTailCall(int stack_param_delta) {
|
| + if (stack_param_delta > 0) {
|
| + int total_discarded_slots = frame()->GetTotalFrameSlotCount();
|
| + // Leave the PC and saved frame pointer on the stack.
|
| + total_discarded_slots -=
|
| + StandardFrameConstants::kFixedFrameSizeFromFp / kPointerSize;
|
| + // Discard only slots that won't be used by new parameters.
|
| + total_discarded_slots -= stack_param_delta;
|
| + if (total_discarded_slots < 0) {
|
| + __ subq(rsp, Immediate(-total_discarded_slots * kPointerSize));
|
| }
|
| }
|
| }
|
| @@ -655,6 +676,9 @@ void CodeGenerator::AssembleArchInstruction(Instruction* instr) {
|
| __ PrepareCallCFunction(num_parameters);
|
| break;
|
| }
|
| + case kArchPrepareTailCall:
|
| + AssemblePrepareTailCall(i.InputInt32(instr->InputCount() - 1));
|
| + break;
|
| case kArchCallCFunction: {
|
| int const num_parameters = MiscField::decode(instr->opcode());
|
| if (HasImmediateInput(instr, 0)) {
|
|
|