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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 V(MathPowInteger) \ | 62 V(MathPowInteger) \ |
63 V(ContextOnly) \ | 63 V(ContextOnly) \ |
64 V(GrowArrayElements) \ | 64 V(GrowArrayElements) \ |
65 V(MathRoundVariantCallFromUnoptimizedCode) \ | 65 V(MathRoundVariantCallFromUnoptimizedCode) \ |
66 V(MathRoundVariantCallFromOptimizedCode) | 66 V(MathRoundVariantCallFromOptimizedCode) |
67 | 67 |
68 | 68 |
69 class CallInterfaceDescriptorData { | 69 class CallInterfaceDescriptorData { |
70 public: | 70 public: |
71 CallInterfaceDescriptorData() | 71 CallInterfaceDescriptorData() |
72 : stack_paramater_count_(-1), | 72 : register_param_count_(-1), function_type_(nullptr) {} |
73 register_param_count_(-1), | |
74 function_type_(nullptr) {} | |
75 | 73 |
76 // A copy of the passed in registers and param_representations is made | 74 // A copy of the passed in registers and param_representations is made |
77 // and owned by the CallInterfaceDescriptorData. | 75 // and owned by the CallInterfaceDescriptorData. |
78 | 76 |
79 void InitializePlatformIndependent(int stack_paramater_count, | 77 void InitializePlatformIndependent(Type::FunctionType* function_type) { |
80 Type::FunctionType* function_type) { | |
81 function_type_ = function_type; | 78 function_type_ = function_type; |
82 stack_paramater_count_ = stack_paramater_count; | |
83 } | 79 } |
84 | 80 |
85 // TODO(mvstanton): Instead of taking parallel arrays register and | 81 // TODO(mvstanton): Instead of taking parallel arrays register and |
86 // param_representations, how about a struct that puts the representation | 82 // param_representations, how about a struct that puts the representation |
87 // and register side by side (eg, RegRep(r1, Representation::Tagged()). | 83 // and register side by side (eg, RegRep(r1, Representation::Tagged()). |
88 // The same should go for the CodeStubDescriptor class. | 84 // The same should go for the CodeStubDescriptor class. |
89 void InitializePlatformSpecific( | 85 void InitializePlatformSpecific( |
90 int register_parameter_count, Register* registers, | 86 int register_parameter_count, Register* registers, |
91 PlatformInterfaceDescriptor* platform_descriptor = NULL); | 87 PlatformInterfaceDescriptor* platform_descriptor = NULL); |
92 | 88 |
93 bool IsInitialized() const { return register_param_count_ >= 0; } | 89 bool IsInitialized() const { return register_param_count_ >= 0; } |
94 | 90 |
| 91 int param_count() const { return function_type_->Arity(); } |
95 int register_param_count() const { return register_param_count_; } | 92 int register_param_count() const { return register_param_count_; } |
96 Register register_param(int index) const { return register_params_[index]; } | 93 Register register_param(int index) const { return register_params_[index]; } |
97 Register* register_params() const { return register_params_.get(); } | 94 Register* register_params() const { return register_params_.get(); } |
98 Type* register_param_type(int index) const { | 95 Type* param_type(int index) const { return function_type_->Parameter(index); } |
99 return function_type_->Parameter(index); | |
100 } | |
101 PlatformInterfaceDescriptor* platform_specific_descriptor() const { | 96 PlatformInterfaceDescriptor* platform_specific_descriptor() const { |
102 return platform_specific_descriptor_; | 97 return platform_specific_descriptor_; |
103 } | 98 } |
104 | 99 |
105 Type::FunctionType* function_type() const { return function_type_; } | 100 Type::FunctionType* function_type() const { return function_type_; } |
106 | 101 |
107 private: | 102 private: |
108 int stack_paramater_count_; | |
109 int register_param_count_; | 103 int register_param_count_; |
110 | 104 |
111 // The Register params are allocated dynamically by the | 105 // The Register params are allocated dynamically by the |
112 // InterfaceDescriptor, and freed on destruction. This is because static | 106 // InterfaceDescriptor, and freed on destruction. This is because static |
113 // arrays of Registers cause creation of runtime static initializers | 107 // arrays of Registers cause creation of runtime static initializers |
114 // which we don't want. | 108 // which we don't want. |
115 base::SmartArrayPointer<Register> register_params_; | 109 base::SmartArrayPointer<Register> register_params_; |
116 | 110 |
117 // Specifies types for parameters and return | 111 // Specifies types for parameters and return |
118 Type::FunctionType* function_type_; | 112 Type::FunctionType* function_type_; |
(...skipping 16 matching lines...) Expand all Loading... |
135 | 129 |
136 | 130 |
137 class CallInterfaceDescriptor { | 131 class CallInterfaceDescriptor { |
138 public: | 132 public: |
139 CallInterfaceDescriptor() : data_(NULL) {} | 133 CallInterfaceDescriptor() : data_(NULL) {} |
140 virtual ~CallInterfaceDescriptor() {} | 134 virtual ~CallInterfaceDescriptor() {} |
141 | 135 |
142 CallInterfaceDescriptor(Isolate* isolate, CallDescriptors::Key key) | 136 CallInterfaceDescriptor(Isolate* isolate, CallDescriptors::Key key) |
143 : data_(isolate->call_descriptor_data(key)) {} | 137 : data_(isolate->call_descriptor_data(key)) {} |
144 | 138 |
| 139 int GetParameterCount() const { return data()->param_count(); } |
| 140 |
145 int GetRegisterParameterCount() const { | 141 int GetRegisterParameterCount() const { |
146 return data()->register_param_count(); | 142 return data()->register_param_count(); |
147 } | 143 } |
148 | 144 |
149 int GetStackParameterCount() const { | 145 int GetStackParameterCount() const { |
150 return data()->function_type()->Arity() - data()->register_param_count(); | 146 return data()->function_type()->Arity() - data()->register_param_count(); |
151 } | 147 } |
152 | 148 |
153 Register GetRegisterParameter(int index) const { | 149 Register GetRegisterParameter(int index) const { |
154 return data()->register_param(index); | 150 return data()->register_param(index); |
155 } | 151 } |
156 | 152 |
157 Type* GetParameterType(int index) const { | 153 Type* GetParameterType(int index) const { |
158 DCHECK(index < data()->register_param_count()); | 154 DCHECK(index < data()->param_count()); |
159 return data()->register_param_type(index); | 155 return data()->param_type(index); |
160 } | 156 } |
161 | 157 |
162 // Some platforms have extra information to associate with the descriptor. | 158 // Some platforms have extra information to associate with the descriptor. |
163 PlatformInterfaceDescriptor* platform_specific_descriptor() const { | 159 PlatformInterfaceDescriptor* platform_specific_descriptor() const { |
164 return data()->platform_specific_descriptor(); | 160 return data()->platform_specific_descriptor(); |
165 } | 161 } |
166 | 162 |
167 Type::FunctionType* GetFunctionType() const { | 163 Type::FunctionType* GetFunctionType() const { |
168 return data()->function_type(); | 164 return data()->function_type(); |
169 } | 165 } |
(...skipping 17 matching lines...) Expand all Loading... |
187 UNREACHABLE(); | 183 UNREACHABLE(); |
188 } | 184 } |
189 | 185 |
190 void Initialize(Isolate* isolate, CallDescriptors::Key key) { | 186 void Initialize(Isolate* isolate, CallDescriptors::Key key) { |
191 if (!data()->IsInitialized()) { | 187 if (!data()->IsInitialized()) { |
192 CallInterfaceDescriptorData* d = isolate->call_descriptor_data(key); | 188 CallInterfaceDescriptorData* d = isolate->call_descriptor_data(key); |
193 InitializePlatformSpecific(d); | 189 InitializePlatformSpecific(d); |
194 Type::FunctionType* function_type = | 190 Type::FunctionType* function_type = |
195 BuildCallInterfaceDescriptorFunctionType(isolate, | 191 BuildCallInterfaceDescriptorFunctionType(isolate, |
196 d->register_param_count()); | 192 d->register_param_count()); |
197 d->InitializePlatformIndependent(0, function_type); | 193 d->InitializePlatformIndependent(function_type); |
198 } | 194 } |
199 } | 195 } |
200 | 196 |
201 private: | 197 private: |
202 const CallInterfaceDescriptorData* data_; | 198 const CallInterfaceDescriptorData* data_; |
203 }; | 199 }; |
204 | 200 |
205 | 201 |
206 #define DECLARE_DESCRIPTOR(name, base) \ | 202 #define DECLARE_DESCRIPTOR(name, base) \ |
207 explicit name(Isolate* isolate) : base(isolate, key()) { \ | 203 explicit name(Isolate* isolate) : base(isolate, key()) { \ |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
247 kParameterCount | 243 kParameterCount |
248 }; | 244 }; |
249 static const Register ReceiverRegister(); | 245 static const Register ReceiverRegister(); |
250 static const Register NameRegister(); | 246 static const Register NameRegister(); |
251 static const Register ValueRegister(); | 247 static const Register ValueRegister(); |
252 }; | 248 }; |
253 | 249 |
254 | 250 |
255 class StoreTransitionDescriptor : public StoreDescriptor { | 251 class StoreTransitionDescriptor : public StoreDescriptor { |
256 public: | 252 public: |
257 DECLARE_DESCRIPTOR(StoreTransitionDescriptor, StoreDescriptor) | 253 DECLARE_DESCRIPTOR_WITH_CUSTOM_FUNCTION_TYPE(StoreTransitionDescriptor, |
| 254 StoreDescriptor) |
258 | 255 |
259 // Extends StoreDescriptor with Map parameter. | 256 // Extends StoreDescriptor with Map parameter. |
260 enum ParameterIndices { | 257 enum ParameterIndices { |
261 kReceiverIndex, | 258 kReceiverIndex, |
262 kNameIndex, | 259 kNameIndex, |
263 kValueIndex, | 260 kValueIndex, |
264 kMapIndex, | 261 kMapIndex, |
265 kParameterCount | 262 kParameterCount |
266 }; | 263 }; |
| 264 |
| 265 // MapRegister() is no_reg on ia32, instead it's on the stack. |
267 static const Register MapRegister(); | 266 static const Register MapRegister(); |
268 }; | 267 }; |
269 | 268 |
270 | 269 |
271 class InstanceofDescriptor : public CallInterfaceDescriptor { | 270 class InstanceofDescriptor : public CallInterfaceDescriptor { |
272 public: | 271 public: |
273 DECLARE_DESCRIPTOR(InstanceofDescriptor, CallInterfaceDescriptor) | 272 DECLARE_DESCRIPTOR(InstanceofDescriptor, CallInterfaceDescriptor) |
274 | 273 |
275 enum ParameterIndices { kLeftIndex, kRightIndex, kParameterCount }; | 274 enum ParameterIndices { kLeftIndex, kRightIndex, kParameterCount }; |
276 static const Register left(); | 275 static const Register left(); |
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
646 } // namespace v8::internal | 645 } // namespace v8::internal |
647 | 646 |
648 | 647 |
649 #if V8_TARGET_ARCH_ARM64 | 648 #if V8_TARGET_ARCH_ARM64 |
650 #include "src/arm64/interface-descriptors-arm64.h" | 649 #include "src/arm64/interface-descriptors-arm64.h" |
651 #elif V8_TARGET_ARCH_ARM | 650 #elif V8_TARGET_ARCH_ARM |
652 #include "src/arm/interface-descriptors-arm.h" | 651 #include "src/arm/interface-descriptors-arm.h" |
653 #endif | 652 #endif |
654 | 653 |
655 #endif // V8_CALL_INTERFACE_DESCRIPTOR_H_ | 654 #endif // V8_CALL_INTERFACE_DESCRIPTOR_H_ |
OLD | NEW |