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_CRANKSHAFT_HYDROGEN_INSTRUCTIONS_H_ | 5 #ifndef V8_CRANKSHAFT_HYDROGEN_INSTRUCTIONS_H_ |
6 #define V8_CRANKSHAFT_HYDROGEN_INSTRUCTIONS_H_ | 6 #define V8_CRANKSHAFT_HYDROGEN_INSTRUCTIONS_H_ |
7 | 7 |
8 #include <cstring> | 8 #include <cstring> |
9 #include <iosfwd> | 9 #include <iosfwd> |
10 | 10 |
(...skipping 3714 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3725 | 3725 |
3726 int32_t int32_value_; | 3726 int32_t int32_value_; |
3727 double double_value_; | 3727 double double_value_; |
3728 ExternalReference external_reference_value_; | 3728 ExternalReference external_reference_value_; |
3729 }; | 3729 }; |
3730 | 3730 |
3731 | 3731 |
3732 class HBinaryOperation : public HTemplateInstruction<3> { | 3732 class HBinaryOperation : public HTemplateInstruction<3> { |
3733 public: | 3733 public: |
3734 HBinaryOperation(HValue* context, HValue* left, HValue* right, | 3734 HBinaryOperation(HValue* context, HValue* left, HValue* right, |
3735 Strength strength, HType type = HType::Tagged()) | 3735 HType type = HType::Tagged()) |
3736 : HTemplateInstruction<3>(type), | 3736 : HTemplateInstruction<3>(type), |
3737 strength_(strength), | |
3738 observed_output_representation_(Representation::None()) { | 3737 observed_output_representation_(Representation::None()) { |
3739 DCHECK(left != NULL && right != NULL); | 3738 DCHECK(left != NULL && right != NULL); |
3740 SetOperandAt(0, context); | 3739 SetOperandAt(0, context); |
3741 SetOperandAt(1, left); | 3740 SetOperandAt(1, left); |
3742 SetOperandAt(2, right); | 3741 SetOperandAt(2, right); |
3743 observed_input_representation_[0] = Representation::None(); | 3742 observed_input_representation_[0] = Representation::None(); |
3744 observed_input_representation_[1] = Representation::None(); | 3743 observed_input_representation_[1] = Representation::None(); |
3745 } | 3744 } |
3746 | 3745 |
3747 HValue* context() const { return OperandAt(0); } | 3746 HValue* context() const { return OperandAt(0); } |
3748 HValue* left() const { return OperandAt(1); } | 3747 HValue* left() const { return OperandAt(1); } |
3749 HValue* right() const { return OperandAt(2); } | 3748 HValue* right() const { return OperandAt(2); } |
3750 Strength strength() const { return strength_; } | |
3751 | 3749 |
3752 // True if switching left and right operands likely generates better code. | 3750 // True if switching left and right operands likely generates better code. |
3753 bool AreOperandsBetterSwitched() { | 3751 bool AreOperandsBetterSwitched() { |
3754 if (!IsCommutative()) return false; | 3752 if (!IsCommutative()) return false; |
3755 | 3753 |
3756 // Constant operands are better off on the right, they can be inlined in | 3754 // Constant operands are better off on the right, they can be inlined in |
3757 // many situations on most platforms. | 3755 // many situations on most platforms. |
3758 if (left()->IsConstant()) return true; | 3756 if (left()->IsConstant()) return true; |
3759 if (right()->IsConstant()) return false; | 3757 if (right()->IsConstant()) return false; |
3760 | 3758 |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3816 | 3814 |
3817 bool RightIsPowerOf2() { | 3815 bool RightIsPowerOf2() { |
3818 if (!right()->IsInteger32Constant()) return false; | 3816 if (!right()->IsInteger32Constant()) return false; |
3819 int32_t value = right()->GetInteger32Constant(); | 3817 int32_t value = right()->GetInteger32Constant(); |
3820 if (value < 0) { | 3818 if (value < 0) { |
3821 return base::bits::IsPowerOfTwo32(static_cast<uint32_t>(-value)); | 3819 return base::bits::IsPowerOfTwo32(static_cast<uint32_t>(-value)); |
3822 } | 3820 } |
3823 return base::bits::IsPowerOfTwo32(static_cast<uint32_t>(value)); | 3821 return base::bits::IsPowerOfTwo32(static_cast<uint32_t>(value)); |
3824 } | 3822 } |
3825 | 3823 |
3826 Strength strength() { return strength_; } | |
3827 | |
3828 DECLARE_ABSTRACT_INSTRUCTION(BinaryOperation) | 3824 DECLARE_ABSTRACT_INSTRUCTION(BinaryOperation) |
3829 | 3825 |
3830 private: | 3826 private: |
3831 bool IgnoreObservedOutputRepresentation(Representation current_rep); | 3827 bool IgnoreObservedOutputRepresentation(Representation current_rep); |
3832 Strength strength_; | |
3833 | 3828 |
3834 Representation observed_input_representation_[2]; | 3829 Representation observed_input_representation_[2]; |
3835 Representation observed_output_representation_; | 3830 Representation observed_output_representation_; |
3836 }; | 3831 }; |
3837 | 3832 |
3838 | 3833 |
3839 class HWrapReceiver final : public HTemplateInstruction<2> { | 3834 class HWrapReceiver final : public HTemplateInstruction<2> { |
3840 public: | 3835 public: |
3841 DECLARE_INSTRUCTION_FACTORY_P2(HWrapReceiver, HValue*, HValue*); | 3836 DECLARE_INSTRUCTION_FACTORY_P2(HWrapReceiver, HValue*, HValue*); |
3842 | 3837 |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4092 std::ostream& PrintDataTo(std::ostream& os) const override; // NOLINT | 4087 std::ostream& PrintDataTo(std::ostream& os) const override; // NOLINT |
4093 | 4088 |
4094 int RedefinedOperandIndex() override { return 0; } | 4089 int RedefinedOperandIndex() override { return 0; } |
4095 bool IsPurelyInformativeDefinition() override { return true; } | 4090 bool IsPurelyInformativeDefinition() override { return true; } |
4096 }; | 4091 }; |
4097 | 4092 |
4098 | 4093 |
4099 class HBitwiseBinaryOperation : public HBinaryOperation { | 4094 class HBitwiseBinaryOperation : public HBinaryOperation { |
4100 public: | 4095 public: |
4101 HBitwiseBinaryOperation(HValue* context, HValue* left, HValue* right, | 4096 HBitwiseBinaryOperation(HValue* context, HValue* left, HValue* right, |
4102 Strength strength, HType type = HType::TaggedNumber()) | 4097 HType type = HType::TaggedNumber()) |
4103 : HBinaryOperation(context, left, right, strength, type) { | 4098 : HBinaryOperation(context, left, right, type) { |
4104 SetFlag(kFlexibleRepresentation); | 4099 SetFlag(kFlexibleRepresentation); |
4105 SetFlag(kTruncatingToInt32); | 4100 SetFlag(kTruncatingToInt32); |
4106 if (!is_strong(strength)) SetFlag(kAllowUndefinedAsNaN); | |
adamk
2016/06/22 19:57:18
This deletion looks wrong: it should have instead
rossberg
2016/06/23 06:28:31
C negation syntax, made easy to overlook since 197
| |
4107 SetAllSideEffects(); | 4101 SetAllSideEffects(); |
4108 } | 4102 } |
4109 | 4103 |
4110 void RepresentationChanged(Representation to) override { | 4104 void RepresentationChanged(Representation to) override { |
4111 if (to.IsTagged() && | 4105 if (to.IsTagged() && |
4112 (left()->ToNumberCanBeObserved() || right()->ToNumberCanBeObserved())) { | 4106 (left()->ToNumberCanBeObserved() || right()->ToNumberCanBeObserved())) { |
4113 SetAllSideEffects(); | 4107 SetAllSideEffects(); |
4114 ClearFlag(kUseGVN); | 4108 ClearFlag(kUseGVN); |
4115 } else { | 4109 } else { |
4116 ClearAllSideEffects(); | 4110 ClearAllSideEffects(); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4151 HValue*, | 4145 HValue*, |
4152 HValue*); | 4146 HValue*); |
4153 | 4147 |
4154 DECLARE_CONCRETE_INSTRUCTION(MathFloorOfDiv) | 4148 DECLARE_CONCRETE_INSTRUCTION(MathFloorOfDiv) |
4155 | 4149 |
4156 protected: | 4150 protected: |
4157 bool DataEquals(HValue* other) override { return true; } | 4151 bool DataEquals(HValue* other) override { return true; } |
4158 | 4152 |
4159 private: | 4153 private: |
4160 HMathFloorOfDiv(HValue* context, HValue* left, HValue* right) | 4154 HMathFloorOfDiv(HValue* context, HValue* left, HValue* right) |
4161 : HBinaryOperation(context, left, right, Strength::WEAK) { | 4155 : HBinaryOperation(context, left, right) { |
4162 set_representation(Representation::Integer32()); | 4156 set_representation(Representation::Integer32()); |
4163 SetFlag(kUseGVN); | 4157 SetFlag(kUseGVN); |
4164 SetFlag(kCanOverflow); | 4158 SetFlag(kCanOverflow); |
4165 SetFlag(kCanBeDivByZero); | 4159 SetFlag(kCanBeDivByZero); |
4166 SetFlag(kLeftCanBeMinInt); | 4160 SetFlag(kLeftCanBeMinInt); |
4167 SetFlag(kLeftCanBeNegative); | 4161 SetFlag(kLeftCanBeNegative); |
4168 SetFlag(kLeftCanBePositive); | 4162 SetFlag(kLeftCanBePositive); |
4169 SetFlag(kAllowUndefinedAsNaN); | 4163 SetFlag(kAllowUndefinedAsNaN); |
4170 } | 4164 } |
4171 | 4165 |
4172 Range* InferRange(Zone* zone) override; | 4166 Range* InferRange(Zone* zone) override; |
4173 | 4167 |
4174 bool IsDeletable() const override { return true; } | 4168 bool IsDeletable() const override { return true; } |
4175 }; | 4169 }; |
4176 | 4170 |
4177 | 4171 |
4178 class HArithmeticBinaryOperation : public HBinaryOperation { | 4172 class HArithmeticBinaryOperation : public HBinaryOperation { |
4179 public: | 4173 public: |
4180 HArithmeticBinaryOperation(HValue* context, HValue* left, HValue* right, | 4174 HArithmeticBinaryOperation(HValue* context, HValue* left, HValue* right) |
4181 Strength strength) | 4175 : HBinaryOperation(context, left, right, HType::TaggedNumber()) { |
4182 : HBinaryOperation(context, left, right, strength, | |
4183 HType::TaggedNumber()) { | |
4184 SetAllSideEffects(); | 4176 SetAllSideEffects(); |
4185 SetFlag(kFlexibleRepresentation); | 4177 SetFlag(kFlexibleRepresentation); |
4186 if (!is_strong(strength)) SetFlag(kAllowUndefinedAsNaN); | 4178 SetFlag(kAllowUndefinedAsNaN); |
4187 } | 4179 } |
4188 | 4180 |
4189 void RepresentationChanged(Representation to) override { | 4181 void RepresentationChanged(Representation to) override { |
4190 if (to.IsTagged() && | 4182 if (to.IsTagged() && |
4191 (left()->ToNumberCanBeObserved() || right()->ToNumberCanBeObserved())) { | 4183 (left()->ToNumberCanBeObserved() || right()->ToNumberCanBeObserved())) { |
4192 SetAllSideEffects(); | 4184 SetAllSideEffects(); |
4193 ClearFlag(kUseGVN); | 4185 ClearFlag(kUseGVN); |
4194 } else { | 4186 } else { |
4195 ClearAllSideEffects(); | 4187 ClearAllSideEffects(); |
4196 SetFlag(kUseGVN); | 4188 SetFlag(kUseGVN); |
4197 } | 4189 } |
4198 if (to.IsTagged()) SetChangesFlag(kNewSpacePromotion); | 4190 if (to.IsTagged()) SetChangesFlag(kNewSpacePromotion); |
4199 } | 4191 } |
4200 | 4192 |
4201 DECLARE_ABSTRACT_INSTRUCTION(ArithmeticBinaryOperation) | 4193 DECLARE_ABSTRACT_INSTRUCTION(ArithmeticBinaryOperation) |
4202 | 4194 |
4203 private: | 4195 private: |
4204 bool IsDeletable() const override { return true; } | 4196 bool IsDeletable() const override { return true; } |
4205 }; | 4197 }; |
4206 | 4198 |
4207 | 4199 |
4208 class HCompareGeneric final : public HBinaryOperation { | 4200 class HCompareGeneric final : public HBinaryOperation { |
4209 public: | 4201 public: |
4210 static HCompareGeneric* New(Isolate* isolate, Zone* zone, HValue* context, | 4202 static HCompareGeneric* New(Isolate* isolate, Zone* zone, HValue* context, |
4211 HValue* left, HValue* right, Token::Value token, | 4203 HValue* left, HValue* right, Token::Value token) { |
4212 Strength strength = Strength::WEAK) { | 4204 return new (zone) HCompareGeneric(context, left, right, token); |
4213 return new (zone) HCompareGeneric(context, left, right, token, strength); | |
4214 } | 4205 } |
4215 | 4206 |
4216 Representation RequiredInputRepresentation(int index) override { | 4207 Representation RequiredInputRepresentation(int index) override { |
4217 return index == 0 | 4208 return index == 0 |
4218 ? Representation::Tagged() | 4209 ? Representation::Tagged() |
4219 : representation(); | 4210 : representation(); |
4220 } | 4211 } |
4221 | 4212 |
4222 Token::Value token() const { return token_; } | 4213 Token::Value token() const { return token_; } |
4223 std::ostream& PrintDataTo(std::ostream& os) const override; // NOLINT | 4214 std::ostream& PrintDataTo(std::ostream& os) const override; // NOLINT |
4224 | 4215 |
4225 DECLARE_CONCRETE_INSTRUCTION(CompareGeneric) | 4216 DECLARE_CONCRETE_INSTRUCTION(CompareGeneric) |
4226 | 4217 |
4227 private: | 4218 private: |
4228 HCompareGeneric(HValue* context, HValue* left, HValue* right, | 4219 HCompareGeneric(HValue* context, HValue* left, HValue* right, |
4229 Token::Value token, Strength strength) | 4220 Token::Value token) |
4230 : HBinaryOperation(context, left, right, strength, HType::Boolean()), | 4221 : HBinaryOperation(context, left, right, HType::Boolean()), |
4231 token_(token) { | 4222 token_(token) { |
4232 DCHECK(Token::IsCompareOp(token)); | 4223 DCHECK(Token::IsCompareOp(token)); |
4233 set_representation(Representation::Tagged()); | 4224 set_representation(Representation::Tagged()); |
4234 SetAllSideEffects(); | 4225 SetAllSideEffects(); |
4235 } | 4226 } |
4236 | 4227 |
4237 Token::Value token_; | 4228 Token::Value token_; |
4238 }; | 4229 }; |
4239 | 4230 |
4240 | 4231 |
4241 class HCompareNumericAndBranch : public HTemplateControlInstruction<2, 2> { | 4232 class HCompareNumericAndBranch : public HTemplateControlInstruction<2, 2> { |
4242 public: | 4233 public: |
4243 static HCompareNumericAndBranch* New(Isolate* isolate, Zone* zone, | 4234 static HCompareNumericAndBranch* New(Isolate* isolate, Zone* zone, |
4244 HValue* context, HValue* left, | 4235 HValue* context, HValue* left, |
4245 HValue* right, Token::Value token, | 4236 HValue* right, Token::Value token, |
4246 HBasicBlock* true_target = NULL, | 4237 HBasicBlock* true_target = NULL, |
4247 HBasicBlock* false_target = NULL, | 4238 HBasicBlock* false_target = NULL) { |
4248 Strength strength = Strength::WEAK) { | |
4249 return new (zone) HCompareNumericAndBranch(left, right, token, true_target, | |
4250 false_target, strength); | |
4251 } | |
4252 static HCompareNumericAndBranch* New(Isolate* isolate, Zone* zone, | |
4253 HValue* context, HValue* left, | |
4254 HValue* right, Token::Value token, | |
4255 Strength strength) { | |
4256 return new (zone) | 4239 return new (zone) |
4257 HCompareNumericAndBranch(left, right, token, NULL, NULL, strength); | 4240 HCompareNumericAndBranch(left, right, token, true_target, false_target); |
4258 } | 4241 } |
4259 | 4242 |
4260 HValue* left() const { return OperandAt(0); } | 4243 HValue* left() const { return OperandAt(0); } |
4261 HValue* right() const { return OperandAt(1); } | 4244 HValue* right() const { return OperandAt(1); } |
4262 Token::Value token() const { return token_; } | 4245 Token::Value token() const { return token_; } |
4263 | 4246 |
4264 void set_observed_input_representation(Representation left, | 4247 void set_observed_input_representation(Representation left, |
4265 Representation right) { | 4248 Representation right) { |
4266 observed_input_representation_[0] = left; | 4249 observed_input_representation_[0] = left; |
4267 observed_input_representation_[1] = right; | 4250 observed_input_representation_[1] = right; |
4268 } | 4251 } |
4269 | 4252 |
4270 void InferRepresentation(HInferRepresentationPhase* h_infer) override; | 4253 void InferRepresentation(HInferRepresentationPhase* h_infer) override; |
4271 | 4254 |
4272 Representation RequiredInputRepresentation(int index) override { | 4255 Representation RequiredInputRepresentation(int index) override { |
4273 return representation(); | 4256 return representation(); |
4274 } | 4257 } |
4275 Representation observed_input_representation(int index) override { | 4258 Representation observed_input_representation(int index) override { |
4276 return observed_input_representation_[index]; | 4259 return observed_input_representation_[index]; |
4277 } | 4260 } |
4278 | 4261 |
4279 bool KnownSuccessorBlock(HBasicBlock** block) override; | 4262 bool KnownSuccessorBlock(HBasicBlock** block) override; |
4280 | 4263 |
4281 Strength strength() const { return strength_; } | |
4282 | |
4283 std::ostream& PrintDataTo(std::ostream& os) const override; // NOLINT | 4264 std::ostream& PrintDataTo(std::ostream& os) const override; // NOLINT |
4284 | 4265 |
4285 void SetOperandPositions(Zone* zone, SourcePosition left_pos, | 4266 void SetOperandPositions(Zone* zone, SourcePosition left_pos, |
4286 SourcePosition right_pos) { | 4267 SourcePosition right_pos) { |
4287 set_operand_position(zone, 0, left_pos); | 4268 set_operand_position(zone, 0, left_pos); |
4288 set_operand_position(zone, 1, right_pos); | 4269 set_operand_position(zone, 1, right_pos); |
4289 } | 4270 } |
4290 | 4271 |
4291 DECLARE_CONCRETE_INSTRUCTION(CompareNumericAndBranch) | 4272 DECLARE_CONCRETE_INSTRUCTION(CompareNumericAndBranch) |
4292 | 4273 |
4293 private: | 4274 private: |
4294 HCompareNumericAndBranch(HValue* left, HValue* right, Token::Value token, | 4275 HCompareNumericAndBranch(HValue* left, HValue* right, Token::Value token, |
4295 HBasicBlock* true_target, HBasicBlock* false_target, | 4276 HBasicBlock* true_target, HBasicBlock* false_target) |
4296 Strength strength) | 4277 : token_(token) { |
4297 : token_(token), strength_(strength) { | |
4298 SetFlag(kFlexibleRepresentation); | 4278 SetFlag(kFlexibleRepresentation); |
4299 DCHECK(Token::IsCompareOp(token)); | 4279 DCHECK(Token::IsCompareOp(token)); |
4300 SetOperandAt(0, left); | 4280 SetOperandAt(0, left); |
4301 SetOperandAt(1, right); | 4281 SetOperandAt(1, right); |
4302 SetSuccessorAt(0, true_target); | 4282 SetSuccessorAt(0, true_target); |
4303 SetSuccessorAt(1, false_target); | 4283 SetSuccessorAt(1, false_target); |
4304 } | 4284 } |
4305 | 4285 |
4306 Representation observed_input_representation_[2]; | 4286 Representation observed_input_representation_[2]; |
4307 Token::Value token_; | 4287 Token::Value token_; |
4308 Strength strength_; | |
4309 }; | 4288 }; |
4310 | 4289 |
4311 | 4290 |
4312 class HCompareHoleAndBranch final : public HUnaryControlInstruction { | 4291 class HCompareHoleAndBranch final : public HUnaryControlInstruction { |
4313 public: | 4292 public: |
4314 DECLARE_INSTRUCTION_FACTORY_P1(HCompareHoleAndBranch, HValue*); | 4293 DECLARE_INSTRUCTION_FACTORY_P1(HCompareHoleAndBranch, HValue*); |
4315 DECLARE_INSTRUCTION_FACTORY_P3(HCompareHoleAndBranch, HValue*, | 4294 DECLARE_INSTRUCTION_FACTORY_P3(HCompareHoleAndBranch, HValue*, |
4316 HBasicBlock*, HBasicBlock*); | 4295 HBasicBlock*, HBasicBlock*); |
4317 | 4296 |
4318 void InferRepresentation(HInferRepresentationPhase* h_infer) override; | 4297 void InferRepresentation(HInferRepresentationPhase* h_infer) override; |
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4630 Representation RequiredInputRepresentation(int index) override { | 4609 Representation RequiredInputRepresentation(int index) override { |
4631 return Representation::Tagged(); | 4610 return Representation::Tagged(); |
4632 } | 4611 } |
4633 | 4612 |
4634 std::ostream& PrintDataTo(std::ostream& os) const override; // NOLINT | 4613 std::ostream& PrintDataTo(std::ostream& os) const override; // NOLINT |
4635 | 4614 |
4636 DECLARE_CONCRETE_INSTRUCTION(InstanceOf) | 4615 DECLARE_CONCRETE_INSTRUCTION(InstanceOf) |
4637 | 4616 |
4638 private: | 4617 private: |
4639 HInstanceOf(HValue* context, HValue* left, HValue* right) | 4618 HInstanceOf(HValue* context, HValue* left, HValue* right) |
4640 : HBinaryOperation(context, left, right, Strength::WEAK, | 4619 : HBinaryOperation(context, left, right, HType::Boolean()) { |
4641 HType::Boolean()) { | |
4642 set_representation(Representation::Tagged()); | 4620 set_representation(Representation::Tagged()); |
4643 SetAllSideEffects(); | 4621 SetAllSideEffects(); |
4644 } | 4622 } |
4645 }; | 4623 }; |
4646 | 4624 |
4647 | 4625 |
4648 class HHasInPrototypeChainAndBranch final | 4626 class HHasInPrototypeChainAndBranch final |
4649 : public HTemplateControlInstruction<2, 2> { | 4627 : public HTemplateControlInstruction<2, 2> { |
4650 public: | 4628 public: |
4651 DECLARE_INSTRUCTION_FACTORY_P2(HHasInPrototypeChainAndBranch, HValue*, | 4629 DECLARE_INSTRUCTION_FACTORY_P2(HHasInPrototypeChainAndBranch, HValue*, |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4714 enum ExternalAddType { | 4692 enum ExternalAddType { |
4715 AddOfExternalAndTagged, | 4693 AddOfExternalAndTagged, |
4716 AddOfExternalAndInt32, | 4694 AddOfExternalAndInt32, |
4717 NoExternalAdd | 4695 NoExternalAdd |
4718 }; | 4696 }; |
4719 | 4697 |
4720 | 4698 |
4721 class HAdd final : public HArithmeticBinaryOperation { | 4699 class HAdd final : public HArithmeticBinaryOperation { |
4722 public: | 4700 public: |
4723 static HInstruction* New(Isolate* isolate, Zone* zone, HValue* context, | 4701 static HInstruction* New(Isolate* isolate, Zone* zone, HValue* context, |
4702 HValue* left, HValue* right); | |
4703 static HInstruction* New(Isolate* isolate, Zone* zone, HValue* context, | |
4724 HValue* left, HValue* right, | 4704 HValue* left, HValue* right, |
4725 Strength strength = Strength::WEAK); | |
4726 static HInstruction* New(Isolate* isolate, Zone* zone, HValue* context, | |
4727 HValue* left, HValue* right, Strength strength, | |
4728 ExternalAddType external_add_type); | 4705 ExternalAddType external_add_type); |
4729 | 4706 |
4730 // Add is only commutative if two integer values are added and not if two | 4707 // Add is only commutative if two integer values are added and not if two |
4731 // tagged values are added (because it might be a String concatenation). | 4708 // tagged values are added (because it might be a String concatenation). |
4732 // We also do not commute (pointer + offset). | 4709 // We also do not commute (pointer + offset). |
4733 bool IsCommutative() const override { | 4710 bool IsCommutative() const override { |
4734 return !representation().IsTagged() && !representation().IsExternal(); | 4711 return !representation().IsTagged() && !representation().IsExternal(); |
4735 } | 4712 } |
4736 | 4713 |
4737 HValue* Canonicalize() override; | 4714 HValue* Canonicalize() override; |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4779 ExternalAddType external_add_type() const { return external_add_type_; } | 4756 ExternalAddType external_add_type() const { return external_add_type_; } |
4780 | 4757 |
4781 DECLARE_CONCRETE_INSTRUCTION(Add) | 4758 DECLARE_CONCRETE_INSTRUCTION(Add) |
4782 | 4759 |
4783 protected: | 4760 protected: |
4784 bool DataEquals(HValue* other) override { return true; } | 4761 bool DataEquals(HValue* other) override { return true; } |
4785 | 4762 |
4786 Range* InferRange(Zone* zone) override; | 4763 Range* InferRange(Zone* zone) override; |
4787 | 4764 |
4788 private: | 4765 private: |
4789 HAdd(HValue* context, HValue* left, HValue* right, Strength strength, | 4766 HAdd(HValue* context, HValue* left, HValue* right, |
4790 ExternalAddType external_add_type = NoExternalAdd) | 4767 ExternalAddType external_add_type = NoExternalAdd) |
4791 : HArithmeticBinaryOperation(context, left, right, strength), | 4768 : HArithmeticBinaryOperation(context, left, right), |
4792 external_add_type_(external_add_type) { | 4769 external_add_type_(external_add_type) { |
4793 SetFlag(kCanOverflow); | 4770 SetFlag(kCanOverflow); |
4794 switch (external_add_type_) { | 4771 switch (external_add_type_) { |
4795 case AddOfExternalAndTagged: | 4772 case AddOfExternalAndTagged: |
4796 DCHECK(left->representation().IsExternal()); | 4773 DCHECK(left->representation().IsExternal()); |
4797 DCHECK(right->representation().IsTagged()); | 4774 DCHECK(right->representation().IsTagged()); |
4798 SetDependsOnFlag(kNewSpacePromotion); | 4775 SetDependsOnFlag(kNewSpacePromotion); |
4799 ClearFlag(HValue::kCanOverflow); | 4776 ClearFlag(HValue::kCanOverflow); |
4800 SetFlag(kHasNoObservableSideEffects); | 4777 SetFlag(kHasNoObservableSideEffects); |
4801 break; | 4778 break; |
(...skipping 14 matching lines...) Expand all Loading... | |
4816 } | 4793 } |
4817 } | 4794 } |
4818 | 4795 |
4819 ExternalAddType external_add_type_; | 4796 ExternalAddType external_add_type_; |
4820 }; | 4797 }; |
4821 | 4798 |
4822 | 4799 |
4823 class HSub final : public HArithmeticBinaryOperation { | 4800 class HSub final : public HArithmeticBinaryOperation { |
4824 public: | 4801 public: |
4825 static HInstruction* New(Isolate* isolate, Zone* zone, HValue* context, | 4802 static HInstruction* New(Isolate* isolate, Zone* zone, HValue* context, |
4826 HValue* left, HValue* right, | 4803 HValue* left, HValue* right); |
4827 Strength strength = Strength::WEAK); | |
4828 | 4804 |
4829 HValue* Canonicalize() override; | 4805 HValue* Canonicalize() override; |
4830 | 4806 |
4831 bool TryDecompose(DecompositionResult* decomposition) override { | 4807 bool TryDecompose(DecompositionResult* decomposition) override { |
4832 if (right()->IsInteger32Constant()) { | 4808 if (right()->IsInteger32Constant()) { |
4833 decomposition->Apply(left(), -right()->GetInteger32Constant()); | 4809 decomposition->Apply(left(), -right()->GetInteger32Constant()); |
4834 return true; | 4810 return true; |
4835 } else { | 4811 } else { |
4836 return false; | 4812 return false; |
4837 } | 4813 } |
4838 } | 4814 } |
4839 | 4815 |
4840 DECLARE_CONCRETE_INSTRUCTION(Sub) | 4816 DECLARE_CONCRETE_INSTRUCTION(Sub) |
4841 | 4817 |
4842 protected: | 4818 protected: |
4843 bool DataEquals(HValue* other) override { return true; } | 4819 bool DataEquals(HValue* other) override { return true; } |
4844 | 4820 |
4845 Range* InferRange(Zone* zone) override; | 4821 Range* InferRange(Zone* zone) override; |
4846 | 4822 |
4847 private: | 4823 private: |
4848 HSub(HValue* context, HValue* left, HValue* right, Strength strength) | 4824 HSub(HValue* context, HValue* left, HValue* right) |
4849 : HArithmeticBinaryOperation(context, left, right, strength) { | 4825 : HArithmeticBinaryOperation(context, left, right) { |
4850 SetFlag(kCanOverflow); | 4826 SetFlag(kCanOverflow); |
4851 } | 4827 } |
4852 }; | 4828 }; |
4853 | 4829 |
4854 | 4830 |
4855 class HMul final : public HArithmeticBinaryOperation { | 4831 class HMul final : public HArithmeticBinaryOperation { |
4856 public: | 4832 public: |
4857 static HInstruction* New(Isolate* isolate, Zone* zone, HValue* context, | 4833 static HInstruction* New(Isolate* isolate, Zone* zone, HValue* context, |
4858 HValue* left, HValue* right, | 4834 HValue* left, HValue* right); |
4859 Strength strength = Strength::WEAK); | |
4860 | 4835 |
4861 static HInstruction* NewImul(Isolate* isolate, Zone* zone, HValue* context, | 4836 static HInstruction* NewImul(Isolate* isolate, Zone* zone, HValue* context, |
4862 HValue* left, HValue* right, | 4837 HValue* left, HValue* right) { |
4863 Strength strength = Strength::WEAK) { | 4838 HInstruction* instr = HMul::New(isolate, zone, context, left, right); |
4864 HInstruction* instr = | |
4865 HMul::New(isolate, zone, context, left, right, strength); | |
4866 if (!instr->IsMul()) return instr; | 4839 if (!instr->IsMul()) return instr; |
4867 HMul* mul = HMul::cast(instr); | 4840 HMul* mul = HMul::cast(instr); |
4868 // TODO(mstarzinger): Prevent bailout on minus zero for imul. | 4841 // TODO(mstarzinger): Prevent bailout on minus zero for imul. |
4869 mul->AssumeRepresentation(Representation::Integer32()); | 4842 mul->AssumeRepresentation(Representation::Integer32()); |
4870 mul->ClearFlag(HValue::kCanOverflow); | 4843 mul->ClearFlag(HValue::kCanOverflow); |
4871 return mul; | 4844 return mul; |
4872 } | 4845 } |
4873 | 4846 |
4874 HValue* Canonicalize() override; | 4847 HValue* Canonicalize() override; |
4875 | 4848 |
4876 // Only commutative if it is certain that not two objects are multiplicated. | 4849 // Only commutative if it is certain that not two objects are multiplicated. |
4877 bool IsCommutative() const override { return !representation().IsTagged(); } | 4850 bool IsCommutative() const override { return !representation().IsTagged(); } |
4878 | 4851 |
4879 void UpdateRepresentation(Representation new_rep, | 4852 void UpdateRepresentation(Representation new_rep, |
4880 HInferRepresentationPhase* h_infer, | 4853 HInferRepresentationPhase* h_infer, |
4881 const char* reason) override { | 4854 const char* reason) override { |
4882 HArithmeticBinaryOperation::UpdateRepresentation(new_rep, h_infer, reason); | 4855 HArithmeticBinaryOperation::UpdateRepresentation(new_rep, h_infer, reason); |
4883 } | 4856 } |
4884 | 4857 |
4885 bool MulMinusOne(); | 4858 bool MulMinusOne(); |
4886 | 4859 |
4887 DECLARE_CONCRETE_INSTRUCTION(Mul) | 4860 DECLARE_CONCRETE_INSTRUCTION(Mul) |
4888 | 4861 |
4889 protected: | 4862 protected: |
4890 bool DataEquals(HValue* other) override { return true; } | 4863 bool DataEquals(HValue* other) override { return true; } |
4891 | 4864 |
4892 Range* InferRange(Zone* zone) override; | 4865 Range* InferRange(Zone* zone) override; |
4893 | 4866 |
4894 private: | 4867 private: |
4895 HMul(HValue* context, HValue* left, HValue* right, Strength strength) | 4868 HMul(HValue* context, HValue* left, HValue* right) |
4896 : HArithmeticBinaryOperation(context, left, right, strength) { | 4869 : HArithmeticBinaryOperation(context, left, right) { |
4897 SetFlag(kCanOverflow); | 4870 SetFlag(kCanOverflow); |
4898 } | 4871 } |
4899 }; | 4872 }; |
4900 | 4873 |
4901 | 4874 |
4902 class HMod final : public HArithmeticBinaryOperation { | 4875 class HMod final : public HArithmeticBinaryOperation { |
4903 public: | 4876 public: |
4904 static HInstruction* New(Isolate* isolate, Zone* zone, HValue* context, | 4877 static HInstruction* New(Isolate* isolate, Zone* zone, HValue* context, |
4905 HValue* left, HValue* right, | 4878 HValue* left, HValue* right); |
4906 Strength strength = Strength::WEAK); | |
4907 | 4879 |
4908 HValue* Canonicalize() override; | 4880 HValue* Canonicalize() override; |
4909 | 4881 |
4910 void UpdateRepresentation(Representation new_rep, | 4882 void UpdateRepresentation(Representation new_rep, |
4911 HInferRepresentationPhase* h_infer, | 4883 HInferRepresentationPhase* h_infer, |
4912 const char* reason) override { | 4884 const char* reason) override { |
4913 if (new_rep.IsSmi()) new_rep = Representation::Integer32(); | 4885 if (new_rep.IsSmi()) new_rep = Representation::Integer32(); |
4914 HArithmeticBinaryOperation::UpdateRepresentation(new_rep, h_infer, reason); | 4886 HArithmeticBinaryOperation::UpdateRepresentation(new_rep, h_infer, reason); |
4915 } | 4887 } |
4916 | 4888 |
4917 DECLARE_CONCRETE_INSTRUCTION(Mod) | 4889 DECLARE_CONCRETE_INSTRUCTION(Mod) |
4918 | 4890 |
4919 protected: | 4891 protected: |
4920 bool DataEquals(HValue* other) override { return true; } | 4892 bool DataEquals(HValue* other) override { return true; } |
4921 | 4893 |
4922 Range* InferRange(Zone* zone) override; | 4894 Range* InferRange(Zone* zone) override; |
4923 | 4895 |
4924 private: | 4896 private: |
4925 HMod(HValue* context, HValue* left, HValue* right, Strength strength) | 4897 HMod(HValue* context, HValue* left, HValue* right) |
4926 : HArithmeticBinaryOperation(context, left, right, strength) { | 4898 : HArithmeticBinaryOperation(context, left, right) { |
4927 SetFlag(kCanBeDivByZero); | 4899 SetFlag(kCanBeDivByZero); |
4928 SetFlag(kCanOverflow); | 4900 SetFlag(kCanOverflow); |
4929 SetFlag(kLeftCanBeNegative); | 4901 SetFlag(kLeftCanBeNegative); |
4930 } | 4902 } |
4931 }; | 4903 }; |
4932 | 4904 |
4933 | 4905 |
4934 class HDiv final : public HArithmeticBinaryOperation { | 4906 class HDiv final : public HArithmeticBinaryOperation { |
4935 public: | 4907 public: |
4936 static HInstruction* New(Isolate* isolate, Zone* zone, HValue* context, | 4908 static HInstruction* New(Isolate* isolate, Zone* zone, HValue* context, |
4937 HValue* left, HValue* right, | 4909 HValue* left, HValue* right); |
4938 Strength strength = Strength::WEAK); | |
4939 | 4910 |
4940 HValue* Canonicalize() override; | 4911 HValue* Canonicalize() override; |
4941 | 4912 |
4942 void UpdateRepresentation(Representation new_rep, | 4913 void UpdateRepresentation(Representation new_rep, |
4943 HInferRepresentationPhase* h_infer, | 4914 HInferRepresentationPhase* h_infer, |
4944 const char* reason) override { | 4915 const char* reason) override { |
4945 if (new_rep.IsSmi()) new_rep = Representation::Integer32(); | 4916 if (new_rep.IsSmi()) new_rep = Representation::Integer32(); |
4946 HArithmeticBinaryOperation::UpdateRepresentation(new_rep, h_infer, reason); | 4917 HArithmeticBinaryOperation::UpdateRepresentation(new_rep, h_infer, reason); |
4947 } | 4918 } |
4948 | 4919 |
4949 DECLARE_CONCRETE_INSTRUCTION(Div) | 4920 DECLARE_CONCRETE_INSTRUCTION(Div) |
4950 | 4921 |
4951 protected: | 4922 protected: |
4952 bool DataEquals(HValue* other) override { return true; } | 4923 bool DataEquals(HValue* other) override { return true; } |
4953 | 4924 |
4954 Range* InferRange(Zone* zone) override; | 4925 Range* InferRange(Zone* zone) override; |
4955 | 4926 |
4956 private: | 4927 private: |
4957 HDiv(HValue* context, HValue* left, HValue* right, Strength strength) | 4928 HDiv(HValue* context, HValue* left, HValue* right) |
4958 : HArithmeticBinaryOperation(context, left, right, strength) { | 4929 : HArithmeticBinaryOperation(context, left, right) { |
4959 SetFlag(kCanBeDivByZero); | 4930 SetFlag(kCanBeDivByZero); |
4960 SetFlag(kCanOverflow); | 4931 SetFlag(kCanOverflow); |
4961 } | 4932 } |
4962 }; | 4933 }; |
4963 | 4934 |
4964 | 4935 |
4965 class HMathMinMax final : public HArithmeticBinaryOperation { | 4936 class HMathMinMax final : public HArithmeticBinaryOperation { |
4966 public: | 4937 public: |
4967 enum Operation { kMathMin, kMathMax }; | 4938 enum Operation { kMathMin, kMathMax }; |
4968 | 4939 |
(...skipping 25 matching lines...) Expand all Loading... | |
4994 protected: | 4965 protected: |
4995 bool DataEquals(HValue* other) override { | 4966 bool DataEquals(HValue* other) override { |
4996 return other->IsMathMinMax() && | 4967 return other->IsMathMinMax() && |
4997 HMathMinMax::cast(other)->operation_ == operation_; | 4968 HMathMinMax::cast(other)->operation_ == operation_; |
4998 } | 4969 } |
4999 | 4970 |
5000 Range* InferRange(Zone* zone) override; | 4971 Range* InferRange(Zone* zone) override; |
5001 | 4972 |
5002 private: | 4973 private: |
5003 HMathMinMax(HValue* context, HValue* left, HValue* right, Operation op) | 4974 HMathMinMax(HValue* context, HValue* left, HValue* right, Operation op) |
5004 : HArithmeticBinaryOperation(context, left, right, Strength::WEAK), | 4975 : HArithmeticBinaryOperation(context, left, right), operation_(op) {} |
5005 operation_(op) {} | |
5006 | 4976 |
5007 Operation operation_; | 4977 Operation operation_; |
5008 }; | 4978 }; |
5009 | 4979 |
5010 | 4980 |
5011 class HBitwise final : public HBitwiseBinaryOperation { | 4981 class HBitwise final : public HBitwiseBinaryOperation { |
5012 public: | 4982 public: |
5013 static HInstruction* New(Isolate* isolate, Zone* zone, HValue* context, | 4983 static HInstruction* New(Isolate* isolate, Zone* zone, HValue* context, |
5014 Token::Value op, HValue* left, HValue* right, | 4984 Token::Value op, HValue* left, HValue* right); |
5015 Strength strength = Strength::WEAK); | |
5016 | 4985 |
5017 Token::Value op() const { return op_; } | 4986 Token::Value op() const { return op_; } |
5018 | 4987 |
5019 bool IsCommutative() const override { return true; } | 4988 bool IsCommutative() const override { return true; } |
5020 | 4989 |
5021 HValue* Canonicalize() override; | 4990 HValue* Canonicalize() override; |
5022 | 4991 |
5023 std::ostream& PrintDataTo(std::ostream& os) const override; // NOLINT | 4992 std::ostream& PrintDataTo(std::ostream& os) const override; // NOLINT |
5024 | 4993 |
5025 DECLARE_CONCRETE_INSTRUCTION(Bitwise) | 4994 DECLARE_CONCRETE_INSTRUCTION(Bitwise) |
5026 | 4995 |
5027 protected: | 4996 protected: |
5028 bool DataEquals(HValue* other) override { | 4997 bool DataEquals(HValue* other) override { |
5029 return op() == HBitwise::cast(other)->op(); | 4998 return op() == HBitwise::cast(other)->op(); |
5030 } | 4999 } |
5031 | 5000 |
5032 Range* InferRange(Zone* zone) override; | 5001 Range* InferRange(Zone* zone) override; |
5033 | 5002 |
5034 private: | 5003 private: |
5035 HBitwise(HValue* context, Token::Value op, HValue* left, HValue* right, | 5004 HBitwise(HValue* context, Token::Value op, HValue* left, HValue* right) |
5036 Strength strength) | 5005 : HBitwiseBinaryOperation(context, left, right), op_(op) { |
5037 : HBitwiseBinaryOperation(context, left, right, strength), op_(op) { | |
5038 DCHECK(op == Token::BIT_AND || op == Token::BIT_OR || op == Token::BIT_XOR); | 5006 DCHECK(op == Token::BIT_AND || op == Token::BIT_OR || op == Token::BIT_XOR); |
5039 // BIT_AND with a smi-range positive value will always unset the | 5007 // BIT_AND with a smi-range positive value will always unset the |
5040 // entire sign-extension of the smi-sign. | 5008 // entire sign-extension of the smi-sign. |
5041 if (op == Token::BIT_AND && | 5009 if (op == Token::BIT_AND && |
5042 ((left->IsConstant() && | 5010 ((left->IsConstant() && |
5043 left->representation().IsSmi() && | 5011 left->representation().IsSmi() && |
5044 HConstant::cast(left)->Integer32Value() >= 0) || | 5012 HConstant::cast(left)->Integer32Value() >= 0) || |
5045 (right->IsConstant() && | 5013 (right->IsConstant() && |
5046 right->representation().IsSmi() && | 5014 right->representation().IsSmi() && |
5047 HConstant::cast(right)->Integer32Value() >= 0))) { | 5015 HConstant::cast(right)->Integer32Value() >= 0))) { |
(...skipping 13 matching lines...) Expand all Loading... | |
5061 } | 5029 } |
5062 } | 5030 } |
5063 | 5031 |
5064 Token::Value op_; | 5032 Token::Value op_; |
5065 }; | 5033 }; |
5066 | 5034 |
5067 | 5035 |
5068 class HShl final : public HBitwiseBinaryOperation { | 5036 class HShl final : public HBitwiseBinaryOperation { |
5069 public: | 5037 public: |
5070 static HInstruction* New(Isolate* isolate, Zone* zone, HValue* context, | 5038 static HInstruction* New(Isolate* isolate, Zone* zone, HValue* context, |
5071 HValue* left, HValue* right, | 5039 HValue* left, HValue* right); |
5072 Strength strength = Strength::WEAK); | |
5073 | 5040 |
5074 Range* InferRange(Zone* zone) override; | 5041 Range* InferRange(Zone* zone) override; |
5075 | 5042 |
5076 void UpdateRepresentation(Representation new_rep, | 5043 void UpdateRepresentation(Representation new_rep, |
5077 HInferRepresentationPhase* h_infer, | 5044 HInferRepresentationPhase* h_infer, |
5078 const char* reason) override { | 5045 const char* reason) override { |
5079 if (new_rep.IsSmi() && | 5046 if (new_rep.IsSmi() && |
5080 !(right()->IsInteger32Constant() && | 5047 !(right()->IsInteger32Constant() && |
5081 right()->GetInteger32Constant() >= 0)) { | 5048 right()->GetInteger32Constant() >= 0)) { |
5082 new_rep = Representation::Integer32(); | 5049 new_rep = Representation::Integer32(); |
5083 } | 5050 } |
5084 HBitwiseBinaryOperation::UpdateRepresentation(new_rep, h_infer, reason); | 5051 HBitwiseBinaryOperation::UpdateRepresentation(new_rep, h_infer, reason); |
5085 } | 5052 } |
5086 | 5053 |
5087 DECLARE_CONCRETE_INSTRUCTION(Shl) | 5054 DECLARE_CONCRETE_INSTRUCTION(Shl) |
5088 | 5055 |
5089 protected: | 5056 protected: |
5090 bool DataEquals(HValue* other) override { return true; } | 5057 bool DataEquals(HValue* other) override { return true; } |
5091 | 5058 |
5092 private: | 5059 private: |
5093 HShl(HValue* context, HValue* left, HValue* right, Strength strength) | 5060 HShl(HValue* context, HValue* left, HValue* right) |
5094 : HBitwiseBinaryOperation(context, left, right, strength) {} | 5061 : HBitwiseBinaryOperation(context, left, right) {} |
5095 }; | 5062 }; |
5096 | 5063 |
5097 | 5064 |
5098 class HShr final : public HBitwiseBinaryOperation { | 5065 class HShr final : public HBitwiseBinaryOperation { |
5099 public: | 5066 public: |
5100 static HInstruction* New(Isolate* isolate, Zone* zone, HValue* context, | 5067 static HInstruction* New(Isolate* isolate, Zone* zone, HValue* context, |
5101 HValue* left, HValue* right, | 5068 HValue* left, HValue* right); |
5102 Strength strength = Strength::WEAK); | |
5103 | 5069 |
5104 bool TryDecompose(DecompositionResult* decomposition) override { | 5070 bool TryDecompose(DecompositionResult* decomposition) override { |
5105 if (right()->IsInteger32Constant()) { | 5071 if (right()->IsInteger32Constant()) { |
5106 if (decomposition->Apply(left(), 0, right()->GetInteger32Constant())) { | 5072 if (decomposition->Apply(left(), 0, right()->GetInteger32Constant())) { |
5107 // This is intended to look for HAdd and HSub, to handle compounds | 5073 // This is intended to look for HAdd and HSub, to handle compounds |
5108 // like ((base + offset) >> scale) with one single decomposition. | 5074 // like ((base + offset) >> scale) with one single decomposition. |
5109 left()->TryDecompose(decomposition); | 5075 left()->TryDecompose(decomposition); |
5110 return true; | 5076 return true; |
5111 } | 5077 } |
5112 } | 5078 } |
5113 return false; | 5079 return false; |
5114 } | 5080 } |
5115 | 5081 |
5116 Range* InferRange(Zone* zone) override; | 5082 Range* InferRange(Zone* zone) override; |
5117 | 5083 |
5118 void UpdateRepresentation(Representation new_rep, | 5084 void UpdateRepresentation(Representation new_rep, |
5119 HInferRepresentationPhase* h_infer, | 5085 HInferRepresentationPhase* h_infer, |
5120 const char* reason) override { | 5086 const char* reason) override { |
5121 if (new_rep.IsSmi()) new_rep = Representation::Integer32(); | 5087 if (new_rep.IsSmi()) new_rep = Representation::Integer32(); |
5122 HBitwiseBinaryOperation::UpdateRepresentation(new_rep, h_infer, reason); | 5088 HBitwiseBinaryOperation::UpdateRepresentation(new_rep, h_infer, reason); |
5123 } | 5089 } |
5124 | 5090 |
5125 DECLARE_CONCRETE_INSTRUCTION(Shr) | 5091 DECLARE_CONCRETE_INSTRUCTION(Shr) |
5126 | 5092 |
5127 protected: | 5093 protected: |
5128 bool DataEquals(HValue* other) override { return true; } | 5094 bool DataEquals(HValue* other) override { return true; } |
5129 | 5095 |
5130 private: | 5096 private: |
5131 HShr(HValue* context, HValue* left, HValue* right, Strength strength) | 5097 HShr(HValue* context, HValue* left, HValue* right) |
5132 : HBitwiseBinaryOperation(context, left, right, strength) {} | 5098 : HBitwiseBinaryOperation(context, left, right) {} |
5133 }; | 5099 }; |
5134 | 5100 |
5135 | 5101 |
5136 class HSar final : public HBitwiseBinaryOperation { | 5102 class HSar final : public HBitwiseBinaryOperation { |
5137 public: | 5103 public: |
5138 static HInstruction* New(Isolate* isolate, Zone* zone, HValue* context, | 5104 static HInstruction* New(Isolate* isolate, Zone* zone, HValue* context, |
5139 HValue* left, HValue* right, | 5105 HValue* left, HValue* right); |
5140 Strength strength = Strength::WEAK); | |
5141 | 5106 |
5142 bool TryDecompose(DecompositionResult* decomposition) override { | 5107 bool TryDecompose(DecompositionResult* decomposition) override { |
5143 if (right()->IsInteger32Constant()) { | 5108 if (right()->IsInteger32Constant()) { |
5144 if (decomposition->Apply(left(), 0, right()->GetInteger32Constant())) { | 5109 if (decomposition->Apply(left(), 0, right()->GetInteger32Constant())) { |
5145 // This is intended to look for HAdd and HSub, to handle compounds | 5110 // This is intended to look for HAdd and HSub, to handle compounds |
5146 // like ((base + offset) >> scale) with one single decomposition. | 5111 // like ((base + offset) >> scale) with one single decomposition. |
5147 left()->TryDecompose(decomposition); | 5112 left()->TryDecompose(decomposition); |
5148 return true; | 5113 return true; |
5149 } | 5114 } |
5150 } | 5115 } |
5151 return false; | 5116 return false; |
5152 } | 5117 } |
5153 | 5118 |
5154 Range* InferRange(Zone* zone) override; | 5119 Range* InferRange(Zone* zone) override; |
5155 | 5120 |
5156 void UpdateRepresentation(Representation new_rep, | 5121 void UpdateRepresentation(Representation new_rep, |
5157 HInferRepresentationPhase* h_infer, | 5122 HInferRepresentationPhase* h_infer, |
5158 const char* reason) override { | 5123 const char* reason) override { |
5159 if (new_rep.IsSmi()) new_rep = Representation::Integer32(); | 5124 if (new_rep.IsSmi()) new_rep = Representation::Integer32(); |
5160 HBitwiseBinaryOperation::UpdateRepresentation(new_rep, h_infer, reason); | 5125 HBitwiseBinaryOperation::UpdateRepresentation(new_rep, h_infer, reason); |
5161 } | 5126 } |
5162 | 5127 |
5163 DECLARE_CONCRETE_INSTRUCTION(Sar) | 5128 DECLARE_CONCRETE_INSTRUCTION(Sar) |
5164 | 5129 |
5165 protected: | 5130 protected: |
5166 bool DataEquals(HValue* other) override { return true; } | 5131 bool DataEquals(HValue* other) override { return true; } |
5167 | 5132 |
5168 private: | 5133 private: |
5169 HSar(HValue* context, HValue* left, HValue* right, Strength strength) | 5134 HSar(HValue* context, HValue* left, HValue* right) |
5170 : HBitwiseBinaryOperation(context, left, right, strength) {} | 5135 : HBitwiseBinaryOperation(context, left, right) {} |
5171 }; | 5136 }; |
5172 | 5137 |
5173 | 5138 |
5174 class HRor final : public HBitwiseBinaryOperation { | 5139 class HRor final : public HBitwiseBinaryOperation { |
5175 public: | 5140 public: |
5176 static HInstruction* New(Isolate* isolate, Zone* zone, HValue* context, | 5141 static HInstruction* New(Isolate* isolate, Zone* zone, HValue* context, |
5177 HValue* left, HValue* right, | 5142 HValue* left, HValue* right) { |
5178 Strength strength = Strength::WEAK) { | 5143 return new (zone) HRor(context, left, right); |
5179 return new (zone) HRor(context, left, right, strength); | |
5180 } | 5144 } |
5181 | 5145 |
5182 void UpdateRepresentation(Representation new_rep, | 5146 void UpdateRepresentation(Representation new_rep, |
5183 HInferRepresentationPhase* h_infer, | 5147 HInferRepresentationPhase* h_infer, |
5184 const char* reason) override { | 5148 const char* reason) override { |
5185 if (new_rep.IsSmi()) new_rep = Representation::Integer32(); | 5149 if (new_rep.IsSmi()) new_rep = Representation::Integer32(); |
5186 HBitwiseBinaryOperation::UpdateRepresentation(new_rep, h_infer, reason); | 5150 HBitwiseBinaryOperation::UpdateRepresentation(new_rep, h_infer, reason); |
5187 } | 5151 } |
5188 | 5152 |
5189 DECLARE_CONCRETE_INSTRUCTION(Ror) | 5153 DECLARE_CONCRETE_INSTRUCTION(Ror) |
5190 | 5154 |
5191 protected: | 5155 protected: |
5192 bool DataEquals(HValue* other) override { return true; } | 5156 bool DataEquals(HValue* other) override { return true; } |
5193 | 5157 |
5194 private: | 5158 private: |
5195 HRor(HValue* context, HValue* left, HValue* right, Strength strength) | 5159 HRor(HValue* context, HValue* left, HValue* right) |
5196 : HBitwiseBinaryOperation(context, left, right, strength) { | 5160 : HBitwiseBinaryOperation(context, left, right) { |
5197 ChangeRepresentation(Representation::Integer32()); | 5161 ChangeRepresentation(Representation::Integer32()); |
5198 } | 5162 } |
5199 }; | 5163 }; |
5200 | 5164 |
5201 | 5165 |
5202 class HOsrEntry final : public HTemplateInstruction<0> { | 5166 class HOsrEntry final : public HTemplateInstruction<0> { |
5203 public: | 5167 public: |
5204 DECLARE_INSTRUCTION_FACTORY_P1(HOsrEntry, BailoutId); | 5168 DECLARE_INSTRUCTION_FACTORY_P1(HOsrEntry, BailoutId); |
5205 | 5169 |
5206 BailoutId ast_id() const { return ast_id_; } | 5170 BailoutId ast_id() const { return ast_id_; } |
(...skipping 2044 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7251 protected: | 7215 protected: |
7252 bool DataEquals(HValue* other) override { | 7216 bool DataEquals(HValue* other) override { |
7253 return flags_ == HStringAdd::cast(other)->flags_ && | 7217 return flags_ == HStringAdd::cast(other)->flags_ && |
7254 pretenure_flag_ == HStringAdd::cast(other)->pretenure_flag_; | 7218 pretenure_flag_ == HStringAdd::cast(other)->pretenure_flag_; |
7255 } | 7219 } |
7256 | 7220 |
7257 private: | 7221 private: |
7258 HStringAdd(HValue* context, HValue* left, HValue* right, | 7222 HStringAdd(HValue* context, HValue* left, HValue* right, |
7259 PretenureFlag pretenure_flag, StringAddFlags flags, | 7223 PretenureFlag pretenure_flag, StringAddFlags flags, |
7260 Handle<AllocationSite> allocation_site) | 7224 Handle<AllocationSite> allocation_site) |
7261 : HBinaryOperation(context, left, right, Strength::WEAK, HType::String()), | 7225 : HBinaryOperation(context, left, right, HType::String()), |
7262 flags_(flags), | 7226 flags_(flags), |
7263 pretenure_flag_(pretenure_flag) { | 7227 pretenure_flag_(pretenure_flag) { |
7264 set_representation(Representation::Tagged()); | 7228 set_representation(Representation::Tagged()); |
7265 if ((flags & STRING_ADD_CONVERT) == STRING_ADD_CONVERT) { | 7229 if ((flags & STRING_ADD_CONVERT) == STRING_ADD_CONVERT) { |
7266 SetAllSideEffects(); | 7230 SetAllSideEffects(); |
7267 ClearFlag(kUseGVN); | 7231 ClearFlag(kUseGVN); |
7268 } else { | 7232 } else { |
7269 SetChangesFlag(kNewSpacePromotion); | 7233 SetChangesFlag(kNewSpacePromotion); |
7270 SetFlag(kUseGVN); | 7234 SetFlag(kUseGVN); |
7271 } | 7235 } |
(...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
7769 | 7733 |
7770 | 7734 |
7771 | 7735 |
7772 #undef DECLARE_INSTRUCTION | 7736 #undef DECLARE_INSTRUCTION |
7773 #undef DECLARE_CONCRETE_INSTRUCTION | 7737 #undef DECLARE_CONCRETE_INSTRUCTION |
7774 | 7738 |
7775 } // namespace internal | 7739 } // namespace internal |
7776 } // namespace v8 | 7740 } // namespace v8 |
7777 | 7741 |
7778 #endif // V8_CRANKSHAFT_HYDROGEN_INSTRUCTIONS_H_ | 7742 #endif // V8_CRANKSHAFT_HYDROGEN_INSTRUCTIONS_H_ |
OLD | NEW |