OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 #if V8_TARGET_ARCH_ARM64 | 5 #if V8_TARGET_ARCH_ARM64 |
6 | 6 |
7 #include "src/bootstrapper.h" | 7 #include "src/bootstrapper.h" |
8 #include "src/code-stubs.h" | 8 #include "src/code-stubs.h" |
9 #include "src/codegen.h" | 9 #include "src/codegen.h" |
10 #include "src/ic/handler-compiler.h" | 10 #include "src/ic/handler-compiler.h" |
(...skipping 5769 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5780 // Save the return value in a callee-save register. | 5780 // Save the return value in a callee-save register. |
5781 Register saved_result = x19; | 5781 Register saved_result = x19; |
5782 __ Mov(saved_result, x0); | 5782 __ Mov(saved_result, x0); |
5783 __ Mov(x0, ExternalReference::isolate_address(isolate)); | 5783 __ Mov(x0, ExternalReference::isolate_address(isolate)); |
5784 __ CallCFunction(ExternalReference::delete_handle_scope_extensions(isolate), | 5784 __ CallCFunction(ExternalReference::delete_handle_scope_extensions(isolate), |
5785 1); | 5785 1); |
5786 __ Mov(x0, saved_result); | 5786 __ Mov(x0, saved_result); |
5787 __ B(&leave_exit_frame); | 5787 __ B(&leave_exit_frame); |
5788 } | 5788 } |
5789 | 5789 |
5790 static void CallApiFunctionStubHelper(MacroAssembler* masm, | 5790 void CallApiCallbackStub::Generate(MacroAssembler* masm) { |
5791 const ParameterCount& argc, | |
5792 bool return_first_arg, | |
5793 bool call_data_undefined, bool is_lazy) { | |
5794 // ----------- S t a t e ------------- | 5791 // ----------- S t a t e ------------- |
5795 // -- x0 : callee | 5792 // -- x0 : callee |
5796 // -- x4 : call_data | 5793 // -- x4 : call_data |
5797 // -- x2 : holder | 5794 // -- x2 : holder |
5798 // -- x1 : api_function_address | 5795 // -- x1 : api_function_address |
5799 // -- x3 : number of arguments if argc is a register | |
5800 // -- cp : context | 5796 // -- cp : context |
5801 // -- | 5797 // -- |
5802 // -- sp[0] : last argument | 5798 // -- sp[0] : last argument |
5803 // -- ... | 5799 // -- ... |
5804 // -- sp[(argc - 1) * 8] : first argument | 5800 // -- sp[(argc - 1) * 8] : first argument |
5805 // -- sp[argc * 8] : receiver | 5801 // -- sp[argc * 8] : receiver |
5806 // ----------------------------------- | 5802 // ----------------------------------- |
5807 | 5803 |
5808 Register callee = x0; | 5804 Register callee = x0; |
5809 Register call_data = x4; | 5805 Register call_data = x4; |
5810 Register holder = x2; | 5806 Register holder = x2; |
5811 Register api_function_address = x1; | 5807 Register api_function_address = x1; |
5812 Register context = cp; | 5808 Register context = cp; |
5813 | 5809 |
5814 typedef FunctionCallbackArguments FCA; | 5810 typedef FunctionCallbackArguments FCA; |
5815 | 5811 |
5816 STATIC_ASSERT(FCA::kContextSaveIndex == 6); | 5812 STATIC_ASSERT(FCA::kContextSaveIndex == 6); |
5817 STATIC_ASSERT(FCA::kCalleeIndex == 5); | 5813 STATIC_ASSERT(FCA::kCalleeIndex == 5); |
5818 STATIC_ASSERT(FCA::kDataIndex == 4); | 5814 STATIC_ASSERT(FCA::kDataIndex == 4); |
5819 STATIC_ASSERT(FCA::kReturnValueOffset == 3); | 5815 STATIC_ASSERT(FCA::kReturnValueOffset == 3); |
5820 STATIC_ASSERT(FCA::kReturnValueDefaultValueIndex == 2); | 5816 STATIC_ASSERT(FCA::kReturnValueDefaultValueIndex == 2); |
5821 STATIC_ASSERT(FCA::kIsolateIndex == 1); | 5817 STATIC_ASSERT(FCA::kIsolateIndex == 1); |
5822 STATIC_ASSERT(FCA::kHolderIndex == 0); | 5818 STATIC_ASSERT(FCA::kHolderIndex == 0); |
5823 STATIC_ASSERT(FCA::kArgsLength == 7); | 5819 STATIC_ASSERT(FCA::kArgsLength == 7); |
5824 | 5820 |
5825 DCHECK(argc.is_immediate() || x3.is(argc.reg())); | |
5826 | |
5827 // FunctionCallbackArguments: context, callee and call data. | 5821 // FunctionCallbackArguments: context, callee and call data. |
5828 __ Push(context, callee, call_data); | 5822 __ Push(context, callee, call_data); |
5829 | 5823 |
5830 if (!is_lazy) { | 5824 if (!is_lazy()) { |
5831 // Load context from callee | 5825 // Load context from callee |
5832 __ Ldr(context, FieldMemOperand(callee, JSFunction::kContextOffset)); | 5826 __ Ldr(context, FieldMemOperand(callee, JSFunction::kContextOffset)); |
5833 } | 5827 } |
5834 | 5828 |
5835 if (!call_data_undefined) { | 5829 if (!call_data_undefined()) { |
5836 __ LoadRoot(call_data, Heap::kUndefinedValueRootIndex); | 5830 __ LoadRoot(call_data, Heap::kUndefinedValueRootIndex); |
5837 } | 5831 } |
5838 Register isolate_reg = x5; | 5832 Register isolate_reg = x5; |
5839 __ Mov(isolate_reg, ExternalReference::isolate_address(masm->isolate())); | 5833 __ Mov(isolate_reg, ExternalReference::isolate_address(masm->isolate())); |
5840 | 5834 |
5841 // FunctionCallbackArguments: | 5835 // FunctionCallbackArguments: |
5842 // return value, return value default, isolate, holder. | 5836 // return value, return value default, isolate, holder. |
5843 __ Push(call_data, call_data, isolate_reg, holder); | 5837 __ Push(call_data, call_data, isolate_reg, holder); |
5844 | 5838 |
5845 // Prepare arguments. | 5839 // Prepare arguments. |
5846 Register args = x6; | 5840 Register args = x6; |
5847 __ Mov(args, masm->StackPointer()); | 5841 __ Mov(args, masm->StackPointer()); |
5848 | 5842 |
5849 // Allocate the v8::Arguments structure in the arguments' space, since it's | 5843 // Allocate the v8::Arguments structure in the arguments' space, since it's |
5850 // not controlled by GC. | 5844 // not controlled by GC. |
5851 const int kApiStackSpace = 4; | 5845 const int kApiStackSpace = 4; |
5852 | 5846 |
5853 // Allocate space for CallApiFunctionAndReturn can store some scratch | 5847 // Allocate space for CallApiFunctionAndReturn can store some scratch |
5854 // registeres on the stack. | 5848 // registeres on the stack. |
5855 const int kCallApiFunctionSpillSpace = 4; | 5849 const int kCallApiFunctionSpillSpace = 4; |
5856 | 5850 |
5857 FrameScope frame_scope(masm, StackFrame::MANUAL); | 5851 FrameScope frame_scope(masm, StackFrame::MANUAL); |
5858 __ EnterExitFrame(false, x10, kApiStackSpace + kCallApiFunctionSpillSpace); | 5852 __ EnterExitFrame(false, x10, kApiStackSpace + kCallApiFunctionSpillSpace); |
5859 | 5853 |
5860 DCHECK(!AreAliased(x0, api_function_address)); | 5854 DCHECK(!AreAliased(x0, api_function_address)); |
5861 // x0 = FunctionCallbackInfo& | 5855 // x0 = FunctionCallbackInfo& |
5862 // Arguments is after the return address. | 5856 // Arguments is after the return address. |
5863 __ Add(x0, masm->StackPointer(), 1 * kPointerSize); | 5857 __ Add(x0, masm->StackPointer(), 1 * kPointerSize); |
5864 if (argc.is_immediate()) { | 5858 // FunctionCallbackInfo::implicit_args_ and FunctionCallbackInfo::values_ |
5865 // FunctionCallbackInfo::implicit_args_ and FunctionCallbackInfo::values_ | 5859 __ Add(x10, args, Operand((FCA::kArgsLength - 1 + argc()) * kPointerSize)); |
5866 __ Add(x10, args, | 5860 __ Stp(args, x10, MemOperand(x0, 0 * kPointerSize)); |
5867 Operand((FCA::kArgsLength - 1 + argc.immediate()) * kPointerSize)); | 5861 // FunctionCallbackInfo::length_ = argc and |
5868 __ Stp(args, x10, MemOperand(x0, 0 * kPointerSize)); | 5862 // FunctionCallbackInfo::is_construct_call = 0 |
5869 // FunctionCallbackInfo::length_ = argc and | 5863 __ Mov(x10, argc()); |
5870 // FunctionCallbackInfo::is_construct_call = 0 | 5864 __ Stp(x10, xzr, MemOperand(x0, 2 * kPointerSize)); |
5871 __ Mov(x10, argc.immediate()); | |
5872 __ Stp(x10, xzr, MemOperand(x0, 2 * kPointerSize)); | |
5873 } else { | |
5874 // FunctionCallbackInfo::implicit_args_ and FunctionCallbackInfo::values_ | |
5875 __ Add(x10, args, Operand(argc.reg(), LSL, kPointerSizeLog2)); | |
5876 __ Add(x10, x10, (FCA::kArgsLength - 1) * kPointerSize); | |
5877 __ Stp(args, x10, MemOperand(x0, 0 * kPointerSize)); | |
5878 // FunctionCallbackInfo::length_ = argc and | |
5879 // FunctionCallbackInfo::is_construct_call | |
5880 __ Add(x10, argc.reg(), FCA::kArgsLength + 1); | |
5881 __ Mov(x10, Operand(x10, LSL, kPointerSizeLog2)); | |
5882 __ Stp(argc.reg(), x10, MemOperand(x0, 2 * kPointerSize)); | |
5883 } | |
5884 | 5865 |
5885 ExternalReference thunk_ref = | 5866 ExternalReference thunk_ref = |
5886 ExternalReference::invoke_function_callback(masm->isolate()); | 5867 ExternalReference::invoke_function_callback(masm->isolate()); |
5887 | 5868 |
5888 AllowExternalCallThatCantCauseGC scope(masm); | 5869 AllowExternalCallThatCantCauseGC scope(masm); |
5889 MemOperand context_restore_operand( | 5870 MemOperand context_restore_operand( |
5890 fp, (2 + FCA::kContextSaveIndex) * kPointerSize); | 5871 fp, (2 + FCA::kContextSaveIndex) * kPointerSize); |
5891 // Stores return the first js argument | 5872 // Stores return the first js argument |
5892 int return_value_offset = 0; | 5873 int return_value_offset = 0; |
5893 if (return_first_arg) { | 5874 if (is_store()) { |
5894 return_value_offset = 2 + FCA::kArgsLength; | 5875 return_value_offset = 2 + FCA::kArgsLength; |
5895 } else { | 5876 } else { |
5896 return_value_offset = 2 + FCA::kReturnValueOffset; | 5877 return_value_offset = 2 + FCA::kReturnValueOffset; |
5897 } | 5878 } |
5898 MemOperand return_value_operand(fp, return_value_offset * kPointerSize); | 5879 MemOperand return_value_operand(fp, return_value_offset * kPointerSize); |
5899 int stack_space = 0; | 5880 int stack_space = 0; |
5900 MemOperand is_construct_call_operand = | 5881 MemOperand is_construct_call_operand = |
5901 MemOperand(masm->StackPointer(), 4 * kPointerSize); | 5882 MemOperand(masm->StackPointer(), 4 * kPointerSize); |
5902 MemOperand* stack_space_operand = &is_construct_call_operand; | 5883 MemOperand* stack_space_operand = &is_construct_call_operand; |
5903 if (argc.is_immediate()) { | 5884 stack_space = argc() + FCA::kArgsLength + 1; |
5904 stack_space = argc.immediate() + FCA::kArgsLength + 1; | 5885 stack_space_operand = NULL; |
5905 stack_space_operand = NULL; | |
5906 } | |
5907 | 5886 |
5908 const int spill_offset = 1 + kApiStackSpace; | 5887 const int spill_offset = 1 + kApiStackSpace; |
5909 CallApiFunctionAndReturn(masm, api_function_address, thunk_ref, stack_space, | 5888 CallApiFunctionAndReturn(masm, api_function_address, thunk_ref, stack_space, |
5910 stack_space_operand, spill_offset, | 5889 stack_space_operand, spill_offset, |
5911 return_value_operand, &context_restore_operand); | 5890 return_value_operand, &context_restore_operand); |
5912 } | 5891 } |
5913 | 5892 |
5914 | 5893 |
5915 void CallApiFunctionStub::Generate(MacroAssembler* masm) { | |
5916 bool call_data_undefined = this->call_data_undefined(); | |
5917 CallApiFunctionStubHelper(masm, ParameterCount(x3), false, | |
5918 call_data_undefined, false); | |
5919 } | |
5920 | |
5921 | |
5922 void CallApiAccessorStub::Generate(MacroAssembler* masm) { | |
5923 bool is_store = this->is_store(); | |
5924 int argc = this->argc(); | |
5925 bool call_data_undefined = this->call_data_undefined(); | |
5926 bool is_lazy = this->is_lazy(); | |
5927 CallApiFunctionStubHelper(masm, ParameterCount(argc), is_store, | |
5928 call_data_undefined, is_lazy); | |
5929 } | |
5930 | |
5931 | |
5932 void CallApiGetterStub::Generate(MacroAssembler* masm) { | 5894 void CallApiGetterStub::Generate(MacroAssembler* masm) { |
5933 // ----------- S t a t e ------------- | 5895 // ----------- S t a t e ------------- |
5934 // -- sp[0] : name | 5896 // -- sp[0] : name |
5935 // -- sp[8 .. (8 + kArgsLength*8)] : v8::PropertyCallbackInfo::args_ | 5897 // -- sp[8 .. (8 + kArgsLength*8)] : v8::PropertyCallbackInfo::args_ |
5936 // -- ... | 5898 // -- ... |
5937 // -- x2 : api_function_address | 5899 // -- x2 : api_function_address |
5938 // ----------------------------------- | 5900 // ----------------------------------- |
5939 | 5901 |
5940 Register api_function_address = ApiGetterDescriptor::function_address(); | 5902 Register api_function_address = ApiGetterDescriptor::function_address(); |
5941 DCHECK(api_function_address.is(x2)); | 5903 DCHECK(api_function_address.is(x2)); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5974 return_value_operand, NULL); | 5936 return_value_operand, NULL); |
5975 } | 5937 } |
5976 | 5938 |
5977 | 5939 |
5978 #undef __ | 5940 #undef __ |
5979 | 5941 |
5980 } // namespace internal | 5942 } // namespace internal |
5981 } // namespace v8 | 5943 } // namespace v8 |
5982 | 5944 |
5983 #endif // V8_TARGET_ARCH_ARM64 | 5945 #endif // V8_TARGET_ARCH_ARM64 |
OLD | NEW |