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(), 1, isolate->interface_descriptor_zone());
121 function->InitParameter(0, UntaggedSigned32());
126 void LoadGlobalViaContextDescriptor::InitializePlatformSpecific(
127 CallInterfaceDescriptorData* data) {
128 Register registers[] = {SlotRegister()};
129 data->InitializePlatformSpecific(arraysize(registers), registers);
134 StoreGlobalViaContextDescriptor::BuildCallInterfaceDescriptorFunctionType(
135 Isolate* isolate, int paramater_count) {
136 Type::FunctionType* function = Type::FunctionType::New(
137 AnyTagged(), Type::Undefined(), 2, isolate->interface_descriptor_zone());
138 function->InitParameter(0, UntaggedSigned32());
139 function->InitParameter(1, AnyTagged());
144 void StoreGlobalViaContextDescriptor::InitializePlatformSpecific(
145 CallInterfaceDescriptorData* data) {
146 Register registers[] = {SlotRegister(), ValueRegister()};
147 data->InitializePlatformSpecific(arraysize(registers), registers);
151 void InstanceofDescriptor::InitializePlatformSpecific(
152 CallInterfaceDescriptorData* data) {
153 Register registers[] = {left(), right()};
154 data->InitializePlatformSpecific(arraysize(registers), registers);
158 void MathPowTaggedDescriptor::InitializePlatformSpecific(
159 CallInterfaceDescriptorData* data) {
160 Register registers[] = {exponent()};
161 data->InitializePlatformSpecific(arraysize(registers), registers);
165 void MathPowIntegerDescriptor::InitializePlatformSpecific(
166 CallInterfaceDescriptorData* data) {
167 Register registers[] = {exponent()};
168 data->InitializePlatformSpecific(arraysize(registers), registers);
173 LoadWithVectorDescriptor::BuildCallInterfaceDescriptorFunctionType(
174 Isolate* isolate, int paramater_count) {
175 Type::FunctionType* function = Type::FunctionType::New(
176 AnyTagged(), Type::Undefined(), 4, isolate->interface_descriptor_zone());
177 function->InitParameter(0, AnyTagged());
178 function->InitParameter(1, AnyTagged());
179 function->InitParameter(2, SmiType());
180 function->InitParameter(3, AnyTagged());
185 void LoadWithVectorDescriptor::InitializePlatformSpecific(
186 CallInterfaceDescriptorData* data) {
187 Register registers[] = {ReceiverRegister(), NameRegister(), SlotRegister(),
189 data->InitializePlatformSpecific(arraysize(registers), registers);
194 VectorStoreICDescriptor::BuildCallInterfaceDescriptorFunctionType(
195 Isolate* isolate, int paramater_count) {
196 Type::FunctionType* function = Type::FunctionType::New(
197 AnyTagged(), Type::Undefined(), 5, isolate->interface_descriptor_zone());
198 function->InitParameter(0, AnyTagged());
199 function->InitParameter(1, AnyTagged());
200 function->InitParameter(2, AnyTagged());
201 function->InitParameter(3, SmiType());
202 function->InitParameter(4, AnyTagged());
207 void VectorStoreICDescriptor::InitializePlatformSpecific(
208 CallInterfaceDescriptorData* data) {
209 Register registers[] = {ReceiverRegister(), NameRegister(), ValueRegister(),
210 SlotRegister(), VectorRegister()};
211 data->InitializePlatformSpecific(arraysize(registers), registers);
216 VectorStoreICTrampolineDescriptor::BuildCallInterfaceDescriptorFunctionType(
217 Isolate* isolate, int paramater_count) {
218 Type::FunctionType* function = Type::FunctionType::New(
219 AnyTagged(), Type::Undefined(), 4, isolate->interface_descriptor_zone());
220 function->InitParameter(0, AnyTagged());
221 function->InitParameter(1, AnyTagged());
222 function->InitParameter(2, AnyTagged());
223 function->InitParameter(3, SmiType());
228 void VectorStoreICTrampolineDescriptor::InitializePlatformSpecific(
229 CallInterfaceDescriptorData* data) {
230 Register registers[] = {ReceiverRegister(), NameRegister(), ValueRegister(),
232 data->InitializePlatformSpecific(arraysize(registers), registers);
237 ApiGetterDescriptor::BuildCallInterfaceDescriptorFunctionType(
238 Isolate* isolate, int paramater_count) {
239 Type::FunctionType* function = Type::FunctionType::New(
240 AnyTagged(), Type::Undefined(), 1, isolate->interface_descriptor_zone());
241 function->InitParameter(0, ExternalPointer());
246 void ApiGetterDescriptor::InitializePlatformSpecific(
247 CallInterfaceDescriptorData* data) {
248 Register registers[] = {function_address()};
249 data->InitializePlatformSpecific(arraysize(registers), registers);
253 void ArgumentsAccessReadDescriptor::InitializePlatformSpecific(
254 CallInterfaceDescriptorData* data) {
255 Register registers[] = {index(), parameter_count()};
256 data->InitializePlatformSpecific(arraysize(registers), registers);
260 void ContextOnlyDescriptor::InitializePlatformSpecific(
261 CallInterfaceDescriptorData* data) {
262 data->InitializePlatformSpecific(0, nullptr);
266 void GrowArrayElementsDescriptor::InitializePlatformSpecific(
267 CallInterfaceDescriptorData* data) {
268 Register registers[] = {ObjectRegister(), KeyRegister()};
269 data->InitializePlatformSpecific(arraysize(registers), registers);
274 FastCloneShallowArrayDescriptor::BuildCallInterfaceDescriptorFunctionType(
275 Isolate* isolate, int paramater_count) {
276 Type::FunctionType* function = Type::FunctionType::New(
277 AnyTagged(), Type::Undefined(), 3, isolate->interface_descriptor_zone());
278 function->InitParameter(0, AnyTagged());
279 function->InitParameter(1, SmiType());
280 function->InitParameter(2, AnyTagged());
286 CreateAllocationSiteDescriptor::BuildCallInterfaceDescriptorFunctionType(
287 Isolate* isolate, int paramater_count) {
288 Type::FunctionType* function = Type::FunctionType::New(
289 AnyTagged(), Type::Undefined(), 2, isolate->interface_descriptor_zone());
290 function->InitParameter(0, AnyTagged());
291 function->InitParameter(1, SmiType());
297 CreateWeakCellDescriptor::BuildCallInterfaceDescriptorFunctionType(
298 Isolate* isolate, int paramater_count) {
299 Type::FunctionType* function = Type::FunctionType::New(
300 AnyTagged(), Type::Undefined(), 3, isolate->interface_descriptor_zone());
301 function->InitParameter(0, AnyTagged());
302 function->InitParameter(1, SmiType());
303 function->InitParameter(2, AnyTagged());
309 CallFunctionWithFeedbackDescriptor::BuildCallInterfaceDescriptorFunctionType(
310 Isolate* isolate, int paramater_count) {
311 Type::FunctionType* function = Type::FunctionType::New(
312 AnyTagged(), Type::Undefined(), 2, isolate->interface_descriptor_zone());
313 function->InitParameter(0, Type::Receiver()); // JSFunction
314 function->InitParameter(1, SmiType());
319 Type::FunctionType* CallFunctionWithFeedbackAndVectorDescriptor::
320 BuildCallInterfaceDescriptorFunctionType(Isolate* isolate,
321 int paramater_count) {
322 Type::FunctionType* function = Type::FunctionType::New(
323 AnyTagged(), Type::Undefined(), 3, isolate->interface_descriptor_zone());
324 function->InitParameter(0, Type::Receiver()); // JSFunction
325 function->InitParameter(1, SmiType());
326 function->InitParameter(2, AnyTagged());
332 ArrayConstructorDescriptor::BuildCallInterfaceDescriptorFunctionType(
333 Isolate* isolate, int paramater_count) {
334 Type::FunctionType* function = Type::FunctionType::New(
335 AnyTagged(), Type::Undefined(), 3, isolate->interface_descriptor_zone());
336 function->InitParameter(0, Type::Receiver()); // JSFunction
337 function->InitParameter(1, AnyTagged());
338 function->InitParameter(2, UntaggedSigned32());
344 InternalArrayConstructorDescriptor::BuildCallInterfaceDescriptorFunctionType(
345 Isolate* isolate, int paramater_count) {
346 Type::FunctionType* function = Type::FunctionType::New(
347 AnyTagged(), Type::Undefined(), 2, isolate->interface_descriptor_zone());
348 function->InitParameter(0, Type::Receiver()); // JSFunction
349 function->InitParameter(1, UntaggedSigned32());
355 ArgumentAdaptorDescriptor::BuildCallInterfaceDescriptorFunctionType(
356 Isolate* isolate, int paramater_count) {
357 Type::FunctionType* function = Type::FunctionType::New(
358 AnyTagged(), Type::Undefined(), 3, isolate->interface_descriptor_zone());
359 function->InitParameter(0, Type::Receiver()); // JSFunction
360 function->InitParameter(1, UntaggedSigned32()); // actual number of arguments
361 function->InitParameter(2,
362 UntaggedSigned32()); // expected number of arguments
368 ApiFunctionDescriptor::BuildCallInterfaceDescriptorFunctionType(
369 Isolate* isolate, int paramater_count) {
370 Type::FunctionType* function = Type::FunctionType::New(
371 AnyTagged(), Type::Undefined(), 5, isolate->interface_descriptor_zone());
372 function->InitParameter(0, AnyTagged()); // callee
373 function->InitParameter(1, AnyTagged()); // call_data
374 function->InitParameter(2, AnyTagged()); // holder
375 function->InitParameter(3, ExternalPointer()); // api_function_address
376 function->InitParameter(4, UntaggedSigned32()); // actual number of arguments
382 ApiAccessorDescriptor::BuildCallInterfaceDescriptorFunctionType(
383 Isolate* isolate, int paramater_count) {
384 Type::FunctionType* function = Type::FunctionType::New(
385 AnyTagged(), Type::Undefined(), 4, isolate->interface_descriptor_zone());
386 function->InitParameter(0, AnyTagged()); // callee
387 function->InitParameter(1, AnyTagged()); // call_data
388 function->InitParameter(2, AnyTagged()); // holder
389 function->InitParameter(3, ExternalPointer()); // api_function_address
394 Type::FunctionType* MathRoundVariantCallFromUnoptimizedCodeDescriptor::
395 BuildCallInterfaceDescriptorFunctionType(Isolate* isolate,
396 int paramater_count) {
397 Type::FunctionType* function = Type::FunctionType::New(
398 AnyTagged(), Type::Undefined(), 4, isolate->interface_descriptor_zone());
399 function->InitParameter(0, Type::Receiver());
400 function->InitParameter(1, SmiType());
401 function->InitParameter(2, AnyTagged());
402 function->InitParameter(3, AnyTagged());
407 Type::FunctionType* MathRoundVariantCallFromOptimizedCodeDescriptor::
408 BuildCallInterfaceDescriptorFunctionType(Isolate* isolate,
409 int paramater_count) {
410 Type::FunctionType* function = Type::FunctionType::New(
411 AnyTagged(), Type::Undefined(), 5, isolate->interface_descriptor_zone());
412 function->InitParameter(0, Type::Receiver());
413 function->InitParameter(1, SmiType());
414 function->InitParameter(2, AnyTagged());
415 function->InitParameter(3, AnyTagged());
416 function->InitParameter(4, AnyTagged());
419 } // namespace internal