Index: src/x64/macro-assembler-x64.cc |
diff --git a/src/x64/macro-assembler-x64.cc b/src/x64/macro-assembler-x64.cc |
index b6378bf7d56311ba8716d5d8b8f19fd558a366fc..d9875129cb0d1c70861be21fda12e9e9372e5583 100644 |
--- a/src/x64/macro-assembler-x64.cc |
+++ b/src/x64/macro-assembler-x64.cc |
@@ -706,12 +706,9 @@ void MacroAssembler::PrepareCallApiFunction(int arg_stack_space) { |
void MacroAssembler::CallApiFunctionAndReturn( |
- Register function_address, |
- ExternalReference thunk_ref, |
- Register thunk_last_arg, |
- int stack_space, |
- Operand return_value_operand, |
- Operand* context_restore_operand) { |
+ Register function_address, ExternalReference thunk_ref, |
+ Register thunk_last_arg, int stack_space, Operand* stack_space_operand, |
+ Operand return_value_operand, Operand* context_restore_operand) { |
Label prologue; |
Label promote_scheduled_exception; |
Label exception_handled; |
@@ -838,8 +835,18 @@ void MacroAssembler::CallApiFunctionAndReturn( |
if (restore_context) { |
movp(rsi, *context_restore_operand); |
} |
+ if (stack_space_operand != nullptr) { |
+ movp(rbx, *stack_space_operand); |
+ } |
LeaveApiExitFrame(!restore_context); |
- ret(stack_space * kPointerSize); |
+ if (stack_space_operand != nullptr) { |
+ DCHECK_EQ(stack_space, 0); |
+ PopReturnAddressTo(rcx); |
+ addq(rsp, rbx); |
+ jmp(rcx); |
+ } else { |
+ ret(stack_space * kPointerSize); |
+ } |
bind(&promote_scheduled_exception); |
{ |