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 #if V8_TARGET_ARCH_X87
6
7 #include "src/interface-descriptors.h"
8
9 namespace v8 {
10 namespace internal {
11
ContextRegister()12 const Register CallInterfaceDescriptor::ContextRegister() { return esi; }
13
14
ReceiverRegister()15 const Register LoadDescriptor::ReceiverRegister() { return edx; }
NameRegister()16 const Register LoadDescriptor::NameRegister() { return ecx; }
SlotRegister()17 const Register LoadDescriptor::SlotRegister() { return eax; }
18
VectorRegister()19 const Register LoadWithVectorDescriptor::VectorRegister() { return ebx; }
20
21
ReceiverRegister()22 const Register StoreDescriptor::ReceiverRegister() { return edx; }
NameRegister()23 const Register StoreDescriptor::NameRegister() { return ecx; }
ValueRegister()24 const Register StoreDescriptor::ValueRegister() { return eax; }
25
26
SlotRegister()27 const Register VectorStoreICTrampolineDescriptor::SlotRegister() { return edi; }
28
29
VectorRegister()30 const Register VectorStoreICDescriptor::VectorRegister() { return ebx; }
31
32
SlotRegister()33 const Register VectorStoreTransitionDescriptor::SlotRegister() {
34 return no_reg;
35 }
36
37
VectorRegister()38 const Register VectorStoreTransitionDescriptor::VectorRegister() { return ebx; }
39
40
MapRegister()41 const Register VectorStoreTransitionDescriptor::MapRegister() { return edi; }
42
43
MapRegister()44 const Register StoreTransitionDescriptor::MapRegister() { return ebx; }
45
46
SlotRegister()47 const Register LoadGlobalViaContextDescriptor::SlotRegister() { return ebx; }
48
49
SlotRegister()50 const Register StoreGlobalViaContextDescriptor::SlotRegister() { return ebx; }
ValueRegister()51 const Register StoreGlobalViaContextDescriptor::ValueRegister() { return eax; }
52
53
LeftRegister()54 const Register InstanceOfDescriptor::LeftRegister() { return edx; }
RightRegister()55 const Register InstanceOfDescriptor::RightRegister() { return eax; }
56
57
LeftRegister()58 const Register StringCompareDescriptor::LeftRegister() { return edx; }
RightRegister()59 const Register StringCompareDescriptor::RightRegister() { return eax; }
60
61
index()62 const Register ArgumentsAccessReadDescriptor::index() { return edx; }
parameter_count()63 const Register ArgumentsAccessReadDescriptor::parameter_count() { return eax; }
64
65
function()66 const Register ArgumentsAccessNewDescriptor::function() { return edi; }
parameter_count()67 const Register ArgumentsAccessNewDescriptor::parameter_count() { return ecx; }
parameter_pointer()68 const Register ArgumentsAccessNewDescriptor::parameter_pointer() { return edx; }
69
70
parameter_count()71 const Register RestParamAccessDescriptor::parameter_count() { return ecx; }
parameter_pointer()72 const Register RestParamAccessDescriptor::parameter_pointer() { return edx; }
rest_parameter_index()73 const Register RestParamAccessDescriptor::rest_parameter_index() { return ebx; }
74
75
function_address()76 const Register ApiGetterDescriptor::function_address() { return edx; }
77
78
exponent()79 const Register MathPowTaggedDescriptor::exponent() { return eax; }
80
81
exponent()82 const Register MathPowIntegerDescriptor::exponent() {
83 return MathPowTaggedDescriptor::exponent();
84 }
85
86
ObjectRegister()87 const Register GrowArrayElementsDescriptor::ObjectRegister() { return eax; }
KeyRegister()88 const Register GrowArrayElementsDescriptor::KeyRegister() { return ebx; }
89
90
InitializePlatformSpecific(CallInterfaceDescriptorData * data)91 void FastNewClosureDescriptor::InitializePlatformSpecific(
92 CallInterfaceDescriptorData* data) {
93 Register registers[] = {ebx};
94 data->InitializePlatformSpecific(arraysize(registers), registers, NULL);
95 }
96
97
InitializePlatformSpecific(CallInterfaceDescriptorData * data)98 void FastNewContextDescriptor::InitializePlatformSpecific(
99 CallInterfaceDescriptorData* data) {
100 Register registers[] = {edi};
101 data->InitializePlatformSpecific(arraysize(registers), registers, NULL);
102 }
103
104
InitializePlatformSpecific(CallInterfaceDescriptorData * data)105 void ToNumberDescriptor::InitializePlatformSpecific(
106 CallInterfaceDescriptorData* data) {
107 // ToNumberStub invokes a function, and therefore needs a context.
108 Register registers[] = {eax};
109 data->InitializePlatformSpecific(arraysize(registers), registers, NULL);
110 }
111
112
113 // static
ReceiverRegister()114 const Register ToLengthDescriptor::ReceiverRegister() { return eax; }
115
116
117 // static
ReceiverRegister()118 const Register ToStringDescriptor::ReceiverRegister() { return eax; }
119
120
121 // static
ReceiverRegister()122 const Register ToObjectDescriptor::ReceiverRegister() { return eax; }
123
124
InitializePlatformSpecific(CallInterfaceDescriptorData * data)125 void NumberToStringDescriptor::InitializePlatformSpecific(
126 CallInterfaceDescriptorData* data) {
127 Register registers[] = {eax};
128 data->InitializePlatformSpecific(arraysize(registers), registers, NULL);
129 }
130
131
InitializePlatformSpecific(CallInterfaceDescriptorData * data)132 void TypeofDescriptor::InitializePlatformSpecific(
133 CallInterfaceDescriptorData* data) {
134 Register registers[] = {ebx};
135 data->InitializePlatformSpecific(arraysize(registers), registers, NULL);
136 }
137
138
InitializePlatformSpecific(CallInterfaceDescriptorData * data)139 void FastCloneRegExpDescriptor::InitializePlatformSpecific(
140 CallInterfaceDescriptorData* data) {
141 Register registers[] = {edi, eax, ecx, edx};
142 data->InitializePlatformSpecific(arraysize(registers), registers);
143 }
144
145
InitializePlatformSpecific(CallInterfaceDescriptorData * data)146 void FastCloneShallowArrayDescriptor::InitializePlatformSpecific(
147 CallInterfaceDescriptorData* data) {
148 Register registers[] = {eax, ebx, ecx};
149 data->InitializePlatformSpecific(arraysize(registers), registers);
150 }
151
152
InitializePlatformSpecific(CallInterfaceDescriptorData * data)153 void FastCloneShallowObjectDescriptor::InitializePlatformSpecific(
154 CallInterfaceDescriptorData* data) {
155 Register registers[] = {eax, ebx, ecx, edx};
156 data->InitializePlatformSpecific(arraysize(registers), registers, NULL);
157 }
158
159
InitializePlatformSpecific(CallInterfaceDescriptorData * data)160 void CreateAllocationSiteDescriptor::InitializePlatformSpecific(
161 CallInterfaceDescriptorData* data) {
162 Register registers[] = {ebx, edx};
163 data->InitializePlatformSpecific(arraysize(registers), registers);
164 }
165
166
InitializePlatformSpecific(CallInterfaceDescriptorData * data)167 void CreateWeakCellDescriptor::InitializePlatformSpecific(
168 CallInterfaceDescriptorData* data) {
169 Register registers[] = {ebx, edx, edi};
170 data->InitializePlatformSpecific(arraysize(registers), registers);
171 }
172
173
InitializePlatformSpecific(CallInterfaceDescriptorData * data)174 void StoreArrayLiteralElementDescriptor::InitializePlatformSpecific(
175 CallInterfaceDescriptorData* data) {
176 Register registers[] = {ecx, eax};
177 data->InitializePlatformSpecific(arraysize(registers), registers, NULL);
178 }
179
180
InitializePlatformSpecific(CallInterfaceDescriptorData * data)181 void CallFunctionDescriptor::InitializePlatformSpecific(
182 CallInterfaceDescriptorData* data) {
183 Register registers[] = {edi};
184 data->InitializePlatformSpecific(arraysize(registers), registers, NULL);
185 }
186
187
InitializePlatformSpecific(CallInterfaceDescriptorData * data)188 void CallFunctionWithFeedbackDescriptor::InitializePlatformSpecific(
189 CallInterfaceDescriptorData* data) {
190 Register registers[] = {edi, edx};
191 data->InitializePlatformSpecific(arraysize(registers), registers);
192 }
193
194
InitializePlatformSpecific(CallInterfaceDescriptorData * data)195 void CallFunctionWithFeedbackAndVectorDescriptor::InitializePlatformSpecific(
196 CallInterfaceDescriptorData* data) {
197 Register registers[] = {edi, edx, ebx};
198 data->InitializePlatformSpecific(arraysize(registers), registers);
199 }
200
201
InitializePlatformSpecific(CallInterfaceDescriptorData * data)202 void CallConstructDescriptor::InitializePlatformSpecific(
203 CallInterfaceDescriptorData* data) {
204 // eax : number of arguments
205 // ebx : feedback vector
206 // ecx : new target (for IsSuperConstructorCall)
207 // edx : slot in feedback vector (Smi, for RecordCallTarget)
208 // edi : constructor function
209 // TODO(turbofan): So far we don't gather type feedback and hence skip the
210 // slot parameter, but ArrayConstructStub needs the vector to be undefined.
211 Register registers[] = {eax, edi, ecx, ebx};
212 data->InitializePlatformSpecific(arraysize(registers), registers, NULL);
213 }
214
215
InitializePlatformSpecific(CallInterfaceDescriptorData * data)216 void CallTrampolineDescriptor::InitializePlatformSpecific(
217 CallInterfaceDescriptorData* data) {
218 // eax : number of arguments
219 // edi : the target to call
220 Register registers[] = {edi, eax};
221 data->InitializePlatformSpecific(arraysize(registers), registers);
222 }
223
224
InitializePlatformSpecific(CallInterfaceDescriptorData * data)225 void ConstructStubDescriptor::InitializePlatformSpecific(
226 CallInterfaceDescriptorData* data) {
227 // eax : number of arguments
228 // edx : the new target
229 // edi : the target to call
230 // ebx : allocation site or undefined
231 Register registers[] = {edi, edx, eax, ebx};
232 data->InitializePlatformSpecific(arraysize(registers), registers);
233 }
234
235
InitializePlatformSpecific(CallInterfaceDescriptorData * data)236 void ConstructTrampolineDescriptor::InitializePlatformSpecific(
237 CallInterfaceDescriptorData* data) {
238 // eax : number of arguments
239 // edx : the new target
240 // edi : the target to call
241 Register registers[] = {edi, edx, eax};
242 data->InitializePlatformSpecific(arraysize(registers), registers);
243 }
244
245
InitializePlatformSpecific(CallInterfaceDescriptorData * data)246 void RegExpConstructResultDescriptor::InitializePlatformSpecific(
247 CallInterfaceDescriptorData* data) {
248 Register registers[] = {ecx, ebx, eax};
249 data->InitializePlatformSpecific(arraysize(registers), registers, NULL);
250 }
251
252
InitializePlatformSpecific(CallInterfaceDescriptorData * data)253 void TransitionElementsKindDescriptor::InitializePlatformSpecific(
254 CallInterfaceDescriptorData* data) {
255 Register registers[] = {eax, ebx};
256 data->InitializePlatformSpecific(arraysize(registers), registers, NULL);
257 }
258
259
InitializePlatformSpecific(CallInterfaceDescriptorData * data)260 void AllocateHeapNumberDescriptor::InitializePlatformSpecific(
261 CallInterfaceDescriptorData* data) {
262 // register state
263 data->InitializePlatformSpecific(0, nullptr, nullptr);
264 }
265
266
InitializePlatformSpecific(CallInterfaceDescriptorData * data)267 void AllocateInNewSpaceDescriptor::InitializePlatformSpecific(
268 CallInterfaceDescriptorData* data) {
269 Register registers[] = {eax};
270 data->InitializePlatformSpecific(arraysize(registers), registers);
271 }
272
273
InitializePlatformSpecific(CallInterfaceDescriptorData * data)274 void ArrayConstructorConstantArgCountDescriptor::InitializePlatformSpecific(
275 CallInterfaceDescriptorData* data) {
276 // register state
277 // eax -- number of arguments
278 // edi -- function
279 // ebx -- allocation site with elements kind
280 Register registers[] = {edi, ebx};
281 data->InitializePlatformSpecific(arraysize(registers), registers, NULL);
282 }
283
284
InitializePlatformSpecific(CallInterfaceDescriptorData * data)285 void ArrayConstructorDescriptor::InitializePlatformSpecific(
286 CallInterfaceDescriptorData* data) {
287 // stack param count needs (constructor pointer, and single argument)
288 Register registers[] = {edi, ebx, eax};
289 data->InitializePlatformSpecific(arraysize(registers), registers);
290 }
291
292
293 void InternalArrayConstructorConstantArgCountDescriptor::
InitializePlatformSpecific(CallInterfaceDescriptorData * data)294 InitializePlatformSpecific(CallInterfaceDescriptorData* data) {
295 // register state
296 // eax -- number of arguments
297 // edi -- function
298 Register registers[] = {edi};
299 data->InitializePlatformSpecific(arraysize(registers), registers, NULL);
300 }
301
302
InitializePlatformSpecific(CallInterfaceDescriptorData * data)303 void InternalArrayConstructorDescriptor::InitializePlatformSpecific(
304 CallInterfaceDescriptorData* data) {
305 // stack param count needs (constructor pointer, and single argument)
306 Register registers[] = {edi, eax};
307 data->InitializePlatformSpecific(arraysize(registers), registers);
308 }
309
310
InitializePlatformSpecific(CallInterfaceDescriptorData * data)311 void CompareDescriptor::InitializePlatformSpecific(
312 CallInterfaceDescriptorData* data) {
313 Register registers[] = {edx, eax};
314 data->InitializePlatformSpecific(arraysize(registers), registers, NULL);
315 }
316
317
InitializePlatformSpecific(CallInterfaceDescriptorData * data)318 void CompareNilDescriptor::InitializePlatformSpecific(
319 CallInterfaceDescriptorData* data) {
320 Register registers[] = {eax};
321 data->InitializePlatformSpecific(arraysize(registers), registers, NULL);
322 }
323
324
InitializePlatformSpecific(CallInterfaceDescriptorData * data)325 void ToBooleanDescriptor::InitializePlatformSpecific(
326 CallInterfaceDescriptorData* data) {
327 Register registers[] = {eax};
328 data->InitializePlatformSpecific(arraysize(registers), registers, NULL);
329 }
330
331
InitializePlatformSpecific(CallInterfaceDescriptorData * data)332 void BinaryOpDescriptor::InitializePlatformSpecific(
333 CallInterfaceDescriptorData* data) {
334 Register registers[] = {edx, eax};
335 data->InitializePlatformSpecific(arraysize(registers), registers, NULL);
336 }
337
338
InitializePlatformSpecific(CallInterfaceDescriptorData * data)339 void BinaryOpWithAllocationSiteDescriptor::InitializePlatformSpecific(
340 CallInterfaceDescriptorData* data) {
341 Register registers[] = {ecx, edx, eax};
342 data->InitializePlatformSpecific(arraysize(registers), registers, NULL);
343 }
344
345
InitializePlatformSpecific(CallInterfaceDescriptorData * data)346 void StringAddDescriptor::InitializePlatformSpecific(
347 CallInterfaceDescriptorData* data) {
348 Register registers[] = {edx, eax};
349 data->InitializePlatformSpecific(arraysize(registers), registers, NULL);
350 }
351
352
InitializePlatformSpecific(CallInterfaceDescriptorData * data)353 void KeyedDescriptor::InitializePlatformSpecific(
354 CallInterfaceDescriptorData* data) {
355 Register registers[] = {
356 ecx, // key
357 };
358 data->InitializePlatformSpecific(arraysize(registers), registers);
359 }
360
361
InitializePlatformSpecific(CallInterfaceDescriptorData * data)362 void NamedDescriptor::InitializePlatformSpecific(
363 CallInterfaceDescriptorData* data) {
364 Register registers[] = {
365 ecx, // name
366 };
367 data->InitializePlatformSpecific(arraysize(registers), registers);
368 }
369
370
InitializePlatformSpecific(CallInterfaceDescriptorData * data)371 void CallHandlerDescriptor::InitializePlatformSpecific(
372 CallInterfaceDescriptorData* data) {
373 Register registers[] = {
374 edx, // name
375 };
376 data->InitializePlatformSpecific(arraysize(registers), registers);
377 }
378
379
InitializePlatformSpecific(CallInterfaceDescriptorData * data)380 void ArgumentAdaptorDescriptor::InitializePlatformSpecific(
381 CallInterfaceDescriptorData* data) {
382 Register registers[] = {
383 edi, // JSFunction
384 edx, // the new target
385 eax, // actual number of arguments
386 ebx, // expected number of arguments
387 };
388 data->InitializePlatformSpecific(arraysize(registers), registers);
389 }
390
391
InitializePlatformSpecific(CallInterfaceDescriptorData * data)392 void ApiFunctionDescriptor::InitializePlatformSpecific(
393 CallInterfaceDescriptorData* data) {
394 Register registers[] = {
395 edi, // callee
396 ebx, // call_data
397 ecx, // holder
398 edx, // api_function_address
399 eax, // actual number of arguments
400 };
401 data->InitializePlatformSpecific(arraysize(registers), registers);
402 }
403
404
InitializePlatformSpecific(CallInterfaceDescriptorData * data)405 void ApiAccessorDescriptor::InitializePlatformSpecific(
406 CallInterfaceDescriptorData* data) {
407 Register registers[] = {
408 edi, // callee
409 ebx, // call_data
410 ecx, // holder
411 edx, // api_function_address
412 };
413 data->InitializePlatformSpecific(arraysize(registers), registers);
414 }
415
416
InitializePlatformSpecific(CallInterfaceDescriptorData * data)417 void InterpreterPushArgsAndCallDescriptor::InitializePlatformSpecific(
418 CallInterfaceDescriptorData* data) {
419 Register registers[] = {
420 eax, // argument count (not including receiver)
421 ebx, // address of first argument
422 edi // the target callable to be call
423 };
424 data->InitializePlatformSpecific(arraysize(registers), registers);
425 }
426
427
InitializePlatformSpecific(CallInterfaceDescriptorData * data)428 void InterpreterPushArgsAndConstructDescriptor::InitializePlatformSpecific(
429 CallInterfaceDescriptorData* data) {
430 Register registers[] = {
431 eax, // argument count (not including receiver)
432 edx, // new target
433 edi, // constructor
434 ebx, // address of first argument
435 };
436 data->InitializePlatformSpecific(arraysize(registers), registers);
437 }
438
439
InitializePlatformSpecific(CallInterfaceDescriptorData * data)440 void InterpreterCEntryDescriptor::InitializePlatformSpecific(
441 CallInterfaceDescriptorData* data) {
442 Register registers[] = {
443 eax, // argument count (argc)
444 ecx, // address of first argument (argv)
445 ebx // the runtime function to call
446 };
447 data->InitializePlatformSpecific(arraysize(registers), registers);
448 }
449
450 } // namespace internal
451 } // namespace v8
452
453 #endif // V8_TARGET_ARCH_X87
454