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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 __ Ldr(result, ContextMemOperand(result, | 42 __ Ldr(result, ContextMemOperand(result, |
43 Context::INTERNAL_ARRAY_FUNCTION_INDEX)); | 43 Context::INTERNAL_ARRAY_FUNCTION_INDEX)); |
44 } | 44 } |
45 | 45 |
46 | 46 |
47 void Builtins::Generate_Adaptor(MacroAssembler* masm, | 47 void Builtins::Generate_Adaptor(MacroAssembler* masm, |
48 CFunctionId id, | 48 CFunctionId id, |
49 BuiltinExtraArguments extra_args) { | 49 BuiltinExtraArguments extra_args) { |
50 // ----------- S t a t e ------------- | 50 // ----------- S t a t e ------------- |
51 // -- x0 : number of arguments excluding receiver | 51 // -- x0 : number of arguments excluding receiver |
52 // -- x1 : called function (only guaranteed when | 52 // (only guaranteed when the called function |
53 // extra_args requires it) | 53 // is not marked as DontAdaptArguments) |
| 54 // -- x1 : called function |
54 // -- sp[0] : last argument | 55 // -- sp[0] : last argument |
55 // -- ... | 56 // -- ... |
56 // -- sp[4 * (argc - 1)] : first argument (argc == x0) | 57 // -- sp[4 * (argc - 1)] : first argument |
57 // -- sp[4 * argc] : receiver | 58 // -- sp[4 * argc] : receiver |
58 // ----------------------------------- | 59 // ----------------------------------- |
59 __ AssertFunction(x1); | 60 __ AssertFunction(x1); |
60 | 61 |
61 // Make sure we operate in the context of the called function (for example | 62 // Make sure we operate in the context of the called function (for example |
62 // ConstructStubs implemented in C++ will be run in the context of the caller | 63 // ConstructStubs implemented in C++ will be run in the context of the caller |
63 // instead of the callee, due to the way that [[Construct]] is defined for | 64 // instead of the callee, due to the way that [[Construct]] is defined for |
64 // ordinary functions). | 65 // ordinary functions). |
65 // TODO(bmeurer): Can we make this more robust? | 66 // TODO(bmeurer): Can we make this more robust? |
66 __ Ldr(cp, FieldMemOperand(x1, JSFunction::kContextOffset)); | 67 __ Ldr(cp, FieldMemOperand(x1, JSFunction::kContextOffset)); |
67 | 68 |
68 // Insert extra arguments. | 69 // Insert extra arguments. |
69 int num_extra_args = 0; | 70 int num_extra_args = 0; |
70 if (extra_args == NEEDS_CALLED_FUNCTION) { | 71 if (extra_args == NEEDS_CALLED_FUNCTION) { |
71 num_extra_args = 1; | 72 num_extra_args = 1; |
72 __ Push(x1); | 73 __ Push(x1); |
73 } else { | 74 } else { |
74 DCHECK(extra_args == NO_EXTRA_ARGUMENTS); | 75 DCHECK(extra_args == NO_EXTRA_ARGUMENTS); |
75 } | 76 } |
76 | 77 |
77 // JumpToExternalReference expects x0 to contain the number of arguments | 78 // JumpToExternalReference expects x0 to contain the number of arguments |
78 // including the receiver and the extra arguments. | 79 // including the receiver and the extra arguments. But x0 is only valid |
| 80 // if the called function is marked as DontAdaptArguments, otherwise we |
| 81 // need to load the argument count from the SharedFunctionInfo. |
| 82 __ Ldr(x2, FieldMemOperand(x1, JSFunction::kSharedFunctionInfoOffset)); |
| 83 __ Ldrsw( |
| 84 x2, FieldMemOperand(x2, SharedFunctionInfo::kFormalParameterCountOffset)); |
| 85 __ Cmp(x2, SharedFunctionInfo::kDontAdaptArgumentsSentinel); |
| 86 __ Csel(x0, x0, x2, eq); |
79 __ Add(x0, x0, num_extra_args + 1); | 87 __ Add(x0, x0, num_extra_args + 1); |
| 88 |
80 __ JumpToExternalReference(ExternalReference(id, masm->isolate())); | 89 __ JumpToExternalReference(ExternalReference(id, masm->isolate())); |
81 } | 90 } |
82 | 91 |
83 | 92 |
84 void Builtins::Generate_InternalArrayCode(MacroAssembler* masm) { | 93 void Builtins::Generate_InternalArrayCode(MacroAssembler* masm) { |
85 // ----------- S t a t e ------------- | 94 // ----------- S t a t e ------------- |
86 // -- x0 : number of arguments | 95 // -- x0 : number of arguments |
87 // -- lr : return address | 96 // -- lr : return address |
88 // -- sp[...]: constructor arguments | 97 // -- sp[...]: constructor arguments |
89 // ----------------------------------- | 98 // ----------------------------------- |
(...skipping 1862 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1952 } | 1961 } |
1953 } | 1962 } |
1954 | 1963 |
1955 | 1964 |
1956 #undef __ | 1965 #undef __ |
1957 | 1966 |
1958 } // namespace internal | 1967 } // namespace internal |
1959 } // namespace v8 | 1968 } // namespace v8 |
1960 | 1969 |
1961 #endif // V8_TARGET_ARCH_ARM | 1970 #endif // V8_TARGET_ARCH_ARM |
OLD | NEW |