Index: src/x64/code-stubs-x64.cc |
diff --git a/src/x64/code-stubs-x64.cc b/src/x64/code-stubs-x64.cc |
index 66dfe1f8e05c111a08887eabe5da20fb7c9526fe..f572ae2477247a0839648230ba4c695662ecd09b 100644 |
--- a/src/x64/code-stubs-x64.cc |
+++ b/src/x64/code-stubs-x64.cc |
@@ -4817,12 +4817,12 @@ static void CallApiFunctionStubHelper(MacroAssembler* masm, |
bool return_first_arg, |
bool call_data_undefined) { |
// ----------- S t a t e ------------- |
- // -- rax : callee |
+ // -- rdi : callee |
// -- rbx : call_data |
// -- rcx : holder |
// -- rdx : api_function_address |
// -- rsi : context |
- // -- rdi : number of arguments if argc is a register |
+ // -- rax : number of arguments if argc is a register |
// -- rsp[0] : return address |
// -- rsp[8] : last argument |
// -- ... |
@@ -4830,11 +4830,12 @@ static void CallApiFunctionStubHelper(MacroAssembler* masm, |
// -- rsp[(argc + 1) * 8] : receiver |
// ----------------------------------- |
- Register callee = rax; |
+ Register callee = rdi; |
Register call_data = rbx; |
Register holder = rcx; |
Register api_function_address = rdx; |
Register context = rsi; |
+ Register return_address = r8; |
typedef FunctionCallbackArguments FCA; |
@@ -4847,17 +4848,12 @@ static void CallApiFunctionStubHelper(MacroAssembler* masm, |
STATIC_ASSERT(FCA::kHolderIndex == 0); |
STATIC_ASSERT(FCA::kArgsLength == 7); |
- DCHECK(argc.is_immediate() || rdi.is(argc.reg())); |
+ DCHECK(argc.is_immediate() || rax.is(argc.reg())); |
- if (kPointerSize == kInt64Size) { |
- // pop return address and save context |
- __ xchgq(context, Operand(rsp, 0)); |
- } else { |
- // x32 handling. |
- __ PopReturnAddressTo(kScratchRegister); |
- __ Push(context); |
- __ movq(context, kScratchRegister); |
- } |
+ __ PopReturnAddressTo(return_address); |
+ |
+ // context save |
+ __ Push(context); |
// callee |
__ Push(callee); |
@@ -4880,7 +4876,7 @@ static void CallApiFunctionStubHelper(MacroAssembler* masm, |
__ movp(scratch, rsp); |
// Push return address back on stack. |
- __ PushReturnAddressFrom(context); |
+ __ PushReturnAddressFrom(return_address); |
// load context from callee |
__ movp(context, FieldOperand(callee, JSFunction::kContextOffset)); |
@@ -4954,9 +4950,8 @@ static void CallApiFunctionStubHelper(MacroAssembler* masm, |
void CallApiFunctionStub::Generate(MacroAssembler* masm) { |
- // TODO(dcarney): make rax contain the function address. |
bool call_data_undefined = this->call_data_undefined(); |
- CallApiFunctionStubHelper(masm, ParameterCount(rdi), false, |
+ CallApiFunctionStubHelper(masm, ParameterCount(rax), false, |
call_data_undefined); |
} |