OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 3911 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3922 Jump(stub->GetCode(isolate()), RelocInfo::CODE_TARGET); | 3922 Jump(stub->GetCode(isolate()), RelocInfo::CODE_TARGET); |
3923 } | 3923 } |
3924 | 3924 |
3925 | 3925 |
3926 static int AddressOffset(ExternalReference ref0, ExternalReference ref1) { | 3926 static int AddressOffset(ExternalReference ref0, ExternalReference ref1) { |
3927 return ref0.address() - ref1.address(); | 3927 return ref0.address() - ref1.address(); |
3928 } | 3928 } |
3929 | 3929 |
3930 | 3930 |
3931 void MacroAssembler::CallApiFunctionAndReturn(ExternalReference function, | 3931 void MacroAssembler::CallApiFunctionAndReturn(ExternalReference function, |
3932 int stack_space) { | 3932 int stack_space, |
| 3933 bool returns_handle, |
| 3934 int return_value_offset_from_fp) { |
3933 ExternalReference next_address = | 3935 ExternalReference next_address = |
3934 ExternalReference::handle_scope_next_address(isolate()); | 3936 ExternalReference::handle_scope_next_address(isolate()); |
3935 const int kNextOffset = 0; | 3937 const int kNextOffset = 0; |
3936 const int kLimitOffset = AddressOffset( | 3938 const int kLimitOffset = AddressOffset( |
3937 ExternalReference::handle_scope_limit_address(isolate()), | 3939 ExternalReference::handle_scope_limit_address(isolate()), |
3938 next_address); | 3940 next_address); |
3939 const int kLevelOffset = AddressOffset( | 3941 const int kLevelOffset = AddressOffset( |
3940 ExternalReference::handle_scope_level_address(isolate()), | 3942 ExternalReference::handle_scope_level_address(isolate()), |
3941 next_address); | 3943 next_address); |
3942 | 3944 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3978 PopSafepointRegisters(); | 3980 PopSafepointRegisters(); |
3979 } | 3981 } |
3980 | 3982 |
3981 // As mentioned above, on MIPS a pointer is returned - we need to dereference | 3983 // As mentioned above, on MIPS a pointer is returned - we need to dereference |
3982 // it to get the actual return value (which is also a pointer). | 3984 // it to get the actual return value (which is also a pointer). |
3983 lw(v0, MemOperand(v0)); | 3985 lw(v0, MemOperand(v0)); |
3984 | 3986 |
3985 Label promote_scheduled_exception; | 3987 Label promote_scheduled_exception; |
3986 Label delete_allocated_handles; | 3988 Label delete_allocated_handles; |
3987 Label leave_exit_frame; | 3989 Label leave_exit_frame; |
| 3990 Label return_value_loaded; |
3988 | 3991 |
3989 // If result is non-zero, dereference to get the result value | 3992 if (returns_handle) { |
3990 // otherwise set it to undefined. | 3993 Label load_return_value; |
3991 Label skip; | 3994 Branch(&load_return_value, eq, v0, Operand(zero_reg)); |
3992 LoadRoot(a0, Heap::kUndefinedValueRootIndex); | 3995 // Dereference returned value. |
3993 Branch(&skip, eq, v0, Operand(zero_reg)); | 3996 lw(v0, MemOperand(v0)); |
3994 lw(a0, MemOperand(v0)); | 3997 b(&return_value_loaded); |
3995 bind(&skip); | 3998 nop(); |
3996 mov(v0, a0); | 3999 bind(&load_return_value); |
| 4000 } |
| 4001 // Load value from ReturnValue. |
| 4002 lw(v0, MemOperand(fp, return_value_offset_from_fp*kPointerSize)); |
| 4003 bind(&return_value_loaded); |
3997 | 4004 |
3998 // No more valid handles (the result handle was the last one). Restore | 4005 // No more valid handles (the result handle was the last one). Restore |
3999 // previous handle scope. | 4006 // previous handle scope. |
4000 sw(s0, MemOperand(s3, kNextOffset)); | 4007 sw(s0, MemOperand(s3, kNextOffset)); |
4001 if (emit_debug_code()) { | 4008 if (emit_debug_code()) { |
4002 lw(a1, MemOperand(s3, kLevelOffset)); | 4009 lw(a1, MemOperand(s3, kLevelOffset)); |
4003 Check(eq, "Unexpected level after return from api call", a1, Operand(s2)); | 4010 Check(eq, "Unexpected level after return from api call", a1, Operand(s2)); |
4004 } | 4011 } |
4005 Subu(s2, s2, Operand(1)); | 4012 Subu(s2, s2, Operand(1)); |
4006 sw(s2, MemOperand(s3, kLevelOffset)); | 4013 sw(s2, MemOperand(s3, kLevelOffset)); |
(...skipping 1530 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5537 opcode == BGTZL); | 5544 opcode == BGTZL); |
5538 opcode = (cond == eq) ? BEQ : BNE; | 5545 opcode = (cond == eq) ? BEQ : BNE; |
5539 instr = (instr & ~kOpcodeMask) | opcode; | 5546 instr = (instr & ~kOpcodeMask) | opcode; |
5540 masm_.emit(instr); | 5547 masm_.emit(instr); |
5541 } | 5548 } |
5542 | 5549 |
5543 | 5550 |
5544 } } // namespace v8::internal | 5551 } } // namespace v8::internal |
5545 | 5552 |
5546 #endif // V8_TARGET_ARCH_MIPS | 5553 #endif // V8_TARGET_ARCH_MIPS |
OLD | NEW |