OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #if V8_TARGET_ARCH_MIPS64 | 7 #if V8_TARGET_ARCH_MIPS64 |
8 | 8 |
9 #include "src/bootstrapper.h" | 9 #include "src/bootstrapper.h" |
10 #include "src/code-stubs.h" | 10 #include "src/code-stubs.h" |
(...skipping 4855 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4866 | 4866 |
4867 Label fast_elements_case; | 4867 Label fast_elements_case; |
4868 __ Branch(&fast_elements_case, eq, a3, Operand(FAST_ELEMENTS)); | 4868 __ Branch(&fast_elements_case, eq, a3, Operand(FAST_ELEMENTS)); |
4869 GenerateCase(masm, FAST_HOLEY_ELEMENTS); | 4869 GenerateCase(masm, FAST_HOLEY_ELEMENTS); |
4870 | 4870 |
4871 __ bind(&fast_elements_case); | 4871 __ bind(&fast_elements_case); |
4872 GenerateCase(masm, FAST_ELEMENTS); | 4872 GenerateCase(masm, FAST_ELEMENTS); |
4873 } | 4873 } |
4874 | 4874 |
4875 | 4875 |
| 4876 static int AddressOffset(ExternalReference ref0, ExternalReference ref1) { |
| 4877 int64_t offset = (ref0.address() - ref1.address()); |
| 4878 DCHECK(static_cast<int>(offset) == offset); |
| 4879 return static_cast<int>(offset); |
| 4880 } |
| 4881 |
| 4882 |
| 4883 // Calls an API function. Allocates HandleScope, extracts returned value |
| 4884 // from handle and propagates exceptions. Restores context. stack_space |
| 4885 // - space to be unwound on exit (includes the call JS arguments space and |
| 4886 // the additional space allocated for the fast call). |
| 4887 static void CallApiFunctionAndReturn(MacroAssembler* masm, |
| 4888 Register function_address, |
| 4889 ExternalReference thunk_ref, |
| 4890 int stack_space, |
| 4891 MemOperand* stack_space_operand, |
| 4892 MemOperand return_value_operand, |
| 4893 MemOperand* context_restore_operand) { |
| 4894 Isolate* isolate = masm->isolate(); |
| 4895 ExternalReference next_address = |
| 4896 ExternalReference::handle_scope_next_address(isolate); |
| 4897 const int kNextOffset = 0; |
| 4898 const int kLimitOffset = AddressOffset( |
| 4899 ExternalReference::handle_scope_limit_address(isolate), next_address); |
| 4900 const int kLevelOffset = AddressOffset( |
| 4901 ExternalReference::handle_scope_level_address(isolate), next_address); |
| 4902 |
| 4903 DCHECK(function_address.is(a1) || function_address.is(a2)); |
| 4904 |
| 4905 Label profiler_disabled; |
| 4906 Label end_profiler_check; |
| 4907 __ li(t9, Operand(ExternalReference::is_profiling_address(isolate))); |
| 4908 __ lb(t9, MemOperand(t9, 0)); |
| 4909 __ Branch(&profiler_disabled, eq, t9, Operand(zero_reg)); |
| 4910 |
| 4911 // Additional parameter is the address of the actual callback. |
| 4912 __ li(t9, Operand(thunk_ref)); |
| 4913 __ jmp(&end_profiler_check); |
| 4914 |
| 4915 __ bind(&profiler_disabled); |
| 4916 __ mov(t9, function_address); |
| 4917 __ bind(&end_profiler_check); |
| 4918 |
| 4919 // Allocate HandleScope in callee-save registers. |
| 4920 __ li(s3, Operand(next_address)); |
| 4921 __ ld(s0, MemOperand(s3, kNextOffset)); |
| 4922 __ ld(s1, MemOperand(s3, kLimitOffset)); |
| 4923 __ ld(s2, MemOperand(s3, kLevelOffset)); |
| 4924 __ Daddu(s2, s2, Operand(1)); |
| 4925 __ sd(s2, MemOperand(s3, kLevelOffset)); |
| 4926 |
| 4927 if (FLAG_log_timer_events) { |
| 4928 FrameScope frame(masm, StackFrame::MANUAL); |
| 4929 __ PushSafepointRegisters(); |
| 4930 __ PrepareCallCFunction(1, a0); |
| 4931 __ li(a0, Operand(ExternalReference::isolate_address(isolate))); |
| 4932 __ CallCFunction(ExternalReference::log_enter_external_function(isolate), |
| 4933 1); |
| 4934 __ PopSafepointRegisters(); |
| 4935 } |
| 4936 |
| 4937 // Native call returns to the DirectCEntry stub which redirects to the |
| 4938 // return address pushed on stack (could have moved after GC). |
| 4939 // DirectCEntry stub itself is generated early and never moves. |
| 4940 DirectCEntryStub stub(isolate); |
| 4941 stub.GenerateCall(masm, t9); |
| 4942 |
| 4943 if (FLAG_log_timer_events) { |
| 4944 FrameScope frame(masm, StackFrame::MANUAL); |
| 4945 __ PushSafepointRegisters(); |
| 4946 __ PrepareCallCFunction(1, a0); |
| 4947 __ li(a0, Operand(ExternalReference::isolate_address(isolate))); |
| 4948 __ CallCFunction(ExternalReference::log_leave_external_function(isolate), |
| 4949 1); |
| 4950 __ PopSafepointRegisters(); |
| 4951 } |
| 4952 |
| 4953 Label promote_scheduled_exception; |
| 4954 Label exception_handled; |
| 4955 Label delete_allocated_handles; |
| 4956 Label leave_exit_frame; |
| 4957 Label return_value_loaded; |
| 4958 |
| 4959 // Load value from ReturnValue. |
| 4960 __ ld(v0, return_value_operand); |
| 4961 __ bind(&return_value_loaded); |
| 4962 |
| 4963 // No more valid handles (the result handle was the last one). Restore |
| 4964 // previous handle scope. |
| 4965 __ sd(s0, MemOperand(s3, kNextOffset)); |
| 4966 if (__ emit_debug_code()) { |
| 4967 __ ld(a1, MemOperand(s3, kLevelOffset)); |
| 4968 __ Check(eq, kUnexpectedLevelAfterReturnFromApiCall, a1, Operand(s2)); |
| 4969 } |
| 4970 __ Dsubu(s2, s2, Operand(1)); |
| 4971 __ sd(s2, MemOperand(s3, kLevelOffset)); |
| 4972 __ ld(at, MemOperand(s3, kLimitOffset)); |
| 4973 __ Branch(&delete_allocated_handles, ne, s1, Operand(at)); |
| 4974 |
| 4975 // Check if the function scheduled an exception. |
| 4976 __ bind(&leave_exit_frame); |
| 4977 __ LoadRoot(a4, Heap::kTheHoleValueRootIndex); |
| 4978 __ li(at, Operand(ExternalReference::scheduled_exception_address(isolate))); |
| 4979 __ ld(a5, MemOperand(at)); |
| 4980 __ Branch(&promote_scheduled_exception, ne, a4, Operand(a5)); |
| 4981 __ bind(&exception_handled); |
| 4982 |
| 4983 bool restore_context = context_restore_operand != NULL; |
| 4984 if (restore_context) { |
| 4985 __ ld(cp, *context_restore_operand); |
| 4986 } |
| 4987 if (stack_space_operand != NULL) { |
| 4988 __ lw(s0, *stack_space_operand); |
| 4989 } else { |
| 4990 __ li(s0, Operand(stack_space)); |
| 4991 } |
| 4992 __ LeaveExitFrame(false, s0, !restore_context, EMIT_RETURN, |
| 4993 stack_space_operand != NULL); |
| 4994 __ bind(&promote_scheduled_exception); |
| 4995 { |
| 4996 FrameScope frame(masm, StackFrame::INTERNAL); |
| 4997 __ CallExternalReference( |
| 4998 ExternalReference(Runtime::kPromoteScheduledException, isolate), 0); |
| 4999 } |
| 5000 __ jmp(&exception_handled); |
| 5001 |
| 5002 // HandleScope limit has changed. Delete allocated extensions. |
| 5003 __ bind(&delete_allocated_handles); |
| 5004 __ sd(s1, MemOperand(s3, kLimitOffset)); |
| 5005 __ mov(s0, v0); |
| 5006 __ mov(a0, v0); |
| 5007 __ PrepareCallCFunction(1, s1); |
| 5008 __ li(a0, Operand(ExternalReference::isolate_address(isolate))); |
| 5009 __ CallCFunction(ExternalReference::delete_handle_scope_extensions(isolate), |
| 5010 1); |
| 5011 __ mov(v0, s0); |
| 5012 __ jmp(&leave_exit_frame); |
| 5013 } |
| 5014 |
| 5015 |
4876 static void CallApiFunctionStubHelper(MacroAssembler* masm, | 5016 static void CallApiFunctionStubHelper(MacroAssembler* masm, |
4877 const ParameterCount& argc, | 5017 const ParameterCount& argc, |
4878 bool return_first_arg, | 5018 bool return_first_arg, |
4879 bool call_data_undefined) { | 5019 bool call_data_undefined) { |
4880 // ----------- S t a t e ------------- | 5020 // ----------- S t a t e ------------- |
4881 // -- a0 : callee | 5021 // -- a0 : callee |
4882 // -- a4 : call_data | 5022 // -- a4 : call_data |
4883 // -- a2 : holder | 5023 // -- a2 : holder |
4884 // -- a1 : api_function_address | 5024 // -- a1 : api_function_address |
4885 // -- a3 : number of arguments if argc is a register | 5025 // -- a3 : number of arguments if argc is a register |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4979 return_value_offset = 2 + FCA::kReturnValueOffset; | 5119 return_value_offset = 2 + FCA::kReturnValueOffset; |
4980 } | 5120 } |
4981 MemOperand return_value_operand(fp, return_value_offset * kPointerSize); | 5121 MemOperand return_value_operand(fp, return_value_offset * kPointerSize); |
4982 int stack_space = 0; | 5122 int stack_space = 0; |
4983 MemOperand is_construct_call_operand = MemOperand(sp, 4 * kPointerSize); | 5123 MemOperand is_construct_call_operand = MemOperand(sp, 4 * kPointerSize); |
4984 MemOperand* stack_space_operand = &is_construct_call_operand; | 5124 MemOperand* stack_space_operand = &is_construct_call_operand; |
4985 if (argc.is_immediate()) { | 5125 if (argc.is_immediate()) { |
4986 stack_space = argc.immediate() + FCA::kArgsLength + 1; | 5126 stack_space = argc.immediate() + FCA::kArgsLength + 1; |
4987 stack_space_operand = NULL; | 5127 stack_space_operand = NULL; |
4988 } | 5128 } |
4989 __ CallApiFunctionAndReturn(api_function_address, thunk_ref, stack_space, | 5129 CallApiFunctionAndReturn(masm, api_function_address, thunk_ref, stack_space, |
4990 stack_space_operand, return_value_operand, | 5130 stack_space_operand, return_value_operand, |
4991 &context_restore_operand); | 5131 &context_restore_operand); |
4992 } | 5132 } |
4993 | 5133 |
4994 | 5134 |
4995 void CallApiFunctionStub::Generate(MacroAssembler* masm) { | 5135 void CallApiFunctionStub::Generate(MacroAssembler* masm) { |
4996 bool call_data_undefined = this->call_data_undefined(); | 5136 bool call_data_undefined = this->call_data_undefined(); |
4997 CallApiFunctionStubHelper(masm, ParameterCount(a3), false, | 5137 CallApiFunctionStubHelper(masm, ParameterCount(a3), false, |
4998 call_data_undefined); | 5138 call_data_undefined); |
4999 } | 5139 } |
5000 | 5140 |
5001 | 5141 |
(...skipping 26 matching lines...) Expand all Loading... |
5028 | 5168 |
5029 // Create PropertyAccessorInfo instance on the stack above the exit frame with | 5169 // Create PropertyAccessorInfo instance on the stack above the exit frame with |
5030 // a1 (internal::Object** args_) as the data. | 5170 // a1 (internal::Object** args_) as the data. |
5031 __ sd(a1, MemOperand(sp, 1 * kPointerSize)); | 5171 __ sd(a1, MemOperand(sp, 1 * kPointerSize)); |
5032 __ Daddu(a1, sp, Operand(1 * kPointerSize)); // a1 = AccessorInfo& | 5172 __ Daddu(a1, sp, Operand(1 * kPointerSize)); // a1 = AccessorInfo& |
5033 | 5173 |
5034 const int kStackUnwindSpace = PropertyCallbackArguments::kArgsLength + 1; | 5174 const int kStackUnwindSpace = PropertyCallbackArguments::kArgsLength + 1; |
5035 | 5175 |
5036 ExternalReference thunk_ref = | 5176 ExternalReference thunk_ref = |
5037 ExternalReference::invoke_accessor_getter_callback(isolate()); | 5177 ExternalReference::invoke_accessor_getter_callback(isolate()); |
5038 __ CallApiFunctionAndReturn(api_function_address, thunk_ref, | 5178 CallApiFunctionAndReturn(masm, api_function_address, thunk_ref, |
5039 kStackUnwindSpace, NULL, | 5179 kStackUnwindSpace, NULL, |
5040 MemOperand(fp, 6 * kPointerSize), NULL); | 5180 MemOperand(fp, 6 * kPointerSize), NULL); |
5041 } | 5181 } |
5042 | 5182 |
5043 | 5183 |
5044 #undef __ | 5184 #undef __ |
5045 | 5185 |
5046 } } // namespace v8::internal | 5186 } } // namespace v8::internal |
5047 | 5187 |
5048 #endif // V8_TARGET_ARCH_MIPS64 | 5188 #endif // V8_TARGET_ARCH_MIPS64 |
OLD | NEW |