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 3829 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3840 stub->CompilingCallsToThisStubIsGCSafe(isolate())); | 3840 stub->CompilingCallsToThisStubIsGCSafe(isolate())); |
3841 Jump(stub->GetCode(isolate()), RelocInfo::CODE_TARGET); | 3841 Jump(stub->GetCode(isolate()), RelocInfo::CODE_TARGET); |
3842 } | 3842 } |
3843 | 3843 |
3844 | 3844 |
3845 static int AddressOffset(ExternalReference ref0, ExternalReference ref1) { | 3845 static int AddressOffset(ExternalReference ref0, ExternalReference ref1) { |
3846 return ref0.address() - ref1.address(); | 3846 return ref0.address() - ref1.address(); |
3847 } | 3847 } |
3848 | 3848 |
3849 | 3849 |
3850 void MacroAssembler::CallApiFunctionAndReturn( | 3850 void MacroAssembler::CallApiFunctionAndReturn(ExternalReference function, |
3851 ExternalReference function, | 3851 Address function_address, |
3852 Address function_address, | 3852 ExternalReference thunk_ref, |
3853 ExternalReference thunk_ref, | 3853 Register thunk_last_arg, |
3854 Register thunk_last_arg, | 3854 int stack_space, |
3855 int stack_space, | 3855 int return_value_offset_from_fp) { |
3856 MemOperand return_value_operand, | |
3857 MemOperand* context_restore_operand) { | |
3858 ExternalReference next_address = | 3856 ExternalReference next_address = |
3859 ExternalReference::handle_scope_next_address(isolate()); | 3857 ExternalReference::handle_scope_next_address(isolate()); |
3860 const int kNextOffset = 0; | 3858 const int kNextOffset = 0; |
3861 const int kLimitOffset = AddressOffset( | 3859 const int kLimitOffset = AddressOffset( |
3862 ExternalReference::handle_scope_limit_address(isolate()), | 3860 ExternalReference::handle_scope_limit_address(isolate()), |
3863 next_address); | 3861 next_address); |
3864 const int kLevelOffset = AddressOffset( | 3862 const int kLevelOffset = AddressOffset( |
3865 ExternalReference::handle_scope_level_address(isolate()), | 3863 ExternalReference::handle_scope_level_address(isolate()), |
3866 next_address); | 3864 next_address); |
3867 | 3865 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3910 if (FLAG_log_timer_events) { | 3908 if (FLAG_log_timer_events) { |
3911 FrameScope frame(this, StackFrame::MANUAL); | 3909 FrameScope frame(this, StackFrame::MANUAL); |
3912 PushSafepointRegisters(); | 3910 PushSafepointRegisters(); |
3913 PrepareCallCFunction(1, a0); | 3911 PrepareCallCFunction(1, a0); |
3914 li(a0, Operand(ExternalReference::isolate_address(isolate()))); | 3912 li(a0, Operand(ExternalReference::isolate_address(isolate()))); |
3915 CallCFunction(ExternalReference::log_leave_external_function(isolate()), 1); | 3913 CallCFunction(ExternalReference::log_leave_external_function(isolate()), 1); |
3916 PopSafepointRegisters(); | 3914 PopSafepointRegisters(); |
3917 } | 3915 } |
3918 | 3916 |
3919 Label promote_scheduled_exception; | 3917 Label promote_scheduled_exception; |
3920 Label exception_handled; | |
3921 Label delete_allocated_handles; | 3918 Label delete_allocated_handles; |
3922 Label leave_exit_frame; | 3919 Label leave_exit_frame; |
3923 Label return_value_loaded; | 3920 Label return_value_loaded; |
3924 | 3921 |
3925 // Load value from ReturnValue. | 3922 // Load value from ReturnValue. |
3926 lw(v0, return_value_operand); | 3923 lw(v0, MemOperand(fp, return_value_offset_from_fp*kPointerSize)); |
3927 bind(&return_value_loaded); | 3924 bind(&return_value_loaded); |
3928 | 3925 |
3929 // No more valid handles (the result handle was the last one). Restore | 3926 // No more valid handles (the result handle was the last one). Restore |
3930 // previous handle scope. | 3927 // previous handle scope. |
3931 sw(s0, MemOperand(s3, kNextOffset)); | 3928 sw(s0, MemOperand(s3, kNextOffset)); |
3932 if (emit_debug_code()) { | 3929 if (emit_debug_code()) { |
3933 lw(a1, MemOperand(s3, kLevelOffset)); | 3930 lw(a1, MemOperand(s3, kLevelOffset)); |
3934 Check(eq, kUnexpectedLevelAfterReturnFromApiCall, a1, Operand(s2)); | 3931 Check(eq, kUnexpectedLevelAfterReturnFromApiCall, a1, Operand(s2)); |
3935 } | 3932 } |
3936 Subu(s2, s2, Operand(1)); | 3933 Subu(s2, s2, Operand(1)); |
3937 sw(s2, MemOperand(s3, kLevelOffset)); | 3934 sw(s2, MemOperand(s3, kLevelOffset)); |
3938 lw(at, MemOperand(s3, kLimitOffset)); | 3935 lw(at, MemOperand(s3, kLimitOffset)); |
3939 Branch(&delete_allocated_handles, ne, s1, Operand(at)); | 3936 Branch(&delete_allocated_handles, ne, s1, Operand(at)); |
3940 | 3937 |
3941 // Check if the function scheduled an exception. | 3938 // Check if the function scheduled an exception. |
3942 bind(&leave_exit_frame); | 3939 bind(&leave_exit_frame); |
3943 LoadRoot(t0, Heap::kTheHoleValueRootIndex); | 3940 LoadRoot(t0, Heap::kTheHoleValueRootIndex); |
3944 li(at, Operand(ExternalReference::scheduled_exception_address(isolate()))); | 3941 li(at, Operand(ExternalReference::scheduled_exception_address(isolate()))); |
3945 lw(t1, MemOperand(at)); | 3942 lw(t1, MemOperand(at)); |
3946 Branch(&promote_scheduled_exception, ne, t0, Operand(t1)); | 3943 Branch(&promote_scheduled_exception, ne, t0, Operand(t1)); |
3947 bind(&exception_handled); | |
3948 | |
3949 bool restore_context = context_restore_operand != NULL; | |
3950 if (restore_context) { | |
3951 lw(cp, *context_restore_operand); | |
3952 } | |
3953 li(s0, Operand(stack_space)); | 3944 li(s0, Operand(stack_space)); |
3954 LeaveExitFrame(false, s0, !restore_context, EMIT_RETURN); | 3945 LeaveExitFrame(false, s0, true); |
3955 | 3946 |
3956 bind(&promote_scheduled_exception); | 3947 bind(&promote_scheduled_exception); |
3957 { | 3948 TailCallExternalReference( |
3958 FrameScope frame(this, StackFrame::INTERNAL); | 3949 ExternalReference(Runtime::kPromoteScheduledException, isolate()), |
3959 CallExternalReference( | 3950 0, |
3960 ExternalReference(Runtime::kPromoteScheduledException, isolate()), | 3951 1); |
3961 0); | |
3962 } | |
3963 jmp(&exception_handled); | |
3964 | 3952 |
3965 // HandleScope limit has changed. Delete allocated extensions. | 3953 // HandleScope limit has changed. Delete allocated extensions. |
3966 bind(&delete_allocated_handles); | 3954 bind(&delete_allocated_handles); |
3967 sw(s1, MemOperand(s3, kLimitOffset)); | 3955 sw(s1, MemOperand(s3, kLimitOffset)); |
3968 mov(s0, v0); | 3956 mov(s0, v0); |
3969 mov(a0, v0); | 3957 mov(a0, v0); |
3970 PrepareCallCFunction(1, s1); | 3958 PrepareCallCFunction(1, s1); |
3971 li(a0, Operand(ExternalReference::isolate_address(isolate()))); | 3959 li(a0, Operand(ExternalReference::isolate_address(isolate()))); |
3972 CallCFunction(ExternalReference::delete_handle_scope_extensions(isolate()), | 3960 CallCFunction(ExternalReference::delete_handle_scope_extensions(isolate()), |
3973 1); | 3961 1); |
(...skipping 715 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4689 | 4677 |
4690 // Set the exit frame sp value to point just before the return address | 4678 // Set the exit frame sp value to point just before the return address |
4691 // location. | 4679 // location. |
4692 addiu(at, sp, kPointerSize); | 4680 addiu(at, sp, kPointerSize); |
4693 sw(at, MemOperand(fp, ExitFrameConstants::kSPOffset)); | 4681 sw(at, MemOperand(fp, ExitFrameConstants::kSPOffset)); |
4694 } | 4682 } |
4695 | 4683 |
4696 | 4684 |
4697 void MacroAssembler::LeaveExitFrame(bool save_doubles, | 4685 void MacroAssembler::LeaveExitFrame(bool save_doubles, |
4698 Register argument_count, | 4686 Register argument_count, |
4699 bool restore_context, | |
4700 bool do_return) { | 4687 bool do_return) { |
4701 // Optionally restore all double registers. | 4688 // Optionally restore all double registers. |
4702 if (save_doubles) { | 4689 if (save_doubles) { |
4703 // Remember: we only need to restore every 2nd double FPU value. | 4690 // Remember: we only need to restore every 2nd double FPU value. |
4704 lw(t8, MemOperand(fp, ExitFrameConstants::kSPOffset)); | 4691 lw(t8, MemOperand(fp, ExitFrameConstants::kSPOffset)); |
4705 for (int i = 0; i < FPURegister::kMaxNumRegisters; i+=2) { | 4692 for (int i = 0; i < FPURegister::kMaxNumRegisters; i+=2) { |
4706 FPURegister reg = FPURegister::from_code(i); | 4693 FPURegister reg = FPURegister::from_code(i); |
4707 ldc1(reg, MemOperand(t8, i * kDoubleSize + kPointerSize)); | 4694 ldc1(reg, MemOperand(t8, i * kDoubleSize + kPointerSize)); |
4708 } | 4695 } |
4709 } | 4696 } |
4710 | 4697 |
4711 // Clear top frame. | 4698 // Clear top frame. |
4712 li(t8, Operand(ExternalReference(Isolate::kCEntryFPAddress, isolate()))); | 4699 li(t8, Operand(ExternalReference(Isolate::kCEntryFPAddress, isolate()))); |
4713 sw(zero_reg, MemOperand(t8)); | 4700 sw(zero_reg, MemOperand(t8)); |
4714 | 4701 |
4715 // Restore current context from top and clear it in debug mode. | 4702 // Restore current context from top and clear it in debug mode. |
4716 if (restore_context) { | 4703 li(t8, Operand(ExternalReference(Isolate::kContextAddress, isolate()))); |
4717 li(t8, Operand(ExternalReference(Isolate::kContextAddress, isolate()))); | 4704 lw(cp, MemOperand(t8)); |
4718 lw(cp, MemOperand(t8)); | |
4719 } | |
4720 #ifdef DEBUG | 4705 #ifdef DEBUG |
4721 li(t8, Operand(ExternalReference(Isolate::kContextAddress, isolate()))); | |
4722 sw(a3, MemOperand(t8)); | 4706 sw(a3, MemOperand(t8)); |
4723 #endif | 4707 #endif |
4724 | 4708 |
4725 // Pop the arguments, restore registers, and return. | 4709 // Pop the arguments, restore registers, and return. |
4726 mov(sp, fp); // Respect ABI stack constraint. | 4710 mov(sp, fp); // Respect ABI stack constraint. |
4727 lw(fp, MemOperand(sp, ExitFrameConstants::kCallerFPOffset)); | 4711 lw(fp, MemOperand(sp, ExitFrameConstants::kCallerFPOffset)); |
4728 lw(ra, MemOperand(sp, ExitFrameConstants::kCallerPCOffset)); | 4712 lw(ra, MemOperand(sp, ExitFrameConstants::kCallerPCOffset)); |
4729 | 4713 |
4730 if (argument_count.is_valid()) { | 4714 if (argument_count.is_valid()) { |
4731 sll(t8, argument_count, kPointerSizeLog2); | 4715 sll(t8, argument_count, kPointerSizeLog2); |
(...skipping 880 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5612 opcode == BGTZL); | 5596 opcode == BGTZL); |
5613 opcode = (cond == eq) ? BEQ : BNE; | 5597 opcode = (cond == eq) ? BEQ : BNE; |
5614 instr = (instr & ~kOpcodeMask) | opcode; | 5598 instr = (instr & ~kOpcodeMask) | opcode; |
5615 masm_.emit(instr); | 5599 masm_.emit(instr); |
5616 } | 5600 } |
5617 | 5601 |
5618 | 5602 |
5619 } } // namespace v8::internal | 5603 } } // namespace v8::internal |
5620 | 5604 |
5621 #endif // V8_TARGET_ARCH_MIPS | 5605 #endif // V8_TARGET_ARCH_MIPS |
OLD | NEW |