Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(111)

Side by Side Diff: src/interface-descriptors.h

Issue 1748123003: Rework CallApi*Stubs. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Minor fixes and make Win compiler happy. Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef V8_CALL_INTERFACE_DESCRIPTOR_H_ 5 #ifndef V8_CALL_INTERFACE_DESCRIPTOR_H_
6 #define V8_CALL_INTERFACE_DESCRIPTOR_H_ 6 #define V8_CALL_INTERFACE_DESCRIPTOR_H_
7 7
8 #include "src/assembler.h" 8 #include "src/assembler.h"
9 #include "src/macro-assembler.h" 9 #include "src/macro-assembler.h"
10 10
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 V(Compare) \ 60 V(Compare) \
61 V(ToBoolean) \ 61 V(ToBoolean) \
62 V(BinaryOp) \ 62 V(BinaryOp) \
63 V(BinaryOpWithAllocationSite) \ 63 V(BinaryOpWithAllocationSite) \
64 V(StringAdd) \ 64 V(StringAdd) \
65 V(StringCompare) \ 65 V(StringCompare) \
66 V(Keyed) \ 66 V(Keyed) \
67 V(Named) \ 67 V(Named) \
68 V(CallHandler) \ 68 V(CallHandler) \
69 V(ArgumentAdaptor) \ 69 V(ArgumentAdaptor) \
70 V(ApiFunction) \ 70 V(ApiCallbackWith0Args) \
71 V(ApiAccessor) \ 71 V(ApiCallbackWith1Args) \
72 V(ApiCallbackWith2Args) \
73 V(ApiCallbackWith3Args) \
74 V(ApiCallbackWith4Args) \
75 V(ApiCallbackWith5Args) \
76 V(ApiCallbackWith6Args) \
77 V(ApiCallbackWith7Args) \
72 V(ApiGetter) \ 78 V(ApiGetter) \
73 V(LoadGlobalViaContext) \ 79 V(LoadGlobalViaContext) \
74 V(StoreGlobalViaContext) \ 80 V(StoreGlobalViaContext) \
75 V(MathPowTagged) \ 81 V(MathPowTagged) \
76 V(MathPowInteger) \ 82 V(MathPowInteger) \
77 V(ContextOnly) \ 83 V(ContextOnly) \
78 V(GrowArrayElements) \ 84 V(GrowArrayElements) \
79 V(InterpreterDispatch) \ 85 V(InterpreterDispatch) \
80 V(InterpreterPushArgsAndCall) \ 86 V(InterpreterPushArgsAndCall) \
81 V(InterpreterPushArgsAndConstruct) \ 87 V(InterpreterPushArgsAndConstruct) \
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 return BuildDefaultFunctionType(isolate, register_param_count); 198 return BuildDefaultFunctionType(isolate, register_param_count);
193 } 199 }
194 200
195 virtual void InitializePlatformSpecific(CallInterfaceDescriptorData* data) { 201 virtual void InitializePlatformSpecific(CallInterfaceDescriptorData* data) {
196 UNREACHABLE(); 202 UNREACHABLE();
197 } 203 }
198 204
199 void Initialize(Isolate* isolate, CallDescriptors::Key key) { 205 void Initialize(Isolate* isolate, CallDescriptors::Key key) {
200 if (!data()->IsInitialized()) { 206 if (!data()->IsInitialized()) {
201 CallInterfaceDescriptorData* d = isolate->call_descriptor_data(key); 207 CallInterfaceDescriptorData* d = isolate->call_descriptor_data(key);
208 DCHECK(d == data()); // d should be a modifiable pointer to data().
202 InitializePlatformSpecific(d); 209 InitializePlatformSpecific(d);
203 FunctionType* function_type = BuildCallInterfaceDescriptorFunctionType( 210 FunctionType* function_type = BuildCallInterfaceDescriptorFunctionType(
204 isolate, d->register_param_count()); 211 isolate, d->register_param_count());
205 d->InitializePlatformIndependent(function_type); 212 d->InitializePlatformIndependent(function_type);
206 } 213 }
207 } 214 }
208 215
209 private: 216 private:
210 const CallInterfaceDescriptorData* data_; 217 const CallInterfaceDescriptorData* data_;
211 }; 218 };
212 219
220 #define DECLARE_DESCRIPTOR_WITH_BASE(name, base) \
221 public: \
222 explicit name(Isolate* isolate) : base(isolate, key()) { \
223 Initialize(isolate, key()); \
224 } \
225 static inline CallDescriptors::Key key();
213 226
214 #define DECLARE_DESCRIPTOR(name, base) \ 227 #define DECLARE_DESCRIPTOR(name, base) \
215 explicit name(Isolate* isolate) : base(isolate, key()) { \ 228 DECLARE_DESCRIPTOR_WITH_BASE(name, base) \
216 Initialize(isolate, key()); \
217 } \
218 \
219 protected: \ 229 protected: \
220 void InitializePlatformSpecific(CallInterfaceDescriptorData* data) override; \ 230 void InitializePlatformSpecific(CallInterfaceDescriptorData* data) override; \
221 name(Isolate* isolate, CallDescriptors::Key key) : base(isolate, key) {} \ 231 name(Isolate* isolate, CallDescriptors::Key key) : base(isolate, key) {} \
222 \ 232 \
223 public: \ 233 public:
224 static inline CallDescriptors::Key key();
225 234
226 #define DECLARE_DESCRIPTOR_WITH_CUSTOM_FUNCTION_TYPE(name, base) \ 235 #define DECLARE_DESCRIPTOR_WITH_CUSTOM_FUNCTION_TYPE(name, base) \
227 DECLARE_DESCRIPTOR(name, base) \ 236 DECLARE_DESCRIPTOR(name, base) \
228 protected: \ 237 protected: \
229 FunctionType* BuildCallInterfaceDescriptorFunctionType( \ 238 FunctionType* BuildCallInterfaceDescriptorFunctionType( \
230 Isolate* isolate, int register_param_count) override; \ 239 Isolate* isolate, int register_param_count) override; \
231 \ 240 \
232 public: 241 public:
233 242
243 #define DECLARE_DESCRIPTOR_WITH_BASE_AND_FUNCTION_TYPE_ARG(name, base, arg) \
244 DECLARE_DESCRIPTOR_WITH_BASE(name, base) \
245 protected: \
246 FunctionType* BuildCallInterfaceDescriptorFunctionType( \
247 Isolate* isolate, int register_param_count) override { \
248 return BuildCallInterfaceDescriptorFunctionTypeWithArg( \
249 isolate, register_param_count, arg); \
250 } \
251 \
252 public:
253
234 class VoidDescriptor : public CallInterfaceDescriptor { 254 class VoidDescriptor : public CallInterfaceDescriptor {
235 public: 255 public:
236 DECLARE_DESCRIPTOR(VoidDescriptor, CallInterfaceDescriptor) 256 DECLARE_DESCRIPTOR(VoidDescriptor, CallInterfaceDescriptor)
237 }; 257 };
238 258
239 259
240 // LoadDescriptor is used by all stubs that implement Load/KeyedLoad ICs. 260 // LoadDescriptor is used by all stubs that implement Load/KeyedLoad ICs.
241 class LoadDescriptor : public CallInterfaceDescriptor { 261 class LoadDescriptor : public CallInterfaceDescriptor {
242 public: 262 public:
243 DECLARE_DESCRIPTOR_WITH_CUSTOM_FUNCTION_TYPE(LoadDescriptor, 263 DECLARE_DESCRIPTOR_WITH_CUSTOM_FUNCTION_TYPE(LoadDescriptor,
(...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after
682 DECLARE_DESCRIPTOR(CallHandlerDescriptor, CallInterfaceDescriptor) 702 DECLARE_DESCRIPTOR(CallHandlerDescriptor, CallInterfaceDescriptor)
683 }; 703 };
684 704
685 705
686 class ArgumentAdaptorDescriptor : public CallInterfaceDescriptor { 706 class ArgumentAdaptorDescriptor : public CallInterfaceDescriptor {
687 public: 707 public:
688 DECLARE_DESCRIPTOR_WITH_CUSTOM_FUNCTION_TYPE(ArgumentAdaptorDescriptor, 708 DECLARE_DESCRIPTOR_WITH_CUSTOM_FUNCTION_TYPE(ArgumentAdaptorDescriptor,
689 CallInterfaceDescriptor) 709 CallInterfaceDescriptor)
690 }; 710 };
691 711
712 // The ApiCallback*Descriptors have a lot of boilerplate. The superclass
713 // ApiCallbackDescriptorBase contains all the logic, and the
714 // ApiCallbackWith*ArgsDescriptor merely instantiate these with a
715 // parameter for the number of args.
716 //
717 // The base class is not meant to be instantiated directly and has no
718 // public constructors to ensure this is so.
719 //
720 // The simplest usage for all the ApiCallback*Descriptors is probably
721 // ApiCallbackDescriptorBase::ForArgs(isolate, argc)
722 //
723 class ApiCallbackDescriptorBase : public CallInterfaceDescriptor {
724 public:
725 static CallInterfaceDescriptor ForArgs(Isolate* isolate, int argc);
692 726
693 class ApiFunctionDescriptor : public CallInterfaceDescriptor { 727 protected:
728 ApiCallbackDescriptorBase(Isolate* isolate, CallDescriptors::Key key)
729 : CallInterfaceDescriptor(isolate, key) {}
730 void InitializePlatformSpecific(CallInterfaceDescriptorData* data) override;
731 FunctionType* BuildCallInterfaceDescriptorFunctionTypeWithArg(
732 Isolate* isolate, int parameter_count, int argc);
733 };
734
735 class ApiCallbackWith0ArgsDescriptor : public ApiCallbackDescriptorBase {
694 public: 736 public:
695 DECLARE_DESCRIPTOR_WITH_CUSTOM_FUNCTION_TYPE(ApiFunctionDescriptor, 737 DECLARE_DESCRIPTOR_WITH_BASE_AND_FUNCTION_TYPE_ARG(
696 CallInterfaceDescriptor) 738 ApiCallbackWith0ArgsDescriptor, ApiCallbackDescriptorBase, 0)
739 };
740
741 class ApiCallbackWith1ArgsDescriptor : public ApiCallbackDescriptorBase {
742 public:
743 DECLARE_DESCRIPTOR_WITH_BASE_AND_FUNCTION_TYPE_ARG(
744 ApiCallbackWith1ArgsDescriptor, ApiCallbackDescriptorBase, 1)
745 };
746
747 class ApiCallbackWith2ArgsDescriptor : public ApiCallbackDescriptorBase {
748 public:
749 DECLARE_DESCRIPTOR_WITH_BASE_AND_FUNCTION_TYPE_ARG(
750 ApiCallbackWith2ArgsDescriptor, ApiCallbackDescriptorBase, 2)
751 };
752
753 class ApiCallbackWith3ArgsDescriptor : public ApiCallbackDescriptorBase {
754 public:
755 DECLARE_DESCRIPTOR_WITH_BASE_AND_FUNCTION_TYPE_ARG(
756 ApiCallbackWith3ArgsDescriptor, ApiCallbackDescriptorBase, 3)
757 };
758
759 class ApiCallbackWith4ArgsDescriptor : public ApiCallbackDescriptorBase {
760 public:
761 DECLARE_DESCRIPTOR_WITH_BASE_AND_FUNCTION_TYPE_ARG(
762 ApiCallbackWith4ArgsDescriptor, ApiCallbackDescriptorBase, 4)
763 };
764
765 class ApiCallbackWith5ArgsDescriptor : public ApiCallbackDescriptorBase {
766 public:
767 DECLARE_DESCRIPTOR_WITH_BASE_AND_FUNCTION_TYPE_ARG(
768 ApiCallbackWith5ArgsDescriptor, ApiCallbackDescriptorBase, 5)
769 };
770
771 class ApiCallbackWith6ArgsDescriptor : public ApiCallbackDescriptorBase {
772 public:
773 DECLARE_DESCRIPTOR_WITH_BASE_AND_FUNCTION_TYPE_ARG(
774 ApiCallbackWith6ArgsDescriptor, ApiCallbackDescriptorBase, 6)
775 };
776
777 class ApiCallbackWith7ArgsDescriptor : public ApiCallbackDescriptorBase {
778 public:
779 DECLARE_DESCRIPTOR_WITH_BASE_AND_FUNCTION_TYPE_ARG(
780 ApiCallbackWith7ArgsDescriptor, ApiCallbackDescriptorBase, 7)
697 }; 781 };
698 782
699 783
700 class ApiAccessorDescriptor : public CallInterfaceDescriptor {
701 public:
702 DECLARE_DESCRIPTOR_WITH_CUSTOM_FUNCTION_TYPE(ApiAccessorDescriptor,
703 CallInterfaceDescriptor)
704 };
705
706
707 class ApiGetterDescriptor : public CallInterfaceDescriptor { 784 class ApiGetterDescriptor : public CallInterfaceDescriptor {
708 public: 785 public:
709 DECLARE_DESCRIPTOR_WITH_CUSTOM_FUNCTION_TYPE(ApiGetterDescriptor, 786 DECLARE_DESCRIPTOR_WITH_CUSTOM_FUNCTION_TYPE(ApiGetterDescriptor,
710 CallInterfaceDescriptor) 787 CallInterfaceDescriptor)
711 788
712 static const Register function_address(); 789 static const Register function_address();
713 }; 790 };
714 791
715 792
716 class MathPowTaggedDescriptor : public CallInterfaceDescriptor { 793 class MathPowTaggedDescriptor : public CallInterfaceDescriptor {
(...skipping 20 matching lines...) Expand all
737 814
738 class GrowArrayElementsDescriptor : public CallInterfaceDescriptor { 815 class GrowArrayElementsDescriptor : public CallInterfaceDescriptor {
739 public: 816 public:
740 DECLARE_DESCRIPTOR(GrowArrayElementsDescriptor, CallInterfaceDescriptor) 817 DECLARE_DESCRIPTOR(GrowArrayElementsDescriptor, CallInterfaceDescriptor)
741 818
742 enum RegisterInfo { kObjectIndex, kKeyIndex }; 819 enum RegisterInfo { kObjectIndex, kKeyIndex };
743 static const Register ObjectRegister(); 820 static const Register ObjectRegister();
744 static const Register KeyRegister(); 821 static const Register KeyRegister();
745 }; 822 };
746 823
747 class InterpreterDispatchDescriptor : public CallInterfaceDescriptor { 824 class InterpreterDispatchDescriptor : public CallInterfaceDescriptor {
748 public: 825 public:
749 DECLARE_DESCRIPTOR_WITH_CUSTOM_FUNCTION_TYPE(InterpreterDispatchDescriptor, 826 DECLARE_DESCRIPTOR_WITH_CUSTOM_FUNCTION_TYPE(InterpreterDispatchDescriptor,
750 CallInterfaceDescriptor) 827 CallInterfaceDescriptor)
751 828
752 static const int kAccumulatorParameter = 0; 829 static const int kAccumulatorParameter = 0;
753 static const int kRegisterFileParameter = 1; 830 static const int kRegisterFileParameter = 1;
754 static const int kBytecodeOffsetParameter = 2; 831 static const int kBytecodeOffsetParameter = 2;
755 static const int kBytecodeArrayParameter = 3; 832 static const int kBytecodeArrayParameter = 3;
756 static const int kDispatchTableParameter = 4; 833 static const int kDispatchTableParameter = 4;
757 static const int kContextParameter = 5; 834 static const int kContextParameter = 5;
(...skipping 12 matching lines...) Expand all
770 DECLARE_DESCRIPTOR(InterpreterPushArgsAndConstructDescriptor, 847 DECLARE_DESCRIPTOR(InterpreterPushArgsAndConstructDescriptor,
771 CallInterfaceDescriptor) 848 CallInterfaceDescriptor)
772 }; 849 };
773 850
774 851
775 class InterpreterCEntryDescriptor : public CallInterfaceDescriptor { 852 class InterpreterCEntryDescriptor : public CallInterfaceDescriptor {
776 public: 853 public:
777 DECLARE_DESCRIPTOR(InterpreterCEntryDescriptor, CallInterfaceDescriptor) 854 DECLARE_DESCRIPTOR(InterpreterCEntryDescriptor, CallInterfaceDescriptor)
778 }; 855 };
779 856
857 #undef DECLARE_DESCRIPTOR_WITH_BASE
780 #undef DECLARE_DESCRIPTOR 858 #undef DECLARE_DESCRIPTOR
781 859 #undef DECLARE_DESCRIPTOR_WITH_CUSTOM_FUNCTION_TYPE
860 #undef DECLARE_DESCRIPTOR_WITH_BASE_AND_FUNCTION_TYPE_ARG
782 861
783 // We define the association between CallDescriptors::Key and the specialized 862 // We define the association between CallDescriptors::Key and the specialized
784 // descriptor here to reduce boilerplate and mistakes. 863 // descriptor here to reduce boilerplate and mistakes.
785 #define DEF_KEY(name) \ 864 #define DEF_KEY(name) \
786 CallDescriptors::Key name##Descriptor::key() { return CallDescriptors::name; } 865 CallDescriptors::Key name##Descriptor::key() { return CallDescriptors::name; }
787 INTERFACE_DESCRIPTOR_LIST(DEF_KEY) 866 INTERFACE_DESCRIPTOR_LIST(DEF_KEY)
788 #undef DEF_KEY 867 #undef DEF_KEY
789 } // namespace internal 868 } // namespace internal
790 } // namespace v8 869 } // namespace v8
791 870
792 871
793 #if V8_TARGET_ARCH_ARM64 872 #if V8_TARGET_ARCH_ARM64
794 #include "src/arm64/interface-descriptors-arm64.h" 873 #include "src/arm64/interface-descriptors-arm64.h"
795 #elif V8_TARGET_ARCH_ARM 874 #elif V8_TARGET_ARCH_ARM
796 #include "src/arm/interface-descriptors-arm.h" 875 #include "src/arm/interface-descriptors-arm.h"
797 #endif 876 #endif
798 877
799 #endif // V8_CALL_INTERFACE_DESCRIPTOR_H_ 878 #endif // V8_CALL_INTERFACE_DESCRIPTOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698