blob: dcce0afe5c9b127883027c5b61674d1e272bff51 [file] [log] [blame]
Ben Murdochb8a8cc12014-11-26 15:28:44 +00001// Copyright 2014 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#ifndef V8_CALL_INTERFACE_DESCRIPTOR_H_
6#define V8_CALL_INTERFACE_DESCRIPTOR_H_
7
8#include "src/assembler.h"
9#include "src/macro-assembler.h"
10
11namespace v8 {
12namespace internal {
13
14class PlatformInterfaceDescriptor;
15
16#define INTERFACE_DESCRIPTOR_LIST(V) \
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000017 V(Void) \
Ben Murdochb8a8cc12014-11-26 15:28:44 +000018 V(Load) \
19 V(Store) \
Emily Bernierd0a1eb72015-03-24 16:35:39 -040020 V(StoreTransition) \
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000021 V(VectorStoreTransition) \
22 V(VectorStoreICTrampoline) \
23 V(VectorStoreIC) \
24 V(InstanceOf) \
25 V(LoadWithVector) \
Ben Murdochda12d292016-06-02 14:46:10 +010026 V(FastArrayPush) \
Ben Murdochb8a8cc12014-11-26 15:28:44 +000027 V(FastNewClosure) \
28 V(FastNewContext) \
Ben Murdoch097c5b22016-05-18 11:27:45 +010029 V(FastNewObject) \
30 V(FastNewRestParameter) \
31 V(FastNewSloppyArguments) \
32 V(FastNewStrictArguments) \
Ben Murdochda12d292016-06-02 14:46:10 +010033 V(TypeConversion) \
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000034 V(Typeof) \
35 V(FastCloneRegExp) \
Ben Murdochb8a8cc12014-11-26 15:28:44 +000036 V(FastCloneShallowArray) \
37 V(FastCloneShallowObject) \
38 V(CreateAllocationSite) \
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000039 V(CreateWeakCell) \
Ben Murdochb8a8cc12014-11-26 15:28:44 +000040 V(CallFunction) \
41 V(CallFunctionWithFeedback) \
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000042 V(CallFunctionWithFeedbackAndVector) \
Ben Murdochb8a8cc12014-11-26 15:28:44 +000043 V(CallConstruct) \
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000044 V(CallTrampoline) \
45 V(ConstructStub) \
46 V(ConstructTrampoline) \
Ben Murdochb8a8cc12014-11-26 15:28:44 +000047 V(RegExpConstructResult) \
48 V(TransitionElementsKind) \
Emily Bernierd0a1eb72015-03-24 16:35:39 -040049 V(AllocateHeapNumber) \
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000050 V(AllocateMutableHeapNumber) \
Ben Murdochda12d292016-06-02 14:46:10 +010051 V(AllocateFloat32x4) \
52 V(AllocateInt32x4) \
53 V(AllocateUint32x4) \
54 V(AllocateBool32x4) \
55 V(AllocateInt16x8) \
56 V(AllocateUint16x8) \
57 V(AllocateBool16x8) \
58 V(AllocateInt8x16) \
59 V(AllocateUint8x16) \
60 V(AllocateBool8x16) \
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000061 V(AllocateInNewSpace) \
Ben Murdochb8a8cc12014-11-26 15:28:44 +000062 V(ArrayConstructorConstantArgCount) \
63 V(ArrayConstructor) \
64 V(InternalArrayConstructorConstantArgCount) \
65 V(InternalArrayConstructor) \
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000066 V(Compare) \
Ben Murdochb8a8cc12014-11-26 15:28:44 +000067 V(BinaryOp) \
68 V(BinaryOpWithAllocationSite) \
69 V(StringAdd) \
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000070 V(StringCompare) \
Ben Murdochb8a8cc12014-11-26 15:28:44 +000071 V(Keyed) \
72 V(Named) \
73 V(CallHandler) \
74 V(ArgumentAdaptor) \
Ben Murdochda12d292016-06-02 14:46:10 +010075 V(ApiCallbackWith0Args) \
76 V(ApiCallbackWith1Args) \
77 V(ApiCallbackWith2Args) \
78 V(ApiCallbackWith3Args) \
79 V(ApiCallbackWith4Args) \
80 V(ApiCallbackWith5Args) \
81 V(ApiCallbackWith6Args) \
82 V(ApiCallbackWith7Args) \
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000083 V(ApiGetter) \
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000084 V(LoadGlobalViaContext) \
85 V(StoreGlobalViaContext) \
Ben Murdochb8a8cc12014-11-26 15:28:44 +000086 V(MathPowTagged) \
87 V(MathPowInteger) \
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000088 V(ContextOnly) \
89 V(GrowArrayElements) \
Ben Murdoch097c5b22016-05-18 11:27:45 +010090 V(InterpreterDispatch) \
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000091 V(InterpreterPushArgsAndCall) \
92 V(InterpreterPushArgsAndConstruct) \
93 V(InterpreterCEntry)
Ben Murdochb8a8cc12014-11-26 15:28:44 +000094
Ben Murdochb8a8cc12014-11-26 15:28:44 +000095class CallInterfaceDescriptorData {
96 public:
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000097 CallInterfaceDescriptorData()
98 : register_param_count_(-1), function_type_(nullptr) {}
Ben Murdochb8a8cc12014-11-26 15:28:44 +000099
100 // A copy of the passed in registers and param_representations is made
101 // and owned by the CallInterfaceDescriptorData.
102
Ben Murdoch097c5b22016-05-18 11:27:45 +0100103 void InitializePlatformIndependent(FunctionType* function_type) {
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000104 function_type_ = function_type;
105 }
106
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000107 // TODO(mvstanton): Instead of taking parallel arrays register and
108 // param_representations, how about a struct that puts the representation
109 // and register side by side (eg, RegRep(r1, Representation::Tagged()).
110 // The same should go for the CodeStubDescriptor class.
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000111 void InitializePlatformSpecific(
112 int register_parameter_count, Register* registers,
113 PlatformInterfaceDescriptor* platform_descriptor = NULL);
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000114
115 bool IsInitialized() const { return register_param_count_ >= 0; }
116
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000117 int param_count() const { return function_type_->Arity(); }
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000118 int register_param_count() const { return register_param_count_; }
119 Register register_param(int index) const { return register_params_[index]; }
120 Register* register_params() const { return register_params_.get(); }
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000121 Type* param_type(int index) const { return function_type_->Parameter(index); }
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000122 PlatformInterfaceDescriptor* platform_specific_descriptor() const {
123 return platform_specific_descriptor_;
124 }
125
Ben Murdoch097c5b22016-05-18 11:27:45 +0100126 FunctionType* function_type() const { return function_type_; }
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000127
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000128 private:
129 int register_param_count_;
130
131 // The Register params are allocated dynamically by the
132 // InterfaceDescriptor, and freed on destruction. This is because static
133 // arrays of Registers cause creation of runtime static initializers
134 // which we don't want.
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000135 base::SmartArrayPointer<Register> register_params_;
136
137 // Specifies types for parameters and return
Ben Murdoch097c5b22016-05-18 11:27:45 +0100138 FunctionType* function_type_;
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000139
140 PlatformInterfaceDescriptor* platform_specific_descriptor_;
141
142 DISALLOW_COPY_AND_ASSIGN(CallInterfaceDescriptorData);
143};
144
145
146class CallDescriptors {
147 public:
148 enum Key {
149#define DEF_ENUM(name) name,
150 INTERFACE_DESCRIPTOR_LIST(DEF_ENUM)
151#undef DEF_ENUM
152 NUMBER_OF_DESCRIPTORS
153 };
154};
155
156
157class CallInterfaceDescriptor {
158 public:
159 CallInterfaceDescriptor() : data_(NULL) {}
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000160 virtual ~CallInterfaceDescriptor() {}
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000161
162 CallInterfaceDescriptor(Isolate* isolate, CallDescriptors::Key key)
163 : data_(isolate->call_descriptor_data(key)) {}
164
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000165 int GetParameterCount() const { return data()->param_count(); }
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000166
167 int GetRegisterParameterCount() const {
168 return data()->register_param_count();
169 }
170
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000171 int GetStackParameterCount() const {
172 return data()->function_type()->Arity() - data()->register_param_count();
173 }
174
175 Register GetRegisterParameter(int index) const {
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000176 return data()->register_param(index);
177 }
178
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000179 Type* GetParameterType(int index) const {
180 DCHECK(index < data()->param_count());
181 return data()->param_type(index);
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000182 }
183
184 // Some platforms have extra information to associate with the descriptor.
185 PlatformInterfaceDescriptor* platform_specific_descriptor() const {
186 return data()->platform_specific_descriptor();
187 }
188
Ben Murdoch097c5b22016-05-18 11:27:45 +0100189 FunctionType* GetFunctionType() const { return data()->function_type(); }
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000190
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000191 static const Register ContextRegister();
192
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400193 const char* DebugName(Isolate* isolate) const;
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000194
Ben Murdoch097c5b22016-05-18 11:27:45 +0100195 static FunctionType* BuildDefaultFunctionType(Isolate* isolate,
196 int paramater_count);
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000197
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000198 protected:
199 const CallInterfaceDescriptorData* data() const { return data_; }
200
Ben Murdoch097c5b22016-05-18 11:27:45 +0100201 virtual FunctionType* BuildCallInterfaceDescriptorFunctionType(
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000202 Isolate* isolate, int register_param_count) {
203 return BuildDefaultFunctionType(isolate, register_param_count);
204 }
205
206 virtual void InitializePlatformSpecific(CallInterfaceDescriptorData* data) {
207 UNREACHABLE();
208 }
209
210 void Initialize(Isolate* isolate, CallDescriptors::Key key) {
211 if (!data()->IsInitialized()) {
212 CallInterfaceDescriptorData* d = isolate->call_descriptor_data(key);
Ben Murdochda12d292016-06-02 14:46:10 +0100213 DCHECK(d == data()); // d should be a modifiable pointer to data().
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000214 InitializePlatformSpecific(d);
Ben Murdoch097c5b22016-05-18 11:27:45 +0100215 FunctionType* function_type = BuildCallInterfaceDescriptorFunctionType(
216 isolate, d->register_param_count());
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000217 d->InitializePlatformIndependent(function_type);
218 }
219 }
220
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000221 private:
222 const CallInterfaceDescriptorData* data_;
223};
224
Ben Murdochda12d292016-06-02 14:46:10 +0100225#define DECLARE_DESCRIPTOR_WITH_BASE(name, base) \
226 public: \
227 explicit name(Isolate* isolate) : base(isolate, key()) { \
228 Initialize(isolate, key()); \
229 } \
230 static inline CallDescriptors::Key key();
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000231
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000232#define DECLARE_DESCRIPTOR(name, base) \
Ben Murdochda12d292016-06-02 14:46:10 +0100233 DECLARE_DESCRIPTOR_WITH_BASE(name, base) \
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000234 protected: \
235 void InitializePlatformSpecific(CallInterfaceDescriptorData* data) override; \
236 name(Isolate* isolate, CallDescriptors::Key key) : base(isolate, key) {} \
237 \
Ben Murdochda12d292016-06-02 14:46:10 +0100238 public:
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000239
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000240#define DECLARE_DESCRIPTOR_WITH_CUSTOM_FUNCTION_TYPE(name, base) \
241 DECLARE_DESCRIPTOR(name, base) \
242 protected: \
Ben Murdoch097c5b22016-05-18 11:27:45 +0100243 FunctionType* BuildCallInterfaceDescriptorFunctionType( \
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000244 Isolate* isolate, int register_param_count) override; \
245 \
246 public:
247
Ben Murdochda12d292016-06-02 14:46:10 +0100248#define DECLARE_DESCRIPTOR_WITH_BASE_AND_FUNCTION_TYPE_ARG(name, base, arg) \
249 DECLARE_DESCRIPTOR_WITH_BASE(name, base) \
250 protected: \
251 FunctionType* BuildCallInterfaceDescriptorFunctionType( \
252 Isolate* isolate, int register_param_count) override { \
253 return BuildCallInterfaceDescriptorFunctionTypeWithArg( \
254 isolate, register_param_count, arg); \
255 } \
256 \
257 public:
258
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000259class VoidDescriptor : public CallInterfaceDescriptor {
260 public:
261 DECLARE_DESCRIPTOR(VoidDescriptor, CallInterfaceDescriptor)
262};
263
264
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000265// LoadDescriptor is used by all stubs that implement Load/KeyedLoad ICs.
266class LoadDescriptor : public CallInterfaceDescriptor {
267 public:
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000268 DECLARE_DESCRIPTOR_WITH_CUSTOM_FUNCTION_TYPE(LoadDescriptor,
269 CallInterfaceDescriptor)
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000270
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000271 enum ParameterIndices { kReceiverIndex, kNameIndex, kSlotIndex };
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000272 static const Register ReceiverRegister();
273 static const Register NameRegister();
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000274 static const Register SlotRegister();
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000275};
276
277
278class StoreDescriptor : public CallInterfaceDescriptor {
279 public:
280 DECLARE_DESCRIPTOR(StoreDescriptor, CallInterfaceDescriptor)
281
282 enum ParameterIndices {
283 kReceiverIndex,
284 kNameIndex,
285 kValueIndex,
286 kParameterCount
287 };
288 static const Register ReceiverRegister();
289 static const Register NameRegister();
290 static const Register ValueRegister();
291};
292
293
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400294class StoreTransitionDescriptor : public StoreDescriptor {
295 public:
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000296 DECLARE_DESCRIPTOR_WITH_CUSTOM_FUNCTION_TYPE(StoreTransitionDescriptor,
297 StoreDescriptor)
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400298
299 // Extends StoreDescriptor with Map parameter.
300 enum ParameterIndices {
301 kReceiverIndex,
302 kNameIndex,
303 kValueIndex,
304 kMapIndex,
305 kParameterCount
306 };
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000307
308 static const Register MapRegister();
309};
310
311
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000312class VectorStoreTransitionDescriptor : public StoreDescriptor {
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000313 public:
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000314 DECLARE_DESCRIPTOR_WITH_CUSTOM_FUNCTION_TYPE(VectorStoreTransitionDescriptor,
315 StoreDescriptor)
316
317 // Extends StoreDescriptor with Map parameter.
318 enum ParameterIndices {
319 kReceiverIndex = 0,
320 kNameIndex = 1,
321 kValueIndex = 2,
322
323 kMapIndex = 3,
324
325 kSlotIndex = 4, // not present on ia32.
326 kVirtualSlotVectorIndex = 4,
327
328 kVectorIndex = 5
329 };
330
331 static const Register MapRegister();
332 static const Register SlotRegister();
333 static const Register VectorRegister();
334};
335
336
337class InstanceOfDescriptor final : public CallInterfaceDescriptor {
338 public:
339 DECLARE_DESCRIPTOR(InstanceOfDescriptor, CallInterfaceDescriptor)
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000340
341 enum ParameterIndices { kLeftIndex, kRightIndex, kParameterCount };
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000342 static const Register LeftRegister();
343 static const Register RightRegister();
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000344};
345
346
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000347class VectorStoreICTrampolineDescriptor : public StoreDescriptor {
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000348 public:
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000349 DECLARE_DESCRIPTOR_WITH_CUSTOM_FUNCTION_TYPE(
350 VectorStoreICTrampolineDescriptor, StoreDescriptor)
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000351
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000352 enum ParameterIndices { kReceiverIndex, kNameIndex, kValueIndex, kSlotIndex };
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000353
354 static const Register SlotRegister();
355};
356
357
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000358class VectorStoreICDescriptor : public VectorStoreICTrampolineDescriptor {
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000359 public:
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000360 DECLARE_DESCRIPTOR_WITH_CUSTOM_FUNCTION_TYPE(
361 VectorStoreICDescriptor, VectorStoreICTrampolineDescriptor)
362
363 enum ParameterIndices {
364 kReceiverIndex,
365 kNameIndex,
366 kValueIndex,
367 kSlotIndex,
368 kVectorIndex
369 };
370
371 static const Register VectorRegister();
372};
373
374
375class LoadWithVectorDescriptor : public LoadDescriptor {
376 public:
377 DECLARE_DESCRIPTOR_WITH_CUSTOM_FUNCTION_TYPE(LoadWithVectorDescriptor,
378 LoadDescriptor)
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000379
380 enum ParameterIndices {
381 kReceiverIndex,
382 kNameIndex,
383 kSlotIndex,
384 kVectorIndex
385 };
386
387 static const Register VectorRegister();
388};
389
390
391class FastNewClosureDescriptor : public CallInterfaceDescriptor {
392 public:
393 DECLARE_DESCRIPTOR(FastNewClosureDescriptor, CallInterfaceDescriptor)
394};
395
396
397class FastNewContextDescriptor : public CallInterfaceDescriptor {
398 public:
399 DECLARE_DESCRIPTOR(FastNewContextDescriptor, CallInterfaceDescriptor)
400};
401
Ben Murdoch097c5b22016-05-18 11:27:45 +0100402class FastNewObjectDescriptor : public CallInterfaceDescriptor {
403 public:
404 DECLARE_DESCRIPTOR(FastNewObjectDescriptor, CallInterfaceDescriptor)
405};
406
407class FastNewRestParameterDescriptor : public CallInterfaceDescriptor {
408 public:
409 DECLARE_DESCRIPTOR(FastNewRestParameterDescriptor, CallInterfaceDescriptor)
410};
411
412class FastNewSloppyArgumentsDescriptor : public CallInterfaceDescriptor {
413 public:
414 DECLARE_DESCRIPTOR(FastNewSloppyArgumentsDescriptor,
415 CallInterfaceDescriptor)
416};
417
418class FastNewStrictArgumentsDescriptor : public CallInterfaceDescriptor {
419 public:
420 DECLARE_DESCRIPTOR(FastNewStrictArgumentsDescriptor,
421 CallInterfaceDescriptor)
422};
423
Ben Murdochda12d292016-06-02 14:46:10 +0100424class TypeConversionDescriptor final : public CallInterfaceDescriptor {
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000425 public:
Ben Murdochda12d292016-06-02 14:46:10 +0100426 enum ParameterIndices { kArgumentIndex };
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000427
Ben Murdochda12d292016-06-02 14:46:10 +0100428 DECLARE_DESCRIPTOR(TypeConversionDescriptor, CallInterfaceDescriptor)
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000429
Ben Murdochda12d292016-06-02 14:46:10 +0100430 static const Register ArgumentRegister();
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000431};
432
433
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000434class TypeofDescriptor : public CallInterfaceDescriptor {
435 public:
436 DECLARE_DESCRIPTOR(TypeofDescriptor, CallInterfaceDescriptor)
437};
438
439
440class FastCloneRegExpDescriptor : public CallInterfaceDescriptor {
441 public:
442 DECLARE_DESCRIPTOR_WITH_CUSTOM_FUNCTION_TYPE(FastCloneRegExpDescriptor,
443 CallInterfaceDescriptor)
444};
445
446
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000447class FastCloneShallowArrayDescriptor : public CallInterfaceDescriptor {
448 public:
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000449 DECLARE_DESCRIPTOR_WITH_CUSTOM_FUNCTION_TYPE(FastCloneShallowArrayDescriptor,
450 CallInterfaceDescriptor)
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000451};
452
453
454class FastCloneShallowObjectDescriptor : public CallInterfaceDescriptor {
455 public:
456 DECLARE_DESCRIPTOR(FastCloneShallowObjectDescriptor, CallInterfaceDescriptor)
457};
458
459
460class CreateAllocationSiteDescriptor : public CallInterfaceDescriptor {
461 public:
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000462 DECLARE_DESCRIPTOR_WITH_CUSTOM_FUNCTION_TYPE(CreateAllocationSiteDescriptor,
463 CallInterfaceDescriptor)
464};
465
466
467class CreateWeakCellDescriptor : public CallInterfaceDescriptor {
468 public:
469 enum ParameterIndices {
470 kVectorIndex,
471 kSlotIndex,
472 kValueIndex,
473 kParameterCount
474 };
475
476 DECLARE_DESCRIPTOR_WITH_CUSTOM_FUNCTION_TYPE(CreateWeakCellDescriptor,
477 CallInterfaceDescriptor)
478};
479
480
481class CallTrampolineDescriptor : public CallInterfaceDescriptor {
482 public:
483 DECLARE_DESCRIPTOR_WITH_CUSTOM_FUNCTION_TYPE(CallTrampolineDescriptor,
484 CallInterfaceDescriptor)
485};
486
487
488class ConstructStubDescriptor : public CallInterfaceDescriptor {
489 public:
490 DECLARE_DESCRIPTOR_WITH_CUSTOM_FUNCTION_TYPE(ConstructStubDescriptor,
491 CallInterfaceDescriptor)
492};
493
494
495class ConstructTrampolineDescriptor : public CallInterfaceDescriptor {
496 public:
497 DECLARE_DESCRIPTOR_WITH_CUSTOM_FUNCTION_TYPE(ConstructTrampolineDescriptor,
498 CallInterfaceDescriptor)
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000499};
500
501
502class CallFunctionDescriptor : public CallInterfaceDescriptor {
503 public:
504 DECLARE_DESCRIPTOR(CallFunctionDescriptor, CallInterfaceDescriptor)
505};
506
507
508class CallFunctionWithFeedbackDescriptor : public CallInterfaceDescriptor {
509 public:
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000510 DECLARE_DESCRIPTOR_WITH_CUSTOM_FUNCTION_TYPE(
511 CallFunctionWithFeedbackDescriptor, CallInterfaceDescriptor)
512};
513
514
515class CallFunctionWithFeedbackAndVectorDescriptor
516 : public CallInterfaceDescriptor {
517 public:
518 DECLARE_DESCRIPTOR_WITH_CUSTOM_FUNCTION_TYPE(
519 CallFunctionWithFeedbackAndVectorDescriptor, CallInterfaceDescriptor)
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000520};
521
522
523class CallConstructDescriptor : public CallInterfaceDescriptor {
524 public:
525 DECLARE_DESCRIPTOR(CallConstructDescriptor, CallInterfaceDescriptor)
526};
527
528
529class RegExpConstructResultDescriptor : public CallInterfaceDescriptor {
530 public:
531 DECLARE_DESCRIPTOR(RegExpConstructResultDescriptor, CallInterfaceDescriptor)
532};
533
534
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000535class LoadGlobalViaContextDescriptor : public CallInterfaceDescriptor {
536 public:
537 DECLARE_DESCRIPTOR_WITH_CUSTOM_FUNCTION_TYPE(LoadGlobalViaContextDescriptor,
538 CallInterfaceDescriptor)
539
540 static const Register SlotRegister();
541};
542
543
544class StoreGlobalViaContextDescriptor : public CallInterfaceDescriptor {
545 public:
546 DECLARE_DESCRIPTOR_WITH_CUSTOM_FUNCTION_TYPE(StoreGlobalViaContextDescriptor,
547 CallInterfaceDescriptor)
548
549 static const Register SlotRegister();
550 static const Register ValueRegister();
551};
552
553
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000554class TransitionElementsKindDescriptor : public CallInterfaceDescriptor {
555 public:
556 DECLARE_DESCRIPTOR(TransitionElementsKindDescriptor, CallInterfaceDescriptor)
557};
558
559
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400560class AllocateHeapNumberDescriptor : public CallInterfaceDescriptor {
561 public:
562 DECLARE_DESCRIPTOR(AllocateHeapNumberDescriptor, CallInterfaceDescriptor)
563};
564
Ben Murdochda12d292016-06-02 14:46:10 +0100565#define SIMD128_ALLOC_DESC(TYPE, Type, type, lane_count, lane_type) \
566 class Allocate##Type##Descriptor : public CallInterfaceDescriptor { \
567 public: \
568 DECLARE_DESCRIPTOR(Allocate##Type##Descriptor, CallInterfaceDescriptor) \
569 };
570SIMD128_TYPES(SIMD128_ALLOC_DESC)
571#undef SIMD128_ALLOC_DESC
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400572
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000573class AllocateMutableHeapNumberDescriptor : public CallInterfaceDescriptor {
574 public:
575 DECLARE_DESCRIPTOR(AllocateMutableHeapNumberDescriptor,
576 CallInterfaceDescriptor)
577};
578
579
580class AllocateInNewSpaceDescriptor : public CallInterfaceDescriptor {
581 public:
582 DECLARE_DESCRIPTOR(AllocateInNewSpaceDescriptor, CallInterfaceDescriptor)
583};
584
585
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000586class ArrayConstructorConstantArgCountDescriptor
587 : public CallInterfaceDescriptor {
588 public:
589 DECLARE_DESCRIPTOR(ArrayConstructorConstantArgCountDescriptor,
590 CallInterfaceDescriptor)
591};
592
593
594class ArrayConstructorDescriptor : public CallInterfaceDescriptor {
595 public:
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000596 DECLARE_DESCRIPTOR_WITH_CUSTOM_FUNCTION_TYPE(ArrayConstructorDescriptor,
597 CallInterfaceDescriptor)
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000598};
599
600
601class InternalArrayConstructorConstantArgCountDescriptor
602 : public CallInterfaceDescriptor {
603 public:
604 DECLARE_DESCRIPTOR(InternalArrayConstructorConstantArgCountDescriptor,
605 CallInterfaceDescriptor)
606};
607
608
609class InternalArrayConstructorDescriptor : public CallInterfaceDescriptor {
610 public:
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000611 DECLARE_DESCRIPTOR_WITH_CUSTOM_FUNCTION_TYPE(
612 InternalArrayConstructorDescriptor, CallInterfaceDescriptor)
613};
614
615
616class CompareDescriptor : public CallInterfaceDescriptor {
617 public:
618 DECLARE_DESCRIPTOR(CompareDescriptor, CallInterfaceDescriptor)
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000619};
620
621
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000622class BinaryOpDescriptor : public CallInterfaceDescriptor {
623 public:
624 DECLARE_DESCRIPTOR(BinaryOpDescriptor, CallInterfaceDescriptor)
625};
626
627
628class BinaryOpWithAllocationSiteDescriptor : public CallInterfaceDescriptor {
629 public:
630 DECLARE_DESCRIPTOR(BinaryOpWithAllocationSiteDescriptor,
631 CallInterfaceDescriptor)
632};
633
634
635class StringAddDescriptor : public CallInterfaceDescriptor {
636 public:
637 DECLARE_DESCRIPTOR(StringAddDescriptor, CallInterfaceDescriptor)
638};
639
640
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000641class StringCompareDescriptor : public CallInterfaceDescriptor {
642 public:
643 DECLARE_DESCRIPTOR(StringCompareDescriptor, CallInterfaceDescriptor)
644
645 enum ParameterIndices { kLeftIndex, kRightIndex, kParameterCount };
646 static const Register LeftRegister();
647 static const Register RightRegister();
648};
649
650
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000651class KeyedDescriptor : public CallInterfaceDescriptor {
652 public:
653 DECLARE_DESCRIPTOR(KeyedDescriptor, CallInterfaceDescriptor)
654};
655
656
657class NamedDescriptor : public CallInterfaceDescriptor {
658 public:
659 DECLARE_DESCRIPTOR(NamedDescriptor, CallInterfaceDescriptor)
660};
661
662
663class CallHandlerDescriptor : public CallInterfaceDescriptor {
664 public:
665 DECLARE_DESCRIPTOR(CallHandlerDescriptor, CallInterfaceDescriptor)
666};
667
668
669class ArgumentAdaptorDescriptor : public CallInterfaceDescriptor {
670 public:
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000671 DECLARE_DESCRIPTOR_WITH_CUSTOM_FUNCTION_TYPE(ArgumentAdaptorDescriptor,
672 CallInterfaceDescriptor)
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000673};
674
Ben Murdochda12d292016-06-02 14:46:10 +0100675// The ApiCallback*Descriptors have a lot of boilerplate. The superclass
676// ApiCallbackDescriptorBase contains all the logic, and the
677// ApiCallbackWith*ArgsDescriptor merely instantiate these with a
678// parameter for the number of args.
679//
680// The base class is not meant to be instantiated directly and has no
681// public constructors to ensure this is so.
682//
683// The simplest usage for all the ApiCallback*Descriptors is probably
684// ApiCallbackDescriptorBase::ForArgs(isolate, argc)
685//
686class ApiCallbackDescriptorBase : public CallInterfaceDescriptor {
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000687 public:
Ben Murdochda12d292016-06-02 14:46:10 +0100688 static CallInterfaceDescriptor ForArgs(Isolate* isolate, int argc);
689
690 protected:
691 ApiCallbackDescriptorBase(Isolate* isolate, CallDescriptors::Key key)
692 : CallInterfaceDescriptor(isolate, key) {}
693 void InitializePlatformSpecific(CallInterfaceDescriptorData* data) override;
694 FunctionType* BuildCallInterfaceDescriptorFunctionTypeWithArg(
695 Isolate* isolate, int parameter_count, int argc);
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000696};
697
Ben Murdochda12d292016-06-02 14:46:10 +0100698class ApiCallbackWith0ArgsDescriptor : public ApiCallbackDescriptorBase {
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000699 public:
Ben Murdochda12d292016-06-02 14:46:10 +0100700 DECLARE_DESCRIPTOR_WITH_BASE_AND_FUNCTION_TYPE_ARG(
701 ApiCallbackWith0ArgsDescriptor, ApiCallbackDescriptorBase, 0)
702};
703
704class ApiCallbackWith1ArgsDescriptor : public ApiCallbackDescriptorBase {
705 public:
706 DECLARE_DESCRIPTOR_WITH_BASE_AND_FUNCTION_TYPE_ARG(
707 ApiCallbackWith1ArgsDescriptor, ApiCallbackDescriptorBase, 1)
708};
709
710class ApiCallbackWith2ArgsDescriptor : public ApiCallbackDescriptorBase {
711 public:
712 DECLARE_DESCRIPTOR_WITH_BASE_AND_FUNCTION_TYPE_ARG(
713 ApiCallbackWith2ArgsDescriptor, ApiCallbackDescriptorBase, 2)
714};
715
716class ApiCallbackWith3ArgsDescriptor : public ApiCallbackDescriptorBase {
717 public:
718 DECLARE_DESCRIPTOR_WITH_BASE_AND_FUNCTION_TYPE_ARG(
719 ApiCallbackWith3ArgsDescriptor, ApiCallbackDescriptorBase, 3)
720};
721
722class ApiCallbackWith4ArgsDescriptor : public ApiCallbackDescriptorBase {
723 public:
724 DECLARE_DESCRIPTOR_WITH_BASE_AND_FUNCTION_TYPE_ARG(
725 ApiCallbackWith4ArgsDescriptor, ApiCallbackDescriptorBase, 4)
726};
727
728class ApiCallbackWith5ArgsDescriptor : public ApiCallbackDescriptorBase {
729 public:
730 DECLARE_DESCRIPTOR_WITH_BASE_AND_FUNCTION_TYPE_ARG(
731 ApiCallbackWith5ArgsDescriptor, ApiCallbackDescriptorBase, 5)
732};
733
734class ApiCallbackWith6ArgsDescriptor : public ApiCallbackDescriptorBase {
735 public:
736 DECLARE_DESCRIPTOR_WITH_BASE_AND_FUNCTION_TYPE_ARG(
737 ApiCallbackWith6ArgsDescriptor, ApiCallbackDescriptorBase, 6)
738};
739
740class ApiCallbackWith7ArgsDescriptor : public ApiCallbackDescriptorBase {
741 public:
742 DECLARE_DESCRIPTOR_WITH_BASE_AND_FUNCTION_TYPE_ARG(
743 ApiCallbackWith7ArgsDescriptor, ApiCallbackDescriptorBase, 7)
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000744};
745
746
747class ApiGetterDescriptor : public CallInterfaceDescriptor {
748 public:
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000749 DECLARE_DESCRIPTOR_WITH_CUSTOM_FUNCTION_TYPE(ApiGetterDescriptor,
750 CallInterfaceDescriptor)
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000751
752 static const Register function_address();
753};
754
755
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000756class MathPowTaggedDescriptor : public CallInterfaceDescriptor {
757 public:
758 DECLARE_DESCRIPTOR(MathPowTaggedDescriptor, CallInterfaceDescriptor)
759
760 static const Register exponent();
761};
762
763
764class MathPowIntegerDescriptor : public CallInterfaceDescriptor {
765 public:
766 DECLARE_DESCRIPTOR(MathPowIntegerDescriptor, CallInterfaceDescriptor)
767
768 static const Register exponent();
769};
770
771
772class ContextOnlyDescriptor : public CallInterfaceDescriptor {
773 public:
774 DECLARE_DESCRIPTOR(ContextOnlyDescriptor, CallInterfaceDescriptor)
775};
776
Ben Murdochda12d292016-06-02 14:46:10 +0100777class FastArrayPushDescriptor : public CallInterfaceDescriptor {
778 public:
779 DECLARE_DESCRIPTOR_WITH_CUSTOM_FUNCTION_TYPE(FastArrayPushDescriptor,
780 CallInterfaceDescriptor)
781};
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000782
783class GrowArrayElementsDescriptor : public CallInterfaceDescriptor {
784 public:
785 DECLARE_DESCRIPTOR(GrowArrayElementsDescriptor, CallInterfaceDescriptor)
786
787 enum RegisterInfo { kObjectIndex, kKeyIndex };
788 static const Register ObjectRegister();
789 static const Register KeyRegister();
790};
791
Ben Murdochda12d292016-06-02 14:46:10 +0100792class InterpreterDispatchDescriptor : public CallInterfaceDescriptor {
Ben Murdoch097c5b22016-05-18 11:27:45 +0100793 public:
794 DECLARE_DESCRIPTOR_WITH_CUSTOM_FUNCTION_TYPE(InterpreterDispatchDescriptor,
795 CallInterfaceDescriptor)
796
797 static const int kAccumulatorParameter = 0;
798 static const int kRegisterFileParameter = 1;
799 static const int kBytecodeOffsetParameter = 2;
800 static const int kBytecodeArrayParameter = 3;
801 static const int kDispatchTableParameter = 4;
802 static const int kContextParameter = 5;
803};
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000804
805class InterpreterPushArgsAndCallDescriptor : public CallInterfaceDescriptor {
806 public:
807 DECLARE_DESCRIPTOR(InterpreterPushArgsAndCallDescriptor,
808 CallInterfaceDescriptor)
809};
810
811
812class InterpreterPushArgsAndConstructDescriptor
813 : public CallInterfaceDescriptor {
814 public:
815 DECLARE_DESCRIPTOR(InterpreterPushArgsAndConstructDescriptor,
816 CallInterfaceDescriptor)
817};
818
819
820class InterpreterCEntryDescriptor : public CallInterfaceDescriptor {
821 public:
822 DECLARE_DESCRIPTOR(InterpreterCEntryDescriptor, CallInterfaceDescriptor)
823};
824
Ben Murdochda12d292016-06-02 14:46:10 +0100825#undef DECLARE_DESCRIPTOR_WITH_BASE
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000826#undef DECLARE_DESCRIPTOR
Ben Murdochda12d292016-06-02 14:46:10 +0100827#undef DECLARE_DESCRIPTOR_WITH_CUSTOM_FUNCTION_TYPE
828#undef DECLARE_DESCRIPTOR_WITH_BASE_AND_FUNCTION_TYPE_ARG
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000829
830// We define the association between CallDescriptors::Key and the specialized
831// descriptor here to reduce boilerplate and mistakes.
832#define DEF_KEY(name) \
833 CallDescriptors::Key name##Descriptor::key() { return CallDescriptors::name; }
834INTERFACE_DESCRIPTOR_LIST(DEF_KEY)
835#undef DEF_KEY
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000836} // namespace internal
837} // namespace v8
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000838
839
840#if V8_TARGET_ARCH_ARM64
841#include "src/arm64/interface-descriptors-arm64.h"
842#elif V8_TARGET_ARCH_ARM
843#include "src/arm/interface-descriptors-arm.h"
844#endif
845
846#endif // V8_CALL_INTERFACE_DESCRIPTOR_H_