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.
9 #include "src/interface-descriptors.h"
14 const Register CallInterfaceDescriptor::ContextRegister() { return rsi; }
17 const Register LoadDescriptor::ReceiverRegister() { return rdx; }
18 const Register LoadDescriptor::NameRegister() { return rcx; }
19 const Register LoadDescriptor::SlotRegister() { return rax; }
22 const Register LoadWithVectorDescriptor::VectorRegister() { return rbx; }
25 const Register StoreDescriptor::ReceiverRegister() { return rdx; }
26 const Register StoreDescriptor::NameRegister() { return rcx; }
27 const Register StoreDescriptor::ValueRegister() { return rax; }
30 const Register VectorStoreICTrampolineDescriptor::SlotRegister() { return rdi; }
33 const Register VectorStoreICDescriptor::VectorRegister() { return rbx; }
36 const Register StoreTransitionDescriptor::MapRegister() { return rbx; }
39 const Register LoadGlobalViaContextDescriptor::SlotRegister() { return rbx; }
42 const Register StoreGlobalViaContextDescriptor::SlotRegister() { return rbx; }
43 const Register StoreGlobalViaContextDescriptor::ValueRegister() { return rax; }
46 const Register InstanceofDescriptor::left() { return rax; }
47 const Register InstanceofDescriptor::right() { return rdx; }
50 const Register ArgumentsAccessReadDescriptor::index() { return rdx; }
51 const Register ArgumentsAccessReadDescriptor::parameter_count() { return rax; }
54 const Register ApiGetterDescriptor::function_address() { return r8; }
57 const Register MathPowTaggedDescriptor::exponent() { return rdx; }
60 const Register MathPowIntegerDescriptor::exponent() {
61 return MathPowTaggedDescriptor::exponent();
65 const Register GrowArrayElementsDescriptor::ObjectRegister() { return rax; }
66 const Register GrowArrayElementsDescriptor::KeyRegister() { return rbx; }
69 void StoreTransitionDescriptor::InitializePlatformSpecific(
70 CallInterfaceDescriptorData* data) {
71 Register registers[] = {ReceiverRegister(), NameRegister(), ValueRegister(),
73 data->InitializePlatformSpecific(arraysize(registers), registers);
77 void FastNewClosureDescriptor::InitializePlatformSpecific(
78 CallInterfaceDescriptorData* data) {
79 Register registers[] = {rbx};
80 data->InitializePlatformSpecific(arraysize(registers), registers);
84 void FastNewContextDescriptor::InitializePlatformSpecific(
85 CallInterfaceDescriptorData* data) {
86 Register registers[] = {rdi};
87 data->InitializePlatformSpecific(arraysize(registers), registers);
91 void TypeofDescriptor::InitializePlatformSpecific(
92 CallInterfaceDescriptorData* data) {
93 Register registers[] = {rbx};
94 data->InitializePlatformSpecific(arraysize(registers), registers);
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);
106 void NumberToStringDescriptor::InitializePlatformSpecific(
107 CallInterfaceDescriptorData* data) {
108 Register registers[] = {rax};
109 data->InitializePlatformSpecific(arraysize(registers), registers);
113 void FastCloneShallowArrayDescriptor::InitializePlatformSpecific(
114 CallInterfaceDescriptorData* data) {
115 Register registers[] = {rax, rbx, rcx};
116 data->InitializePlatformSpecific(arraysize(registers), registers);
120 void FastCloneShallowObjectDescriptor::InitializePlatformSpecific(
121 CallInterfaceDescriptorData* data) {
122 Register registers[] = {rax, rbx, rcx, rdx};
123 data->InitializePlatformSpecific(arraysize(registers), registers);
127 void CreateAllocationSiteDescriptor::InitializePlatformSpecific(
128 CallInterfaceDescriptorData* data) {
129 Register registers[] = {rbx, rdx};
130 data->InitializePlatformSpecific(arraysize(registers), registers);
134 void CreateWeakCellDescriptor::InitializePlatformSpecific(
135 CallInterfaceDescriptorData* data) {
136 Register registers[] = {rbx, rdx, rdi};
137 data->InitializePlatformSpecific(arraysize(registers), registers);
141 void StoreArrayLiteralElementDescriptor::InitializePlatformSpecific(
142 CallInterfaceDescriptorData* data) {
143 Register registers[] = {rcx, rax};
144 data->InitializePlatformSpecific(arraysize(registers), registers);
148 void CallFunctionDescriptor::InitializePlatformSpecific(
149 CallInterfaceDescriptorData* data) {
150 Register registers[] = {rdi};
151 data->InitializePlatformSpecific(arraysize(registers), registers);
155 void CallFunctionWithFeedbackDescriptor::InitializePlatformSpecific(
156 CallInterfaceDescriptorData* data) {
157 Register registers[] = {rdi, rdx};
158 data->InitializePlatformSpecific(arraysize(registers), registers);
162 void CallFunctionWithFeedbackAndVectorDescriptor::InitializePlatformSpecific(
163 CallInterfaceDescriptorData* data) {
164 Register registers[] = {rdi, rdx, rbx};
165 data->InitializePlatformSpecific(arraysize(registers), registers);
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);
183 void RegExpConstructResultDescriptor::InitializePlatformSpecific(
184 CallInterfaceDescriptorData* data) {
185 Register registers[] = {rcx, rbx, rax};
186 data->InitializePlatformSpecific(arraysize(registers), registers);
190 void TransitionElementsKindDescriptor::InitializePlatformSpecific(
191 CallInterfaceDescriptorData* data) {
192 Register registers[] = {rax, rbx};
193 data->InitializePlatformSpecific(arraysize(registers), registers);
197 void AllocateHeapNumberDescriptor::InitializePlatformSpecific(
198 CallInterfaceDescriptorData* data) {
199 data->InitializePlatformSpecific(0, nullptr, nullptr);
203 void ArrayConstructorConstantArgCountDescriptor::InitializePlatformSpecific(
204 CallInterfaceDescriptorData* data) {
206 // rax -- number of arguments
208 // rbx -- allocation site with elements kind
209 Register registers[] = {rdi, rbx};
210 data->InitializePlatformSpecific(arraysize(registers), registers);
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);
222 void InternalArrayConstructorConstantArgCountDescriptor::
223 InitializePlatformSpecific(CallInterfaceDescriptorData* data) {
225 // rax -- number of arguments
226 // rdi -- constructor function
227 Register registers[] = {rdi};
228 data->InitializePlatformSpecific(arraysize(registers), registers);
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);
240 void CompareDescriptor::InitializePlatformSpecific(
241 CallInterfaceDescriptorData* data) {
242 Register registers[] = {rdx, rax};
243 data->InitializePlatformSpecific(arraysize(registers), registers);
247 void CompareNilDescriptor::InitializePlatformSpecific(
248 CallInterfaceDescriptorData* data) {
249 Register registers[] = {rax};
250 data->InitializePlatformSpecific(arraysize(registers), registers);
254 void ToBooleanDescriptor::InitializePlatformSpecific(
255 CallInterfaceDescriptorData* data) {
256 Register registers[] = {rax};
257 data->InitializePlatformSpecific(arraysize(registers), registers);
261 void BinaryOpDescriptor::InitializePlatformSpecific(
262 CallInterfaceDescriptorData* data) {
263 Register registers[] = {rdx, rax};
264 data->InitializePlatformSpecific(arraysize(registers), registers);
268 void BinaryOpWithAllocationSiteDescriptor::InitializePlatformSpecific(
269 CallInterfaceDescriptorData* data) {
270 Register registers[] = {rcx, rdx, rax};
271 data->InitializePlatformSpecific(arraysize(registers), registers);
275 void StringAddDescriptor::InitializePlatformSpecific(
276 CallInterfaceDescriptorData* data) {
277 Register registers[] = {rdx, rax};
278 data->InitializePlatformSpecific(arraysize(registers), registers);
282 void KeyedDescriptor::InitializePlatformSpecific(
283 CallInterfaceDescriptorData* data) {
284 Register registers[] = {
287 data->InitializePlatformSpecific(arraysize(registers), registers);
291 void NamedDescriptor::InitializePlatformSpecific(
292 CallInterfaceDescriptorData* data) {
293 Register registers[] = {
296 data->InitializePlatformSpecific(arraysize(registers), registers);
300 void CallHandlerDescriptor::InitializePlatformSpecific(
301 CallInterfaceDescriptorData* data) {
302 Register registers[] = {
305 data->InitializePlatformSpecific(arraysize(registers), registers);
309 void ArgumentAdaptorDescriptor::InitializePlatformSpecific(
310 CallInterfaceDescriptorData* data) {
311 Register registers[] = {
313 rax, // actual number of arguments
314 rbx, // expected number of arguments
316 data->InitializePlatformSpecific(arraysize(registers), registers);
320 void ApiFunctionDescriptor::InitializePlatformSpecific(
321 CallInterfaceDescriptorData* data) {
322 Register registers[] = {
326 rdx, // api_function_address
327 rax, // actual number of arguments
329 data->InitializePlatformSpecific(arraysize(registers), registers);
333 void ApiAccessorDescriptor::InitializePlatformSpecific(
334 CallInterfaceDescriptorData* data) {
335 Register registers[] = {
339 rdx, // api_function_address
341 data->InitializePlatformSpecific(arraysize(registers), registers);
345 void MathRoundVariantCallFromUnoptimizedCodeDescriptor::
346 InitializePlatformSpecific(CallInterfaceDescriptorData* data) {
347 Register registers[] = {
348 rdi, // math rounding function
349 rdx, // vector slot id
351 data->InitializePlatformSpecific(arraysize(registers), registers);
355 void MathRoundVariantCallFromOptimizedCodeDescriptor::
356 InitializePlatformSpecific(CallInterfaceDescriptorData* data) {
357 Register registers[] = {
358 rdi, // math rounding function
359 rdx, // vector slot id
362 data->InitializePlatformSpecific(arraysize(registers), registers);
364 } // namespace internal
367 #endif // V8_TARGET_ARCH_X64