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 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 V(LoadKeyed) \ | 140 V(LoadKeyed) \ |
141 V(LoadKeyedGeneric) \ | 141 V(LoadKeyedGeneric) \ |
142 V(LoadNamedField) \ | 142 V(LoadNamedField) \ |
143 V(LoadNamedFieldPolymorphic) \ | 143 V(LoadNamedFieldPolymorphic) \ |
144 V(LoadNamedGeneric) \ | 144 V(LoadNamedGeneric) \ |
145 V(MapEnumLength) \ | 145 V(MapEnumLength) \ |
146 V(MathFloorOfDiv) \ | 146 V(MathFloorOfDiv) \ |
147 V(MathMinMax) \ | 147 V(MathMinMax) \ |
148 V(Mod) \ | 148 V(Mod) \ |
149 V(Mul) \ | 149 V(Mul) \ |
| 150 V(NumericConstraint) \ |
150 V(ObjectLiteral) \ | 151 V(ObjectLiteral) \ |
151 V(OsrEntry) \ | 152 V(OsrEntry) \ |
152 V(OuterContext) \ | 153 V(OuterContext) \ |
153 V(Parameter) \ | 154 V(Parameter) \ |
154 V(Power) \ | 155 V(Power) \ |
155 V(PushArgument) \ | 156 V(PushArgument) \ |
156 V(Random) \ | 157 V(Random) \ |
157 V(RegExpLiteral) \ | 158 V(RegExpLiteral) \ |
158 V(Return) \ | 159 V(Return) \ |
159 V(Ror) \ | 160 V(Ror) \ |
(...skipping 546 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
706 | 707 |
707 virtual void AddInformativeDefinitions() {} | 708 virtual void AddInformativeDefinitions() {} |
708 | 709 |
709 void UpdateRedefinedUsesWhileSettingUpInformativeDefinitions() { | 710 void UpdateRedefinedUsesWhileSettingUpInformativeDefinitions() { |
710 UpdateRedefinedUsesInner<TestDominanceUsingProcessedFlag>(); | 711 UpdateRedefinedUsesInner<TestDominanceUsingProcessedFlag>(); |
711 } | 712 } |
712 void UpdateRedefinedUses() { | 713 void UpdateRedefinedUses() { |
713 UpdateRedefinedUsesInner<Dominates>(); | 714 UpdateRedefinedUsesInner<Dominates>(); |
714 } | 715 } |
715 | 716 |
| 717 bool IsInteger32Constant(); |
| 718 int32_t GetInteger32Constant(); |
| 719 |
716 bool IsDefinedAfter(HBasicBlock* other) const; | 720 bool IsDefinedAfter(HBasicBlock* other) const; |
717 | 721 |
718 // Operands. | 722 // Operands. |
719 virtual int OperandCount() = 0; | 723 virtual int OperandCount() = 0; |
720 virtual HValue* OperandAt(int index) const = 0; | 724 virtual HValue* OperandAt(int index) const = 0; |
721 void SetOperandAt(int index, HValue* value); | 725 void SetOperandAt(int index, HValue* value); |
722 | 726 |
723 void DeleteAndReplaceWith(HValue* other); | 727 void DeleteAndReplaceWith(HValue* other); |
724 void ReplaceAllUsesWith(HValue* other); | 728 void ReplaceAllUsesWith(HValue* other); |
725 bool HasNoUses() const { return use_list_ == NULL; } | 729 bool HasNoUses() const { return use_list_ == NULL; } |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
832 } | 836 } |
833 | 837 |
834 bool IsDead() const { | 838 bool IsDead() const { |
835 return HasNoUses() && !HasObservableSideEffects() && IsDeletable(); | 839 return HasNoUses() && !HasObservableSideEffects() && IsDeletable(); |
836 } | 840 } |
837 | 841 |
838 #ifdef DEBUG | 842 #ifdef DEBUG |
839 virtual void Verify() = 0; | 843 virtual void Verify() = 0; |
840 #endif | 844 #endif |
841 | 845 |
| 846 class NumericRelation { |
| 847 public: |
| 848 enum Kind { NONE, EQ, GT, GE, LT, LE, NE }; |
| 849 static const char* MnemonicFromKind(Kind kind) { |
| 850 switch (kind) { |
| 851 case NONE: return "NONE"; |
| 852 case EQ: return "EQ"; |
| 853 case GT: return "GT"; |
| 854 case GE: return "GE"; |
| 855 case LT: return "LT"; |
| 856 case LE: return "LE"; |
| 857 case NE: return "NE"; |
| 858 } |
| 859 UNREACHABLE(); |
| 860 return NULL; |
| 861 } |
| 862 const char* Mnemonic() const { return MnemonicFromKind((Kind) kind_); } |
| 863 |
| 864 static NumericRelation None() { return NumericRelation(NONE); } |
| 865 static NumericRelation Eq() { return NumericRelation(EQ); } |
| 866 static NumericRelation Gt() { return NumericRelation(GT); } |
| 867 static NumericRelation Ge() { return NumericRelation(GE); } |
| 868 static NumericRelation Lt() { return NumericRelation(LT); } |
| 869 static NumericRelation Le() { return NumericRelation(LE); } |
| 870 static NumericRelation Ne() { return NumericRelation(NE); } |
| 871 |
| 872 bool operator==(const NumericRelation& other) { |
| 873 return kind_ == other.kind_; |
| 874 } |
| 875 bool operator!=(const NumericRelation& other) { |
| 876 return kind_ != other.kind_; |
| 877 } |
| 878 |
| 879 // The semantics of "Reversed" is that if "x rel y" is true then also |
| 880 // "y rel.Reversed() x" is true, and that rel.Reversed().Reversed() == rel. |
| 881 NumericRelation Reversed() { |
| 882 switch (kind_) { |
| 883 case NONE: return None(); |
| 884 case EQ: return Eq(); |
| 885 case GT: return Lt(); |
| 886 case GE: return Le(); |
| 887 case LT: return Gt(); |
| 888 case LE: return Ge(); |
| 889 case NE: return Ne(); |
| 890 } |
| 891 UNREACHABLE(); |
| 892 return None(); |
| 893 } |
| 894 |
| 895 // The semantics of "Implies" is that if "x rel y" is true |
| 896 // then also "x other_relation y" is true. |
| 897 bool Implies(NumericRelation other_relation) { |
| 898 switch (kind_) { |
| 899 case NONE: return false; |
| 900 case EQ: return (other_relation.kind_ == EQ) |
| 901 || (other_relation.kind_ == GE) |
| 902 || (other_relation.kind_ == LE); |
| 903 case GT: return (other_relation.kind_ == GT) |
| 904 || (other_relation.kind_ == GE) |
| 905 || (other_relation.kind_ == NE); |
| 906 case LT: return (other_relation.kind_ == LT) |
| 907 || (other_relation.kind_ == LE) |
| 908 || (other_relation.kind_ == NE); |
| 909 case GE: return (other_relation.kind_ == GE); |
| 910 case LE: return (other_relation.kind_ == LE); |
| 911 case NE: return (other_relation.kind_ == NE); |
| 912 default: |
| 913 UNREACHABLE(); |
| 914 return false; |
| 915 } |
| 916 } |
| 917 |
| 918 // The semantics of "IsExtendable" is that if |
| 919 // "rel.IsExtendable(direction) is true" then |
| 920 // "x rel y" implies "(x + direction) rel y" . |
| 921 bool IsExtendable(int direction) { |
| 922 switch (kind_) { |
| 923 case NONE: return false; |
| 924 case EQ: return false; |
| 925 case GT: return (direction >= 0); |
| 926 case GE: return (direction >= 0); |
| 927 case LT: return (direction <= 0); |
| 928 case LE: return (direction <= 0); |
| 929 case NE: return false; |
| 930 } |
| 931 UNREACHABLE(); |
| 932 return false; |
| 933 } |
| 934 |
| 935 private: |
| 936 explicit NumericRelation(Kind kind) : kind_(kind) {} |
| 937 |
| 938 Kind kind_; |
| 939 }; |
| 940 |
| 941 // This method is recursive but it is guaranteed to terminate because |
| 942 // RedefinedOperand() always dominates "this". |
| 943 bool IsRelationTrue(NumericRelation relation, HValue* other) { |
| 944 if (this == other) { |
| 945 return NumericRelation::Eq().Implies(relation); |
| 946 } |
| 947 |
| 948 bool result = CheckRelation(relation, other) || |
| 949 other->CheckRelation(relation.Reversed(), this); |
| 950 if (!result) { |
| 951 HValue* redefined = RedefinedOperand(); |
| 952 if (redefined != NULL) { |
| 953 result = redefined->IsRelationTrue(relation, other); |
| 954 } |
| 955 } |
| 956 return result; |
| 957 } |
| 958 |
| 959 HValue* AddNumericConstraint(HInstruction* insertion_point, |
| 960 HValue* related_value, |
| 961 NumericRelation relation); |
| 962 |
842 protected: | 963 protected: |
843 // This function must be overridden for instructions with flag kUseGVN, to | 964 // This function must be overridden for instructions with flag kUseGVN, to |
844 // compare the non-Operand parts of the instruction. | 965 // compare the non-Operand parts of the instruction. |
845 virtual bool DataEquals(HValue* other) { | 966 virtual bool DataEquals(HValue* other) { |
846 UNREACHABLE(); | 967 UNREACHABLE(); |
847 return false; | 968 return false; |
848 } | 969 } |
849 | 970 |
850 virtual Representation RepresentationFromInputs() { | 971 virtual Representation RepresentationFromInputs() { |
851 return representation(); | 972 return representation(); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
894 if (input != NULL) { | 1015 if (input != NULL) { |
895 for (HUseIterator uses = input->uses(); !uses.Done(); uses.Advance()) { | 1016 for (HUseIterator uses = input->uses(); !uses.Done(); uses.Advance()) { |
896 HValue* use = uses.value(); | 1017 HValue* use = uses.value(); |
897 if (TestDominance(this, use)) { | 1018 if (TestDominance(this, use)) { |
898 use->SetOperandAt(uses.index(), this); | 1019 use->SetOperandAt(uses.index(), this); |
899 } | 1020 } |
900 } | 1021 } |
901 } | 1022 } |
902 } | 1023 } |
903 | 1024 |
| 1025 // Informative definitions can override this method to state any numeric |
| 1026 // relation they provide on the redefined value. |
| 1027 virtual bool CheckRelation(NumericRelation relation, HValue* other) { |
| 1028 return false; |
| 1029 } |
| 1030 |
904 static GVNFlagSet AllDependsOnFlagSet() { | 1031 static GVNFlagSet AllDependsOnFlagSet() { |
905 GVNFlagSet result; | 1032 GVNFlagSet result; |
906 // Create changes mask. | 1033 // Create changes mask. |
907 #define ADD_FLAG(type) result.Add(kDependsOn##type); | 1034 #define ADD_FLAG(type) result.Add(kDependsOn##type); |
908 GVN_TRACKED_FLAG_LIST(ADD_FLAG) | 1035 GVN_TRACKED_FLAG_LIST(ADD_FLAG) |
909 GVN_UNTRACKED_FLAG_LIST(ADD_FLAG) | 1036 GVN_UNTRACKED_FLAG_LIST(ADD_FLAG) |
910 #undef ADD_FLAG | 1037 #undef ADD_FLAG |
911 return result; | 1038 return result; |
912 } | 1039 } |
913 | 1040 |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1118 virtual Representation RequiredInputRepresentation(int index) { | 1245 virtual Representation RequiredInputRepresentation(int index) { |
1119 return Representation::None(); | 1246 return Representation::None(); |
1120 } | 1247 } |
1121 | 1248 |
1122 virtual void PrintDataTo(StringStream* stream); | 1249 virtual void PrintDataTo(StringStream* stream); |
1123 | 1250 |
1124 DECLARE_CONCRETE_INSTRUCTION(DummyUse); | 1251 DECLARE_CONCRETE_INSTRUCTION(DummyUse); |
1125 }; | 1252 }; |
1126 | 1253 |
1127 | 1254 |
| 1255 class HNumericConstraint : public HTemplateInstruction<2> { |
| 1256 public: |
| 1257 static HNumericConstraint* New(HInstruction* insertion_point, |
| 1258 HValue* constrained_value, |
| 1259 HValue* related_value, |
| 1260 NumericRelation relation); |
| 1261 |
| 1262 HValue* constrained_value() { return OperandAt(0); } |
| 1263 HValue* related_value() { return OperandAt(1); } |
| 1264 NumericRelation relation() { return relation_; } |
| 1265 |
| 1266 virtual int RedefinedOperandIndex() { return 0; } |
| 1267 |
| 1268 virtual Representation RequiredInputRepresentation(int index) { |
| 1269 return constrained_value()->RequiredInputRepresentation(index); |
| 1270 } |
| 1271 |
| 1272 virtual void PrintDataTo(StringStream* stream); |
| 1273 |
| 1274 virtual bool CheckRelation(NumericRelation other_relation, |
| 1275 HValue* other_related_value) { |
| 1276 if (related_value() == other_related_value) { |
| 1277 return relation().Implies(other_relation); |
| 1278 } else { |
| 1279 return false; |
| 1280 } |
| 1281 } |
| 1282 |
| 1283 DECLARE_CONCRETE_INSTRUCTION(NumericConstraint) |
| 1284 |
| 1285 private: |
| 1286 explicit HNumericConstraint(HValue* constrained_value, |
| 1287 HValue* related_value, |
| 1288 NumericRelation relation) |
| 1289 : relation_(relation) { |
| 1290 SetOperandAt(0, constrained_value); |
| 1291 SetOperandAt(1, related_value); |
| 1292 set_representation(constrained_value->representation()); |
| 1293 } |
| 1294 |
| 1295 NumericRelation relation_; |
| 1296 }; |
| 1297 |
| 1298 |
1128 // We insert soft-deoptimize when we hit code with unknown typefeedback, | 1299 // We insert soft-deoptimize when we hit code with unknown typefeedback, |
1129 // so that we get a chance of re-optimizing with useful typefeedback. | 1300 // so that we get a chance of re-optimizing with useful typefeedback. |
1130 // HSoftDeoptimize does not end a basic block as opposed to HDeoptimize. | 1301 // HSoftDeoptimize does not end a basic block as opposed to HDeoptimize. |
1131 class HSoftDeoptimize: public HTemplateInstruction<0> { | 1302 class HSoftDeoptimize: public HTemplateInstruction<0> { |
1132 public: | 1303 public: |
1133 virtual Representation RequiredInputRepresentation(int index) { | 1304 virtual Representation RequiredInputRepresentation(int index) { |
1134 return Representation::None(); | 1305 return Representation::None(); |
1135 } | 1306 } |
1136 | 1307 |
1137 DECLARE_CONCRETE_INSTRUCTION(SoftDeoptimize) | 1308 DECLARE_CONCRETE_INSTRUCTION(SoftDeoptimize) |
(...skipping 1532 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2670 virtual int OperandCount() { return inputs_.length(); } | 2841 virtual int OperandCount() { return inputs_.length(); } |
2671 virtual HValue* OperandAt(int index) const { return inputs_[index]; } | 2842 virtual HValue* OperandAt(int index) const { return inputs_[index]; } |
2672 HValue* GetRedundantReplacement(); | 2843 HValue* GetRedundantReplacement(); |
2673 void AddInput(HValue* value); | 2844 void AddInput(HValue* value); |
2674 bool HasRealUses(); | 2845 bool HasRealUses(); |
2675 | 2846 |
2676 bool IsReceiver() { return merged_index_ == 0; } | 2847 bool IsReceiver() { return merged_index_ == 0; } |
2677 | 2848 |
2678 int merged_index() const { return merged_index_; } | 2849 int merged_index() const { return merged_index_; } |
2679 | 2850 |
| 2851 virtual void AddInformativeDefinitions(); |
| 2852 |
2680 virtual void PrintTo(StringStream* stream); | 2853 virtual void PrintTo(StringStream* stream); |
2681 | 2854 |
2682 #ifdef DEBUG | 2855 #ifdef DEBUG |
2683 virtual void Verify(); | 2856 virtual void Verify(); |
2684 #endif | 2857 #endif |
2685 | 2858 |
2686 void InitRealUses(int id); | 2859 void InitRealUses(int id); |
2687 void AddNonPhiUsesFrom(HPhi* other); | 2860 void AddNonPhiUsesFrom(HPhi* other); |
2688 void AddIndirectUsesTo(int* use_count); | 2861 void AddIndirectUsesTo(int* use_count); |
2689 | 2862 |
(...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3147 bool skip_check() { return skip_check_; } | 3320 bool skip_check() { return skip_check_; } |
3148 void set_skip_check(bool skip_check) { skip_check_ = skip_check; } | 3321 void set_skip_check(bool skip_check) { skip_check_ = skip_check; } |
3149 | 3322 |
3150 virtual Representation RequiredInputRepresentation(int arg_index) { | 3323 virtual Representation RequiredInputRepresentation(int arg_index) { |
3151 return representation(); | 3324 return representation(); |
3152 } | 3325 } |
3153 virtual Representation observed_input_representation(int index) { | 3326 virtual Representation observed_input_representation(int index) { |
3154 return Representation::Integer32(); | 3327 return Representation::Integer32(); |
3155 } | 3328 } |
3156 | 3329 |
| 3330 virtual bool CheckRelation(NumericRelation relation, HValue* related_value); |
| 3331 |
3157 virtual void PrintDataTo(StringStream* stream); | 3332 virtual void PrintDataTo(StringStream* stream); |
3158 virtual void InferRepresentation(HInferRepresentation* h_infer); | 3333 virtual void InferRepresentation(HInferRepresentation* h_infer); |
3159 | 3334 |
3160 HValue* index() { return OperandAt(0); } | 3335 HValue* index() { return OperandAt(0); } |
3161 HValue* length() { return OperandAt(1); } | 3336 HValue* length() { return OperandAt(1); } |
3162 | 3337 |
3163 virtual int RedefinedOperandIndex() { return 0; } | 3338 virtual int RedefinedOperandIndex() { return 0; } |
3164 | 3339 |
3165 DECLARE_CONCRETE_INSTRUCTION(BoundsCheck) | 3340 DECLARE_CONCRETE_INSTRUCTION(BoundsCheck) |
3166 | 3341 |
(...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3734 | 3909 |
3735 static HInstruction* NewHAdd(Zone* zone, | 3910 static HInstruction* NewHAdd(Zone* zone, |
3736 HValue* context, | 3911 HValue* context, |
3737 HValue* left, | 3912 HValue* left, |
3738 HValue* right); | 3913 HValue* right); |
3739 | 3914 |
3740 virtual HType CalculateInferredType(); | 3915 virtual HType CalculateInferredType(); |
3741 | 3916 |
3742 virtual HValue* Canonicalize(); | 3917 virtual HValue* Canonicalize(); |
3743 | 3918 |
| 3919 virtual bool CheckRelation(NumericRelation relation, HValue* other) { |
| 3920 HValue* base = NULL; |
| 3921 int32_t offset = 0; |
| 3922 if (left()->IsInteger32Constant()) { |
| 3923 base = right(); |
| 3924 offset = left()->GetInteger32Constant(); |
| 3925 } else if (right()->IsInteger32Constant()) { |
| 3926 base = left(); |
| 3927 offset = right()->GetInteger32Constant(); |
| 3928 } else { |
| 3929 return false; |
| 3930 } |
| 3931 |
| 3932 return relation.IsExtendable(offset) |
| 3933 ? base->IsRelationTrue(relation, other) : false; |
| 3934 } |
| 3935 |
3744 DECLARE_CONCRETE_INSTRUCTION(Add) | 3936 DECLARE_CONCRETE_INSTRUCTION(Add) |
3745 | 3937 |
3746 protected: | 3938 protected: |
3747 virtual bool DataEquals(HValue* other) { return true; } | 3939 virtual bool DataEquals(HValue* other) { return true; } |
3748 | 3940 |
3749 virtual Range* InferRange(Zone* zone); | 3941 virtual Range* InferRange(Zone* zone); |
3750 }; | 3942 }; |
3751 | 3943 |
3752 | 3944 |
3753 class HSub: public HArithmeticBinaryOperation { | 3945 class HSub: public HArithmeticBinaryOperation { |
3754 public: | 3946 public: |
3755 HSub(HValue* context, HValue* left, HValue* right) | 3947 HSub(HValue* context, HValue* left, HValue* right) |
3756 : HArithmeticBinaryOperation(context, left, right) { | 3948 : HArithmeticBinaryOperation(context, left, right) { |
3757 SetFlag(kCanOverflow); | 3949 SetFlag(kCanOverflow); |
3758 } | 3950 } |
3759 | 3951 |
3760 virtual HValue* EnsureAndPropagateNotMinusZero(BitVector* visited); | 3952 virtual HValue* EnsureAndPropagateNotMinusZero(BitVector* visited); |
3761 | 3953 |
3762 virtual HValue* Canonicalize(); | 3954 virtual HValue* Canonicalize(); |
3763 | 3955 |
3764 static HInstruction* NewHSub(Zone* zone, | 3956 static HInstruction* NewHSub(Zone* zone, |
3765 HValue* context, | 3957 HValue* context, |
3766 HValue* left, | 3958 HValue* left, |
3767 HValue* right); | 3959 HValue* right); |
3768 | 3960 |
| 3961 virtual bool CheckRelation(NumericRelation relation, HValue* other) { |
| 3962 if (right()->IsInteger32Constant()) { |
| 3963 HValue* base = left(); |
| 3964 int32_t offset = right()->GetInteger32Constant(); |
| 3965 return relation.IsExtendable(offset) |
| 3966 ? base->IsRelationTrue(relation, other) : false; |
| 3967 } else { |
| 3968 return false; |
| 3969 } |
| 3970 } |
| 3971 |
3769 DECLARE_CONCRETE_INSTRUCTION(Sub) | 3972 DECLARE_CONCRETE_INSTRUCTION(Sub) |
3770 | 3973 |
3771 protected: | 3974 protected: |
3772 virtual bool DataEquals(HValue* other) { return true; } | 3975 virtual bool DataEquals(HValue* other) { return true; } |
3773 | 3976 |
3774 virtual Range* InferRange(Zone* zone); | 3977 virtual Range* InferRange(Zone* zone); |
3775 }; | 3978 }; |
3776 | 3979 |
3777 | 3980 |
3778 class HMul: public HArithmeticBinaryOperation { | 3981 class HMul: public HArithmeticBinaryOperation { |
3779 public: | 3982 public: |
3780 HMul(HValue* context, HValue* left, HValue* right) | 3983 HMul(HValue* context, HValue* left, HValue* right) |
3781 : HArithmeticBinaryOperation(context, left, right) { | 3984 : HArithmeticBinaryOperation(context, left, right) { |
3782 SetFlag(kCanOverflow); | 3985 SetFlag(kCanOverflow); |
3783 } | 3986 } |
3784 | 3987 |
3785 virtual HValue* EnsureAndPropagateNotMinusZero(BitVector* visited); | 3988 virtual HValue* EnsureAndPropagateNotMinusZero(BitVector* visited); |
3786 | 3989 |
3787 // Only commutative if it is certain that not two objects are multiplicated. | 3990 // Only commutative if it is certain that not two objects are multiplicated. |
3788 virtual bool IsCommutative() const { | 3991 virtual bool IsCommutative() const { |
3789 return !representation().IsTagged(); | 3992 return !representation().IsTagged(); |
3790 } | 3993 } |
3791 | 3994 |
3792 static HInstruction* NewHMul(Zone* zone, | 3995 static HInstruction* NewHMul(Zone* zone, |
3793 HValue* context, | 3996 HValue* context, |
3794 HValue* left, | 3997 HValue* left, |
3795 HValue* right); | 3998 HValue* right); |
3796 | 3999 |
| 4000 // The idea is that "k > 1" implies that "base * k >= base". |
| 4001 virtual bool CheckRelation(NumericRelation relation, HValue* other) { |
| 4002 HValue* base = NULL; |
| 4003 int32_t k = 0; |
| 4004 if (left()->IsInteger32Constant()) { |
| 4005 base = right(); |
| 4006 k = left()->GetInteger32Constant(); |
| 4007 } else if (right()->IsInteger32Constant()) { |
| 4008 base = left(); |
| 4009 k = right()->GetInteger32Constant(); |
| 4010 } else { |
| 4011 return false; |
| 4012 } |
| 4013 |
| 4014 return (k > 1 && relation.IsExtendable(1)) |
| 4015 ? base->IsRelationTrue(relation, other) : false; |
| 4016 } |
| 4017 |
3797 DECLARE_CONCRETE_INSTRUCTION(Mul) | 4018 DECLARE_CONCRETE_INSTRUCTION(Mul) |
3798 | 4019 |
3799 protected: | 4020 protected: |
3800 virtual bool DataEquals(HValue* other) { return true; } | 4021 virtual bool DataEquals(HValue* other) { return true; } |
3801 | 4022 |
3802 virtual Range* InferRange(Zone* zone); | 4023 virtual Range* InferRange(Zone* zone); |
3803 }; | 4024 }; |
3804 | 4025 |
3805 | 4026 |
3806 class HMod: public HArithmeticBinaryOperation { | 4027 class HMod: public HArithmeticBinaryOperation { |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3960 HShl(HValue* context, HValue* left, HValue* right) | 4181 HShl(HValue* context, HValue* left, HValue* right) |
3961 : HBitwiseBinaryOperation(context, left, right) { } | 4182 : HBitwiseBinaryOperation(context, left, right) { } |
3962 | 4183 |
3963 virtual Range* InferRange(Zone* zone); | 4184 virtual Range* InferRange(Zone* zone); |
3964 | 4185 |
3965 static HInstruction* NewHShl(Zone* zone, | 4186 static HInstruction* NewHShl(Zone* zone, |
3966 HValue* context, | 4187 HValue* context, |
3967 HValue* left, | 4188 HValue* left, |
3968 HValue* right); | 4189 HValue* right); |
3969 | 4190 |
| 4191 virtual bool CheckRelation(NumericRelation relation, HValue* other); |
| 4192 |
3970 DECLARE_CONCRETE_INSTRUCTION(Shl) | 4193 DECLARE_CONCRETE_INSTRUCTION(Shl) |
3971 | 4194 |
3972 protected: | 4195 protected: |
3973 virtual bool DataEquals(HValue* other) { return true; } | 4196 virtual bool DataEquals(HValue* other) { return true; } |
3974 }; | 4197 }; |
3975 | 4198 |
3976 | 4199 |
3977 class HShr: public HBitwiseBinaryOperation { | 4200 class HShr: public HBitwiseBinaryOperation { |
3978 public: | 4201 public: |
3979 HShr(HValue* context, HValue* left, HValue* right) | 4202 HShr(HValue* context, HValue* left, HValue* right) |
3980 : HBitwiseBinaryOperation(context, left, right) { } | 4203 : HBitwiseBinaryOperation(context, left, right) { } |
3981 | 4204 |
3982 virtual Range* InferRange(Zone* zone); | 4205 virtual Range* InferRange(Zone* zone); |
3983 | 4206 |
3984 static HInstruction* NewHShr(Zone* zone, | 4207 static HInstruction* NewHShr(Zone* zone, |
3985 HValue* context, | 4208 HValue* context, |
3986 HValue* left, | 4209 HValue* left, |
3987 HValue* right); | 4210 HValue* right); |
3988 | 4211 |
| 4212 virtual bool CheckRelation(NumericRelation relation, HValue* other); |
| 4213 |
3989 DECLARE_CONCRETE_INSTRUCTION(Shr) | 4214 DECLARE_CONCRETE_INSTRUCTION(Shr) |
3990 | 4215 |
3991 protected: | 4216 protected: |
3992 virtual bool DataEquals(HValue* other) { return true; } | 4217 virtual bool DataEquals(HValue* other) { return true; } |
3993 }; | 4218 }; |
3994 | 4219 |
3995 | 4220 |
3996 class HSar: public HBitwiseBinaryOperation { | 4221 class HSar: public HBitwiseBinaryOperation { |
3997 public: | 4222 public: |
3998 HSar(HValue* context, HValue* left, HValue* right) | 4223 HSar(HValue* context, HValue* left, HValue* right) |
(...skipping 1786 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5785 virtual bool IsDeletable() const { return true; } | 6010 virtual bool IsDeletable() const { return true; } |
5786 }; | 6011 }; |
5787 | 6012 |
5788 | 6013 |
5789 #undef DECLARE_INSTRUCTION | 6014 #undef DECLARE_INSTRUCTION |
5790 #undef DECLARE_CONCRETE_INSTRUCTION | 6015 #undef DECLARE_CONCRETE_INSTRUCTION |
5791 | 6016 |
5792 } } // namespace v8::internal | 6017 } } // namespace v8::internal |
5793 | 6018 |
5794 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ | 6019 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ |
OLD | NEW |