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/api-arguments.h" | 7 #include "src/api-arguments.h" |
8 #include "src/arm64/assembler-arm64-inl.h" | 8 #include "src/arm64/assembler-arm64-inl.h" |
9 #include "src/arm64/frames-arm64.h" | 9 #include "src/arm64/frames-arm64.h" |
10 #include "src/arm64/macro-assembler-arm64-inl.h" | 10 #include "src/arm64/macro-assembler-arm64-inl.h" |
(...skipping 2923 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2934 // -- x0 : callee | 2934 // -- x0 : callee |
2935 // -- x4 : call_data | 2935 // -- x4 : call_data |
2936 // -- x2 : holder | 2936 // -- x2 : holder |
2937 // -- x1 : api_function_address | 2937 // -- x1 : api_function_address |
2938 // -- cp : context | 2938 // -- cp : context |
2939 // -- | 2939 // -- |
2940 // -- sp[0] : last argument | 2940 // -- sp[0] : last argument |
2941 // -- ... | 2941 // -- ... |
2942 // -- sp[(argc - 1) * 8] : first argument | 2942 // -- sp[(argc - 1) * 8] : first argument |
2943 // -- sp[argc * 8] : receiver | 2943 // -- sp[argc * 8] : receiver |
2944 // -- sp[(argc + 1) * 8] : accessor_holder | |
2945 // ----------------------------------- | 2944 // ----------------------------------- |
2946 | 2945 |
2947 Register callee = x0; | 2946 Register callee = x0; |
2948 Register call_data = x4; | 2947 Register call_data = x4; |
2949 Register holder = x2; | 2948 Register holder = x2; |
2950 Register api_function_address = x1; | 2949 Register api_function_address = x1; |
2951 Register context = cp; | 2950 Register context = cp; |
2952 | 2951 |
2953 typedef FunctionCallbackArguments FCA; | 2952 typedef FunctionCallbackArguments FCA; |
2954 | 2953 |
2955 STATIC_ASSERT(FCA::kContextSaveIndex == 6); | 2954 STATIC_ASSERT(FCA::kContextSaveIndex == 6); |
2956 STATIC_ASSERT(FCA::kCalleeIndex == 5); | 2955 STATIC_ASSERT(FCA::kCalleeIndex == 5); |
2957 STATIC_ASSERT(FCA::kDataIndex == 4); | 2956 STATIC_ASSERT(FCA::kDataIndex == 4); |
2958 STATIC_ASSERT(FCA::kReturnValueOffset == 3); | 2957 STATIC_ASSERT(FCA::kReturnValueOffset == 3); |
2959 STATIC_ASSERT(FCA::kReturnValueDefaultValueIndex == 2); | 2958 STATIC_ASSERT(FCA::kReturnValueDefaultValueIndex == 2); |
2960 STATIC_ASSERT(FCA::kIsolateIndex == 1); | 2959 STATIC_ASSERT(FCA::kIsolateIndex == 1); |
2961 STATIC_ASSERT(FCA::kHolderIndex == 0); | 2960 STATIC_ASSERT(FCA::kHolderIndex == 0); |
2962 STATIC_ASSERT(FCA::kNewTargetIndex == 7); | 2961 STATIC_ASSERT(FCA::kNewTargetIndex == 7); |
2963 STATIC_ASSERT(FCA::kArgsLength == 8); | 2962 STATIC_ASSERT(FCA::kArgsLength == 8); |
2964 | 2963 |
2965 // FunctionCallbackArguments | 2964 // FunctionCallbackArguments |
2966 | 2965 |
2967 // new target | 2966 // new target |
2968 __ PushRoot(Heap::kUndefinedValueRootIndex); | 2967 __ PushRoot(Heap::kUndefinedValueRootIndex); |
2969 | 2968 |
2970 // context, callee and call data. | 2969 // context, callee and call data. |
2971 __ Push(context, callee, call_data); | 2970 __ Push(context, callee, call_data); |
2972 | 2971 |
2973 Register scratch = call_data; | 2972 if (!is_lazy()) { |
2974 __ LoadRoot(scratch, Heap::kUndefinedValueRootIndex); | 2973 // Load context from callee |
| 2974 __ Ldr(context, FieldMemOperand(callee, JSFunction::kContextOffset)); |
| 2975 } |
| 2976 |
| 2977 __ LoadRoot(call_data, Heap::kUndefinedValueRootIndex); |
2975 Register isolate_reg = x5; | 2978 Register isolate_reg = x5; |
2976 __ Mov(isolate_reg, ExternalReference::isolate_address(masm->isolate())); | 2979 __ Mov(isolate_reg, ExternalReference::isolate_address(masm->isolate())); |
2977 | 2980 |
2978 // FunctionCallbackArguments: | 2981 // FunctionCallbackArguments: |
2979 // return value, return value default, isolate, holder. | 2982 // return value, return value default, isolate, holder. |
2980 __ Push(scratch, scratch, isolate_reg, holder); | 2983 __ Push(call_data, call_data, isolate_reg, holder); |
2981 | |
2982 // Enter a new context | |
2983 if (is_lazy()) { | |
2984 // Load context from accessor_holder | |
2985 Register accessor_holder = context; | |
2986 __ Ldr(accessor_holder, | |
2987 MemOperand(__ StackPointer(), | |
2988 (FCA::kArgsLength + 1 + argc()) * kPointerSize)); | |
2989 __ Ldr(scratch, FieldMemOperand(accessor_holder, HeapObject::kMapOffset)); | |
2990 __ GetMapConstructor(scratch, scratch, context, callee); | |
2991 __ Ldr(context, FieldMemOperand(scratch, JSFunction::kContextOffset)); | |
2992 } else { | |
2993 // Load context from callee | |
2994 __ Ldr(context, FieldMemOperand(callee, JSFunction::kContextOffset)); | |
2995 } | |
2996 | 2984 |
2997 // Prepare arguments. | 2985 // Prepare arguments. |
2998 Register args = x6; | 2986 Register args = x6; |
2999 __ Mov(args, masm->StackPointer()); | 2987 __ Mov(args, masm->StackPointer()); |
3000 | 2988 |
3001 // Allocate the v8::Arguments structure in the arguments' space, since it's | 2989 // Allocate the v8::Arguments structure in the arguments' space, since it's |
3002 // not controlled by GC. | 2990 // not controlled by GC. |
3003 const int kApiStackSpace = 3; | 2991 const int kApiStackSpace = 3; |
3004 | 2992 |
3005 // Allocate space for CallApiFunctionAndReturn can store some scratch | 2993 // Allocate space for CallApiFunctionAndReturn can store some scratch |
(...skipping 21 matching lines...) Expand all Loading... |
3027 MemOperand context_restore_operand( | 3015 MemOperand context_restore_operand( |
3028 fp, (2 + FCA::kContextSaveIndex) * kPointerSize); | 3016 fp, (2 + FCA::kContextSaveIndex) * kPointerSize); |
3029 // Stores return the first js argument | 3017 // Stores return the first js argument |
3030 int return_value_offset = 0; | 3018 int return_value_offset = 0; |
3031 if (is_store()) { | 3019 if (is_store()) { |
3032 return_value_offset = 2 + FCA::kArgsLength; | 3020 return_value_offset = 2 + FCA::kArgsLength; |
3033 } else { | 3021 } else { |
3034 return_value_offset = 2 + FCA::kReturnValueOffset; | 3022 return_value_offset = 2 + FCA::kReturnValueOffset; |
3035 } | 3023 } |
3036 MemOperand return_value_operand(fp, return_value_offset * kPointerSize); | 3024 MemOperand return_value_operand(fp, return_value_offset * kPointerSize); |
3037 const int stack_space = argc() + FCA::kArgsLength + 2; | 3025 int stack_space = 0; |
3038 MemOperand* stack_space_operand = nullptr; | 3026 MemOperand length_operand = |
| 3027 MemOperand(masm->StackPointer(), 3 * kPointerSize); |
| 3028 MemOperand* stack_space_operand = &length_operand; |
| 3029 stack_space = argc() + FCA::kArgsLength + 1; |
| 3030 stack_space_operand = NULL; |
3039 | 3031 |
3040 const int spill_offset = 1 + kApiStackSpace; | 3032 const int spill_offset = 1 + kApiStackSpace; |
3041 CallApiFunctionAndReturn(masm, api_function_address, thunk_ref, stack_space, | 3033 CallApiFunctionAndReturn(masm, api_function_address, thunk_ref, stack_space, |
3042 stack_space_operand, spill_offset, | 3034 stack_space_operand, spill_offset, |
3043 return_value_operand, &context_restore_operand); | 3035 return_value_operand, &context_restore_operand); |
3044 } | 3036 } |
3045 | 3037 |
3046 | 3038 |
3047 void CallApiGetterStub::Generate(MacroAssembler* masm) { | 3039 void CallApiGetterStub::Generate(MacroAssembler* masm) { |
3048 // Build v8::PropertyCallbackInfo::args_ array on the stack and push property | 3040 // Build v8::PropertyCallbackInfo::args_ array on the stack and push property |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3112 kStackUnwindSpace, NULL, spill_offset, | 3104 kStackUnwindSpace, NULL, spill_offset, |
3113 return_value_operand, NULL); | 3105 return_value_operand, NULL); |
3114 } | 3106 } |
3115 | 3107 |
3116 #undef __ | 3108 #undef __ |
3117 | 3109 |
3118 } // namespace internal | 3110 } // namespace internal |
3119 } // namespace v8 | 3111 } // namespace v8 |
3120 | 3112 |
3121 #endif // V8_TARGET_ARCH_ARM64 | 3113 #endif // V8_TARGET_ARCH_ARM64 |
OLD | NEW |