6deeabfcf516b60fd603aa371670e278e864f309
[platform/upstream/nodejs.git] / deps / v8 / src / arm64 / interface-descriptors-arm64.cc
1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "src/v8.h"
6
7 #if V8_TARGET_ARCH_ARM64
8
9 #include "src/interface-descriptors.h"
10
11 namespace v8 {
12 namespace internal {
13
14 const Register CallInterfaceDescriptor::ContextRegister() { return cp; }
15
16
17 const Register LoadDescriptor::ReceiverRegister() { return x1; }
18 const Register LoadDescriptor::NameRegister() { return x2; }
19
20
21 const Register VectorLoadICTrampolineDescriptor::SlotRegister() { return x0; }
22
23
24 const Register VectorLoadICDescriptor::VectorRegister() { return x3; }
25
26
27 const Register StoreDescriptor::ReceiverRegister() { return x1; }
28 const Register StoreDescriptor::NameRegister() { return x2; }
29 const Register StoreDescriptor::ValueRegister() { return x0; }
30
31
32 const Register StoreTransitionDescriptor::MapRegister() { return x3; }
33
34
35 const Register ElementTransitionAndStoreDescriptor::MapRegister() { return x3; }
36
37
38 const Register InstanceofDescriptor::left() {
39   // Object to check (instanceof lhs).
40   return x11;
41 }
42
43
44 const Register InstanceofDescriptor::right() {
45   // Constructor function (instanceof rhs).
46   return x10;
47 }
48
49
50 const Register ArgumentsAccessReadDescriptor::index() { return x1; }
51 const Register ArgumentsAccessReadDescriptor::parameter_count() { return x0; }
52
53
54 const Register ApiGetterDescriptor::function_address() { return x2; }
55
56
57 const Register MathPowTaggedDescriptor::exponent() { return x11; }
58
59
60 const Register MathPowIntegerDescriptor::exponent() { return x12; }
61
62
63 void FastNewClosureDescriptor::Initialize(CallInterfaceDescriptorData* data) {
64   // cp: context
65   // x2: function info
66   Register registers[] = {cp, x2};
67   data->Initialize(arraysize(registers), registers, NULL);
68 }
69
70
71 void FastNewContextDescriptor::Initialize(CallInterfaceDescriptorData* data) {
72   // cp: context
73   // x1: function
74   Register registers[] = {cp, x1};
75   data->Initialize(arraysize(registers), registers, NULL);
76 }
77
78
79 void ToNumberDescriptor::Initialize(CallInterfaceDescriptorData* data) {
80   // cp: context
81   // x0: value
82   Register registers[] = {cp, x0};
83   data->Initialize(arraysize(registers), registers, NULL);
84 }
85
86
87 void NumberToStringDescriptor::Initialize(CallInterfaceDescriptorData* data) {
88   // cp: context
89   // x0: value
90   Register registers[] = {cp, x0};
91   data->Initialize(arraysize(registers), registers, NULL);
92 }
93
94
95 void FastCloneShallowArrayDescriptor::Initialize(
96     CallInterfaceDescriptorData* data) {
97   // cp: context
98   // x3: array literals array
99   // x2: array literal index
100   // x1: constant elements
101   Register registers[] = {cp, x3, x2, x1};
102   Representation representations[] = {
103       Representation::Tagged(), Representation::Tagged(), Representation::Smi(),
104       Representation::Tagged()};
105   data->Initialize(arraysize(registers), registers, representations);
106 }
107
108
109 void FastCloneShallowObjectDescriptor::Initialize(
110     CallInterfaceDescriptorData* data) {
111   // cp: context
112   // x3: object literals array
113   // x2: object literal index
114   // x1: constant properties
115   // x0: object literal flags
116   Register registers[] = {cp, x3, x2, x1, x0};
117   data->Initialize(arraysize(registers), registers, NULL);
118 }
119
120
121 void CreateAllocationSiteDescriptor::Initialize(
122     CallInterfaceDescriptorData* data) {
123   // cp: context
124   // x2: feedback vector
125   // x3: call feedback slot
126   Register registers[] = {cp, x2, x3};
127   Representation representations[] = {Representation::Tagged(),
128                                       Representation::Tagged(),
129                                       Representation::Smi()};
130   data->Initialize(arraysize(registers), registers, representations);
131 }
132
133
134 void CreateWeakCellDescriptor::Initialize(CallInterfaceDescriptorData* data) {
135   // cp: context
136   // x2: feedback vector
137   // x3: call feedback slot
138   // x1: tagged value to put in the weak cell
139   Register registers[] = {cp, x2, x3, x1};
140   Representation representations[] = {
141       Representation::Tagged(), Representation::Tagged(), Representation::Smi(),
142       Representation::Tagged()};
143   data->Initialize(arraysize(registers), registers, representations);
144 }
145
146
147 void StoreArrayLiteralElementDescriptor::Initialize(
148     CallInterfaceDescriptorData* data) {
149   Register registers[] = {cp, x3, x0};
150   data->Initialize(arraysize(registers), registers, NULL);
151 }
152
153
154 void CallFunctionDescriptor::Initialize(CallInterfaceDescriptorData* data) {
155   // x1  function    the function to call
156   Register registers[] = {cp, x1};
157   data->Initialize(arraysize(registers), registers, NULL);
158 }
159
160
161 void CallFunctionWithFeedbackDescriptor::Initialize(
162     CallInterfaceDescriptorData* data) {
163   Register registers[] = {cp, x1, x3};
164   Representation representations[] = {Representation::Tagged(),
165                                       Representation::Tagged(),
166                                       Representation::Smi()};
167   data->Initialize(arraysize(registers), registers, representations);
168 }
169
170
171 void CallFunctionWithFeedbackAndVectorDescriptor::Initialize(
172     CallInterfaceDescriptorData* data) {
173   Register registers[] = {cp, x1, x3, x2};
174   Representation representations[] = {
175       Representation::Tagged(), Representation::Tagged(), Representation::Smi(),
176       Representation::Tagged()};
177   data->Initialize(arraysize(registers), registers, representations);
178 }
179
180
181 void CallConstructDescriptor::Initialize(CallInterfaceDescriptorData* data) {
182   // x0 : number of arguments
183   // x1 : the function to call
184   // x2 : feedback vector
185   // x3 : slot in feedback vector (smi) (if r2 is not the megamorphic symbol)
186   // TODO(turbofan): So far we don't gather type feedback and hence skip the
187   // slot parameter, but ArrayConstructStub needs the vector to be undefined.
188   Register registers[] = {cp, x0, x1, x2};
189   data->Initialize(arraysize(registers), registers, NULL);
190 }
191
192
193 void RegExpConstructResultDescriptor::Initialize(
194     CallInterfaceDescriptorData* data) {
195   // cp: context
196   // x2: length
197   // x1: index (of last match)
198   // x0: string
199   Register registers[] = {cp, x2, x1, x0};
200   data->Initialize(arraysize(registers), registers, NULL);
201 }
202
203
204 void TransitionElementsKindDescriptor::Initialize(
205     CallInterfaceDescriptorData* data) {
206   // cp: context
207   // x0: value (js_array)
208   // x1: to_map
209   Register registers[] = {cp, x0, x1};
210   data->Initialize(arraysize(registers), registers, NULL);
211 }
212
213
214 void AllocateHeapNumberDescriptor::Initialize(
215     CallInterfaceDescriptorData* data) {
216   // cp: context
217   Register registers[] = {cp};
218   data->Initialize(arraysize(registers), registers, nullptr);
219 }
220
221
222 void ArrayConstructorConstantArgCountDescriptor::Initialize(
223     CallInterfaceDescriptorData* data) {
224   // cp: context
225   // x1: function
226   // x2: allocation site with elements kind
227   // x0: number of arguments to the constructor function
228   Register registers[] = {cp, x1, x2};
229   data->Initialize(arraysize(registers), registers, NULL);
230 }
231
232
233 void ArrayConstructorDescriptor::Initialize(CallInterfaceDescriptorData* data) {
234   // stack param count needs (constructor pointer, and single argument)
235   Register registers[] = {cp, x1, x2, x0};
236   Representation representations[] = {
237       Representation::Tagged(), Representation::Tagged(),
238       Representation::Tagged(), Representation::Integer32()};
239   data->Initialize(arraysize(registers), registers, representations);
240 }
241
242
243 void InternalArrayConstructorConstantArgCountDescriptor::Initialize(
244     CallInterfaceDescriptorData* data) {
245   // cp: context
246   // x1: constructor function
247   // x0: number of arguments to the constructor function
248   Register registers[] = {cp, x1};
249   data->Initialize(arraysize(registers), registers, NULL);
250 }
251
252
253 void InternalArrayConstructorDescriptor::Initialize(
254     CallInterfaceDescriptorData* data) {
255   // stack param count needs (constructor pointer, and single argument)
256   Register registers[] = {cp, x1, x0};
257   Representation representations[] = {Representation::Tagged(),
258                                       Representation::Tagged(),
259                                       Representation::Integer32()};
260   data->Initialize(arraysize(registers), registers, representations);
261 }
262
263
264 void CompareNilDescriptor::Initialize(CallInterfaceDescriptorData* data) {
265   // cp: context
266   // x0: value to compare
267   Register registers[] = {cp, x0};
268   data->Initialize(arraysize(registers), registers, NULL);
269 }
270
271
272 void ToBooleanDescriptor::Initialize(CallInterfaceDescriptorData* data) {
273   // cp: context
274   // x0: value
275   Register registers[] = {cp, x0};
276   data->Initialize(arraysize(registers), registers, NULL);
277 }
278
279
280 void BinaryOpDescriptor::Initialize(CallInterfaceDescriptorData* data) {
281   // cp: context
282   // x1: left operand
283   // x0: right operand
284   Register registers[] = {cp, x1, x0};
285   data->Initialize(arraysize(registers), registers, NULL);
286 }
287
288
289 void BinaryOpWithAllocationSiteDescriptor::Initialize(
290     CallInterfaceDescriptorData* data) {
291   // cp: context
292   // x2: allocation site
293   // x1: left operand
294   // x0: right operand
295   Register registers[] = {cp, x2, x1, x0};
296   data->Initialize(arraysize(registers), registers, NULL);
297 }
298
299
300 void StringAddDescriptor::Initialize(CallInterfaceDescriptorData* data) {
301   // cp: context
302   // x1: left operand
303   // x0: right operand
304   Register registers[] = {cp, x1, x0};
305   data->Initialize(arraysize(registers), registers, NULL);
306 }
307
308
309 void KeyedDescriptor::Initialize(CallInterfaceDescriptorData* data) {
310   static PlatformInterfaceDescriptor noInlineDescriptor =
311       PlatformInterfaceDescriptor(NEVER_INLINE_TARGET_ADDRESS);
312
313   Register registers[] = {
314       cp,  // context
315       x2,  // key
316   };
317   Representation representations[] = {
318       Representation::Tagged(),  // context
319       Representation::Tagged(),  // key
320   };
321   data->Initialize(arraysize(registers), registers, representations,
322                    &noInlineDescriptor);
323 }
324
325
326 void NamedDescriptor::Initialize(CallInterfaceDescriptorData* data) {
327   static PlatformInterfaceDescriptor noInlineDescriptor =
328       PlatformInterfaceDescriptor(NEVER_INLINE_TARGET_ADDRESS);
329
330   Register registers[] = {
331       cp,  // context
332       x2,  // name
333   };
334   Representation representations[] = {
335       Representation::Tagged(),  // context
336       Representation::Tagged(),  // name
337   };
338   data->Initialize(arraysize(registers), registers, representations,
339                    &noInlineDescriptor);
340 }
341
342
343 void CallHandlerDescriptor::Initialize(CallInterfaceDescriptorData* data) {
344   static PlatformInterfaceDescriptor default_descriptor =
345       PlatformInterfaceDescriptor(CAN_INLINE_TARGET_ADDRESS);
346
347   Register registers[] = {
348       cp,  // context
349       x0,  // receiver
350   };
351   Representation representations[] = {
352       Representation::Tagged(),  // context
353       Representation::Tagged(),  // receiver
354   };
355   data->Initialize(arraysize(registers), registers, representations,
356                    &default_descriptor);
357 }
358
359
360 void ArgumentAdaptorDescriptor::Initialize(CallInterfaceDescriptorData* data) {
361   static PlatformInterfaceDescriptor default_descriptor =
362       PlatformInterfaceDescriptor(CAN_INLINE_TARGET_ADDRESS);
363
364   Register registers[] = {
365       cp,  // context
366       x1,  // JSFunction
367       x0,  // actual number of arguments
368       x2,  // expected number of arguments
369   };
370   Representation representations[] = {
371       Representation::Tagged(),     // context
372       Representation::Tagged(),     // JSFunction
373       Representation::Integer32(),  // actual number of arguments
374       Representation::Integer32(),  // expected number of arguments
375   };
376   data->Initialize(arraysize(registers), registers, representations,
377                    &default_descriptor);
378 }
379
380
381 void ApiFunctionDescriptor::Initialize(CallInterfaceDescriptorData* data) {
382   static PlatformInterfaceDescriptor default_descriptor =
383       PlatformInterfaceDescriptor(CAN_INLINE_TARGET_ADDRESS);
384
385   Register registers[] = {
386       cp,  // context
387       x0,  // callee
388       x4,  // call_data
389       x2,  // holder
390       x1,  // api_function_address
391       x3,  // actual number of arguments
392   };
393   Representation representations[] = {
394       Representation::Tagged(),     // context
395       Representation::Tagged(),     // callee
396       Representation::Tagged(),     // call_data
397       Representation::Tagged(),     // holder
398       Representation::External(),   // api_function_address
399       Representation::Integer32(),  // actual number of arguments
400   };
401   data->Initialize(arraysize(registers), registers, representations,
402                    &default_descriptor);
403 }
404
405
406 void ApiAccessorDescriptor::Initialize(CallInterfaceDescriptorData* data) {
407   static PlatformInterfaceDescriptor default_descriptor =
408       PlatformInterfaceDescriptor(CAN_INLINE_TARGET_ADDRESS);
409
410   Register registers[] = {
411       cp,  // context
412       x0,  // callee
413       x4,  // call_data
414       x2,  // holder
415       x1,  // api_function_address
416   };
417   Representation representations[] = {
418       Representation::Tagged(),    // context
419       Representation::Tagged(),    // callee
420       Representation::Tagged(),    // call_data
421       Representation::Tagged(),    // holder
422       Representation::External(),  // api_function_address
423   };
424   data->Initialize(arraysize(registers), registers, representations,
425                    &default_descriptor);
426 }
427 }
428 }  // namespace v8::internal
429
430 #endif  // V8_TARGET_ARCH_ARM64