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