| Index: src/x64/macro-assembler-x64.cc
|
| diff --git a/src/x64/macro-assembler-x64.cc b/src/x64/macro-assembler-x64.cc
|
| index 76491a331cebb03981e3788917c70bd5f33e66c6..e2955eb8e5557d54079fd1d41310021e6b0a0c3e 100644
|
| --- a/src/x64/macro-assembler-x64.cc
|
| +++ b/src/x64/macro-assembler-x64.cc
|
| @@ -692,8 +692,8 @@ void MacroAssembler::PrepareCallApiFunction(int arg_stack_space) {
|
|
|
|
|
| void MacroAssembler::CallApiFunctionAndReturn(Address function_address,
|
| - int stack_space) {
|
| - Label empty_result;
|
| + int stack_space,
|
| + int return_value_offset) {
|
| Label prologue;
|
| Label promote_scheduled_exception;
|
| Label delete_allocated_handles;
|
| @@ -745,15 +745,26 @@ void MacroAssembler::CallApiFunctionAndReturn(Address function_address,
|
| PopSafepointRegisters();
|
| }
|
|
|
| + // Can skip the result check for new-style callbacks
|
| + // TODO(dcarney): may need to pass this information down
|
| + // as some function_addresses might not have been registered
|
| + if (!CallbackTable::ReturnsVoid(isolate(), function_address)) {
|
| + Label empty_result;
|
| #if defined(_WIN64) && !defined(__MINGW64__)
|
| - // rax keeps a pointer to v8::Handle, unpack it.
|
| - movq(rax, Operand(rax, 0));
|
| + // rax keeps a pointer to v8::Handle, unpack it.
|
| + movq(rax, Operand(rax, 0));
|
| #endif
|
| - // Check if the result handle holds 0.
|
| - testq(rax, rax);
|
| - j(zero, &empty_result);
|
| - // It was non-zero. Dereference to get the result value.
|
| - movq(rax, Operand(rax, 0));
|
| + // Check if the result handle holds 0.
|
| + testq(rax, rax);
|
| + j(zero, &empty_result);
|
| + // It was non-zero. Dereference to get the result value.
|
| + movq(rax, Operand(rax, 0));
|
| + jmp(&prologue);
|
| + bind(&empty_result);
|
| + }
|
| + // Load the value from ReturnValue
|
| + movq(rax, StackSpaceOperand(0));
|
| + movq(rax, Operand(rax, return_value_offset * kPointerSize));
|
| bind(&prologue);
|
|
|
| // No more valid handles (the result handle was the last one). Restore
|
| @@ -807,11 +818,6 @@ void MacroAssembler::CallApiFunctionAndReturn(Address function_address,
|
| LeaveApiExitFrame();
|
| ret(stack_space * kPointerSize);
|
|
|
| - bind(&empty_result);
|
| - // It was zero; the result is undefined.
|
| - LoadRoot(rax, Heap::kUndefinedValueRootIndex);
|
| - jmp(&prologue);
|
| -
|
| bind(&promote_scheduled_exception);
|
| TailCallRuntime(Runtime::kPromoteScheduledException, 0, 1);
|
|
|
|
|