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