Index: src/ia32/macro-assembler-ia32.cc |
diff --git a/src/ia32/macro-assembler-ia32.cc b/src/ia32/macro-assembler-ia32.cc |
index 733dbdb033d42069c43c15c15ba607eb44bc0978..838f74f6943618c2b37f9a397216f15c2bdd345f 100644 |
--- a/src/ia32/macro-assembler-ia32.cc |
+++ b/src/ia32/macro-assembler-ia32.cc |
@@ -1968,7 +1968,8 @@ void MacroAssembler::PrepareCallApiFunction(int argc) { |
void MacroAssembler::CallApiFunctionAndReturn(Address function_address, |
- int stack_space) { |
+ int stack_space, |
+ int return_value_offset) { |
ExternalReference next_address = |
ExternalReference::handle_scope_next_address(isolate()); |
ExternalReference limit_address = |
@@ -2004,23 +2005,29 @@ void MacroAssembler::CallApiFunctionAndReturn(Address function_address, |
PopSafepointRegisters(); |
} |
- if (!kReturnHandlesDirectly) { |
- // PrepareCallApiFunction saved pointer to the output slot into |
- // callee-save register esi. |
- mov(eax, Operand(esi, 0)); |
- } |
- |
- Label empty_handle; |
Label prologue; |
+ if (!CallbackTable::ReturnsVoid(isolate(), function_address)) { |
+ if (!kReturnHandlesDirectly) { |
+ // PrepareCallApiFunction saved pointer to the output slot into |
+ // callee-save register esi. |
+ mov(eax, Operand(esi, 0)); |
+ } |
+ Label empty_handle; |
+ // Check if the result handle holds 0. |
+ test(eax, eax); |
+ j(zero, &empty_handle); |
+ // It was non-zero. Dereference to get the result value. |
+ mov(eax, Operand(eax, 0)); |
+ jmp(&prologue); |
+ bind(&empty_handle); |
+ } |
+ // Load the value from ReturnValue |
+ mov(eax, Operand(esp, return_value_offset * kPointerSize)); |
+ |
Label promote_scheduled_exception; |
Label delete_allocated_handles; |
Label leave_exit_frame; |
- // Check if the result handle holds 0. |
- test(eax, eax); |
- j(zero, &empty_handle); |
- // It was non-zero. Dereference to get the result value. |
- mov(eax, Operand(eax, 0)); |
bind(&prologue); |
// No more valid handles (the result handle was the last one). Restore |
// previous handle scope. |
@@ -2076,11 +2083,6 @@ void MacroAssembler::CallApiFunctionAndReturn(Address function_address, |
LeaveApiExitFrame(); |
ret(stack_space * kPointerSize); |
- bind(&empty_handle); |
- // It was zero; the result is undefined. |
- mov(eax, isolate()->factory()->undefined_value()); |
- jmp(&prologue); |
- |
bind(&promote_scheduled_exception); |
TailCallRuntime(Runtime::kPromoteScheduledException, 0, 1); |