| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 V(Change) \ | 90 V(Change) \ |
| 91 V(CheckFunction) \ | 91 V(CheckFunction) \ |
| 92 V(CheckHeapObject) \ | 92 V(CheckHeapObject) \ |
| 93 V(CheckInstanceType) \ | 93 V(CheckInstanceType) \ |
| 94 V(CheckMaps) \ | 94 V(CheckMaps) \ |
| 95 V(CheckMapValue) \ | 95 V(CheckMapValue) \ |
| 96 V(CheckSmi) \ | 96 V(CheckSmi) \ |
| 97 V(ClampToUint8) \ | 97 V(ClampToUint8) \ |
| 98 V(ClassOfTestAndBranch) \ | 98 V(ClassOfTestAndBranch) \ |
| 99 V(CompareNumericAndBranch) \ | 99 V(CompareNumericAndBranch) \ |
| 100 V(CompareHoleAndBranch) \ |
| 100 V(CompareGeneric) \ | 101 V(CompareGeneric) \ |
| 101 V(CompareObjectEqAndBranch) \ | 102 V(CompareObjectEqAndBranch) \ |
| 102 V(CompareMap) \ | 103 V(CompareMap) \ |
| 103 V(Constant) \ | 104 V(Constant) \ |
| 104 V(Context) \ | 105 V(Context) \ |
| 105 V(DateField) \ | 106 V(DateField) \ |
| 106 V(DebugBreak) \ | 107 V(DebugBreak) \ |
| 107 V(DeclareGlobals) \ | 108 V(DeclareGlobals) \ |
| 108 V(Deoptimize) \ | 109 V(Deoptimize) \ |
| 109 V(Div) \ | 110 V(Div) \ |
| (...skipping 685 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 795 | 796 |
| 796 // Mark this HValue as dead and to be removed from other HValues' use lists. | 797 // Mark this HValue as dead and to be removed from other HValues' use lists. |
| 797 void Kill(); | 798 void Kill(); |
| 798 | 799 |
| 799 int flags() const { return flags_; } | 800 int flags() const { return flags_; } |
| 800 void SetFlag(Flag f) { flags_ |= (1 << f); } | 801 void SetFlag(Flag f) { flags_ |= (1 << f); } |
| 801 void ClearFlag(Flag f) { flags_ &= ~(1 << f); } | 802 void ClearFlag(Flag f) { flags_ &= ~(1 << f); } |
| 802 bool CheckFlag(Flag f) const { return (flags_ & (1 << f)) != 0; } | 803 bool CheckFlag(Flag f) const { return (flags_ & (1 << f)) != 0; } |
| 803 | 804 |
| 804 // Returns true if the flag specified is set for all uses, false otherwise. | 805 // Returns true if the flag specified is set for all uses, false otherwise. |
| 805 bool CheckUsesForFlag(Flag f); | 806 bool CheckUsesForFlag(Flag f) const; |
| 806 // Returns true if the flag specified is set for all uses, and this set | 807 // Returns true if the flag specified is set for all uses, and this set |
| 807 // of uses is non-empty. | 808 // of uses is non-empty. |
| 808 bool HasAtLeastOneUseWithFlagAndNoneWithout(Flag f); | 809 bool HasAtLeastOneUseWithFlagAndNoneWithout(Flag f) const; |
| 809 | 810 |
| 810 GVNFlagSet gvn_flags() const { return gvn_flags_; } | 811 GVNFlagSet gvn_flags() const { return gvn_flags_; } |
| 811 void SetGVNFlag(GVNFlag f) { gvn_flags_.Add(f); } | 812 void SetGVNFlag(GVNFlag f) { gvn_flags_.Add(f); } |
| 812 void ClearGVNFlag(GVNFlag f) { gvn_flags_.Remove(f); } | 813 void ClearGVNFlag(GVNFlag f) { gvn_flags_.Remove(f); } |
| 813 bool CheckGVNFlag(GVNFlag f) const { return gvn_flags_.Contains(f); } | 814 bool CheckGVNFlag(GVNFlag f) const { return gvn_flags_.Contains(f); } |
| 814 void SetAllSideEffects() { gvn_flags_.Add(AllSideEffectsFlagSet()); } | 815 void SetAllSideEffects() { gvn_flags_.Add(AllSideEffectsFlagSet()); } |
| 815 void ClearAllSideEffects() { | 816 void ClearAllSideEffects() { |
| 816 gvn_flags_.Remove(AllSideEffectsFlagSet()); | 817 gvn_flags_.Remove(AllSideEffectsFlagSet()); |
| 817 } | 818 } |
| 818 bool HasSideEffects() const { | 819 bool HasSideEffects() const { |
| (...skipping 692 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1511 set_representation(required_representation); | 1512 set_representation(required_representation); |
| 1512 } | 1513 } |
| 1513 }; | 1514 }; |
| 1514 | 1515 |
| 1515 | 1516 |
| 1516 class HChange: public HUnaryOperation { | 1517 class HChange: public HUnaryOperation { |
| 1517 public: | 1518 public: |
| 1518 HChange(HValue* value, | 1519 HChange(HValue* value, |
| 1519 Representation to, | 1520 Representation to, |
| 1520 bool is_truncating_to_smi, | 1521 bool is_truncating_to_smi, |
| 1521 bool is_truncating_to_int32, | 1522 bool is_truncating_to_int32) |
| 1522 bool allow_undefined_as_nan) | |
| 1523 : HUnaryOperation(value) { | 1523 : HUnaryOperation(value) { |
| 1524 ASSERT(!value->representation().IsNone()); | 1524 ASSERT(!value->representation().IsNone()); |
| 1525 ASSERT(!to.IsNone()); | 1525 ASSERT(!to.IsNone()); |
| 1526 ASSERT(!value->representation().Equals(to)); | 1526 ASSERT(!value->representation().Equals(to)); |
| 1527 set_representation(to); | 1527 set_representation(to); |
| 1528 SetFlag(kUseGVN); | 1528 SetFlag(kUseGVN); |
| 1529 if (allow_undefined_as_nan) SetFlag(kAllowUndefinedAsNaN); | |
| 1530 if (is_truncating_to_smi) SetFlag(kTruncatingToSmi); | 1529 if (is_truncating_to_smi) SetFlag(kTruncatingToSmi); |
| 1531 if (is_truncating_to_int32) SetFlag(kTruncatingToInt32); | 1530 if (is_truncating_to_int32) SetFlag(kTruncatingToInt32); |
| 1532 if (value->representation().IsSmi() || value->type().IsSmi()) { | 1531 if (value->representation().IsSmi() || value->type().IsSmi()) { |
| 1533 set_type(HType::Smi()); | 1532 set_type(HType::Smi()); |
| 1534 } else { | 1533 } else { |
| 1535 set_type(HType::TaggedNumber()); | 1534 set_type(HType::TaggedNumber()); |
| 1536 if (to.IsTagged()) SetGVNFlag(kChangesNewSpacePromotion); | 1535 if (to.IsTagged()) SetGVNFlag(kChangesNewSpacePromotion); |
| 1537 } | 1536 } |
| 1538 } | 1537 } |
| 1539 | 1538 |
| 1539 bool can_convert_undefined_to_nan() { |
| 1540 return CheckUsesForFlag(kAllowUndefinedAsNaN); |
| 1541 } |
| 1542 |
| 1540 virtual HValue* EnsureAndPropagateNotMinusZero(BitVector* visited); | 1543 virtual HValue* EnsureAndPropagateNotMinusZero(BitVector* visited); |
| 1541 virtual HType CalculateInferredType(); | 1544 virtual HType CalculateInferredType(); |
| 1542 virtual HValue* Canonicalize(); | 1545 virtual HValue* Canonicalize(); |
| 1543 | 1546 |
| 1544 Representation from() const { return value()->representation(); } | 1547 Representation from() const { return value()->representation(); } |
| 1545 Representation to() const { return representation(); } | 1548 Representation to() const { return representation(); } |
| 1546 bool allow_undefined_as_nan() const { | |
| 1547 return CheckFlag(kAllowUndefinedAsNaN); | |
| 1548 } | |
| 1549 bool deoptimize_on_minus_zero() const { | 1549 bool deoptimize_on_minus_zero() const { |
| 1550 return CheckFlag(kBailoutOnMinusZero); | 1550 return CheckFlag(kBailoutOnMinusZero); |
| 1551 } | 1551 } |
| 1552 virtual Representation RequiredInputRepresentation(int index) { | 1552 virtual Representation RequiredInputRepresentation(int index) { |
| 1553 return from(); | 1553 return from(); |
| 1554 } | 1554 } |
| 1555 | 1555 |
| 1556 virtual Range* InferRange(Zone* zone); | 1556 virtual Range* InferRange(Zone* zone); |
| 1557 | 1557 |
| 1558 virtual void PrintDataTo(StringStream* stream); | 1558 virtual void PrintDataTo(StringStream* stream); |
| (...skipping 2379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3938 virtual void PrintDataTo(StringStream* stream); | 3938 virtual void PrintDataTo(StringStream* stream); |
| 3939 | 3939 |
| 3940 DECLARE_CONCRETE_INSTRUCTION(CompareNumericAndBranch) | 3940 DECLARE_CONCRETE_INSTRUCTION(CompareNumericAndBranch) |
| 3941 | 3941 |
| 3942 private: | 3942 private: |
| 3943 Representation observed_input_representation_[2]; | 3943 Representation observed_input_representation_[2]; |
| 3944 Token::Value token_; | 3944 Token::Value token_; |
| 3945 }; | 3945 }; |
| 3946 | 3946 |
| 3947 | 3947 |
| 3948 class HCompareHoleAndBranch: public HTemplateControlInstruction<2, 1> { |
| 3949 public: |
| 3950 // TODO(danno): make this private when the IfBuilder properly constructs |
| 3951 // control flow instructions. |
| 3952 explicit HCompareHoleAndBranch(HValue* object) { |
| 3953 SetFlag(kFlexibleRepresentation); |
| 3954 SetFlag(kAllowUndefinedAsNaN); |
| 3955 SetOperandAt(0, object); |
| 3956 } |
| 3957 |
| 3958 DECLARE_INSTRUCTION_FACTORY_P1(HCompareHoleAndBranch, HValue*); |
| 3959 |
| 3960 HValue* object() { return OperandAt(0); } |
| 3961 |
| 3962 virtual void InferRepresentation(HInferRepresentationPhase* h_infer); |
| 3963 |
| 3964 virtual Representation RequiredInputRepresentation(int index) { |
| 3965 return representation(); |
| 3966 } |
| 3967 |
| 3968 virtual void PrintDataTo(StringStream* stream); |
| 3969 |
| 3970 DECLARE_CONCRETE_INSTRUCTION(CompareHoleAndBranch) |
| 3971 }; |
| 3972 |
| 3973 |
| 3948 class HCompareObjectEqAndBranch: public HTemplateControlInstruction<2, 2> { | 3974 class HCompareObjectEqAndBranch: public HTemplateControlInstruction<2, 2> { |
| 3949 public: | 3975 public: |
| 3950 // TODO(danno): make this private when the IfBuilder properly constructs | 3976 // TODO(danno): make this private when the IfBuilder properly constructs |
| 3951 // control flow instructions. | 3977 // control flow instructions. |
| 3952 HCompareObjectEqAndBranch(HValue* left, | 3978 HCompareObjectEqAndBranch(HValue* left, |
| 3953 HValue* right) { | 3979 HValue* right) { |
| 3954 SetOperandAt(0, left); | 3980 SetOperandAt(0, left); |
| 3955 SetOperandAt(1, right); | 3981 SetOperandAt(1, right); |
| 3956 } | 3982 } |
| 3957 | 3983 |
| (...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4321 decomposition->Apply(right(), left()->GetInteger32Constant()); | 4347 decomposition->Apply(right(), left()->GetInteger32Constant()); |
| 4322 return true; | 4348 return true; |
| 4323 } else if (right()->IsInteger32Constant()) { | 4349 } else if (right()->IsInteger32Constant()) { |
| 4324 decomposition->Apply(left(), right()->GetInteger32Constant()); | 4350 decomposition->Apply(left(), right()->GetInteger32Constant()); |
| 4325 return true; | 4351 return true; |
| 4326 } else { | 4352 } else { |
| 4327 return false; | 4353 return false; |
| 4328 } | 4354 } |
| 4329 } | 4355 } |
| 4330 | 4356 |
| 4357 virtual void RepresentationChanged(Representation to) { |
| 4358 if (to.IsTagged()) ClearFlag(kAllowUndefinedAsNaN); |
| 4359 HArithmeticBinaryOperation::RepresentationChanged(to); |
| 4360 } |
| 4361 |
| 4331 DECLARE_CONCRETE_INSTRUCTION(Add) | 4362 DECLARE_CONCRETE_INSTRUCTION(Add) |
| 4332 | 4363 |
| 4333 protected: | 4364 protected: |
| 4334 virtual bool DataEquals(HValue* other) { return true; } | 4365 virtual bool DataEquals(HValue* other) { return true; } |
| 4335 | 4366 |
| 4336 virtual Range* InferRange(Zone* zone); | 4367 virtual Range* InferRange(Zone* zone); |
| 4337 | 4368 |
| 4338 private: | 4369 private: |
| 4339 HAdd(HValue* context, HValue* left, HValue* right) | 4370 HAdd(HValue* context, HValue* left, HValue* right) |
| 4340 : HArithmeticBinaryOperation(context, left, right) { | 4371 : HArithmeticBinaryOperation(context, left, right) { |
| (...skipping 2437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6778 virtual bool IsDeletable() const { return true; } | 6809 virtual bool IsDeletable() const { return true; } |
| 6779 }; | 6810 }; |
| 6780 | 6811 |
| 6781 | 6812 |
| 6782 #undef DECLARE_INSTRUCTION | 6813 #undef DECLARE_INSTRUCTION |
| 6783 #undef DECLARE_CONCRETE_INSTRUCTION | 6814 #undef DECLARE_CONCRETE_INSTRUCTION |
| 6784 | 6815 |
| 6785 } } // namespace v8::internal | 6816 } } // namespace v8::internal |
| 6786 | 6817 |
| 6787 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ | 6818 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ |
| OLD | NEW |