OLD | NEW |
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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 | 82 |
83 | 83 |
84 class CallInterfaceDescriptorData { | 84 class CallInterfaceDescriptorData { |
85 public: | 85 public: |
86 CallInterfaceDescriptorData() | 86 CallInterfaceDescriptorData() |
87 : register_param_count_(-1), function_type_(nullptr) {} | 87 : register_param_count_(-1), function_type_(nullptr) {} |
88 | 88 |
89 // A copy of the passed in registers and param_representations is made | 89 // A copy of the passed in registers and param_representations is made |
90 // and owned by the CallInterfaceDescriptorData. | 90 // and owned by the CallInterfaceDescriptorData. |
91 | 91 |
92 void InitializePlatformIndependent(Type::FunctionType* function_type) { | 92 void InitializePlatformIndependent(FunctionType* function_type) { |
93 function_type_ = function_type; | 93 function_type_ = function_type; |
94 } | 94 } |
95 | 95 |
96 // TODO(mvstanton): Instead of taking parallel arrays register and | 96 // TODO(mvstanton): Instead of taking parallel arrays register and |
97 // param_representations, how about a struct that puts the representation | 97 // param_representations, how about a struct that puts the representation |
98 // and register side by side (eg, RegRep(r1, Representation::Tagged()). | 98 // and register side by side (eg, RegRep(r1, Representation::Tagged()). |
99 // The same should go for the CodeStubDescriptor class. | 99 // The same should go for the CodeStubDescriptor class. |
100 void InitializePlatformSpecific( | 100 void InitializePlatformSpecific( |
101 int register_parameter_count, Register* registers, | 101 int register_parameter_count, Register* registers, |
102 PlatformInterfaceDescriptor* platform_descriptor = NULL); | 102 PlatformInterfaceDescriptor* platform_descriptor = NULL); |
103 | 103 |
104 bool IsInitialized() const { return register_param_count_ >= 0; } | 104 bool IsInitialized() const { return register_param_count_ >= 0; } |
105 | 105 |
106 int param_count() const { return function_type_->Arity(); } | 106 int param_count() const { return function_type_->Arity(); } |
107 int register_param_count() const { return register_param_count_; } | 107 int register_param_count() const { return register_param_count_; } |
108 Register register_param(int index) const { return register_params_[index]; } | 108 Register register_param(int index) const { return register_params_[index]; } |
109 Register* register_params() const { return register_params_.get(); } | 109 Register* register_params() const { return register_params_.get(); } |
110 Type* param_type(int index) const { return function_type_->Parameter(index); } | 110 Type* param_type(int index) const { return function_type_->Parameter(index); } |
111 PlatformInterfaceDescriptor* platform_specific_descriptor() const { | 111 PlatformInterfaceDescriptor* platform_specific_descriptor() const { |
112 return platform_specific_descriptor_; | 112 return platform_specific_descriptor_; |
113 } | 113 } |
114 | 114 |
115 Type::FunctionType* function_type() const { return function_type_; } | 115 FunctionType* function_type() const { return function_type_; } |
116 | 116 |
117 private: | 117 private: |
118 int register_param_count_; | 118 int register_param_count_; |
119 | 119 |
120 // The Register params are allocated dynamically by the | 120 // The Register params are allocated dynamically by the |
121 // InterfaceDescriptor, and freed on destruction. This is because static | 121 // InterfaceDescriptor, and freed on destruction. This is because static |
122 // arrays of Registers cause creation of runtime static initializers | 122 // arrays of Registers cause creation of runtime static initializers |
123 // which we don't want. | 123 // which we don't want. |
124 base::SmartArrayPointer<Register> register_params_; | 124 base::SmartArrayPointer<Register> register_params_; |
125 | 125 |
126 // Specifies types for parameters and return | 126 // Specifies types for parameters and return |
127 Type::FunctionType* function_type_; | 127 FunctionType* function_type_; |
128 | 128 |
129 PlatformInterfaceDescriptor* platform_specific_descriptor_; | 129 PlatformInterfaceDescriptor* platform_specific_descriptor_; |
130 | 130 |
131 DISALLOW_COPY_AND_ASSIGN(CallInterfaceDescriptorData); | 131 DISALLOW_COPY_AND_ASSIGN(CallInterfaceDescriptorData); |
132 }; | 132 }; |
133 | 133 |
134 | 134 |
135 class CallDescriptors { | 135 class CallDescriptors { |
136 public: | 136 public: |
137 enum Key { | 137 enum Key { |
(...skipping 30 matching lines...) Expand all Loading... |
168 Type* GetParameterType(int index) const { | 168 Type* GetParameterType(int index) const { |
169 DCHECK(index < data()->param_count()); | 169 DCHECK(index < data()->param_count()); |
170 return data()->param_type(index); | 170 return data()->param_type(index); |
171 } | 171 } |
172 | 172 |
173 // Some platforms have extra information to associate with the descriptor. | 173 // Some platforms have extra information to associate with the descriptor. |
174 PlatformInterfaceDescriptor* platform_specific_descriptor() const { | 174 PlatformInterfaceDescriptor* platform_specific_descriptor() const { |
175 return data()->platform_specific_descriptor(); | 175 return data()->platform_specific_descriptor(); |
176 } | 176 } |
177 | 177 |
178 Type::FunctionType* GetFunctionType() const { | 178 FunctionType* GetFunctionType() const { return data()->function_type(); } |
179 return data()->function_type(); | |
180 } | |
181 | 179 |
182 static const Register ContextRegister(); | 180 static const Register ContextRegister(); |
183 | 181 |
184 const char* DebugName(Isolate* isolate) const; | 182 const char* DebugName(Isolate* isolate) const; |
185 | 183 |
186 static Type::FunctionType* BuildDefaultFunctionType(Isolate* isolate, | 184 static FunctionType* BuildDefaultFunctionType(Isolate* isolate, |
187 int paramater_count); | 185 int paramater_count); |
188 | 186 |
189 protected: | 187 protected: |
190 const CallInterfaceDescriptorData* data() const { return data_; } | 188 const CallInterfaceDescriptorData* data() const { return data_; } |
191 | 189 |
192 virtual Type::FunctionType* BuildCallInterfaceDescriptorFunctionType( | 190 virtual FunctionType* BuildCallInterfaceDescriptorFunctionType( |
193 Isolate* isolate, int register_param_count) { | 191 Isolate* isolate, int register_param_count) { |
194 return BuildDefaultFunctionType(isolate, register_param_count); | 192 return BuildDefaultFunctionType(isolate, register_param_count); |
195 } | 193 } |
196 | 194 |
197 virtual void InitializePlatformSpecific(CallInterfaceDescriptorData* data) { | 195 virtual void InitializePlatformSpecific(CallInterfaceDescriptorData* data) { |
198 UNREACHABLE(); | 196 UNREACHABLE(); |
199 } | 197 } |
200 | 198 |
201 void Initialize(Isolate* isolate, CallDescriptors::Key key) { | 199 void Initialize(Isolate* isolate, CallDescriptors::Key key) { |
202 if (!data()->IsInitialized()) { | 200 if (!data()->IsInitialized()) { |
203 CallInterfaceDescriptorData* d = isolate->call_descriptor_data(key); | 201 CallInterfaceDescriptorData* d = isolate->call_descriptor_data(key); |
204 InitializePlatformSpecific(d); | 202 InitializePlatformSpecific(d); |
205 Type::FunctionType* function_type = | 203 FunctionType* function_type = BuildCallInterfaceDescriptorFunctionType( |
206 BuildCallInterfaceDescriptorFunctionType(isolate, | 204 isolate, d->register_param_count()); |
207 d->register_param_count()); | |
208 d->InitializePlatformIndependent(function_type); | 205 d->InitializePlatformIndependent(function_type); |
209 } | 206 } |
210 } | 207 } |
211 | 208 |
212 private: | 209 private: |
213 const CallInterfaceDescriptorData* data_; | 210 const CallInterfaceDescriptorData* data_; |
214 }; | 211 }; |
215 | 212 |
216 | 213 |
217 #define DECLARE_DESCRIPTOR(name, base) \ | 214 #define DECLARE_DESCRIPTOR(name, base) \ |
218 explicit name(Isolate* isolate) : base(isolate, key()) { \ | 215 explicit name(Isolate* isolate) : base(isolate, key()) { \ |
219 Initialize(isolate, key()); \ | 216 Initialize(isolate, key()); \ |
220 } \ | 217 } \ |
221 \ | 218 \ |
222 protected: \ | 219 protected: \ |
223 void InitializePlatformSpecific(CallInterfaceDescriptorData* data) override; \ | 220 void InitializePlatformSpecific(CallInterfaceDescriptorData* data) override; \ |
224 name(Isolate* isolate, CallDescriptors::Key key) : base(isolate, key) {} \ | 221 name(Isolate* isolate, CallDescriptors::Key key) : base(isolate, key) {} \ |
225 \ | 222 \ |
226 public: \ | 223 public: \ |
227 static inline CallDescriptors::Key key(); | 224 static inline CallDescriptors::Key key(); |
228 | 225 |
229 | |
230 #define DECLARE_DESCRIPTOR_WITH_CUSTOM_FUNCTION_TYPE(name, base) \ | 226 #define DECLARE_DESCRIPTOR_WITH_CUSTOM_FUNCTION_TYPE(name, base) \ |
231 DECLARE_DESCRIPTOR(name, base) \ | 227 DECLARE_DESCRIPTOR(name, base) \ |
232 protected: \ | 228 protected: \ |
233 Type::FunctionType* BuildCallInterfaceDescriptorFunctionType( \ | 229 FunctionType* BuildCallInterfaceDescriptorFunctionType( \ |
234 Isolate* isolate, int register_param_count) override; \ | 230 Isolate* isolate, int register_param_count) override; \ |
235 \ | 231 \ |
236 public: | 232 public: |
237 | 233 |
238 | |
239 class VoidDescriptor : public CallInterfaceDescriptor { | 234 class VoidDescriptor : public CallInterfaceDescriptor { |
240 public: | 235 public: |
241 DECLARE_DESCRIPTOR(VoidDescriptor, CallInterfaceDescriptor) | 236 DECLARE_DESCRIPTOR(VoidDescriptor, CallInterfaceDescriptor) |
242 }; | 237 }; |
243 | 238 |
244 | 239 |
245 // LoadDescriptor is used by all stubs that implement Load/KeyedLoad ICs. | 240 // LoadDescriptor is used by all stubs that implement Load/KeyedLoad ICs. |
246 class LoadDescriptor : public CallInterfaceDescriptor { | 241 class LoadDescriptor : public CallInterfaceDescriptor { |
247 public: | 242 public: |
248 DECLARE_DESCRIPTOR_WITH_CUSTOM_FUNCTION_TYPE(LoadDescriptor, | 243 DECLARE_DESCRIPTOR_WITH_CUSTOM_FUNCTION_TYPE(LoadDescriptor, |
(...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
798 } // namespace v8 | 793 } // namespace v8 |
799 | 794 |
800 | 795 |
801 #if V8_TARGET_ARCH_ARM64 | 796 #if V8_TARGET_ARCH_ARM64 |
802 #include "src/arm64/interface-descriptors-arm64.h" | 797 #include "src/arm64/interface-descriptors-arm64.h" |
803 #elif V8_TARGET_ARCH_ARM | 798 #elif V8_TARGET_ARCH_ARM |
804 #include "src/arm/interface-descriptors-arm.h" | 799 #include "src/arm/interface-descriptors-arm.h" |
805 #endif | 800 #endif |
806 | 801 |
807 #endif // V8_CALL_INTERFACE_DESCRIPTOR_H_ | 802 #endif // V8_CALL_INTERFACE_DESCRIPTOR_H_ |
OLD | NEW |