interface-descriptors.h revision 537ba893e2530051ec7f296e769fdd37bb4ae4a0
1// 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) \ 17 V(Void) \ 18 V(Load) \ 19 V(Store) \ 20 V(StoreTransition) \ 21 V(VectorStoreTransition) \ 22 V(VectorStoreICTrampoline) \ 23 V(VectorStoreIC) \ 24 V(LoadWithVector) \ 25 V(FastArrayPush) \ 26 V(FastNewClosure) \ 27 V(FastNewContext) \ 28 V(FastNewObject) \ 29 V(FastNewRestParameter) \ 30 V(FastNewSloppyArguments) \ 31 V(FastNewStrictArguments) \ 32 V(TypeConversion) \ 33 V(Typeof) \ 34 V(FastCloneRegExp) \ 35 V(FastCloneShallowArray) \ 36 V(FastCloneShallowObject) \ 37 V(CreateAllocationSite) \ 38 V(CreateWeakCell) \ 39 V(CallFunction) \ 40 V(CallFunctionWithFeedback) \ 41 V(CallFunctionWithFeedbackAndVector) \ 42 V(CallConstruct) \ 43 V(CallTrampoline) \ 44 V(ConstructStub) \ 45 V(ConstructTrampoline) \ 46 V(RegExpConstructResult) \ 47 V(TransitionElementsKind) \ 48 V(AllocateHeapNumber) \ 49 V(AllocateFloat32x4) \ 50 V(AllocateInt32x4) \ 51 V(AllocateUint32x4) \ 52 V(AllocateBool32x4) \ 53 V(AllocateInt16x8) \ 54 V(AllocateUint16x8) \ 55 V(AllocateBool16x8) \ 56 V(AllocateInt8x16) \ 57 V(AllocateUint8x16) \ 58 V(AllocateBool8x16) \ 59 V(ArrayNoArgumentConstructor) \ 60 V(ArrayConstructorConstantArgCount) \ 61 V(ArrayConstructor) \ 62 V(InternalArrayConstructorConstantArgCount) \ 63 V(InternalArrayConstructor) \ 64 V(Compare) \ 65 V(BinaryOp) \ 66 V(BinaryOpWithAllocationSite) \ 67 V(CountOp) \ 68 V(StringAdd) \ 69 V(StringCompare) \ 70 V(Keyed) \ 71 V(Named) \ 72 V(HasProperty) \ 73 V(CallHandler) \ 74 V(ArgumentAdaptor) \ 75 V(ApiCallbackWith0Args) \ 76 V(ApiCallbackWith1Args) \ 77 V(ApiCallbackWith2Args) \ 78 V(ApiCallbackWith3Args) \ 79 V(ApiCallbackWith4Args) \ 80 V(ApiCallbackWith5Args) \ 81 V(ApiCallbackWith6Args) \ 82 V(ApiCallbackWith7Args) \ 83 V(ApiGetter) \ 84 V(LoadGlobalViaContext) \ 85 V(StoreGlobalViaContext) \ 86 V(MathPowTagged) \ 87 V(MathPowInteger) \ 88 V(ContextOnly) \ 89 V(GrowArrayElements) \ 90 V(InterpreterDispatch) \ 91 V(InterpreterPushArgsAndCall) \ 92 V(InterpreterPushArgsAndConstruct) \ 93 V(InterpreterCEntry) \ 94 V(ResumeGenerator) 95 96class CallInterfaceDescriptorData { 97 public: 98 CallInterfaceDescriptorData() 99 : register_param_count_(-1), function_type_(nullptr) {} 100 101 // A copy of the passed in registers and param_representations is made 102 // and owned by the CallInterfaceDescriptorData. 103 104 void InitializePlatformIndependent(FunctionType* function_type) { 105 function_type_ = function_type; 106 } 107 108 // TODO(mvstanton): Instead of taking parallel arrays register and 109 // param_representations, how about a struct that puts the representation 110 // and register side by side (eg, RegRep(r1, Representation::Tagged()). 111 // The same should go for the CodeStubDescriptor class. 112 void InitializePlatformSpecific( 113 int register_parameter_count, Register* registers, 114 PlatformInterfaceDescriptor* platform_descriptor = NULL); 115 116 bool IsInitialized() const { return register_param_count_ >= 0; } 117 118 int param_count() const { return function_type_->Arity(); } 119 int register_param_count() const { return register_param_count_; } 120 Register register_param(int index) const { return register_params_[index]; } 121 Register* register_params() const { return register_params_.get(); } 122 Type* param_type(int index) const { return function_type_->Parameter(index); } 123 PlatformInterfaceDescriptor* platform_specific_descriptor() const { 124 return platform_specific_descriptor_; 125 } 126 127 FunctionType* function_type() const { return function_type_; } 128 129 private: 130 int register_param_count_; 131 132 // The Register params are allocated dynamically by the 133 // InterfaceDescriptor, and freed on destruction. This is because static 134 // arrays of Registers cause creation of runtime static initializers 135 // which we don't want. 136 base::SmartArrayPointer<Register> register_params_; 137 138 // Specifies types for parameters and return 139 FunctionType* function_type_; 140 141 PlatformInterfaceDescriptor* platform_specific_descriptor_; 142 143 DISALLOW_COPY_AND_ASSIGN(CallInterfaceDescriptorData); 144}; 145 146 147class CallDescriptors { 148 public: 149 enum Key { 150#define DEF_ENUM(name) name, 151 INTERFACE_DESCRIPTOR_LIST(DEF_ENUM) 152#undef DEF_ENUM 153 NUMBER_OF_DESCRIPTORS 154 }; 155}; 156 157 158class CallInterfaceDescriptor { 159 public: 160 CallInterfaceDescriptor() : data_(NULL) {} 161 virtual ~CallInterfaceDescriptor() {} 162 163 CallInterfaceDescriptor(Isolate* isolate, CallDescriptors::Key key) 164 : data_(isolate->call_descriptor_data(key)) {} 165 166 int GetParameterCount() const { return data()->param_count(); } 167 168 int GetRegisterParameterCount() const { 169 return data()->register_param_count(); 170 } 171 172 int GetStackParameterCount() const { 173 return data()->function_type()->Arity() - data()->register_param_count(); 174 } 175 176 Register GetRegisterParameter(int index) const { 177 return data()->register_param(index); 178 } 179 180 Type* GetParameterType(int index) const { 181 DCHECK(index < data()->param_count()); 182 return data()->param_type(index); 183 } 184 185 // Some platforms have extra information to associate with the descriptor. 186 PlatformInterfaceDescriptor* platform_specific_descriptor() const { 187 return data()->platform_specific_descriptor(); 188 } 189 190 FunctionType* GetFunctionType() const { return data()->function_type(); } 191 192 static const Register ContextRegister(); 193 194 const char* DebugName(Isolate* isolate) const; 195 196 static FunctionType* BuildDefaultFunctionType(Isolate* isolate, 197 int paramater_count); 198 199 protected: 200 const CallInterfaceDescriptorData* data() const { return data_; } 201 202 virtual FunctionType* BuildCallInterfaceDescriptorFunctionType( 203 Isolate* isolate, int register_param_count) { 204 return BuildDefaultFunctionType(isolate, register_param_count); 205 } 206 207 virtual void InitializePlatformSpecific(CallInterfaceDescriptorData* data) { 208 UNREACHABLE(); 209 } 210 211 void Initialize(Isolate* isolate, CallDescriptors::Key key) { 212 if (!data()->IsInitialized()) { 213 CallInterfaceDescriptorData* d = isolate->call_descriptor_data(key); 214 DCHECK(d == data()); // d should be a modifiable pointer to data(). 215 InitializePlatformSpecific(d); 216 FunctionType* function_type = BuildCallInterfaceDescriptorFunctionType( 217 isolate, d->register_param_count()); 218 d->InitializePlatformIndependent(function_type); 219 } 220 } 221 222 private: 223 const CallInterfaceDescriptorData* data_; 224}; 225 226#define DECLARE_DESCRIPTOR_WITH_BASE(name, base) \ 227 public: \ 228 explicit name(Isolate* isolate) : base(isolate, key()) { \ 229 Initialize(isolate, key()); \ 230 } \ 231 static inline CallDescriptors::Key key(); 232 233#define DECLARE_DESCRIPTOR(name, base) \ 234 DECLARE_DESCRIPTOR_WITH_BASE(name, base) \ 235 protected: \ 236 void InitializePlatformSpecific(CallInterfaceDescriptorData* data) override; \ 237 name(Isolate* isolate, CallDescriptors::Key key) : base(isolate, key) {} \ 238 \ 239 public: 240 241#define DECLARE_DESCRIPTOR_WITH_CUSTOM_FUNCTION_TYPE(name, base) \ 242 DECLARE_DESCRIPTOR(name, base) \ 243 protected: \ 244 FunctionType* BuildCallInterfaceDescriptorFunctionType( \ 245 Isolate* isolate, int register_param_count) override; \ 246 \ 247 public: 248 249#define DECLARE_DESCRIPTOR_WITH_BASE_AND_FUNCTION_TYPE_ARG(name, base, arg) \ 250 DECLARE_DESCRIPTOR_WITH_BASE(name, base) \ 251 protected: \ 252 FunctionType* BuildCallInterfaceDescriptorFunctionType( \ 253 Isolate* isolate, int register_param_count) override { \ 254 return BuildCallInterfaceDescriptorFunctionTypeWithArg( \ 255 isolate, register_param_count, arg); \ 256 } \ 257 \ 258 public: 259 260class VoidDescriptor : public CallInterfaceDescriptor { 261 public: 262 DECLARE_DESCRIPTOR(VoidDescriptor, CallInterfaceDescriptor) 263}; 264 265 266// LoadDescriptor is used by all stubs that implement Load/KeyedLoad ICs. 267class LoadDescriptor : public CallInterfaceDescriptor { 268 public: 269 DECLARE_DESCRIPTOR_WITH_CUSTOM_FUNCTION_TYPE(LoadDescriptor, 270 CallInterfaceDescriptor) 271 272 enum ParameterIndices { kReceiverIndex, kNameIndex, kSlotIndex }; 273 static const Register ReceiverRegister(); 274 static const Register NameRegister(); 275 static const Register SlotRegister(); 276}; 277 278 279class StoreDescriptor : public CallInterfaceDescriptor { 280 public: 281 DECLARE_DESCRIPTOR(StoreDescriptor, CallInterfaceDescriptor) 282 283 enum ParameterIndices { 284 kReceiverIndex, 285 kNameIndex, 286 kValueIndex, 287 kParameterCount 288 }; 289 static const Register ReceiverRegister(); 290 static const Register NameRegister(); 291 static const Register ValueRegister(); 292}; 293 294 295class StoreTransitionDescriptor : public StoreDescriptor { 296 public: 297 DECLARE_DESCRIPTOR_WITH_CUSTOM_FUNCTION_TYPE(StoreTransitionDescriptor, 298 StoreDescriptor) 299 300 // Extends StoreDescriptor with Map parameter. 301 enum ParameterIndices { 302 kReceiverIndex, 303 kNameIndex, 304 kValueIndex, 305 kMapIndex, 306 kParameterCount 307 }; 308 309 static const Register MapRegister(); 310}; 311 312 313class VectorStoreTransitionDescriptor : public StoreDescriptor { 314 public: 315 DECLARE_DESCRIPTOR_WITH_CUSTOM_FUNCTION_TYPE(VectorStoreTransitionDescriptor, 316 StoreDescriptor) 317 318 // Extends StoreDescriptor with Map parameter. 319 enum ParameterIndices { 320 kReceiverIndex = 0, 321 kNameIndex = 1, 322 kValueIndex = 2, 323 324 kMapIndex = 3, 325 326 kSlotIndex = 4, // not present on ia32. 327 kVirtualSlotVectorIndex = 4, 328 329 kVectorIndex = 5 330 }; 331 332 static const Register MapRegister(); 333 static const Register SlotRegister(); 334 static const Register VectorRegister(); 335}; 336 337 338class VectorStoreICTrampolineDescriptor : public StoreDescriptor { 339 public: 340 DECLARE_DESCRIPTOR_WITH_CUSTOM_FUNCTION_TYPE( 341 VectorStoreICTrampolineDescriptor, StoreDescriptor) 342 343 enum ParameterIndices { kReceiverIndex, kNameIndex, kValueIndex, kSlotIndex }; 344 345 static const Register SlotRegister(); 346}; 347 348 349class VectorStoreICDescriptor : public VectorStoreICTrampolineDescriptor { 350 public: 351 DECLARE_DESCRIPTOR_WITH_CUSTOM_FUNCTION_TYPE( 352 VectorStoreICDescriptor, VectorStoreICTrampolineDescriptor) 353 354 enum ParameterIndices { 355 kReceiverIndex, 356 kNameIndex, 357 kValueIndex, 358 kSlotIndex, 359 kVectorIndex 360 }; 361 362 static const Register VectorRegister(); 363}; 364 365 366class LoadWithVectorDescriptor : public LoadDescriptor { 367 public: 368 DECLARE_DESCRIPTOR_WITH_CUSTOM_FUNCTION_TYPE(LoadWithVectorDescriptor, 369 LoadDescriptor) 370 371 enum ParameterIndices { 372 kReceiverIndex, 373 kNameIndex, 374 kSlotIndex, 375 kVectorIndex 376 }; 377 378 static const Register VectorRegister(); 379}; 380 381 382class FastNewClosureDescriptor : public CallInterfaceDescriptor { 383 public: 384 DECLARE_DESCRIPTOR(FastNewClosureDescriptor, CallInterfaceDescriptor) 385}; 386 387 388class FastNewContextDescriptor : public CallInterfaceDescriptor { 389 public: 390 DECLARE_DESCRIPTOR(FastNewContextDescriptor, CallInterfaceDescriptor) 391}; 392 393class FastNewObjectDescriptor : public CallInterfaceDescriptor { 394 public: 395 DECLARE_DESCRIPTOR(FastNewObjectDescriptor, CallInterfaceDescriptor) 396}; 397 398class FastNewRestParameterDescriptor : public CallInterfaceDescriptor { 399 public: 400 DECLARE_DESCRIPTOR(FastNewRestParameterDescriptor, CallInterfaceDescriptor) 401}; 402 403class FastNewSloppyArgumentsDescriptor : public CallInterfaceDescriptor { 404 public: 405 DECLARE_DESCRIPTOR(FastNewSloppyArgumentsDescriptor, 406 CallInterfaceDescriptor) 407}; 408 409class FastNewStrictArgumentsDescriptor : public CallInterfaceDescriptor { 410 public: 411 DECLARE_DESCRIPTOR(FastNewStrictArgumentsDescriptor, 412 CallInterfaceDescriptor) 413}; 414 415class TypeConversionDescriptor final : public CallInterfaceDescriptor { 416 public: 417 enum ParameterIndices { kArgumentIndex }; 418 419 DECLARE_DESCRIPTOR(TypeConversionDescriptor, CallInterfaceDescriptor) 420 421 static const Register ArgumentRegister(); 422}; 423 424class HasPropertyDescriptor final : public CallInterfaceDescriptor { 425 public: 426 enum ParameterIndices { kKeyIndex, kObjectIndex }; 427 428 DECLARE_DESCRIPTOR(HasPropertyDescriptor, CallInterfaceDescriptor) 429 430 static const Register KeyRegister(); 431 static const Register ObjectRegister(); 432}; 433 434class 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 447class FastCloneShallowArrayDescriptor : public CallInterfaceDescriptor { 448 public: 449 DECLARE_DESCRIPTOR_WITH_CUSTOM_FUNCTION_TYPE(FastCloneShallowArrayDescriptor, 450 CallInterfaceDescriptor) 451}; 452 453 454class FastCloneShallowObjectDescriptor : public CallInterfaceDescriptor { 455 public: 456 DECLARE_DESCRIPTOR(FastCloneShallowObjectDescriptor, CallInterfaceDescriptor) 457}; 458 459 460class CreateAllocationSiteDescriptor : public CallInterfaceDescriptor { 461 public: 462 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) 499}; 500 501 502class CallFunctionDescriptor : public CallInterfaceDescriptor { 503 public: 504 DECLARE_DESCRIPTOR(CallFunctionDescriptor, CallInterfaceDescriptor) 505}; 506 507 508class CallFunctionWithFeedbackDescriptor : public CallInterfaceDescriptor { 509 public: 510 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) 520}; 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 535class 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 554class TransitionElementsKindDescriptor : public CallInterfaceDescriptor { 555 public: 556 DECLARE_DESCRIPTOR(TransitionElementsKindDescriptor, CallInterfaceDescriptor) 557}; 558 559 560class AllocateHeapNumberDescriptor : public CallInterfaceDescriptor { 561 public: 562 DECLARE_DESCRIPTOR(AllocateHeapNumberDescriptor, CallInterfaceDescriptor) 563}; 564 565#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 572 573class ArrayNoArgumentConstructorDescriptor : public CallInterfaceDescriptor { 574 public: 575 DECLARE_DESCRIPTOR_WITH_CUSTOM_FUNCTION_TYPE( 576 ArrayNoArgumentConstructorDescriptor, CallInterfaceDescriptor) 577 enum ParameterIndices { 578 kFunctionIndex, 579 kAllocationSiteIndex, 580 kArgumentCountIndex, 581 kContextIndex 582 }; 583}; 584 585class ArrayConstructorConstantArgCountDescriptor 586 : public CallInterfaceDescriptor { 587 public: 588 DECLARE_DESCRIPTOR(ArrayConstructorConstantArgCountDescriptor, 589 CallInterfaceDescriptor) 590}; 591 592 593class ArrayConstructorDescriptor : public CallInterfaceDescriptor { 594 public: 595 DECLARE_DESCRIPTOR_WITH_CUSTOM_FUNCTION_TYPE(ArrayConstructorDescriptor, 596 CallInterfaceDescriptor) 597}; 598 599 600class InternalArrayConstructorConstantArgCountDescriptor 601 : public CallInterfaceDescriptor { 602 public: 603 DECLARE_DESCRIPTOR(InternalArrayConstructorConstantArgCountDescriptor, 604 CallInterfaceDescriptor) 605}; 606 607 608class InternalArrayConstructorDescriptor : public CallInterfaceDescriptor { 609 public: 610 DECLARE_DESCRIPTOR_WITH_CUSTOM_FUNCTION_TYPE( 611 InternalArrayConstructorDescriptor, CallInterfaceDescriptor) 612}; 613 614 615class CompareDescriptor : public CallInterfaceDescriptor { 616 public: 617 DECLARE_DESCRIPTOR(CompareDescriptor, CallInterfaceDescriptor) 618}; 619 620 621class BinaryOpDescriptor : public CallInterfaceDescriptor { 622 public: 623 DECLARE_DESCRIPTOR(BinaryOpDescriptor, CallInterfaceDescriptor) 624}; 625 626 627class BinaryOpWithAllocationSiteDescriptor : public CallInterfaceDescriptor { 628 public: 629 DECLARE_DESCRIPTOR(BinaryOpWithAllocationSiteDescriptor, 630 CallInterfaceDescriptor) 631}; 632 633class CountOpDescriptor final : public CallInterfaceDescriptor { 634 public: 635 DECLARE_DESCRIPTOR(CountOpDescriptor, CallInterfaceDescriptor) 636}; 637 638class StringAddDescriptor : public CallInterfaceDescriptor { 639 public: 640 DECLARE_DESCRIPTOR(StringAddDescriptor, CallInterfaceDescriptor) 641}; 642 643 644class StringCompareDescriptor : public CallInterfaceDescriptor { 645 public: 646 DECLARE_DESCRIPTOR(StringCompareDescriptor, CallInterfaceDescriptor) 647 648 enum ParameterIndices { kLeftIndex, kRightIndex, kParameterCount }; 649 static const Register LeftRegister(); 650 static const Register RightRegister(); 651}; 652 653 654class KeyedDescriptor : public CallInterfaceDescriptor { 655 public: 656 DECLARE_DESCRIPTOR(KeyedDescriptor, CallInterfaceDescriptor) 657}; 658 659 660class NamedDescriptor : public CallInterfaceDescriptor { 661 public: 662 DECLARE_DESCRIPTOR(NamedDescriptor, CallInterfaceDescriptor) 663}; 664 665 666class CallHandlerDescriptor : public CallInterfaceDescriptor { 667 public: 668 DECLARE_DESCRIPTOR(CallHandlerDescriptor, CallInterfaceDescriptor) 669}; 670 671 672class ArgumentAdaptorDescriptor : public CallInterfaceDescriptor { 673 public: 674 DECLARE_DESCRIPTOR_WITH_CUSTOM_FUNCTION_TYPE(ArgumentAdaptorDescriptor, 675 CallInterfaceDescriptor) 676}; 677 678// The ApiCallback*Descriptors have a lot of boilerplate. The superclass 679// ApiCallbackDescriptorBase contains all the logic, and the 680// ApiCallbackWith*ArgsDescriptor merely instantiate these with a 681// parameter for the number of args. 682// 683// The base class is not meant to be instantiated directly and has no 684// public constructors to ensure this is so. 685// 686// The simplest usage for all the ApiCallback*Descriptors is probably 687// ApiCallbackDescriptorBase::ForArgs(isolate, argc) 688// 689class ApiCallbackDescriptorBase : public CallInterfaceDescriptor { 690 public: 691 static CallInterfaceDescriptor ForArgs(Isolate* isolate, int argc); 692 693 protected: 694 ApiCallbackDescriptorBase(Isolate* isolate, CallDescriptors::Key key) 695 : CallInterfaceDescriptor(isolate, key) {} 696 void InitializePlatformSpecific(CallInterfaceDescriptorData* data) override; 697 FunctionType* BuildCallInterfaceDescriptorFunctionTypeWithArg( 698 Isolate* isolate, int parameter_count, int argc); 699}; 700 701class ApiCallbackWith0ArgsDescriptor : public ApiCallbackDescriptorBase { 702 public: 703 DECLARE_DESCRIPTOR_WITH_BASE_AND_FUNCTION_TYPE_ARG( 704 ApiCallbackWith0ArgsDescriptor, ApiCallbackDescriptorBase, 0) 705}; 706 707class ApiCallbackWith1ArgsDescriptor : public ApiCallbackDescriptorBase { 708 public: 709 DECLARE_DESCRIPTOR_WITH_BASE_AND_FUNCTION_TYPE_ARG( 710 ApiCallbackWith1ArgsDescriptor, ApiCallbackDescriptorBase, 1) 711}; 712 713class ApiCallbackWith2ArgsDescriptor : public ApiCallbackDescriptorBase { 714 public: 715 DECLARE_DESCRIPTOR_WITH_BASE_AND_FUNCTION_TYPE_ARG( 716 ApiCallbackWith2ArgsDescriptor, ApiCallbackDescriptorBase, 2) 717}; 718 719class ApiCallbackWith3ArgsDescriptor : public ApiCallbackDescriptorBase { 720 public: 721 DECLARE_DESCRIPTOR_WITH_BASE_AND_FUNCTION_TYPE_ARG( 722 ApiCallbackWith3ArgsDescriptor, ApiCallbackDescriptorBase, 3) 723}; 724 725class ApiCallbackWith4ArgsDescriptor : public ApiCallbackDescriptorBase { 726 public: 727 DECLARE_DESCRIPTOR_WITH_BASE_AND_FUNCTION_TYPE_ARG( 728 ApiCallbackWith4ArgsDescriptor, ApiCallbackDescriptorBase, 4) 729}; 730 731class ApiCallbackWith5ArgsDescriptor : public ApiCallbackDescriptorBase { 732 public: 733 DECLARE_DESCRIPTOR_WITH_BASE_AND_FUNCTION_TYPE_ARG( 734 ApiCallbackWith5ArgsDescriptor, ApiCallbackDescriptorBase, 5) 735}; 736 737class ApiCallbackWith6ArgsDescriptor : public ApiCallbackDescriptorBase { 738 public: 739 DECLARE_DESCRIPTOR_WITH_BASE_AND_FUNCTION_TYPE_ARG( 740 ApiCallbackWith6ArgsDescriptor, ApiCallbackDescriptorBase, 6) 741}; 742 743class ApiCallbackWith7ArgsDescriptor : public ApiCallbackDescriptorBase { 744 public: 745 DECLARE_DESCRIPTOR_WITH_BASE_AND_FUNCTION_TYPE_ARG( 746 ApiCallbackWith7ArgsDescriptor, ApiCallbackDescriptorBase, 7) 747}; 748 749 750class ApiGetterDescriptor : public CallInterfaceDescriptor { 751 public: 752 DECLARE_DESCRIPTOR(ApiGetterDescriptor, CallInterfaceDescriptor) 753 754 static const Register ReceiverRegister(); 755 static const Register HolderRegister(); 756 static const Register CallbackRegister(); 757}; 758 759 760class MathPowTaggedDescriptor : public CallInterfaceDescriptor { 761 public: 762 DECLARE_DESCRIPTOR(MathPowTaggedDescriptor, CallInterfaceDescriptor) 763 764 static const Register exponent(); 765}; 766 767 768class MathPowIntegerDescriptor : public CallInterfaceDescriptor { 769 public: 770 DECLARE_DESCRIPTOR(MathPowIntegerDescriptor, CallInterfaceDescriptor) 771 772 static const Register exponent(); 773}; 774 775 776class ContextOnlyDescriptor : public CallInterfaceDescriptor { 777 public: 778 DECLARE_DESCRIPTOR(ContextOnlyDescriptor, CallInterfaceDescriptor) 779}; 780 781class FastArrayPushDescriptor : public CallInterfaceDescriptor { 782 public: 783 DECLARE_DESCRIPTOR_WITH_CUSTOM_FUNCTION_TYPE(FastArrayPushDescriptor, 784 CallInterfaceDescriptor) 785}; 786 787class GrowArrayElementsDescriptor : public CallInterfaceDescriptor { 788 public: 789 DECLARE_DESCRIPTOR(GrowArrayElementsDescriptor, CallInterfaceDescriptor) 790 791 enum RegisterInfo { kObjectIndex, kKeyIndex }; 792 static const Register ObjectRegister(); 793 static const Register KeyRegister(); 794}; 795 796class InterpreterDispatchDescriptor : public CallInterfaceDescriptor { 797 public: 798 DECLARE_DESCRIPTOR_WITH_CUSTOM_FUNCTION_TYPE(InterpreterDispatchDescriptor, 799 CallInterfaceDescriptor) 800 801 static const int kAccumulatorParameter = 0; 802 static const int kBytecodeOffsetParameter = 1; 803 static const int kBytecodeArrayParameter = 2; 804 static const int kDispatchTableParameter = 3; 805}; 806 807class InterpreterPushArgsAndCallDescriptor : public CallInterfaceDescriptor { 808 public: 809 DECLARE_DESCRIPTOR(InterpreterPushArgsAndCallDescriptor, 810 CallInterfaceDescriptor) 811}; 812 813 814class InterpreterPushArgsAndConstructDescriptor 815 : public CallInterfaceDescriptor { 816 public: 817 DECLARE_DESCRIPTOR(InterpreterPushArgsAndConstructDescriptor, 818 CallInterfaceDescriptor) 819}; 820 821 822class InterpreterCEntryDescriptor : public CallInterfaceDescriptor { 823 public: 824 DECLARE_DESCRIPTOR(InterpreterCEntryDescriptor, CallInterfaceDescriptor) 825}; 826 827class ResumeGeneratorDescriptor final : public CallInterfaceDescriptor { 828 public: 829 DECLARE_DESCRIPTOR(ResumeGeneratorDescriptor, CallInterfaceDescriptor) 830}; 831 832#undef DECLARE_DESCRIPTOR_WITH_BASE 833#undef DECLARE_DESCRIPTOR 834#undef DECLARE_DESCRIPTOR_WITH_CUSTOM_FUNCTION_TYPE 835#undef DECLARE_DESCRIPTOR_WITH_BASE_AND_FUNCTION_TYPE_ARG 836 837// We define the association between CallDescriptors::Key and the specialized 838// descriptor here to reduce boilerplate and mistakes. 839#define DEF_KEY(name) \ 840 CallDescriptors::Key name##Descriptor::key() { return CallDescriptors::name; } 841INTERFACE_DESCRIPTOR_LIST(DEF_KEY) 842#undef DEF_KEY 843} // namespace internal 844} // namespace v8 845 846 847#if V8_TARGET_ARCH_ARM64 848#include "src/arm64/interface-descriptors-arm64.h" 849#elif V8_TARGET_ARCH_ARM 850#include "src/arm/interface-descriptors-arm.h" 851#endif 852 853#endif // V8_CALL_INTERFACE_DESCRIPTOR_H_ 854