interface-descriptors.h 27.8 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
// Copyright 2014 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef V8_CALL_INTERFACE_DESCRIPTOR_H_
#define V8_CALL_INTERFACE_DESCRIPTOR_H_

#include "src/assembler.h"
#include "src/macro-assembler.h"

namespace v8 {
namespace internal {

class PlatformInterfaceDescriptor;

16
#define INTERFACE_DESCRIPTOR_LIST(V)          \
17
  V(Void)                                     \
18 19
  V(Load)                                     \
  V(Store)                                    \
20
  V(StoreTransition)                          \
21
  V(VectorStoreTransition)                    \
22 23
  V(VectorStoreICTrampoline)                  \
  V(VectorStoreIC)                            \
24
  V(InstanceOf)                               \
25
  V(LoadWithVector)                           \
26
  V(FastArrayPush)                            \
27 28
  V(FastNewClosure)                           \
  V(FastNewContext)                           \
29
  V(FastNewObject)                            \
30
  V(FastNewRestParameter)                     \
31 32
  V(FastNewSloppyArguments)                   \
  V(FastNewStrictArguments)                   \
33
  V(TypeConversion)                           \
34
  V(Typeof)                                   \
35
  V(FastCloneRegExp)                          \
36 37 38
  V(FastCloneShallowArray)                    \
  V(FastCloneShallowObject)                   \
  V(CreateAllocationSite)                     \
39
  V(CreateWeakCell)                           \
40
  V(CallFunction)                             \
41
  V(CallFunctionWithFeedback)                 \
42
  V(CallFunctionWithFeedbackAndVector)        \
43
  V(CallConstruct)                            \
44
  V(CallTrampoline)                           \
45
  V(ConstructStub)                            \
46
  V(ConstructTrampoline)                      \
47 48
  V(RegExpConstructResult)                    \
  V(TransitionElementsKind)                   \
49
  V(AllocateHeapNumber)                       \
50
  V(AllocateMutableHeapNumber)                \
bbudge's avatar
bbudge committed
51 52 53 54 55 56 57 58 59 60
  V(AllocateFloat32x4)                        \
  V(AllocateInt32x4)                          \
  V(AllocateUint32x4)                         \
  V(AllocateBool32x4)                         \
  V(AllocateInt16x8)                          \
  V(AllocateUint16x8)                         \
  V(AllocateBool16x8)                         \
  V(AllocateInt8x16)                          \
  V(AllocateUint8x16)                         \
  V(AllocateBool8x16)                         \
61
  V(ArrayNoArgumentConstructor)               \
62 63 64 65
  V(ArrayConstructorConstantArgCount)         \
  V(ArrayConstructor)                         \
  V(InternalArrayConstructorConstantArgCount) \
  V(InternalArrayConstructor)                 \
66
  V(Compare)                                  \
67 68
  V(BinaryOp)                                 \
  V(BinaryOpWithAllocationSite)               \
69
  V(CountOp)                                  \
70
  V(StringAdd)                                \
71
  V(StringCompare)                            \
72 73
  V(Keyed)                                    \
  V(Named)                                    \
74
  V(HasProperty)                              \
75 76
  V(CallHandler)                              \
  V(ArgumentAdaptor)                          \
vogelheim's avatar
vogelheim committed
77 78 79 80 81 82 83 84
  V(ApiCallbackWith0Args)                     \
  V(ApiCallbackWith1Args)                     \
  V(ApiCallbackWith2Args)                     \
  V(ApiCallbackWith3Args)                     \
  V(ApiCallbackWith4Args)                     \
  V(ApiCallbackWith5Args)                     \
  V(ApiCallbackWith6Args)                     \
  V(ApiCallbackWith7Args)                     \
85
  V(ApiGetter)                                \
86 87
  V(LoadGlobalViaContext)                     \
  V(StoreGlobalViaContext)                    \
88 89
  V(MathPowTagged)                            \
  V(MathPowInteger)                           \
90
  V(ContextOnly)                              \
91
  V(GrowArrayElements)                        \
92
  V(InterpreterDispatch)                      \
93
  V(InterpreterPushArgsAndCall)               \
94
  V(InterpreterPushArgsAndConstruct)          \
95
  V(InterpreterCEntry)                        \
96
  V(ResumeGenerator)
97 98

class CallInterfaceDescriptorData {
99
 public:
100
  CallInterfaceDescriptorData()
101
      : register_param_count_(-1), function_type_(nullptr) {}
102 103

  // A copy of the passed in registers and param_representations is made
104
  // and owned by the CallInterfaceDescriptorData.
105

106
  void InitializePlatformIndependent(FunctionType* function_type) {
107 108 109
    function_type_ = function_type;
  }

110 111 112
  // TODO(mvstanton): Instead of taking parallel arrays register and
  // param_representations, how about a struct that puts the representation
  // and register side by side (eg, RegRep(r1, Representation::Tagged()).
113
  // The same should go for the CodeStubDescriptor class.
114 115 116
  void InitializePlatformSpecific(
      int register_parameter_count, Register* registers,
      PlatformInterfaceDescriptor* platform_descriptor = NULL);
117

118 119
  bool IsInitialized() const { return register_param_count_ >= 0; }

120
  int param_count() const { return function_type_->Arity(); }
121 122 123
  int register_param_count() const { return register_param_count_; }
  Register register_param(int index) const { return register_params_[index]; }
  Register* register_params() const { return register_params_.get(); }
124
  Type* param_type(int index) const { return function_type_->Parameter(index); }
125 126 127 128
  PlatformInterfaceDescriptor* platform_specific_descriptor() const {
    return platform_specific_descriptor_;
  }

129
  FunctionType* function_type() const { return function_type_; }
130

131 132 133 134 135 136 137
 private:
  int register_param_count_;

  // The Register params are allocated dynamically by the
  // InterfaceDescriptor, and freed on destruction. This is because static
  // arrays of Registers cause creation of runtime static initializers
  // which we don't want.
rmcilroy's avatar
rmcilroy committed
138
  base::SmartArrayPointer<Register> register_params_;
139 140

  // Specifies types for parameters and return
141
  FunctionType* function_type_;
142

143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162
  PlatformInterfaceDescriptor* platform_specific_descriptor_;

  DISALLOW_COPY_AND_ASSIGN(CallInterfaceDescriptorData);
};


class CallDescriptors {
 public:
  enum Key {
#define DEF_ENUM(name) name,
    INTERFACE_DESCRIPTOR_LIST(DEF_ENUM)
#undef DEF_ENUM
    NUMBER_OF_DESCRIPTORS
  };
};


class CallInterfaceDescriptor {
 public:
  CallInterfaceDescriptor() : data_(NULL) {}
163
  virtual ~CallInterfaceDescriptor() {}
164 165 166 167

  CallInterfaceDescriptor(Isolate* isolate, CallDescriptors::Key key)
      : data_(isolate->call_descriptor_data(key)) {}

168 169
  int GetParameterCount() const { return data()->param_count(); }

170 171 172
  int GetRegisterParameterCount() const {
    return data()->register_param_count();
  }
173

174 175 176 177 178
  int GetStackParameterCount() const {
    return data()->function_type()->Arity() - data()->register_param_count();
  }

  Register GetRegisterParameter(int index) const {
179
    return data()->register_param(index);
180 181
  }

182
  Type* GetParameterType(int index) const {
183 184
    DCHECK(index < data()->param_count());
    return data()->param_type(index);
185 186 187 188
  }

  // Some platforms have extra information to associate with the descriptor.
  PlatformInterfaceDescriptor* platform_specific_descriptor() const {
189
    return data()->platform_specific_descriptor();
190 191
  }

192
  FunctionType* GetFunctionType() const { return data()->function_type(); }
193

194 195
  static const Register ContextRegister();

196
  const char* DebugName(Isolate* isolate) const;
197

198 199
  static FunctionType* BuildDefaultFunctionType(Isolate* isolate,
                                                int paramater_count);
200

201 202 203
 protected:
  const CallInterfaceDescriptorData* data() const { return data_; }

204
  virtual FunctionType* BuildCallInterfaceDescriptorFunctionType(
205 206 207 208 209 210 211 212 213 214 215
      Isolate* isolate, int register_param_count) {
    return BuildDefaultFunctionType(isolate, register_param_count);
  }

  virtual void InitializePlatformSpecific(CallInterfaceDescriptorData* data) {
    UNREACHABLE();
  }

  void Initialize(Isolate* isolate, CallDescriptors::Key key) {
    if (!data()->IsInitialized()) {
      CallInterfaceDescriptorData* d = isolate->call_descriptor_data(key);
vogelheim's avatar
vogelheim committed
216
      DCHECK(d == data());  // d should be a modifiable pointer to data().
217
      InitializePlatformSpecific(d);
218 219
      FunctionType* function_type = BuildCallInterfaceDescriptorFunctionType(
          isolate, d->register_param_count());
220
      d->InitializePlatformIndependent(function_type);
221 222 223
    }
  }

224
 private:
225 226
  const CallInterfaceDescriptorData* data_;
};
227

vogelheim's avatar
vogelheim committed
228 229 230 231 232 233
#define DECLARE_DESCRIPTOR_WITH_BASE(name, base)           \
 public:                                                   \
  explicit name(Isolate* isolate) : base(isolate, key()) { \
    Initialize(isolate, key());                            \
  }                                                        \
  static inline CallDescriptors::Key key();
234

235
#define DECLARE_DESCRIPTOR(name, base)                                         \
vogelheim's avatar
vogelheim committed
236
  DECLARE_DESCRIPTOR_WITH_BASE(name, base)                                     \
237 238 239 240
 protected:                                                                    \
  void InitializePlatformSpecific(CallInterfaceDescriptorData* data) override; \
  name(Isolate* isolate, CallDescriptors::Key key) : base(isolate, key) {}     \
                                                                               \
vogelheim's avatar
vogelheim committed
241
 public:
242

243 244 245
#define DECLARE_DESCRIPTOR_WITH_CUSTOM_FUNCTION_TYPE(name, base) \
  DECLARE_DESCRIPTOR(name, base)                                 \
 protected:                                                      \
246
  FunctionType* BuildCallInterfaceDescriptorFunctionType(        \
247 248
      Isolate* isolate, int register_param_count) override;      \
                                                                 \
249
 public:
250

vogelheim's avatar
vogelheim committed
251 252 253 254 255 256 257 258 259 260 261
#define DECLARE_DESCRIPTOR_WITH_BASE_AND_FUNCTION_TYPE_ARG(name, base, arg) \
  DECLARE_DESCRIPTOR_WITH_BASE(name, base)                                  \
 protected:                                                                 \
  FunctionType* BuildCallInterfaceDescriptorFunctionType(                   \
      Isolate* isolate, int register_param_count) override {                \
    return BuildCallInterfaceDescriptorFunctionTypeWithArg(                 \
        isolate, register_param_count, arg);                                \
  }                                                                         \
                                                                            \
 public:

262 263 264 265 266 267
class VoidDescriptor : public CallInterfaceDescriptor {
 public:
  DECLARE_DESCRIPTOR(VoidDescriptor, CallInterfaceDescriptor)
};


268
// LoadDescriptor is used by all stubs that implement Load/KeyedLoad ICs.
269 270
class LoadDescriptor : public CallInterfaceDescriptor {
 public:
271 272
  DECLARE_DESCRIPTOR_WITH_CUSTOM_FUNCTION_TYPE(LoadDescriptor,
                                               CallInterfaceDescriptor)
273

274
  enum ParameterIndices { kReceiverIndex, kNameIndex, kSlotIndex };
275 276
  static const Register ReceiverRegister();
  static const Register NameRegister();
277
  static const Register SlotRegister();
278 279 280
};


281
class StoreDescriptor : public CallInterfaceDescriptor {
282
 public:
283
  DECLARE_DESCRIPTOR(StoreDescriptor, CallInterfaceDescriptor)
284

285 286 287 288 289 290 291 292 293
  enum ParameterIndices {
    kReceiverIndex,
    kNameIndex,
    kValueIndex,
    kParameterCount
  };
  static const Register ReceiverRegister();
  static const Register NameRegister();
  static const Register ValueRegister();
294
};
295 296


297
class StoreTransitionDescriptor : public StoreDescriptor {
298
 public:
299 300
  DECLARE_DESCRIPTOR_WITH_CUSTOM_FUNCTION_TYPE(StoreTransitionDescriptor,
                                               StoreDescriptor)
301 302 303 304 305 306 307 308 309

  // Extends StoreDescriptor with Map parameter.
  enum ParameterIndices {
    kReceiverIndex,
    kNameIndex,
    kValueIndex,
    kMapIndex,
    kParameterCount
  };
310

311 312 313 314 315 316 317 318 319 320 321
  static const Register MapRegister();
};


class VectorStoreTransitionDescriptor : public StoreDescriptor {
 public:
  DECLARE_DESCRIPTOR_WITH_CUSTOM_FUNCTION_TYPE(VectorStoreTransitionDescriptor,
                                               StoreDescriptor)

  // Extends StoreDescriptor with Map parameter.
  enum ParameterIndices {
322 323 324 325 326 327 328 329 330 331
    kReceiverIndex = 0,
    kNameIndex = 1,
    kValueIndex = 2,

    kMapIndex = 3,

    kSlotIndex = 4,  // not present on ia32.
    kVirtualSlotVectorIndex = 4,

    kVectorIndex = 5
332 333
  };

334
  static const Register MapRegister();
335 336
  static const Register SlotRegister();
  static const Register VectorRegister();
337 338 339
};


340
class InstanceOfDescriptor final : public CallInterfaceDescriptor {
341
 public:
342
  DECLARE_DESCRIPTOR(InstanceOfDescriptor, CallInterfaceDescriptor)
343 344

  enum ParameterIndices { kLeftIndex, kRightIndex, kParameterCount };
345 346
  static const Register LeftRegister();
  static const Register RightRegister();
347 348 349
};


350 351
class VectorStoreICTrampolineDescriptor : public StoreDescriptor {
 public:
352 353
  DECLARE_DESCRIPTOR_WITH_CUSTOM_FUNCTION_TYPE(
      VectorStoreICTrampolineDescriptor, StoreDescriptor)
354 355 356 357 358 359 360 361 362

  enum ParameterIndices { kReceiverIndex, kNameIndex, kValueIndex, kSlotIndex };

  static const Register SlotRegister();
};


class VectorStoreICDescriptor : public VectorStoreICTrampolineDescriptor {
 public:
363 364
  DECLARE_DESCRIPTOR_WITH_CUSTOM_FUNCTION_TYPE(
      VectorStoreICDescriptor, VectorStoreICTrampolineDescriptor)
365 366 367 368 369 370 371 372 373 374 375 376 377

  enum ParameterIndices {
    kReceiverIndex,
    kNameIndex,
    kValueIndex,
    kSlotIndex,
    kVectorIndex
  };

  static const Register VectorRegister();
};


378
class LoadWithVectorDescriptor : public LoadDescriptor {
379
 public:
380 381
  DECLARE_DESCRIPTOR_WITH_CUSTOM_FUNCTION_TYPE(LoadWithVectorDescriptor,
                                               LoadDescriptor)
382 383 384 385 386

  enum ParameterIndices {
    kReceiverIndex,
    kNameIndex,
    kSlotIndex,
387
    kVectorIndex
388 389 390 391 392 393 394 395
  };

  static const Register VectorRegister();
};


class FastNewClosureDescriptor : public CallInterfaceDescriptor {
 public:
396
  DECLARE_DESCRIPTOR(FastNewClosureDescriptor, CallInterfaceDescriptor)
397 398 399 400 401
};


class FastNewContextDescriptor : public CallInterfaceDescriptor {
 public:
402
  DECLARE_DESCRIPTOR(FastNewContextDescriptor, CallInterfaceDescriptor)
403 404
};

405 406 407 408 409
class FastNewObjectDescriptor : public CallInterfaceDescriptor {
 public:
  DECLARE_DESCRIPTOR(FastNewObjectDescriptor, CallInterfaceDescriptor)
};

410 411 412 413 414
class FastNewRestParameterDescriptor : public CallInterfaceDescriptor {
 public:
  DECLARE_DESCRIPTOR(FastNewRestParameterDescriptor, CallInterfaceDescriptor)
};

415 416 417 418 419 420
class FastNewSloppyArgumentsDescriptor : public CallInterfaceDescriptor {
 public:
  DECLARE_DESCRIPTOR(FastNewSloppyArgumentsDescriptor,
                     CallInterfaceDescriptor)
};

421 422 423 424 425 426
class FastNewStrictArgumentsDescriptor : public CallInterfaceDescriptor {
 public:
  DECLARE_DESCRIPTOR(FastNewStrictArgumentsDescriptor,
                     CallInterfaceDescriptor)
};

427
class TypeConversionDescriptor final : public CallInterfaceDescriptor {
428
 public:
429
  enum ParameterIndices { kArgumentIndex };
430

431
  DECLARE_DESCRIPTOR(TypeConversionDescriptor, CallInterfaceDescriptor)
432

433
  static const Register ArgumentRegister();
434 435
};

436 437 438 439 440 441 442 443 444
class HasPropertyDescriptor final : public CallInterfaceDescriptor {
 public:
  enum ParameterIndices { kKeyIndex, kObjectIndex };

  DECLARE_DESCRIPTOR(HasPropertyDescriptor, CallInterfaceDescriptor)

  static const Register KeyRegister();
  static const Register ObjectRegister();
};
445

446 447 448 449 450
class TypeofDescriptor : public CallInterfaceDescriptor {
 public:
  DECLARE_DESCRIPTOR(TypeofDescriptor, CallInterfaceDescriptor)
};

451 452 453 454 455 456 457

class FastCloneRegExpDescriptor : public CallInterfaceDescriptor {
 public:
  DECLARE_DESCRIPTOR_WITH_CUSTOM_FUNCTION_TYPE(FastCloneRegExpDescriptor,
                                               CallInterfaceDescriptor)
};

458

459 460
class FastCloneShallowArrayDescriptor : public CallInterfaceDescriptor {
 public:
461 462
  DECLARE_DESCRIPTOR_WITH_CUSTOM_FUNCTION_TYPE(FastCloneShallowArrayDescriptor,
                                               CallInterfaceDescriptor)
463 464 465 466 467
};


class FastCloneShallowObjectDescriptor : public CallInterfaceDescriptor {
 public:
468
  DECLARE_DESCRIPTOR(FastCloneShallowObjectDescriptor, CallInterfaceDescriptor)
469 470 471 472 473
};


class CreateAllocationSiteDescriptor : public CallInterfaceDescriptor {
 public:
474 475
  DECLARE_DESCRIPTOR_WITH_CUSTOM_FUNCTION_TYPE(CreateAllocationSiteDescriptor,
                                               CallInterfaceDescriptor)
476 477 478
};


479 480 481 482 483 484 485 486 487
class CreateWeakCellDescriptor : public CallInterfaceDescriptor {
 public:
  enum ParameterIndices {
    kVectorIndex,
    kSlotIndex,
    kValueIndex,
    kParameterCount
  };

488 489
  DECLARE_DESCRIPTOR_WITH_CUSTOM_FUNCTION_TYPE(CreateWeakCellDescriptor,
                                               CallInterfaceDescriptor)
490 491 492
};


493 494 495 496 497 498 499
class CallTrampolineDescriptor : public CallInterfaceDescriptor {
 public:
  DECLARE_DESCRIPTOR_WITH_CUSTOM_FUNCTION_TYPE(CallTrampolineDescriptor,
                                               CallInterfaceDescriptor)
};


500 501 502 503 504 505 506
class ConstructStubDescriptor : public CallInterfaceDescriptor {
 public:
  DECLARE_DESCRIPTOR_WITH_CUSTOM_FUNCTION_TYPE(ConstructStubDescriptor,
                                               CallInterfaceDescriptor)
};


507 508 509 510 511 512 513
class ConstructTrampolineDescriptor : public CallInterfaceDescriptor {
 public:
  DECLARE_DESCRIPTOR_WITH_CUSTOM_FUNCTION_TYPE(ConstructTrampolineDescriptor,
                                               CallInterfaceDescriptor)
};


514 515
class CallFunctionDescriptor : public CallInterfaceDescriptor {
 public:
516 517 518 519 520 521
  DECLARE_DESCRIPTOR(CallFunctionDescriptor, CallInterfaceDescriptor)
};


class CallFunctionWithFeedbackDescriptor : public CallInterfaceDescriptor {
 public:
522 523
  DECLARE_DESCRIPTOR_WITH_CUSTOM_FUNCTION_TYPE(
      CallFunctionWithFeedbackDescriptor, CallInterfaceDescriptor)
524 525 526
};


527 528 529
class CallFunctionWithFeedbackAndVectorDescriptor
    : public CallInterfaceDescriptor {
 public:
530 531
  DECLARE_DESCRIPTOR_WITH_CUSTOM_FUNCTION_TYPE(
      CallFunctionWithFeedbackAndVectorDescriptor, CallInterfaceDescriptor)
532 533 534
};


535
class CallConstructDescriptor : public CallInterfaceDescriptor {
536
 public:
537
  DECLARE_DESCRIPTOR(CallConstructDescriptor, CallInterfaceDescriptor)
538 539 540 541 542
};


class RegExpConstructResultDescriptor : public CallInterfaceDescriptor {
 public:
543
  DECLARE_DESCRIPTOR(RegExpConstructResultDescriptor, CallInterfaceDescriptor)
544 545 546
};


547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565
class LoadGlobalViaContextDescriptor : public CallInterfaceDescriptor {
 public:
  DECLARE_DESCRIPTOR_WITH_CUSTOM_FUNCTION_TYPE(LoadGlobalViaContextDescriptor,
                                               CallInterfaceDescriptor)

  static const Register SlotRegister();
};


class StoreGlobalViaContextDescriptor : public CallInterfaceDescriptor {
 public:
  DECLARE_DESCRIPTOR_WITH_CUSTOM_FUNCTION_TYPE(StoreGlobalViaContextDescriptor,
                                               CallInterfaceDescriptor)

  static const Register SlotRegister();
  static const Register ValueRegister();
};


566 567
class TransitionElementsKindDescriptor : public CallInterfaceDescriptor {
 public:
568
  DECLARE_DESCRIPTOR(TransitionElementsKindDescriptor, CallInterfaceDescriptor)
569 570 571
};


572 573 574 575 576
class AllocateHeapNumberDescriptor : public CallInterfaceDescriptor {
 public:
  DECLARE_DESCRIPTOR(AllocateHeapNumberDescriptor, CallInterfaceDescriptor)
};

bbudge's avatar
bbudge committed
577 578 579 580 581 582 583
#define SIMD128_ALLOC_DESC(TYPE, Type, type, lane_count, lane_type)         \
  class Allocate##Type##Descriptor : public CallInterfaceDescriptor {       \
   public:                                                                  \
    DECLARE_DESCRIPTOR(Allocate##Type##Descriptor, CallInterfaceDescriptor) \
  };
SIMD128_TYPES(SIMD128_ALLOC_DESC)
#undef SIMD128_ALLOC_DESC
584

585 586 587 588 589 590
class AllocateMutableHeapNumberDescriptor : public CallInterfaceDescriptor {
 public:
  DECLARE_DESCRIPTOR(AllocateMutableHeapNumberDescriptor,
                     CallInterfaceDescriptor)
};

591 592 593 594 595 596 597 598 599 600 601
class ArrayNoArgumentConstructorDescriptor : public CallInterfaceDescriptor {
 public:
  DECLARE_DESCRIPTOR_WITH_CUSTOM_FUNCTION_TYPE(
      ArrayNoArgumentConstructorDescriptor, CallInterfaceDescriptor)
  enum ParameterIndices {
    kFunctionIndex,
    kAllocationSiteIndex,
    kArgumentCountIndex,
    kContextIndex
  };
};
602

603 604 605
class ArrayConstructorConstantArgCountDescriptor
    : public CallInterfaceDescriptor {
 public:
606 607
  DECLARE_DESCRIPTOR(ArrayConstructorConstantArgCountDescriptor,
                     CallInterfaceDescriptor)
608 609 610 611 612
};


class ArrayConstructorDescriptor : public CallInterfaceDescriptor {
 public:
613 614
  DECLARE_DESCRIPTOR_WITH_CUSTOM_FUNCTION_TYPE(ArrayConstructorDescriptor,
                                               CallInterfaceDescriptor)
615 616 617 618 619 620
};


class InternalArrayConstructorConstantArgCountDescriptor
    : public CallInterfaceDescriptor {
 public:
621 622
  DECLARE_DESCRIPTOR(InternalArrayConstructorConstantArgCountDescriptor,
                     CallInterfaceDescriptor)
623 624 625 626 627
};


class InternalArrayConstructorDescriptor : public CallInterfaceDescriptor {
 public:
628 629
  DECLARE_DESCRIPTOR_WITH_CUSTOM_FUNCTION_TYPE(
      InternalArrayConstructorDescriptor, CallInterfaceDescriptor)
630 631 632
};


633 634 635 636 637 638
class CompareDescriptor : public CallInterfaceDescriptor {
 public:
  DECLARE_DESCRIPTOR(CompareDescriptor, CallInterfaceDescriptor)
};


639 640
class BinaryOpDescriptor : public CallInterfaceDescriptor {
 public:
641
  DECLARE_DESCRIPTOR(BinaryOpDescriptor, CallInterfaceDescriptor)
642 643 644 645 646
};


class BinaryOpWithAllocationSiteDescriptor : public CallInterfaceDescriptor {
 public:
647 648
  DECLARE_DESCRIPTOR(BinaryOpWithAllocationSiteDescriptor,
                     CallInterfaceDescriptor)
649 650
};

651 652 653 654
class CountOpDescriptor final : public CallInterfaceDescriptor {
 public:
  DECLARE_DESCRIPTOR(CountOpDescriptor, CallInterfaceDescriptor)
};
655 656 657

class StringAddDescriptor : public CallInterfaceDescriptor {
 public:
658
  DECLARE_DESCRIPTOR(StringAddDescriptor, CallInterfaceDescriptor)
659 660 661
};


662 663 664 665 666 667 668 669 670 671
class StringCompareDescriptor : public CallInterfaceDescriptor {
 public:
  DECLARE_DESCRIPTOR(StringCompareDescriptor, CallInterfaceDescriptor)

  enum ParameterIndices { kLeftIndex, kRightIndex, kParameterCount };
  static const Register LeftRegister();
  static const Register RightRegister();
};


672 673
class KeyedDescriptor : public CallInterfaceDescriptor {
 public:
674
  DECLARE_DESCRIPTOR(KeyedDescriptor, CallInterfaceDescriptor)
675 676 677 678 679
};


class NamedDescriptor : public CallInterfaceDescriptor {
 public:
680
  DECLARE_DESCRIPTOR(NamedDescriptor, CallInterfaceDescriptor)
681 682 683 684 685
};


class CallHandlerDescriptor : public CallInterfaceDescriptor {
 public:
686
  DECLARE_DESCRIPTOR(CallHandlerDescriptor, CallInterfaceDescriptor)
687 688 689 690 691
};


class ArgumentAdaptorDescriptor : public CallInterfaceDescriptor {
 public:
692 693
  DECLARE_DESCRIPTOR_WITH_CUSTOM_FUNCTION_TYPE(ArgumentAdaptorDescriptor,
                                               CallInterfaceDescriptor)
694 695
};

vogelheim's avatar
vogelheim committed
696 697 698 699 700 701 702 703 704 705 706 707 708 709
// The ApiCallback*Descriptors have a lot of boilerplate. The superclass
// ApiCallbackDescriptorBase contains all the logic, and the
// ApiCallbackWith*ArgsDescriptor merely instantiate these with a
// parameter for the number of args.
//
// The base class is not meant to be instantiated directly and has no
// public constructors to ensure this is so.
//
// The simplest usage for all the ApiCallback*Descriptors is probably
//   ApiCallbackDescriptorBase::ForArgs(isolate, argc)
//
class ApiCallbackDescriptorBase : public CallInterfaceDescriptor {
 public:
  static CallInterfaceDescriptor ForArgs(Isolate* isolate, int argc);
vogelheim's avatar
vogelheim committed
710

vogelheim's avatar
vogelheim committed
711 712 713 714 715 716 717 718 719
 protected:
  ApiCallbackDescriptorBase(Isolate* isolate, CallDescriptors::Key key)
      : CallInterfaceDescriptor(isolate, key) {}
  void InitializePlatformSpecific(CallInterfaceDescriptorData* data) override;
  FunctionType* BuildCallInterfaceDescriptorFunctionTypeWithArg(
      Isolate* isolate, int parameter_count, int argc);
};

class ApiCallbackWith0ArgsDescriptor : public ApiCallbackDescriptorBase {
vogelheim's avatar
vogelheim committed
720
 public:
vogelheim's avatar
vogelheim committed
721 722
  DECLARE_DESCRIPTOR_WITH_BASE_AND_FUNCTION_TYPE_ARG(
      ApiCallbackWith0ArgsDescriptor, ApiCallbackDescriptorBase, 0)
vogelheim's avatar
vogelheim committed
723 724
};

vogelheim's avatar
vogelheim committed
725 726 727 728 729
class ApiCallbackWith1ArgsDescriptor : public ApiCallbackDescriptorBase {
 public:
  DECLARE_DESCRIPTOR_WITH_BASE_AND_FUNCTION_TYPE_ARG(
      ApiCallbackWith1ArgsDescriptor, ApiCallbackDescriptorBase, 1)
};
vogelheim's avatar
vogelheim committed
730

vogelheim's avatar
vogelheim committed
731
class ApiCallbackWith2ArgsDescriptor : public ApiCallbackDescriptorBase {
vogelheim's avatar
vogelheim committed
732
 public:
vogelheim's avatar
vogelheim committed
733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764
  DECLARE_DESCRIPTOR_WITH_BASE_AND_FUNCTION_TYPE_ARG(
      ApiCallbackWith2ArgsDescriptor, ApiCallbackDescriptorBase, 2)
};

class ApiCallbackWith3ArgsDescriptor : public ApiCallbackDescriptorBase {
 public:
  DECLARE_DESCRIPTOR_WITH_BASE_AND_FUNCTION_TYPE_ARG(
      ApiCallbackWith3ArgsDescriptor, ApiCallbackDescriptorBase, 3)
};

class ApiCallbackWith4ArgsDescriptor : public ApiCallbackDescriptorBase {
 public:
  DECLARE_DESCRIPTOR_WITH_BASE_AND_FUNCTION_TYPE_ARG(
      ApiCallbackWith4ArgsDescriptor, ApiCallbackDescriptorBase, 4)
};

class ApiCallbackWith5ArgsDescriptor : public ApiCallbackDescriptorBase {
 public:
  DECLARE_DESCRIPTOR_WITH_BASE_AND_FUNCTION_TYPE_ARG(
      ApiCallbackWith5ArgsDescriptor, ApiCallbackDescriptorBase, 5)
};

class ApiCallbackWith6ArgsDescriptor : public ApiCallbackDescriptorBase {
 public:
  DECLARE_DESCRIPTOR_WITH_BASE_AND_FUNCTION_TYPE_ARG(
      ApiCallbackWith6ArgsDescriptor, ApiCallbackDescriptorBase, 6)
};

class ApiCallbackWith7ArgsDescriptor : public ApiCallbackDescriptorBase {
 public:
  DECLARE_DESCRIPTOR_WITH_BASE_AND_FUNCTION_TYPE_ARG(
      ApiCallbackWith7ArgsDescriptor, ApiCallbackDescriptorBase, 7)
765 766 767
};


768 769
class ApiGetterDescriptor : public CallInterfaceDescriptor {
 public:
770
  DECLARE_DESCRIPTOR(ApiGetterDescriptor, CallInterfaceDescriptor)
771

772 773 774
  static const Register ReceiverRegister();
  static const Register HolderRegister();
  static const Register CallbackRegister();
775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796
};


class MathPowTaggedDescriptor : public CallInterfaceDescriptor {
 public:
  DECLARE_DESCRIPTOR(MathPowTaggedDescriptor, CallInterfaceDescriptor)

  static const Register exponent();
};


class MathPowIntegerDescriptor : public CallInterfaceDescriptor {
 public:
  DECLARE_DESCRIPTOR(MathPowIntegerDescriptor, CallInterfaceDescriptor)

  static const Register exponent();
};


class ContextOnlyDescriptor : public CallInterfaceDescriptor {
 public:
  DECLARE_DESCRIPTOR(ContextOnlyDescriptor, CallInterfaceDescriptor)
797 798
};

799 800 801 802 803
class FastArrayPushDescriptor : public CallInterfaceDescriptor {
 public:
  DECLARE_DESCRIPTOR_WITH_CUSTOM_FUNCTION_TYPE(FastArrayPushDescriptor,
                                               CallInterfaceDescriptor)
};
804 805 806 807 808

class GrowArrayElementsDescriptor : public CallInterfaceDescriptor {
 public:
  DECLARE_DESCRIPTOR(GrowArrayElementsDescriptor, CallInterfaceDescriptor)

809
  enum RegisterInfo { kObjectIndex, kKeyIndex };
810 811 812 813
  static const Register ObjectRegister();
  static const Register KeyRegister();
};

vogelheim's avatar
vogelheim committed
814
class InterpreterDispatchDescriptor : public CallInterfaceDescriptor {
815 816 817 818 819
 public:
  DECLARE_DESCRIPTOR_WITH_CUSTOM_FUNCTION_TYPE(InterpreterDispatchDescriptor,
                                               CallInterfaceDescriptor)

  static const int kAccumulatorParameter = 0;
820 821 822
  static const int kBytecodeOffsetParameter = 1;
  static const int kBytecodeArrayParameter = 2;
  static const int kDispatchTableParameter = 3;
823
};
824

825
class InterpreterPushArgsAndCallDescriptor : public CallInterfaceDescriptor {
826
 public:
827 828 829 830
  DECLARE_DESCRIPTOR(InterpreterPushArgsAndCallDescriptor,
                     CallInterfaceDescriptor)
};

831

832 833 834 835 836 837 838 839
class InterpreterPushArgsAndConstructDescriptor
    : public CallInterfaceDescriptor {
 public:
  DECLARE_DESCRIPTOR(InterpreterPushArgsAndConstructDescriptor,
                     CallInterfaceDescriptor)
};


840 841 842
class InterpreterCEntryDescriptor : public CallInterfaceDescriptor {
 public:
  DECLARE_DESCRIPTOR(InterpreterCEntryDescriptor, CallInterfaceDescriptor)
843 844
};

845 846 847 848 849
class ResumeGeneratorDescriptor final : public CallInterfaceDescriptor {
 public:
  DECLARE_DESCRIPTOR(ResumeGeneratorDescriptor, CallInterfaceDescriptor)
};

vogelheim's avatar
vogelheim committed
850
#undef DECLARE_DESCRIPTOR_WITH_BASE
851
#undef DECLARE_DESCRIPTOR
vogelheim's avatar
vogelheim committed
852 853
#undef DECLARE_DESCRIPTOR_WITH_CUSTOM_FUNCTION_TYPE
#undef DECLARE_DESCRIPTOR_WITH_BASE_AND_FUNCTION_TYPE_ARG
854 855 856 857 858 859 860

// We define the association between CallDescriptors::Key and the specialized
// descriptor here to reduce boilerplate and mistakes.
#define DEF_KEY(name) \
  CallDescriptors::Key name##Descriptor::key() { return CallDescriptors::name; }
INTERFACE_DESCRIPTOR_LIST(DEF_KEY)
#undef DEF_KEY
861 862
}  // namespace internal
}  // namespace v8
863

864

865 866 867 868 869 870 871
#if V8_TARGET_ARCH_ARM64
#include "src/arm64/interface-descriptors-arm64.h"
#elif V8_TARGET_ARCH_ARM
#include "src/arm/interface-descriptors-arm.h"
#endif

#endif  // V8_CALL_INTERFACE_DESCRIPTOR_H_