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 #include "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #if V8_TARGET_ARCH_ARM64 | 7 #if V8_TARGET_ARCH_ARM64 |
8 | 8 |
9 #include "src/bootstrapper.h" | 9 #include "src/bootstrapper.h" |
10 #include "src/code-stubs.h" | 10 #include "src/code-stubs.h" |
11 #include "src/codegen.h" | 11 #include "src/codegen.h" |
12 #include "src/ic/handler-compiler.h" | 12 #include "src/ic/handler-compiler.h" |
13 #include "src/isolate.h" | 13 #include "src/isolate.h" |
14 #include "src/jsregexp.h" | 14 #include "src/jsregexp.h" |
15 #include "src/regexp-macro-assembler.h" | 15 #include "src/regexp-macro-assembler.h" |
16 #include "src/runtime.h" | 16 #include "src/runtime.h" |
17 | 17 |
18 namespace v8 { | 18 namespace v8 { |
19 namespace internal { | 19 namespace internal { |
20 | 20 |
21 void FastNewClosureStub::InitializeInterfaceDescriptor( | |
22 CodeStubInterfaceDescriptor* descriptor) { | |
23 // cp: context | |
24 // x2: function info | |
25 Register registers[] = { cp, x2 }; | |
26 descriptor->Initialize( | |
27 MajorKey(), arraysize(registers), registers, | |
28 Runtime::FunctionForId(Runtime::kNewClosureFromStubFailure)->entry); | |
29 } | |
30 | |
31 | |
32 void FastNewContextStub::InitializeInterfaceDescriptor( | |
33 CodeStubInterfaceDescriptor* descriptor) { | |
34 // cp: context | |
35 // x1: function | |
36 Register registers[] = { cp, x1 }; | |
37 descriptor->Initialize(MajorKey(), arraysize(registers), registers); | |
38 } | |
39 | |
40 | |
41 void ToNumberStub::InitializeInterfaceDescriptor( | |
42 CodeStubInterfaceDescriptor* descriptor) { | |
43 // cp: context | |
44 // x0: value | |
45 Register registers[] = { cp, x0 }; | |
46 descriptor->Initialize(MajorKey(), arraysize(registers), registers); | |
47 } | |
48 | |
49 | |
50 void NumberToStringStub::InitializeInterfaceDescriptor( | |
51 CodeStubInterfaceDescriptor* descriptor) { | |
52 // cp: context | |
53 // x0: value | |
54 Register registers[] = { cp, x0 }; | |
55 descriptor->Initialize( | |
56 MajorKey(), arraysize(registers), registers, | |
57 Runtime::FunctionForId(Runtime::kNumberToStringRT)->entry); | |
58 } | |
59 | |
60 | |
61 void FastCloneShallowArrayStub::InitializeInterfaceDescriptor( | |
62 CodeStubInterfaceDescriptor* descriptor) { | |
63 // cp: context | |
64 // x3: array literals array | |
65 // x2: array literal index | |
66 // x1: constant elements | |
67 Register registers[] = { cp, x3, x2, x1 }; | |
68 Representation representations[] = { | |
69 Representation::Tagged(), | |
70 Representation::Tagged(), | |
71 Representation::Smi(), | |
72 Representation::Tagged() }; | |
73 descriptor->Initialize( | |
74 MajorKey(), arraysize(registers), registers, | |
75 Runtime::FunctionForId(Runtime::kCreateArrayLiteralStubBailout)->entry, | |
76 representations); | |
77 } | |
78 | |
79 | |
80 void FastCloneShallowObjectStub::InitializeInterfaceDescriptor( | |
81 CodeStubInterfaceDescriptor* descriptor) { | |
82 // cp: context | |
83 // x3: object literals array | |
84 // x2: object literal index | |
85 // x1: constant properties | |
86 // x0: object literal flags | |
87 Register registers[] = { cp, x3, x2, x1, x0 }; | |
88 descriptor->Initialize( | |
89 MajorKey(), arraysize(registers), registers, | |
90 Runtime::FunctionForId(Runtime::kCreateObjectLiteral)->entry); | |
91 } | |
92 | |
93 | |
94 void CreateAllocationSiteStub::InitializeInterfaceDescriptor( | |
95 CodeStubInterfaceDescriptor* descriptor) { | |
96 // cp: context | |
97 // x2: feedback vector | |
98 // x3: call feedback slot | |
99 Register registers[] = { cp, x2, x3 }; | |
100 descriptor->Initialize(MajorKey(), arraysize(registers), registers); | |
101 } | |
102 | |
103 | |
104 void CallFunctionStub::InitializeInterfaceDescriptor( | |
105 CodeStubInterfaceDescriptor* descriptor) { | |
106 // x1 function the function to call | |
107 Register registers[] = {cp, x1}; | |
108 descriptor->Initialize(MajorKey(), arraysize(registers), registers); | |
109 } | |
110 | |
111 | |
112 void CallConstructStub::InitializeInterfaceDescriptor( | |
113 CodeStubInterfaceDescriptor* descriptor) { | |
114 // x0 : number of arguments | |
115 // x1 : the function to call | |
116 // x2 : feedback vector | |
117 // x3 : slot in feedback vector (smi) (if r2 is not the megamorphic symbol) | |
118 // TODO(turbofan): So far we don't gather type feedback and hence skip the | |
119 // slot parameter, but ArrayConstructStub needs the vector to be undefined. | |
120 Register registers[] = {cp, x0, x1, x2}; | |
121 descriptor->Initialize(MajorKey(), arraysize(registers), registers); | |
122 } | |
123 | |
124 | |
125 void RegExpConstructResultStub::InitializeInterfaceDescriptor( | |
126 CodeStubInterfaceDescriptor* descriptor) { | |
127 // cp: context | |
128 // x2: length | |
129 // x1: index (of last match) | |
130 // x0: string | |
131 Register registers[] = { cp, x2, x1, x0 }; | |
132 descriptor->Initialize( | |
133 MajorKey(), arraysize(registers), registers, | |
134 Runtime::FunctionForId(Runtime::kRegExpConstructResult)->entry); | |
135 } | |
136 | |
137 | |
138 void TransitionElementsKindStub::InitializeInterfaceDescriptor( | |
139 CodeStubInterfaceDescriptor* descriptor) { | |
140 // cp: context | |
141 // x0: value (js_array) | |
142 // x1: to_map | |
143 Register registers[] = { cp, x0, x1 }; | |
144 Address entry = | |
145 Runtime::FunctionForId(Runtime::kTransitionElementsKind)->entry; | |
146 descriptor->Initialize(MajorKey(), arraysize(registers), registers, | |
147 FUNCTION_ADDR(entry)); | |
148 } | |
149 | |
150 | |
151 void CompareNilICStub::InitializeInterfaceDescriptor( | |
152 CodeStubInterfaceDescriptor* descriptor) { | |
153 // cp: context | |
154 // x0: value to compare | |
155 Register registers[] = { cp, x0 }; | |
156 descriptor->Initialize(MajorKey(), arraysize(registers), registers, | |
157 FUNCTION_ADDR(CompareNilIC_Miss)); | |
158 descriptor->SetMissHandler( | |
159 ExternalReference(IC_Utility(IC::kCompareNilIC_Miss), isolate())); | |
160 } | |
161 | |
162 | 21 |
163 static void InitializeArrayConstructorDescriptor( | 22 static void InitializeArrayConstructorDescriptor( |
164 CodeStub::Major major, CodeStubInterfaceDescriptor* descriptor, | 23 Isolate* isolate, CodeStub::Major major, |
| 24 CodeStubInterfaceDescriptor* descriptor, |
165 int constant_stack_parameter_count) { | 25 int constant_stack_parameter_count) { |
166 // cp: context | 26 // cp: context |
167 // x1: function | 27 // x1: function |
168 // x2: allocation site with elements kind | 28 // x2: allocation site with elements kind |
169 // x0: number of arguments to the constructor function | 29 // x0: number of arguments to the constructor function |
170 Address deopt_handler = Runtime::FunctionForId( | 30 Address deopt_handler = Runtime::FunctionForId( |
171 Runtime::kArrayConstructor)->entry; | 31 Runtime::kArrayConstructor)->entry; |
172 | 32 |
173 if (constant_stack_parameter_count == 0) { | 33 if (constant_stack_parameter_count == 0) { |
174 Register registers[] = { cp, x1, x2 }; | 34 CallInterfaceDescriptor* call_descriptor = isolate->call_descriptor( |
175 descriptor->Initialize(major, arraysize(registers), registers, | 35 CallDescriptorKey::ArrayConstructorConstantArgCountCall); |
176 deopt_handler, NULL, constant_stack_parameter_count, | 36 descriptor->Initialize(major, call_descriptor, deopt_handler, |
| 37 constant_stack_parameter_count, |
177 JS_FUNCTION_STUB_MODE); | 38 JS_FUNCTION_STUB_MODE); |
178 } else { | 39 } else { |
179 // stack param count needs (constructor pointer, and single argument) | 40 CallInterfaceDescriptor* call_descriptor = |
180 Register registers[] = { cp, x1, x2, x0 }; | 41 isolate->call_descriptor(CallDescriptorKey::ArrayConstructorCall); |
181 Representation representations[] = { | 42 descriptor->Initialize(major, call_descriptor, x0, deopt_handler, |
182 Representation::Tagged(), | |
183 Representation::Tagged(), | |
184 Representation::Tagged(), | |
185 Representation::Integer32() }; | |
186 descriptor->Initialize(major, arraysize(registers), registers, x0, | |
187 deopt_handler, representations, | |
188 constant_stack_parameter_count, | 43 constant_stack_parameter_count, |
189 JS_FUNCTION_STUB_MODE, PASS_ARGUMENTS); | 44 JS_FUNCTION_STUB_MODE, PASS_ARGUMENTS); |
190 } | 45 } |
191 } | 46 } |
192 | 47 |
193 | 48 |
194 void ArrayNoArgumentConstructorStub::InitializeInterfaceDescriptor( | 49 void ArrayNoArgumentConstructorStub::InitializeInterfaceDescriptor( |
195 CodeStubInterfaceDescriptor* descriptor) { | 50 CodeStubInterfaceDescriptor* descriptor) { |
196 InitializeArrayConstructorDescriptor(MajorKey(), descriptor, 0); | 51 InitializeArrayConstructorDescriptor(isolate(), MajorKey(), descriptor, 0); |
197 } | 52 } |
198 | 53 |
199 | 54 |
200 void ArraySingleArgumentConstructorStub::InitializeInterfaceDescriptor( | 55 void ArraySingleArgumentConstructorStub::InitializeInterfaceDescriptor( |
201 CodeStubInterfaceDescriptor* descriptor) { | 56 CodeStubInterfaceDescriptor* descriptor) { |
202 InitializeArrayConstructorDescriptor(MajorKey(), descriptor, 1); | 57 InitializeArrayConstructorDescriptor(isolate(), MajorKey(), descriptor, 1); |
203 } | 58 } |
204 | 59 |
205 | 60 |
206 void ArrayNArgumentsConstructorStub::InitializeInterfaceDescriptor( | 61 void ArrayNArgumentsConstructorStub::InitializeInterfaceDescriptor( |
207 CodeStubInterfaceDescriptor* descriptor) { | 62 CodeStubInterfaceDescriptor* descriptor) { |
208 InitializeArrayConstructorDescriptor(MajorKey(), descriptor, -1); | 63 InitializeArrayConstructorDescriptor(isolate(), MajorKey(), descriptor, -1); |
209 } | 64 } |
210 | 65 |
211 | 66 |
212 static void InitializeInternalArrayConstructorDescriptor( | 67 static void InitializeInternalArrayConstructorDescriptor( |
213 CodeStub::Major major, CodeStubInterfaceDescriptor* descriptor, | 68 Isolate* isolate, CodeStub::Major major, |
| 69 CodeStubInterfaceDescriptor* descriptor, |
214 int constant_stack_parameter_count) { | 70 int constant_stack_parameter_count) { |
215 // cp: context | |
216 // x1: constructor function | |
217 // x0: number of arguments to the constructor function | |
218 Address deopt_handler = Runtime::FunctionForId( | 71 Address deopt_handler = Runtime::FunctionForId( |
219 Runtime::kInternalArrayConstructor)->entry; | 72 Runtime::kInternalArrayConstructor)->entry; |
220 | 73 |
221 if (constant_stack_parameter_count == 0) { | 74 if (constant_stack_parameter_count == 0) { |
222 Register registers[] = { cp, x1 }; | 75 CallInterfaceDescriptor* call_descriptor = isolate->call_descriptor( |
223 descriptor->Initialize(major, arraysize(registers), registers, | 76 CallDescriptorKey::InternalArrayConstructorConstantArgCountCall); |
224 deopt_handler, NULL, constant_stack_parameter_count, | 77 descriptor->Initialize(major, call_descriptor, deopt_handler, |
| 78 constant_stack_parameter_count, |
225 JS_FUNCTION_STUB_MODE); | 79 JS_FUNCTION_STUB_MODE); |
226 } else { | 80 } else { |
227 // stack param count needs (constructor pointer, and single argument) | 81 CallInterfaceDescriptor* call_descriptor = isolate->call_descriptor( |
228 Register registers[] = { cp, x1, x0 }; | 82 CallDescriptorKey::InternalArrayConstructorCall); |
229 Representation representations[] = { | 83 descriptor->Initialize(major, call_descriptor, x0, deopt_handler, |
230 Representation::Tagged(), | |
231 Representation::Tagged(), | |
232 Representation::Integer32() }; | |
233 descriptor->Initialize(major, arraysize(registers), registers, x0, | |
234 deopt_handler, representations, | |
235 constant_stack_parameter_count, | 84 constant_stack_parameter_count, |
236 JS_FUNCTION_STUB_MODE, PASS_ARGUMENTS); | 85 JS_FUNCTION_STUB_MODE, PASS_ARGUMENTS); |
237 } | 86 } |
238 } | 87 } |
239 | 88 |
240 | 89 |
241 void InternalArrayNoArgumentConstructorStub::InitializeInterfaceDescriptor( | 90 void InternalArrayNoArgumentConstructorStub::InitializeInterfaceDescriptor( |
242 CodeStubInterfaceDescriptor* descriptor) { | 91 CodeStubInterfaceDescriptor* descriptor) { |
243 InitializeInternalArrayConstructorDescriptor(MajorKey(), descriptor, 0); | 92 InitializeInternalArrayConstructorDescriptor(isolate(), MajorKey(), |
| 93 descriptor, 0); |
244 } | 94 } |
245 | 95 |
246 | 96 |
247 void InternalArraySingleArgumentConstructorStub::InitializeInterfaceDescriptor( | 97 void InternalArraySingleArgumentConstructorStub::InitializeInterfaceDescriptor( |
248 CodeStubInterfaceDescriptor* descriptor) { | 98 CodeStubInterfaceDescriptor* descriptor) { |
249 InitializeInternalArrayConstructorDescriptor(MajorKey(), descriptor, 1); | 99 InitializeInternalArrayConstructorDescriptor(isolate(), MajorKey(), |
| 100 descriptor, 1); |
250 } | 101 } |
251 | 102 |
252 | 103 |
253 void InternalArrayNArgumentsConstructorStub::InitializeInterfaceDescriptor( | 104 void InternalArrayNArgumentsConstructorStub::InitializeInterfaceDescriptor( |
254 CodeStubInterfaceDescriptor* descriptor) { | 105 CodeStubInterfaceDescriptor* descriptor) { |
255 InitializeInternalArrayConstructorDescriptor(MajorKey(), descriptor, -1); | 106 InitializeInternalArrayConstructorDescriptor(isolate(), MajorKey(), |
| 107 descriptor, -1); |
256 } | 108 } |
257 | 109 |
258 | 110 |
259 void ToBooleanStub::InitializeInterfaceDescriptor( | |
260 CodeStubInterfaceDescriptor* descriptor) { | |
261 // cp: context | |
262 // x0: value | |
263 Register registers[] = { cp, x0 }; | |
264 descriptor->Initialize(MajorKey(), arraysize(registers), registers, | |
265 FUNCTION_ADDR(ToBooleanIC_Miss)); | |
266 descriptor->SetMissHandler( | |
267 ExternalReference(IC_Utility(IC::kToBooleanIC_Miss), isolate())); | |
268 } | |
269 | |
270 | |
271 void BinaryOpICStub::InitializeInterfaceDescriptor( | |
272 CodeStubInterfaceDescriptor* descriptor) { | |
273 // cp: context | |
274 // x1: left operand | |
275 // x0: right operand | |
276 Register registers[] = { cp, x1, x0 }; | |
277 descriptor->Initialize(MajorKey(), arraysize(registers), registers, | |
278 FUNCTION_ADDR(BinaryOpIC_Miss)); | |
279 descriptor->SetMissHandler( | |
280 ExternalReference(IC_Utility(IC::kBinaryOpIC_Miss), isolate())); | |
281 } | |
282 | |
283 | |
284 void BinaryOpWithAllocationSiteStub::InitializeInterfaceDescriptor( | |
285 CodeStubInterfaceDescriptor* descriptor) { | |
286 // cp: context | |
287 // x2: allocation site | |
288 // x1: left operand | |
289 // x0: right operand | |
290 Register registers[] = { cp, x2, x1, x0 }; | |
291 descriptor->Initialize(MajorKey(), arraysize(registers), registers, | |
292 FUNCTION_ADDR(BinaryOpIC_MissWithAllocationSite)); | |
293 } | |
294 | |
295 | |
296 void StringAddStub::InitializeInterfaceDescriptor( | |
297 CodeStubInterfaceDescriptor* descriptor) { | |
298 // cp: context | |
299 // x1: left operand | |
300 // x0: right operand | |
301 Register registers[] = { cp, x1, x0 }; | |
302 descriptor->Initialize(MajorKey(), arraysize(registers), registers, | |
303 Runtime::FunctionForId(Runtime::kStringAdd)->entry); | |
304 } | |
305 | |
306 | |
307 #define __ ACCESS_MASM(masm) | 111 #define __ ACCESS_MASM(masm) |
308 | 112 |
309 | 113 |
310 void HydrogenCodeStub::GenerateLightweightMiss(MacroAssembler* masm) { | 114 void HydrogenCodeStub::GenerateLightweightMiss(MacroAssembler* masm) { |
311 // Update the static counter each time a new code stub is generated. | 115 // Update the static counter each time a new code stub is generated. |
312 isolate()->counters()->code_stubs()->Increment(); | 116 isolate()->counters()->code_stubs()->Increment(); |
313 | 117 |
314 CodeStubInterfaceDescriptor* descriptor = GetInterfaceDescriptor(); | 118 CodeStubInterfaceDescriptor* descriptor = GetInterfaceDescriptor(); |
315 int param_count = descriptor->GetEnvironmentParameterCount(); | 119 int param_count = descriptor->GetEnvironmentParameterCount(); |
316 { | 120 { |
(...skipping 1494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1811 if (ReturnTrueFalseObject()) { | 1615 if (ReturnTrueFalseObject()) { |
1812 // Reload true/false because they were clobbered in the builtin call. | 1616 // Reload true/false because they were clobbered in the builtin call. |
1813 __ LoadTrueFalseRoots(res_true, res_false); | 1617 __ LoadTrueFalseRoots(res_true, res_false); |
1814 __ Cmp(result, 0); | 1618 __ Cmp(result, 0); |
1815 __ Csel(result, res_true, res_false, eq); | 1619 __ Csel(result, res_true, res_false, eq); |
1816 } | 1620 } |
1817 __ Ret(); | 1621 __ Ret(); |
1818 } | 1622 } |
1819 | 1623 |
1820 | 1624 |
1821 Register InstanceofStub::left() { | |
1822 // Object to check (instanceof lhs). | |
1823 return x11; | |
1824 } | |
1825 | |
1826 | |
1827 Register InstanceofStub::right() { | |
1828 // Constructor function (instanceof rhs). | |
1829 return x10; | |
1830 } | |
1831 | |
1832 | |
1833 void ArgumentsAccessStub::GenerateReadElement(MacroAssembler* masm) { | 1625 void ArgumentsAccessStub::GenerateReadElement(MacroAssembler* masm) { |
1834 Register arg_count = x0; | 1626 Register arg_count = x0; |
1835 Register key = x1; | 1627 Register key = x1; |
1836 | 1628 |
1837 // The displacement is the offset of the last parameter (if any) relative | 1629 // The displacement is the offset of the last parameter (if any) relative |
1838 // to the frame pointer. | 1630 // to the frame pointer. |
1839 static const int kDisplacement = | 1631 static const int kDisplacement = |
1840 StandardFrameConstants::kCallerSPOffset - kPointerSize; | 1632 StandardFrameConstants::kCallerSPOffset - kPointerSize; |
1841 | 1633 |
1842 // Check that the key is a smi. | 1634 // Check that the key is a smi. |
(...skipping 3506 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5349 MemOperand(fp, 6 * kPointerSize), | 5141 MemOperand(fp, 6 * kPointerSize), |
5350 NULL); | 5142 NULL); |
5351 } | 5143 } |
5352 | 5144 |
5353 | 5145 |
5354 #undef __ | 5146 #undef __ |
5355 | 5147 |
5356 } } // namespace v8::internal | 5148 } } // namespace v8::internal |
5357 | 5149 |
5358 #endif // V8_TARGET_ARCH_ARM64 | 5150 #endif // V8_TARGET_ARCH_ARM64 |
OLD | NEW |