Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(115)

Side by Side Diff: src/mips/code-stubs-mips.cc

Issue 860013002: move CallApiFunctionAndReturn to code-stubs-* (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/ia32/macro-assembler-ia32.cc ('k') | src/mips/macro-assembler-mips.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_MIPS 7 #if V8_TARGET_ARCH_MIPS
8 8
9 #include "src/base/bits.h" 9 #include "src/base/bits.h"
10 #include "src/bootstrapper.h" 10 #include "src/bootstrapper.h"
(...skipping 4815 matching lines...) Expand 10 before | Expand all | Expand 10 after
4826 4826
4827 Label fast_elements_case; 4827 Label fast_elements_case;
4828 __ Branch(&fast_elements_case, eq, a3, Operand(FAST_ELEMENTS)); 4828 __ Branch(&fast_elements_case, eq, a3, Operand(FAST_ELEMENTS));
4829 GenerateCase(masm, FAST_HOLEY_ELEMENTS); 4829 GenerateCase(masm, FAST_HOLEY_ELEMENTS);
4830 4830
4831 __ bind(&fast_elements_case); 4831 __ bind(&fast_elements_case);
4832 GenerateCase(masm, FAST_ELEMENTS); 4832 GenerateCase(masm, FAST_ELEMENTS);
4833 } 4833 }
4834 4834
4835 4835
4836 static int AddressOffset(ExternalReference ref0, ExternalReference ref1) {
4837 return ref0.address() - ref1.address();
4838 }
4839
4840
4841 // Calls an API function. Allocates HandleScope, extracts returned value
4842 // from handle and propagates exceptions. Restores context. stack_space
4843 // - space to be unwound on exit (includes the call JS arguments space and
4844 // the additional space allocated for the fast call).
4845 static void CallApiFunctionAndReturn(MacroAssembler* masm,
4846 Register function_address,
4847 ExternalReference thunk_ref,
4848 int stack_space,
4849 MemOperand* stack_space_operand,
4850 MemOperand return_value_operand,
4851 MemOperand* context_restore_operand) {
4852 Isolate* isolate = masm->isolate();
4853 ExternalReference next_address =
4854 ExternalReference::handle_scope_next_address(isolate);
4855 const int kNextOffset = 0;
4856 const int kLimitOffset = AddressOffset(
4857 ExternalReference::handle_scope_limit_address(isolate), next_address);
4858 const int kLevelOffset = AddressOffset(
4859 ExternalReference::handle_scope_level_address(isolate), next_address);
4860
4861 DCHECK(function_address.is(a1) || function_address.is(a2));
4862
4863 Label profiler_disabled;
4864 Label end_profiler_check;
4865 __ li(t9, Operand(ExternalReference::is_profiling_address(isolate)));
4866 __ lb(t9, MemOperand(t9, 0));
4867 __ Branch(&profiler_disabled, eq, t9, Operand(zero_reg));
4868
4869 // Additional parameter is the address of the actual callback.
4870 __ li(t9, Operand(thunk_ref));
4871 __ jmp(&end_profiler_check);
4872
4873 __ bind(&profiler_disabled);
4874 __ mov(t9, function_address);
4875 __ bind(&end_profiler_check);
4876
4877 // Allocate HandleScope in callee-save registers.
4878 __ li(s3, Operand(next_address));
4879 __ lw(s0, MemOperand(s3, kNextOffset));
4880 __ lw(s1, MemOperand(s3, kLimitOffset));
4881 __ lw(s2, MemOperand(s3, kLevelOffset));
4882 __ Addu(s2, s2, Operand(1));
4883 __ sw(s2, MemOperand(s3, kLevelOffset));
4884
4885 if (FLAG_log_timer_events) {
4886 FrameScope frame(masm, StackFrame::MANUAL);
4887 __ PushSafepointRegisters();
4888 __ PrepareCallCFunction(1, a0);
4889 __ li(a0, Operand(ExternalReference::isolate_address(isolate)));
4890 __ CallCFunction(ExternalReference::log_enter_external_function(isolate),
4891 1);
4892 __ PopSafepointRegisters();
4893 }
4894
4895 // Native call returns to the DirectCEntry stub which redirects to the
4896 // return address pushed on stack (could have moved after GC).
4897 // DirectCEntry stub itself is generated early and never moves.
4898 DirectCEntryStub stub(isolate);
4899 stub.GenerateCall(masm, t9);
4900
4901 if (FLAG_log_timer_events) {
4902 FrameScope frame(masm, StackFrame::MANUAL);
4903 __ PushSafepointRegisters();
4904 __ PrepareCallCFunction(1, a0);
4905 __ li(a0, Operand(ExternalReference::isolate_address(isolate)));
4906 __ CallCFunction(ExternalReference::log_leave_external_function(isolate),
4907 1);
4908 __ PopSafepointRegisters();
4909 }
4910
4911 Label promote_scheduled_exception;
4912 Label exception_handled;
4913 Label delete_allocated_handles;
4914 Label leave_exit_frame;
4915 Label return_value_loaded;
4916
4917 // Load value from ReturnValue.
4918 __ lw(v0, return_value_operand);
4919 __ bind(&return_value_loaded);
4920
4921 // No more valid handles (the result handle was the last one). Restore
4922 // previous handle scope.
4923 __ sw(s0, MemOperand(s3, kNextOffset));
4924 if (__ emit_debug_code()) {
4925 __ lw(a1, MemOperand(s3, kLevelOffset));
4926 __ Check(eq, kUnexpectedLevelAfterReturnFromApiCall, a1, Operand(s2));
4927 }
4928 __ Subu(s2, s2, Operand(1));
4929 __ sw(s2, MemOperand(s3, kLevelOffset));
4930 __ lw(at, MemOperand(s3, kLimitOffset));
4931 __ Branch(&delete_allocated_handles, ne, s1, Operand(at));
4932
4933 // Check if the function scheduled an exception.
4934 __ bind(&leave_exit_frame);
4935 __ LoadRoot(t0, Heap::kTheHoleValueRootIndex);
4936 __ li(at, Operand(ExternalReference::scheduled_exception_address(isolate)));
4937 __ lw(t1, MemOperand(at));
4938 __ Branch(&promote_scheduled_exception, ne, t0, Operand(t1));
4939 __ bind(&exception_handled);
4940
4941 bool restore_context = context_restore_operand != NULL;
4942 if (restore_context) {
4943 __ lw(cp, *context_restore_operand);
4944 }
4945 if (stack_space_operand != NULL) {
4946 __ lw(s0, *stack_space_operand);
4947 } else {
4948 __ li(s0, Operand(stack_space));
4949 }
4950 __ LeaveExitFrame(false, s0, !restore_context, EMIT_RETURN,
4951 stack_space_operand != NULL);
4952
4953 __ bind(&promote_scheduled_exception);
4954 {
4955 FrameScope frame(masm, StackFrame::INTERNAL);
4956 __ CallExternalReference(
4957 ExternalReference(Runtime::kPromoteScheduledException, isolate), 0);
4958 }
4959 __ jmp(&exception_handled);
4960
4961 // HandleScope limit has changed. Delete allocated extensions.
4962 __ bind(&delete_allocated_handles);
4963 __ sw(s1, MemOperand(s3, kLimitOffset));
4964 __ mov(s0, v0);
4965 __ mov(a0, v0);
4966 __ PrepareCallCFunction(1, s1);
4967 __ li(a0, Operand(ExternalReference::isolate_address(isolate)));
4968 __ CallCFunction(ExternalReference::delete_handle_scope_extensions(isolate),
4969 1);
4970 __ mov(v0, s0);
4971 __ jmp(&leave_exit_frame);
4972 }
4973
4974
4836 static void CallApiFunctionStubHelper(MacroAssembler* masm, 4975 static void CallApiFunctionStubHelper(MacroAssembler* masm,
4837 const ParameterCount& argc, 4976 const ParameterCount& argc,
4838 bool return_first_arg, 4977 bool return_first_arg,
4839 bool call_data_undefined) { 4978 bool call_data_undefined) {
4840 // ----------- S t a t e ------------- 4979 // ----------- S t a t e -------------
4841 // -- a0 : callee 4980 // -- a0 : callee
4842 // -- t0 : call_data 4981 // -- t0 : call_data
4843 // -- a2 : holder 4982 // -- a2 : holder
4844 // -- a1 : api_function_address 4983 // -- a1 : api_function_address
4845 // -- a3 : number of arguments if argc is a register 4984 // -- a3 : number of arguments if argc is a register
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
4940 } 5079 }
4941 MemOperand return_value_operand(fp, return_value_offset * kPointerSize); 5080 MemOperand return_value_operand(fp, return_value_offset * kPointerSize);
4942 int stack_space = 0; 5081 int stack_space = 0;
4943 MemOperand is_construct_call_operand = 5082 MemOperand is_construct_call_operand =
4944 MemOperand(sp, 4 * kPointerSize + kCArgsSlotsSize); 5083 MemOperand(sp, 4 * kPointerSize + kCArgsSlotsSize);
4945 MemOperand* stack_space_operand = &is_construct_call_operand; 5084 MemOperand* stack_space_operand = &is_construct_call_operand;
4946 if (argc.is_immediate()) { 5085 if (argc.is_immediate()) {
4947 stack_space = argc.immediate() + FCA::kArgsLength + 1; 5086 stack_space = argc.immediate() + FCA::kArgsLength + 1;
4948 stack_space_operand = NULL; 5087 stack_space_operand = NULL;
4949 } 5088 }
4950 __ CallApiFunctionAndReturn(api_function_address, thunk_ref, stack_space, 5089 CallApiFunctionAndReturn(masm, api_function_address, thunk_ref, stack_space,
4951 stack_space_operand, return_value_operand, 5090 stack_space_operand, return_value_operand,
4952 &context_restore_operand); 5091 &context_restore_operand);
4953 } 5092 }
4954 5093
4955 5094
4956 void CallApiFunctionStub::Generate(MacroAssembler* masm) { 5095 void CallApiFunctionStub::Generate(MacroAssembler* masm) {
4957 bool call_data_undefined = this->call_data_undefined(); 5096 bool call_data_undefined = this->call_data_undefined();
4958 CallApiFunctionStubHelper(masm, ParameterCount(a3), false, 5097 CallApiFunctionStubHelper(masm, ParameterCount(a3), false,
4959 call_data_undefined); 5098 call_data_undefined);
4960 } 5099 }
4961 5100
4962 5101
(...skipping 26 matching lines...) Expand all
4989 5128
4990 // Create PropertyAccessorInfo instance on the stack above the exit frame with 5129 // Create PropertyAccessorInfo instance on the stack above the exit frame with
4991 // a1 (internal::Object** args_) as the data. 5130 // a1 (internal::Object** args_) as the data.
4992 __ sw(a1, MemOperand(sp, 1 * kPointerSize)); 5131 __ sw(a1, MemOperand(sp, 1 * kPointerSize));
4993 __ Addu(a1, sp, Operand(1 * kPointerSize)); // a1 = AccessorInfo& 5132 __ Addu(a1, sp, Operand(1 * kPointerSize)); // a1 = AccessorInfo&
4994 5133
4995 const int kStackUnwindSpace = PropertyCallbackArguments::kArgsLength + 1; 5134 const int kStackUnwindSpace = PropertyCallbackArguments::kArgsLength + 1;
4996 5135
4997 ExternalReference thunk_ref = 5136 ExternalReference thunk_ref =
4998 ExternalReference::invoke_accessor_getter_callback(isolate()); 5137 ExternalReference::invoke_accessor_getter_callback(isolate());
4999 __ CallApiFunctionAndReturn(api_function_address, thunk_ref, 5138 CallApiFunctionAndReturn(masm, api_function_address, thunk_ref,
5000 kStackUnwindSpace, NULL, 5139 kStackUnwindSpace, NULL,
5001 MemOperand(fp, 6 * kPointerSize), NULL); 5140 MemOperand(fp, 6 * kPointerSize), NULL);
5002 } 5141 }
5003 5142
5004 5143
5005 #undef __ 5144 #undef __
5006 5145
5007 } } // namespace v8::internal 5146 } } // namespace v8::internal
5008 5147
5009 #endif // V8_TARGET_ARCH_MIPS 5148 #endif // V8_TARGET_ARCH_MIPS
OLDNEW
« no previous file with comments | « src/ia32/macro-assembler-ia32.cc ('k') | src/mips/macro-assembler-mips.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698