| 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 a5212cb75ef3389c85012077076569850cd0999f..129302ab02b94ecc25a80166f28edd52e4003cf4 100644
|
| --- a/src/compiler/x64/code-generator-x64.cc
|
| +++ b/src/compiler/x64/code-generator-x64.cc
|
| @@ -4,6 +4,8 @@
|
|
|
| #include "src/compiler/code-generator.h"
|
|
|
| +#include <limits>
|
| +
|
| #include "src/compilation-info.h"
|
| #include "src/compiler/code-generator-impl.h"
|
| #include "src/compiler/gap-resolver.h"
|
| @@ -921,7 +923,7 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
|
| break;
|
| }
|
| case kArchRet:
|
| - AssembleReturn();
|
| + AssembleReturn(instr->InputAt(0));
|
| break;
|
| case kArchStackPointer:
|
| __ movq(i.OutputRegister(), rsp);
|
| @@ -2450,8 +2452,7 @@ void CodeGenerator::AssembleConstructFrame() {
|
| }
|
| }
|
|
|
| -
|
| -void CodeGenerator::AssembleReturn() {
|
| +void CodeGenerator::AssembleReturn(InstructionOperand* pop) {
|
| CallDescriptor* descriptor = linkage()->GetIncomingDescriptor();
|
|
|
| // Restore registers.
|
| @@ -2492,10 +2493,23 @@ void CodeGenerator::AssembleReturn() {
|
| AssembleDeconstructFrame();
|
| }
|
| }
|
| - size_t pop_size = descriptor->StackParameterCount() * kPointerSize;
|
| - // Might need rcx for scratch if pop_size is too big.
|
| + // Might need rcx for scratch if pop_size is too big or if there is a variable
|
| + // pop count.
|
| DCHECK_EQ(0u, descriptor->CalleeSavedRegisters() & rcx.bit());
|
| - __ Ret(static_cast<int>(pop_size), rcx);
|
| + size_t pop_size = descriptor->StackParameterCount() * kPointerSize;
|
| + X64OperandConverter g(this, nullptr);
|
| + if (pop->IsImmediate()) {
|
| + DCHECK_EQ(Constant::kInt32, g.ToConstant(pop).type());
|
| + pop_size += g.ToConstant(pop).ToInt32() * kPointerSize;
|
| + CHECK_LT(pop_size, std::numeric_limits<int>::max());
|
| + __ Ret(static_cast<int>(pop_size), rcx);
|
| + } else {
|
| + Register reg = g.ToRegister(pop);
|
| + __ popq(rcx);
|
| + CHECK_LT(pop_size, std::numeric_limits<int>::max());
|
| + __ leaq(rsp, Operand(rsp, reg, times_8, static_cast<int>(pop_size)));
|
| + __ jmp(rcx);
|
| + }
|
| }
|
|
|
|
|
|
|