| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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_HYDROGEN_INSTRUCTIONS_H_ | 5 #ifndef V8_HYDROGEN_INSTRUCTIONS_H_ |
| 6 #define V8_HYDROGEN_INSTRUCTIONS_H_ | 6 #define V8_HYDROGEN_INSTRUCTIONS_H_ |
| 7 | 7 |
| 8 #include <cstring> | 8 #include <cstring> |
| 9 #include <iosfwd> | 9 #include <iosfwd> |
| 10 | 10 |
| (...skipping 2243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2254 enum CallMode { NORMAL_CALL, TAIL_CALL }; | 2254 enum CallMode { NORMAL_CALL, TAIL_CALL }; |
| 2255 | 2255 |
| 2256 | 2256 |
| 2257 class HCallWithDescriptor final : public HInstruction { | 2257 class HCallWithDescriptor final : public HInstruction { |
| 2258 public: | 2258 public: |
| 2259 static HCallWithDescriptor* New(Isolate* isolate, Zone* zone, HValue* context, | 2259 static HCallWithDescriptor* New(Isolate* isolate, Zone* zone, HValue* context, |
| 2260 HValue* target, int argument_count, | 2260 HValue* target, int argument_count, |
| 2261 CallInterfaceDescriptor descriptor, | 2261 CallInterfaceDescriptor descriptor, |
| 2262 const Vector<HValue*>& operands, | 2262 const Vector<HValue*>& operands, |
| 2263 CallMode call_mode = NORMAL_CALL) { | 2263 CallMode call_mode = NORMAL_CALL) { |
| 2264 DCHECK(operands.length() == descriptor.GetEnvironmentLength()); | |
| 2265 HCallWithDescriptor* res = new (zone) HCallWithDescriptor( | 2264 HCallWithDescriptor* res = new (zone) HCallWithDescriptor( |
| 2266 target, argument_count, descriptor, operands, call_mode, zone); | 2265 target, argument_count, descriptor, operands, call_mode, zone); |
| 2266 DCHECK(operands.length() == res->GetParameterCount()); |
| 2267 return res; | 2267 return res; |
| 2268 } | 2268 } |
| 2269 | 2269 |
| 2270 int OperandCount() const final { return values_.length(); } | 2270 int OperandCount() const final { return values_.length(); } |
| 2271 HValue* OperandAt(int index) const final { return values_[index]; } | 2271 HValue* OperandAt(int index) const final { return values_[index]; } |
| 2272 | 2272 |
| 2273 Representation RequiredInputRepresentation(int index) final { | 2273 Representation RequiredInputRepresentation(int index) final { |
| 2274 if (index == 0) { | 2274 if (index == 0 || index == 1) { |
| 2275 // Target + context |
| 2275 return Representation::Tagged(); | 2276 return Representation::Tagged(); |
| 2276 } else { | 2277 } else { |
| 2277 int par_index = index - 1; | 2278 int par_index = index - 2; |
| 2278 DCHECK(par_index < descriptor_.GetEnvironmentLength()); | 2279 DCHECK(par_index < GetParameterCount()); |
| 2279 return RepresentationFromType(descriptor_.GetParameterType(par_index)); | 2280 return RepresentationFromType(descriptor_.GetParameterType(par_index)); |
| 2280 } | 2281 } |
| 2281 } | 2282 } |
| 2282 | 2283 |
| 2283 DECLARE_CONCRETE_INSTRUCTION(CallWithDescriptor) | 2284 DECLARE_CONCRETE_INSTRUCTION(CallWithDescriptor) |
| 2284 | 2285 |
| 2285 HType CalculateInferredType() final { return HType::Tagged(); } | 2286 HType CalculateInferredType() final { return HType::Tagged(); } |
| 2286 | 2287 |
| 2287 bool IsTailCall() const { return call_mode_ == TAIL_CALL; } | 2288 bool IsTailCall() const { return call_mode_ == TAIL_CALL; } |
| 2288 | 2289 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 2300 | 2301 |
| 2301 std::ostream& PrintDataTo(std::ostream& os) const override; // NOLINT | 2302 std::ostream& PrintDataTo(std::ostream& os) const override; // NOLINT |
| 2302 | 2303 |
| 2303 private: | 2304 private: |
| 2304 // The argument count includes the receiver. | 2305 // The argument count includes the receiver. |
| 2305 HCallWithDescriptor(HValue* target, int argument_count, | 2306 HCallWithDescriptor(HValue* target, int argument_count, |
| 2306 CallInterfaceDescriptor descriptor, | 2307 CallInterfaceDescriptor descriptor, |
| 2307 const Vector<HValue*>& operands, CallMode call_mode, | 2308 const Vector<HValue*>& operands, CallMode call_mode, |
| 2308 Zone* zone) | 2309 Zone* zone) |
| 2309 : descriptor_(descriptor), | 2310 : descriptor_(descriptor), |
| 2310 values_(descriptor.GetEnvironmentLength() + 1, zone), | 2311 values_(GetParameterCount() + 1, zone), |
| 2311 argument_count_(argument_count), | 2312 argument_count_(argument_count), |
| 2312 call_mode_(call_mode) { | 2313 call_mode_(call_mode) { |
| 2313 // We can only tail call without any stack arguments. | 2314 // We can only tail call without any stack arguments. |
| 2314 DCHECK(call_mode != TAIL_CALL || argument_count == 0); | 2315 DCHECK(call_mode != TAIL_CALL || argument_count == 0); |
| 2315 AddOperand(target, zone); | 2316 AddOperand(target, zone); |
| 2316 for (int i = 0; i < operands.length(); i++) { | 2317 for (int i = 0; i < operands.length(); i++) { |
| 2317 AddOperand(operands[i], zone); | 2318 AddOperand(operands[i], zone); |
| 2318 } | 2319 } |
| 2319 this->set_representation(Representation::Tagged()); | 2320 this->set_representation(Representation::Tagged()); |
| 2320 this->SetAllSideEffects(); | 2321 this->SetAllSideEffects(); |
| 2321 } | 2322 } |
| 2322 | 2323 |
| 2323 void AddOperand(HValue* v, Zone* zone) { | 2324 void AddOperand(HValue* v, Zone* zone) { |
| 2324 values_.Add(NULL, zone); | 2325 values_.Add(NULL, zone); |
| 2325 SetOperandAt(values_.length() - 1, v); | 2326 SetOperandAt(values_.length() - 1, v); |
| 2326 } | 2327 } |
| 2327 | 2328 |
| 2329 int GetParameterCount() const { |
| 2330 return descriptor_.GetRegisterParameterCount() + 1; |
| 2331 } |
| 2332 |
| 2328 void InternalSetOperandAt(int index, HValue* value) final { | 2333 void InternalSetOperandAt(int index, HValue* value) final { |
| 2329 values_[index] = value; | 2334 values_[index] = value; |
| 2330 } | 2335 } |
| 2331 | 2336 |
| 2332 CallInterfaceDescriptor descriptor_; | 2337 CallInterfaceDescriptor descriptor_; |
| 2333 ZoneList<HValue*> values_; | 2338 ZoneList<HValue*> values_; |
| 2334 int argument_count_; | 2339 int argument_count_; |
| 2335 CallMode call_mode_; | 2340 CallMode call_mode_; |
| 2336 }; | 2341 }; |
| 2337 | 2342 |
| (...skipping 5596 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7934 }; | 7939 }; |
| 7935 | 7940 |
| 7936 | 7941 |
| 7937 | 7942 |
| 7938 #undef DECLARE_INSTRUCTION | 7943 #undef DECLARE_INSTRUCTION |
| 7939 #undef DECLARE_CONCRETE_INSTRUCTION | 7944 #undef DECLARE_CONCRETE_INSTRUCTION |
| 7940 | 7945 |
| 7941 } } // namespace v8::internal | 7946 } } // namespace v8::internal |
| 7942 | 7947 |
| 7943 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ | 7948 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ |
| OLD | NEW |