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/arm64/frames-arm64.h" | 7 #include "src/arm64/frames-arm64.h" |
8 #include "src/codegen.h" | 8 #include "src/codegen.h" |
9 #include "src/debug/debug.h" | 9 #include "src/debug/debug.h" |
10 #include "src/deoptimizer.h" | 10 #include "src/deoptimizer.h" |
(...skipping 20 matching lines...) Expand all Loading... |
31 // Load the InternalArray function from the native context. | 31 // Load the InternalArray function from the native context. |
32 __ LoadNativeContextSlot(Context::INTERNAL_ARRAY_FUNCTION_INDEX, result); | 32 __ LoadNativeContextSlot(Context::INTERNAL_ARRAY_FUNCTION_INDEX, result); |
33 } | 33 } |
34 | 34 |
35 | 35 |
36 void Builtins::Generate_Adaptor(MacroAssembler* masm, | 36 void Builtins::Generate_Adaptor(MacroAssembler* masm, |
37 CFunctionId id, | 37 CFunctionId id, |
38 BuiltinExtraArguments extra_args) { | 38 BuiltinExtraArguments extra_args) { |
39 // ----------- S t a t e ------------- | 39 // ----------- S t a t e ------------- |
40 // -- x0 : number of arguments excluding receiver | 40 // -- x0 : number of arguments excluding receiver |
41 // (only guaranteed when the called function | |
42 // is not marked as DontAdaptArguments) | |
43 // -- x1 : called function | 41 // -- x1 : called function |
44 // -- sp[0] : last argument | 42 // -- sp[0] : last argument |
45 // -- ... | 43 // -- ... |
46 // -- sp[4 * (argc - 1)] : first argument | 44 // -- sp[4 * (argc - 1)] : first argument |
47 // -- sp[4 * argc] : receiver | 45 // -- sp[4 * argc] : receiver |
48 // ----------------------------------- | 46 // ----------------------------------- |
49 __ AssertFunction(x1); | 47 __ AssertFunction(x1); |
50 | 48 |
51 // Make sure we operate in the context of the called function (for example | |
52 // ConstructStubs implemented in C++ will be run in the context of the caller | |
53 // instead of the callee, due to the way that [[Construct]] is defined for | |
54 // ordinary functions). | |
55 // TODO(bmeurer): Can we make this more robust? | |
56 __ Ldr(cp, FieldMemOperand(x1, JSFunction::kContextOffset)); | |
57 | |
58 // Insert extra arguments. | 49 // Insert extra arguments. |
59 int num_extra_args = 0; | 50 int num_extra_args = 0; |
60 if (extra_args == NEEDS_CALLED_FUNCTION) { | 51 if (extra_args == NEEDS_CALLED_FUNCTION) { |
61 num_extra_args = 1; | 52 num_extra_args = 1; |
62 __ Push(x1); | 53 __ Push(x1); |
63 } else { | 54 } else { |
64 DCHECK(extra_args == NO_EXTRA_ARGUMENTS); | 55 DCHECK(extra_args == NO_EXTRA_ARGUMENTS); |
65 } | 56 } |
66 | 57 |
67 // JumpToExternalReference expects x0 to contain the number of arguments | 58 // JumpToExternalReference expects x0 to contain the number of arguments |
68 // including the receiver and the extra arguments. But x0 is only valid | 59 // including the receiver and the extra arguments. |
69 // if the called function is marked as DontAdaptArguments, otherwise we | |
70 // need to load the argument count from the SharedFunctionInfo. | |
71 __ Ldr(x2, FieldMemOperand(x1, JSFunction::kSharedFunctionInfoOffset)); | |
72 __ Ldrsw( | |
73 x2, FieldMemOperand(x2, SharedFunctionInfo::kFormalParameterCountOffset)); | |
74 __ Cmp(x2, SharedFunctionInfo::kDontAdaptArgumentsSentinel); | |
75 __ Csel(x0, x0, x2, eq); | |
76 __ Add(x0, x0, num_extra_args + 1); | 60 __ Add(x0, x0, num_extra_args + 1); |
77 | 61 |
78 __ JumpToExternalReference(ExternalReference(id, masm->isolate())); | 62 __ JumpToExternalReference(ExternalReference(id, masm->isolate())); |
79 } | 63 } |
80 | 64 |
81 | 65 |
82 void Builtins::Generate_InternalArrayCode(MacroAssembler* masm) { | 66 void Builtins::Generate_InternalArrayCode(MacroAssembler* masm) { |
83 // ----------- S t a t e ------------- | 67 // ----------- S t a t e ------------- |
84 // -- x0 : number of arguments | 68 // -- x0 : number of arguments |
85 // -- lr : return address | 69 // -- lr : return address |
(...skipping 1957 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2043 } | 2027 } |
2044 } | 2028 } |
2045 | 2029 |
2046 | 2030 |
2047 #undef __ | 2031 #undef __ |
2048 | 2032 |
2049 } // namespace internal | 2033 } // namespace internal |
2050 } // namespace v8 | 2034 } // namespace v8 |
2051 | 2035 |
2052 #endif // V8_TARGET_ARCH_ARM | 2036 #endif // V8_TARGET_ARCH_ARM |
OLD | NEW |