Index: src/arm/macro-assembler-arm.cc |
diff --git a/src/arm/macro-assembler-arm.cc b/src/arm/macro-assembler-arm.cc |
index 6e0b4a7040ae080faa5e91b814338956924ddca0..fc96446d1f5165d278c28f7b9263f8505d52d027 100644 |
--- a/src/arm/macro-assembler-arm.cc |
+++ b/src/arm/macro-assembler-arm.cc |
@@ -2268,7 +2268,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) { |
ExternalReference next_address = |
ExternalReference::handle_scope_next_address(isolate()); |
const int kNextOffset = 0; |
@@ -2314,13 +2316,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. |
- cmp(r0, Operand::Zero()); |
- LoadRoot(r0, Heap::kUndefinedValueRootIndex, eq); |
- ldr(r0, MemOperand(r0), ne); |
- |
+ Label return_value_loaded; |
+ |
+ if (returns_handle) { |
+ Label load_return_value; |
+ cmp(r0, Operand::Zero()); |
+ b(eq, &load_return_value); |
+ // derefernce returned value |
+ ldr(r0, MemOperand(r0)); |
+ b(&return_value_loaded); |
+ bind(&load_return_value); |
+ } |
+ // load value from ReturnValue |
+ ldr(r0, MemOperand(fp, return_value_offset*kPointerSize)); |
+ bind(&return_value_loaded); |
// No more valid handles (the result handle was the last one). Restore |
// previous handle scope. |
str(r4, MemOperand(r7, kNextOffset)); |