da5e506b2a4c83b88e638f555052c90d45f8986c
[platform/upstream/v8.git] / src / x64 / interface-descriptors-x64.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_X64
8
9 #include "src/interface-descriptors.h"
10
11 namespace v8 {
12 namespace internal {
13
14 const Register CallInterfaceDescriptor::ContextRegister() { return rsi; }
15
16
17 const Register LoadDescriptor::ReceiverRegister() { return rdx; }
18 const Register LoadDescriptor::NameRegister() { return rcx; }
19 const Register LoadDescriptor::SlotRegister() { return rax; }
20
21
22 const Register LoadWithVectorDescriptor::VectorRegister() { return rbx; }
23
24
25 const Register StoreDescriptor::ReceiverRegister() { return rdx; }
26 const Register StoreDescriptor::NameRegister() { return rcx; }
27 const Register StoreDescriptor::ValueRegister() { return rax; }
28
29
30 const Register VectorStoreICTrampolineDescriptor::SlotRegister() { return rdi; }
31
32
33 const Register VectorStoreICDescriptor::VectorRegister() { return rbx; }
34
35
36 const Register StoreTransitionDescriptor::MapRegister() { return rbx; }
37
38
39 const Register LoadGlobalViaContextDescriptor::SlotRegister() { return rbx; }
40
41
42 const Register StoreGlobalViaContextDescriptor::SlotRegister() { return rbx; }
43 const Register StoreGlobalViaContextDescriptor::ValueRegister() { return rax; }
44
45
46 const Register InstanceofDescriptor::left() { return rax; }
47 const Register InstanceofDescriptor::right() { return rdx; }
48
49
50 const Register ArgumentsAccessReadDescriptor::index() { return rdx; }
51 const Register ArgumentsAccessReadDescriptor::parameter_count() { return rax; }
52
53
54 const Register ApiGetterDescriptor::function_address() { return r8; }
55
56
57 const Register MathPowTaggedDescriptor::exponent() { return rdx; }
58
59
60 const Register MathPowIntegerDescriptor::exponent() {
61   return MathPowTaggedDescriptor::exponent();
62 }
63
64
65 const Register GrowArrayElementsDescriptor::ObjectRegister() { return rax; }
66 const Register GrowArrayElementsDescriptor::KeyRegister() { return rbx; }
67
68
69 void StoreTransitionDescriptor::InitializePlatformSpecific(
70     CallInterfaceDescriptorData* data) {
71   Register registers[] = {ReceiverRegister(), NameRegister(), ValueRegister(),
72                           MapRegister()};
73   data->InitializePlatformSpecific(arraysize(registers), registers);
74 }
75
76
77 void FastNewClosureDescriptor::InitializePlatformSpecific(
78     CallInterfaceDescriptorData* data) {
79   Register registers[] = {rbx};
80   data->InitializePlatformSpecific(arraysize(registers), registers);
81 }
82
83
84 void FastNewContextDescriptor::InitializePlatformSpecific(
85     CallInterfaceDescriptorData* data) {
86   Register registers[] = {rdi};
87   data->InitializePlatformSpecific(arraysize(registers), registers);
88 }
89
90
91 void TypeofDescriptor::InitializePlatformSpecific(
92     CallInterfaceDescriptorData* data) {
93   Register registers[] = {rbx};
94   data->InitializePlatformSpecific(arraysize(registers), registers);
95 }
96
97
98 void ToNumberDescriptor::InitializePlatformSpecific(
99     CallInterfaceDescriptorData* data) {
100   // ToNumberStub invokes a function, and therefore needs a context.
101   Register registers[] = {rax};
102   data->InitializePlatformSpecific(arraysize(registers), registers);
103 }
104
105
106 void NumberToStringDescriptor::InitializePlatformSpecific(
107     CallInterfaceDescriptorData* data) {
108   Register registers[] = {rax};
109   data->InitializePlatformSpecific(arraysize(registers), registers);
110 }
111
112
113 void FastCloneShallowArrayDescriptor::InitializePlatformSpecific(
114     CallInterfaceDescriptorData* data) {
115   Register registers[] = {rax, rbx, rcx};
116   data->InitializePlatformSpecific(arraysize(registers), registers);
117 }
118
119
120 void FastCloneShallowObjectDescriptor::InitializePlatformSpecific(
121     CallInterfaceDescriptorData* data) {
122   Register registers[] = {rax, rbx, rcx, rdx};
123   data->InitializePlatformSpecific(arraysize(registers), registers);
124 }
125
126
127 void CreateAllocationSiteDescriptor::InitializePlatformSpecific(
128     CallInterfaceDescriptorData* data) {
129   Register registers[] = {rbx, rdx};
130   data->InitializePlatformSpecific(arraysize(registers), registers);
131 }
132
133
134 void CreateWeakCellDescriptor::InitializePlatformSpecific(
135     CallInterfaceDescriptorData* data) {
136   Register registers[] = {rbx, rdx, rdi};
137   data->InitializePlatformSpecific(arraysize(registers), registers);
138 }
139
140
141 void StoreArrayLiteralElementDescriptor::InitializePlatformSpecific(
142     CallInterfaceDescriptorData* data) {
143   Register registers[] = {rcx, rax};
144   data->InitializePlatformSpecific(arraysize(registers), registers);
145 }
146
147
148 void CallFunctionDescriptor::InitializePlatformSpecific(
149     CallInterfaceDescriptorData* data) {
150   Register registers[] = {rdi};
151   data->InitializePlatformSpecific(arraysize(registers), registers);
152 }
153
154
155 void CallFunctionWithFeedbackDescriptor::InitializePlatformSpecific(
156     CallInterfaceDescriptorData* data) {
157   Register registers[] = {rdi, rdx};
158   data->InitializePlatformSpecific(arraysize(registers), registers);
159 }
160
161
162 void CallFunctionWithFeedbackAndVectorDescriptor::InitializePlatformSpecific(
163     CallInterfaceDescriptorData* data) {
164   Register registers[] = {rdi, rdx, rbx};
165   data->InitializePlatformSpecific(arraysize(registers), registers);
166 }
167
168
169 void CallConstructDescriptor::InitializePlatformSpecific(
170     CallInterfaceDescriptorData* data) {
171   // rax : number of arguments
172   // rbx : feedback vector
173   // rcx : original constructor (for IsSuperConstructorCall)
174   // rdx : slot in feedback vector (Smi, for RecordCallTarget)
175   // rdi : constructor function
176   // TODO(turbofan): So far we don't gather type feedback and hence skip the
177   // slot parameter, but ArrayConstructStub needs the vector to be undefined.
178   Register registers[] = {rax, rdi, rcx, rbx};
179   data->InitializePlatformSpecific(arraysize(registers), registers);
180 }
181
182
183 void RegExpConstructResultDescriptor::InitializePlatformSpecific(
184     CallInterfaceDescriptorData* data) {
185   Register registers[] = {rcx, rbx, rax};
186   data->InitializePlatformSpecific(arraysize(registers), registers);
187 }
188
189
190 void TransitionElementsKindDescriptor::InitializePlatformSpecific(
191     CallInterfaceDescriptorData* data) {
192   Register registers[] = {rax, rbx};
193   data->InitializePlatformSpecific(arraysize(registers), registers);
194 }
195
196
197 void AllocateHeapNumberDescriptor::InitializePlatformSpecific(
198     CallInterfaceDescriptorData* data) {
199   data->InitializePlatformSpecific(0, nullptr, nullptr);
200 }
201
202
203 void ArrayConstructorConstantArgCountDescriptor::InitializePlatformSpecific(
204     CallInterfaceDescriptorData* data) {
205   // register state
206   // rax -- number of arguments
207   // rdi -- function
208   // rbx -- allocation site with elements kind
209   Register registers[] = {rdi, rbx};
210   data->InitializePlatformSpecific(arraysize(registers), registers);
211 }
212
213
214 void ArrayConstructorDescriptor::InitializePlatformSpecific(
215     CallInterfaceDescriptorData* data) {
216   // stack param count needs (constructor pointer, and single argument)
217   Register registers[] = {rdi, rbx, rax};
218   data->InitializePlatformSpecific(arraysize(registers), registers);
219 }
220
221
222 void InternalArrayConstructorConstantArgCountDescriptor::
223     InitializePlatformSpecific(CallInterfaceDescriptorData* data) {
224   // register state
225   // rax -- number of arguments
226   // rdi -- constructor function
227   Register registers[] = {rdi};
228   data->InitializePlatformSpecific(arraysize(registers), registers);
229 }
230
231
232 void InternalArrayConstructorDescriptor::InitializePlatformSpecific(
233     CallInterfaceDescriptorData* data) {
234   // stack param count needs (constructor pointer, and single argument)
235   Register registers[] = {rdi, rax};
236   data->InitializePlatformSpecific(arraysize(registers), registers);
237 }
238
239
240 void CompareDescriptor::InitializePlatformSpecific(
241     CallInterfaceDescriptorData* data) {
242   Register registers[] = {rdx, rax};
243   data->InitializePlatformSpecific(arraysize(registers), registers);
244 }
245
246
247 void CompareNilDescriptor::InitializePlatformSpecific(
248     CallInterfaceDescriptorData* data) {
249   Register registers[] = {rax};
250   data->InitializePlatformSpecific(arraysize(registers), registers);
251 }
252
253
254 void ToBooleanDescriptor::InitializePlatformSpecific(
255     CallInterfaceDescriptorData* data) {
256   Register registers[] = {rax};
257   data->InitializePlatformSpecific(arraysize(registers), registers);
258 }
259
260
261 void BinaryOpDescriptor::InitializePlatformSpecific(
262     CallInterfaceDescriptorData* data) {
263   Register registers[] = {rdx, rax};
264   data->InitializePlatformSpecific(arraysize(registers), registers);
265 }
266
267
268 void BinaryOpWithAllocationSiteDescriptor::InitializePlatformSpecific(
269     CallInterfaceDescriptorData* data) {
270   Register registers[] = {rcx, rdx, rax};
271   data->InitializePlatformSpecific(arraysize(registers), registers);
272 }
273
274
275 void StringAddDescriptor::InitializePlatformSpecific(
276     CallInterfaceDescriptorData* data) {
277   Register registers[] = {rdx, rax};
278   data->InitializePlatformSpecific(arraysize(registers), registers);
279 }
280
281
282 void KeyedDescriptor::InitializePlatformSpecific(
283     CallInterfaceDescriptorData* data) {
284   Register registers[] = {
285       rcx,  // key
286   };
287   data->InitializePlatformSpecific(arraysize(registers), registers);
288 }
289
290
291 void NamedDescriptor::InitializePlatformSpecific(
292     CallInterfaceDescriptorData* data) {
293   Register registers[] = {
294       rcx,  // name
295   };
296   data->InitializePlatformSpecific(arraysize(registers), registers);
297 }
298
299
300 void CallHandlerDescriptor::InitializePlatformSpecific(
301     CallInterfaceDescriptorData* data) {
302   Register registers[] = {
303       rdx,  // receiver
304   };
305   data->InitializePlatformSpecific(arraysize(registers), registers);
306 }
307
308
309 void ArgumentAdaptorDescriptor::InitializePlatformSpecific(
310     CallInterfaceDescriptorData* data) {
311   Register registers[] = {
312       rdi,  // JSFunction
313       rax,  // actual number of arguments
314       rbx,  // expected number of arguments
315   };
316   data->InitializePlatformSpecific(arraysize(registers), registers);
317 }
318
319
320 void ApiFunctionDescriptor::InitializePlatformSpecific(
321     CallInterfaceDescriptorData* data) {
322   Register registers[] = {
323       rdi,  // callee
324       rbx,  // call_data
325       rcx,  // holder
326       rdx,  // api_function_address
327       rax,  // actual number of arguments
328   };
329   data->InitializePlatformSpecific(arraysize(registers), registers);
330 }
331
332
333 void ApiAccessorDescriptor::InitializePlatformSpecific(
334     CallInterfaceDescriptorData* data) {
335   Register registers[] = {
336       rdi,  // callee
337       rbx,  // call_data
338       rcx,  // holder
339       rdx,  // api_function_address
340   };
341   data->InitializePlatformSpecific(arraysize(registers), registers);
342 }
343
344
345 void MathRoundVariantCallFromUnoptimizedCodeDescriptor::
346     InitializePlatformSpecific(CallInterfaceDescriptorData* data) {
347   Register registers[] = {
348       rdi,  // math rounding function
349       rdx,  // vector slot id
350   };
351   data->InitializePlatformSpecific(arraysize(registers), registers);
352 }
353
354
355 void MathRoundVariantCallFromOptimizedCodeDescriptor::
356     InitializePlatformSpecific(CallInterfaceDescriptorData* data) {
357   Register registers[] = {
358       rdi,  // math rounding function
359       rdx,  // vector slot id
360       rbx   // type vector
361   };
362   data->InitializePlatformSpecific(arraysize(registers), registers);
363 }
364 }  // namespace internal
365 }  // namespace v8
366
367 #endif  // V8_TARGET_ARCH_X64