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.
7 #include "src/interface-descriptors.h"
13 // Constructors for common combined semantic and representation types.
15 return Type::Intersect(Type::SignedSmall(), Type::TaggedSigned());
19 Type* UntaggedSigned32() {
20 return Type::Intersect(Type::Signed32(), Type::UntaggedSigned32());
25 return Type::Intersect(
26 Type::Any(), Type::Union(Type::TaggedPointer(), Type::TaggedSigned()));
30 Type* ExternalPointer() {
31 return Type::Intersect(Type::Internal(), Type::UntaggedPointer());
36 Type::FunctionType* CallInterfaceDescriptor::BuildDefaultFunctionType(
37 Isolate* isolate, int parameter_count) {
38 Type::FunctionType* function =
39 Type::FunctionType::New(AnyTagged(), Type::Undefined(), parameter_count,
40 isolate->interface_descriptor_zone());
41 while (parameter_count-- != 0) {
42 function->InitParameter(parameter_count, AnyTagged());
48 void CallInterfaceDescriptorData::InitializePlatformSpecific(
49 int register_parameter_count, Register* registers,
50 PlatformInterfaceDescriptor* platform_descriptor) {
51 platform_specific_descriptor_ = platform_descriptor;
52 register_param_count_ = register_parameter_count;
54 // InterfaceDescriptor owns a copy of the registers array.
55 register_params_.Reset(NewArray<Register>(register_parameter_count));
56 for (int i = 0; i < register_parameter_count; i++) {
57 register_params_[i] = registers[i];
61 const char* CallInterfaceDescriptor::DebugName(Isolate* isolate) const {
62 CallInterfaceDescriptorData* start = isolate->call_descriptor_data(0);
63 size_t index = data_ - start;
64 DCHECK(index < CallDescriptors::NUMBER_OF_DESCRIPTORS);
65 CallDescriptors::Key key = static_cast<CallDescriptors::Key>(index);
67 #define DEF_CASE(NAME) \
68 case CallDescriptors::NAME: \
69 return #NAME " Descriptor";
70 INTERFACE_DESCRIPTOR_LIST(DEF_CASE)
72 case CallDescriptors::NUMBER_OF_DESCRIPTORS:
79 Type::FunctionType* LoadDescriptor::BuildCallInterfaceDescriptorFunctionType(
80 Isolate* isolate, int paramater_count) {
81 Type::FunctionType* function = Type::FunctionType::New(
82 AnyTagged(), Type::Undefined(), 3, isolate->interface_descriptor_zone());
83 function->InitParameter(0, AnyTagged());
84 function->InitParameter(1, AnyTagged());
85 function->InitParameter(2, SmiType());
89 void LoadDescriptor::InitializePlatformSpecific(
90 CallInterfaceDescriptorData* data) {
91 Register registers[] = {ReceiverRegister(), NameRegister(), SlotRegister()};
92 data->InitializePlatformSpecific(arraysize(registers), registers);
96 void StoreDescriptor::InitializePlatformSpecific(
97 CallInterfaceDescriptorData* data) {
98 Register registers[] = {ReceiverRegister(), NameRegister(), ValueRegister()};
99 data->InitializePlatformSpecific(arraysize(registers), registers);
104 StoreTransitionDescriptor::BuildCallInterfaceDescriptorFunctionType(
105 Isolate* isolate, int paramater_count) {
106 Type::FunctionType* function = Type::FunctionType::New(
107 AnyTagged(), Type::Undefined(), 4, isolate->interface_descriptor_zone());
108 function->InitParameter(0, AnyTagged()); // Receiver
109 function->InitParameter(1, AnyTagged()); // Name
110 function->InitParameter(2, AnyTagged()); // Value
111 function->InitParameter(3, AnyTagged()); // Map
117 LoadGlobalViaContextDescriptor::BuildCallInterfaceDescriptorFunctionType(
118 Isolate* isolate, int paramater_count) {
119 Type::FunctionType* function = Type::FunctionType::New(
120 AnyTagged(), Type::Undefined(), 3, isolate->interface_descriptor_zone());
121 function->InitParameter(0, SmiType());
122 function->InitParameter(1, SmiType());
123 function->InitParameter(2, AnyTagged());
128 void LoadGlobalViaContextDescriptor::InitializePlatformSpecific(
129 CallInterfaceDescriptorData* data) {
130 Register registers[] = {DepthRegister(), SlotRegister(), NameRegister()};
131 data->InitializePlatformSpecific(arraysize(registers), registers);
136 StoreGlobalViaContextDescriptor::BuildCallInterfaceDescriptorFunctionType(
137 Isolate* isolate, int paramater_count) {
138 Type::FunctionType* function = Type::FunctionType::New(
139 AnyTagged(), Type::Undefined(), 4, isolate->interface_descriptor_zone());
140 function->InitParameter(0, SmiType());
141 function->InitParameter(1, SmiType());
142 function->InitParameter(2, AnyTagged());
143 function->InitParameter(3, AnyTagged());
148 void StoreGlobalViaContextDescriptor::InitializePlatformSpecific(
149 CallInterfaceDescriptorData* data) {
150 Register registers[] = {DepthRegister(), SlotRegister(), NameRegister(),
152 data->InitializePlatformSpecific(arraysize(registers), registers);
156 void InstanceofDescriptor::InitializePlatformSpecific(
157 CallInterfaceDescriptorData* data) {
158 Register registers[] = {left(), right()};
159 data->InitializePlatformSpecific(arraysize(registers), registers);
163 void MathPowTaggedDescriptor::InitializePlatformSpecific(
164 CallInterfaceDescriptorData* data) {
165 Register registers[] = {exponent()};
166 data->InitializePlatformSpecific(arraysize(registers), registers);
170 void MathPowIntegerDescriptor::InitializePlatformSpecific(
171 CallInterfaceDescriptorData* data) {
172 Register registers[] = {exponent()};
173 data->InitializePlatformSpecific(arraysize(registers), registers);
178 LoadWithVectorDescriptor::BuildCallInterfaceDescriptorFunctionType(
179 Isolate* isolate, int paramater_count) {
180 Type::FunctionType* function = Type::FunctionType::New(
181 AnyTagged(), Type::Undefined(), 4, isolate->interface_descriptor_zone());
182 function->InitParameter(0, AnyTagged());
183 function->InitParameter(1, AnyTagged());
184 function->InitParameter(2, SmiType());
185 function->InitParameter(3, AnyTagged());
190 void LoadWithVectorDescriptor::InitializePlatformSpecific(
191 CallInterfaceDescriptorData* data) {
192 Register registers[] = {ReceiverRegister(), NameRegister(), SlotRegister(),
194 data->InitializePlatformSpecific(arraysize(registers), registers);
199 VectorStoreICDescriptor::BuildCallInterfaceDescriptorFunctionType(
200 Isolate* isolate, int paramater_count) {
201 Type::FunctionType* function = Type::FunctionType::New(
202 AnyTagged(), Type::Undefined(), 5, isolate->interface_descriptor_zone());
203 function->InitParameter(0, AnyTagged());
204 function->InitParameter(1, AnyTagged());
205 function->InitParameter(2, AnyTagged());
206 function->InitParameter(3, SmiType());
207 function->InitParameter(4, AnyTagged());
212 void VectorStoreICDescriptor::InitializePlatformSpecific(
213 CallInterfaceDescriptorData* data) {
214 Register registers[] = {ReceiverRegister(), NameRegister(), ValueRegister(),
215 SlotRegister(), VectorRegister()};
216 data->InitializePlatformSpecific(arraysize(registers), registers);
221 VectorStoreICTrampolineDescriptor::BuildCallInterfaceDescriptorFunctionType(
222 Isolate* isolate, int paramater_count) {
223 Type::FunctionType* function = Type::FunctionType::New(
224 AnyTagged(), Type::Undefined(), 4, isolate->interface_descriptor_zone());
225 function->InitParameter(0, AnyTagged());
226 function->InitParameter(1, AnyTagged());
227 function->InitParameter(2, AnyTagged());
228 function->InitParameter(3, SmiType());
233 void VectorStoreICTrampolineDescriptor::InitializePlatformSpecific(
234 CallInterfaceDescriptorData* data) {
235 Register registers[] = {ReceiverRegister(), NameRegister(), ValueRegister(),
237 data->InitializePlatformSpecific(arraysize(registers), registers);
242 ApiGetterDescriptor::BuildCallInterfaceDescriptorFunctionType(
243 Isolate* isolate, int paramater_count) {
244 Type::FunctionType* function = Type::FunctionType::New(
245 AnyTagged(), Type::Undefined(), 1, isolate->interface_descriptor_zone());
246 function->InitParameter(0, ExternalPointer());
251 void ApiGetterDescriptor::InitializePlatformSpecific(
252 CallInterfaceDescriptorData* data) {
253 Register registers[] = {function_address()};
254 data->InitializePlatformSpecific(arraysize(registers), registers);
258 void ArgumentsAccessReadDescriptor::InitializePlatformSpecific(
259 CallInterfaceDescriptorData* data) {
260 Register registers[] = {index(), parameter_count()};
261 data->InitializePlatformSpecific(arraysize(registers), registers);
265 void ContextOnlyDescriptor::InitializePlatformSpecific(
266 CallInterfaceDescriptorData* data) {
267 data->InitializePlatformSpecific(0, nullptr);
271 void GrowArrayElementsDescriptor::InitializePlatformSpecific(
272 CallInterfaceDescriptorData* data) {
273 Register registers[] = {ObjectRegister(), KeyRegister()};
274 data->InitializePlatformSpecific(arraysize(registers), registers);
279 FastCloneShallowArrayDescriptor::BuildCallInterfaceDescriptorFunctionType(
280 Isolate* isolate, int paramater_count) {
281 Type::FunctionType* function = Type::FunctionType::New(
282 AnyTagged(), Type::Undefined(), 3, isolate->interface_descriptor_zone());
283 function->InitParameter(0, AnyTagged());
284 function->InitParameter(1, SmiType());
285 function->InitParameter(2, AnyTagged());
291 CreateAllocationSiteDescriptor::BuildCallInterfaceDescriptorFunctionType(
292 Isolate* isolate, int paramater_count) {
293 Type::FunctionType* function = Type::FunctionType::New(
294 AnyTagged(), Type::Undefined(), 2, isolate->interface_descriptor_zone());
295 function->InitParameter(0, AnyTagged());
296 function->InitParameter(1, SmiType());
302 CreateWeakCellDescriptor::BuildCallInterfaceDescriptorFunctionType(
303 Isolate* isolate, int paramater_count) {
304 Type::FunctionType* function = Type::FunctionType::New(
305 AnyTagged(), Type::Undefined(), 3, isolate->interface_descriptor_zone());
306 function->InitParameter(0, AnyTagged());
307 function->InitParameter(1, SmiType());
308 function->InitParameter(2, AnyTagged());
314 CallFunctionWithFeedbackDescriptor::BuildCallInterfaceDescriptorFunctionType(
315 Isolate* isolate, int paramater_count) {
316 Type::FunctionType* function = Type::FunctionType::New(
317 AnyTagged(), Type::Undefined(), 2, isolate->interface_descriptor_zone());
318 function->InitParameter(0, Type::Receiver()); // JSFunction
319 function->InitParameter(1, SmiType());
324 Type::FunctionType* CallFunctionWithFeedbackAndVectorDescriptor::
325 BuildCallInterfaceDescriptorFunctionType(Isolate* isolate,
326 int paramater_count) {
327 Type::FunctionType* function = Type::FunctionType::New(
328 AnyTagged(), Type::Undefined(), 3, isolate->interface_descriptor_zone());
329 function->InitParameter(0, Type::Receiver()); // JSFunction
330 function->InitParameter(1, SmiType());
331 function->InitParameter(2, AnyTagged());
337 ArrayConstructorDescriptor::BuildCallInterfaceDescriptorFunctionType(
338 Isolate* isolate, int paramater_count) {
339 Type::FunctionType* function = Type::FunctionType::New(
340 AnyTagged(), Type::Undefined(), 3, isolate->interface_descriptor_zone());
341 function->InitParameter(0, Type::Receiver()); // JSFunction
342 function->InitParameter(1, AnyTagged());
343 function->InitParameter(2, UntaggedSigned32());
349 InternalArrayConstructorDescriptor::BuildCallInterfaceDescriptorFunctionType(
350 Isolate* isolate, int paramater_count) {
351 Type::FunctionType* function = Type::FunctionType::New(
352 AnyTagged(), Type::Undefined(), 2, isolate->interface_descriptor_zone());
353 function->InitParameter(0, Type::Receiver()); // JSFunction
354 function->InitParameter(1, UntaggedSigned32());
360 ArgumentAdaptorDescriptor::BuildCallInterfaceDescriptorFunctionType(
361 Isolate* isolate, int paramater_count) {
362 Type::FunctionType* function = Type::FunctionType::New(
363 AnyTagged(), Type::Undefined(), 3, isolate->interface_descriptor_zone());
364 function->InitParameter(0, Type::Receiver()); // JSFunction
365 function->InitParameter(1, UntaggedSigned32()); // actual number of arguments
366 function->InitParameter(2,
367 UntaggedSigned32()); // expected number of arguments
373 ApiFunctionDescriptor::BuildCallInterfaceDescriptorFunctionType(
374 Isolate* isolate, int paramater_count) {
375 Type::FunctionType* function = Type::FunctionType::New(
376 AnyTagged(), Type::Undefined(), 5, isolate->interface_descriptor_zone());
377 function->InitParameter(0, AnyTagged()); // callee
378 function->InitParameter(1, AnyTagged()); // call_data
379 function->InitParameter(2, AnyTagged()); // holder
380 function->InitParameter(3, ExternalPointer()); // api_function_address
381 function->InitParameter(4, UntaggedSigned32()); // actual number of arguments
387 ApiAccessorDescriptor::BuildCallInterfaceDescriptorFunctionType(
388 Isolate* isolate, int paramater_count) {
389 Type::FunctionType* function = Type::FunctionType::New(
390 AnyTagged(), Type::Undefined(), 4, isolate->interface_descriptor_zone());
391 function->InitParameter(0, AnyTagged()); // callee
392 function->InitParameter(1, AnyTagged()); // call_data
393 function->InitParameter(2, AnyTagged()); // holder
394 function->InitParameter(3, ExternalPointer()); // api_function_address
399 Type::FunctionType* MathRoundVariantCallFromUnoptimizedCodeDescriptor::
400 BuildCallInterfaceDescriptorFunctionType(Isolate* isolate,
401 int paramater_count) {
402 Type::FunctionType* function = Type::FunctionType::New(
403 AnyTagged(), Type::Undefined(), 4, isolate->interface_descriptor_zone());
404 function->InitParameter(0, Type::Receiver());
405 function->InitParameter(1, SmiType());
406 function->InitParameter(2, AnyTagged());
407 function->InitParameter(3, AnyTagged());
412 Type::FunctionType* MathRoundVariantCallFromOptimizedCodeDescriptor::
413 BuildCallInterfaceDescriptorFunctionType(Isolate* isolate,
414 int paramater_count) {
415 Type::FunctionType* function = Type::FunctionType::New(
416 AnyTagged(), Type::Undefined(), 5, isolate->interface_descriptor_zone());
417 function->InitParameter(0, Type::Receiver());
418 function->InitParameter(1, SmiType());
419 function->InitParameter(2, AnyTagged());
420 function->InitParameter(3, AnyTagged());
421 function->InitParameter(4, AnyTagged());
424 } // namespace internal