Index: src/mips/macro-assembler-mips.cc |
diff --git a/src/mips/macro-assembler-mips.cc b/src/mips/macro-assembler-mips.cc |
index 81e9ec980e6b8b56e2bf79f275046a4ff1999472..d9d511be0280ec6471e112841067ff3e24976410 100644 |
--- a/src/mips/macro-assembler-mips.cc |
+++ b/src/mips/macro-assembler-mips.cc |
@@ -3929,7 +3929,9 @@ static int AddressOffset(ExternalReference ref0, ExternalReference ref1) { |
void MacroAssembler::CallApiFunctionAndReturn(ExternalReference function, |
- int stack_space) { |
+ int stack_space, |
+ bool returns_handle, |
+ int return_value_offset_from_fp) { |
ExternalReference next_address = |
ExternalReference::handle_scope_next_address(isolate()); |
const int kNextOffset = 0; |
@@ -3985,15 +3987,20 @@ void MacroAssembler::CallApiFunctionAndReturn(ExternalReference function, |
Label promote_scheduled_exception; |
Label delete_allocated_handles; |
Label leave_exit_frame; |
- |
- // If result is non-zero, dereference to get the result value |
- // otherwise set it to undefined. |
- Label skip; |
- LoadRoot(a0, Heap::kUndefinedValueRootIndex); |
- Branch(&skip, eq, v0, Operand(zero_reg)); |
- lw(a0, MemOperand(v0)); |
- bind(&skip); |
- mov(v0, a0); |
+ Label return_value_loaded; |
+ |
+ if (returns_handle) { |
+ Label load_return_value; |
+ Branch(&load_return_value, eq, v0, Operand(zero_reg)); |
+ // Dereference returned value. |
+ lw(v0, MemOperand(v0)); |
+ b(&return_value_loaded); |
+ nop(); |
+ bind(&load_return_value); |
+ } |
+ // Load value from ReturnValue. |
+ lw(v0, MemOperand(fp, return_value_offset_from_fp*kPointerSize)); |
+ bind(&return_value_loaded); |
// No more valid handles (the result handle was the last one). Restore |
// previous handle scope. |