Chromium Code Reviews| 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 | |
|
Jakob Kummerow
2013/02/12 15:10:42
nit: position of the closing quote:
// "rel.Is
Massi
2013/02/13 11:56:42
Done.
| |
| 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 2009 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3147 bool skip_check() { return skip_check_; } | 3318 bool skip_check() { return skip_check_; } |
| 3148 void set_skip_check(bool skip_check) { skip_check_ = skip_check; } | 3319 void set_skip_check(bool skip_check) { skip_check_ = skip_check; } |
| 3149 | 3320 |
| 3150 virtual Representation RequiredInputRepresentation(int arg_index) { | 3321 virtual Representation RequiredInputRepresentation(int arg_index) { |
| 3151 return representation(); | 3322 return representation(); |
| 3152 } | 3323 } |
| 3153 virtual Representation observed_input_representation(int index) { | 3324 virtual Representation observed_input_representation(int index) { |
| 3154 return Representation::Integer32(); | 3325 return Representation::Integer32(); |
| 3155 } | 3326 } |
| 3156 | 3327 |
| 3328 virtual bool CheckRelation(NumericRelation relation, HValue* related_value); | |
| 3329 | |
| 3157 virtual void PrintDataTo(StringStream* stream); | 3330 virtual void PrintDataTo(StringStream* stream); |
| 3158 virtual void InferRepresentation(HInferRepresentation* h_infer); | 3331 virtual void InferRepresentation(HInferRepresentation* h_infer); |
| 3159 | 3332 |
| 3160 HValue* index() { return OperandAt(0); } | 3333 HValue* index() { return OperandAt(0); } |
| 3161 HValue* length() { return OperandAt(1); } | 3334 HValue* length() { return OperandAt(1); } |
| 3162 | 3335 |
| 3163 virtual int RedefinedOperandIndex() { return 0; } | 3336 virtual int RedefinedOperandIndex() { return 0; } |
| 3164 | 3337 |
| 3165 DECLARE_CONCRETE_INSTRUCTION(BoundsCheck) | 3338 DECLARE_CONCRETE_INSTRUCTION(BoundsCheck) |
| 3166 | 3339 |
| (...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3734 | 3907 |
| 3735 static HInstruction* NewHAdd(Zone* zone, | 3908 static HInstruction* NewHAdd(Zone* zone, |
| 3736 HValue* context, | 3909 HValue* context, |
| 3737 HValue* left, | 3910 HValue* left, |
| 3738 HValue* right); | 3911 HValue* right); |
| 3739 | 3912 |
| 3740 virtual HType CalculateInferredType(); | 3913 virtual HType CalculateInferredType(); |
| 3741 | 3914 |
| 3742 virtual HValue* Canonicalize(); | 3915 virtual HValue* Canonicalize(); |
| 3743 | 3916 |
| 3917 virtual bool CheckRelation(NumericRelation relation, HValue* other) { | |
| 3918 HValue* base = NULL; | |
| 3919 int32_t offset = 0; | |
| 3920 if (left()->IsInteger32Constant()) { | |
| 3921 base = right(); | |
| 3922 offset = left()->GetInteger32Constant(); | |
| 3923 } else if (right()->IsInteger32Constant()) { | |
| 3924 base = left(); | |
| 3925 offset = right()->GetInteger32Constant(); | |
| 3926 } else { | |
| 3927 return false; | |
| 3928 } | |
| 3929 | |
| 3930 return relation.IsExtendable(offset) | |
| 3931 ? base->IsRelationTrue(relation, other) : false; | |
| 3932 } | |
| 3933 | |
| 3744 DECLARE_CONCRETE_INSTRUCTION(Add) | 3934 DECLARE_CONCRETE_INSTRUCTION(Add) |
| 3745 | 3935 |
| 3746 protected: | 3936 protected: |
| 3747 virtual bool DataEquals(HValue* other) { return true; } | 3937 virtual bool DataEquals(HValue* other) { return true; } |
| 3748 | 3938 |
| 3749 virtual Range* InferRange(Zone* zone); | 3939 virtual Range* InferRange(Zone* zone); |
| 3750 }; | 3940 }; |
| 3751 | 3941 |
| 3752 | 3942 |
| 3753 class HSub: public HArithmeticBinaryOperation { | 3943 class HSub: public HArithmeticBinaryOperation { |
| 3754 public: | 3944 public: |
| 3755 HSub(HValue* context, HValue* left, HValue* right) | 3945 HSub(HValue* context, HValue* left, HValue* right) |
| 3756 : HArithmeticBinaryOperation(context, left, right) { | 3946 : HArithmeticBinaryOperation(context, left, right) { |
| 3757 SetFlag(kCanOverflow); | 3947 SetFlag(kCanOverflow); |
| 3758 } | 3948 } |
| 3759 | 3949 |
| 3760 virtual HValue* EnsureAndPropagateNotMinusZero(BitVector* visited); | 3950 virtual HValue* EnsureAndPropagateNotMinusZero(BitVector* visited); |
| 3761 | 3951 |
| 3762 virtual HValue* Canonicalize(); | 3952 virtual HValue* Canonicalize(); |
| 3763 | 3953 |
| 3764 static HInstruction* NewHSub(Zone* zone, | 3954 static HInstruction* NewHSub(Zone* zone, |
| 3765 HValue* context, | 3955 HValue* context, |
| 3766 HValue* left, | 3956 HValue* left, |
| 3767 HValue* right); | 3957 HValue* right); |
| 3768 | 3958 |
| 3959 virtual bool CheckRelation(NumericRelation relation, HValue* other) { | |
| 3960 if (right()->IsInteger32Constant()) { | |
| 3961 HValue* base = left(); | |
| 3962 int32_t offset = right()->GetInteger32Constant(); | |
| 3963 return relation.IsExtendable(offset) | |
|
Jakob Kummerow
2013/02/12 15:10:42
-offset
Massi
2013/02/13 11:56:42
Done.
| |
| 3964 ? base->IsRelationTrue(relation, other) : false; | |
| 3965 } else { | |
| 3966 return false; | |
| 3967 } | |
| 3968 } | |
| 3969 | |
| 3769 DECLARE_CONCRETE_INSTRUCTION(Sub) | 3970 DECLARE_CONCRETE_INSTRUCTION(Sub) |
| 3770 | 3971 |
| 3771 protected: | 3972 protected: |
| 3772 virtual bool DataEquals(HValue* other) { return true; } | 3973 virtual bool DataEquals(HValue* other) { return true; } |
| 3773 | 3974 |
| 3774 virtual Range* InferRange(Zone* zone); | 3975 virtual Range* InferRange(Zone* zone); |
| 3775 }; | 3976 }; |
| 3776 | 3977 |
| 3777 | 3978 |
| 3778 class HMul: public HArithmeticBinaryOperation { | 3979 class HMul: public HArithmeticBinaryOperation { |
| 3779 public: | 3980 public: |
| 3780 HMul(HValue* context, HValue* left, HValue* right) | 3981 HMul(HValue* context, HValue* left, HValue* right) |
| 3781 : HArithmeticBinaryOperation(context, left, right) { | 3982 : HArithmeticBinaryOperation(context, left, right) { |
| 3782 SetFlag(kCanOverflow); | 3983 SetFlag(kCanOverflow); |
| 3783 } | 3984 } |
| 3784 | 3985 |
| 3785 virtual HValue* EnsureAndPropagateNotMinusZero(BitVector* visited); | 3986 virtual HValue* EnsureAndPropagateNotMinusZero(BitVector* visited); |
| 3786 | 3987 |
| 3787 // Only commutative if it is certain that not two objects are multiplicated. | 3988 // Only commutative if it is certain that not two objects are multiplicated. |
| 3788 virtual bool IsCommutative() const { | 3989 virtual bool IsCommutative() const { |
| 3789 return !representation().IsTagged(); | 3990 return !representation().IsTagged(); |
| 3790 } | 3991 } |
| 3791 | 3992 |
| 3792 static HInstruction* NewHMul(Zone* zone, | 3993 static HInstruction* NewHMul(Zone* zone, |
| 3793 HValue* context, | 3994 HValue* context, |
| 3794 HValue* left, | 3995 HValue* left, |
| 3795 HValue* right); | 3996 HValue* right); |
| 3796 | 3997 |
| 3998 // The idea is that "k > 1" implies that "base * k >= base". | |
|
Jakob Kummerow
2013/02/12 15:10:42
As discussed, we should probably postpone this imp
Massi
2013/02/13 11:56:42
Done.
| |
| 3999 virtual bool CheckRelation(NumericRelation relation, HValue* other) { | |
| 4000 HValue* base = NULL; | |
| 4001 int32_t k = 0; | |
| 4002 if (left()->IsInteger32Constant()) { | |
| 4003 base = right(); | |
| 4004 k = left()->GetInteger32Constant(); | |
| 4005 } else if (right()->IsInteger32Constant()) { | |
| 4006 base = left(); | |
| 4007 k = right()->GetInteger32Constant(); | |
| 4008 } else { | |
| 4009 return false; | |
| 4010 } | |
| 4011 | |
| 4012 return (k > 1 && relation.IsExtendable(1)) | |
| 4013 ? base->IsRelationTrue(relation, other) : false; | |
| 4014 } | |
| 4015 | |
| 3797 DECLARE_CONCRETE_INSTRUCTION(Mul) | 4016 DECLARE_CONCRETE_INSTRUCTION(Mul) |
| 3798 | 4017 |
| 3799 protected: | 4018 protected: |
| 3800 virtual bool DataEquals(HValue* other) { return true; } | 4019 virtual bool DataEquals(HValue* other) { return true; } |
| 3801 | 4020 |
| 3802 virtual Range* InferRange(Zone* zone); | 4021 virtual Range* InferRange(Zone* zone); |
| 3803 }; | 4022 }; |
| 3804 | 4023 |
| 3805 | 4024 |
| 3806 class HMod: public HArithmeticBinaryOperation { | 4025 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) | 4179 HShl(HValue* context, HValue* left, HValue* right) |
| 3961 : HBitwiseBinaryOperation(context, left, right) { } | 4180 : HBitwiseBinaryOperation(context, left, right) { } |
| 3962 | 4181 |
| 3963 virtual Range* InferRange(Zone* zone); | 4182 virtual Range* InferRange(Zone* zone); |
| 3964 | 4183 |
| 3965 static HInstruction* NewHShl(Zone* zone, | 4184 static HInstruction* NewHShl(Zone* zone, |
| 3966 HValue* context, | 4185 HValue* context, |
| 3967 HValue* left, | 4186 HValue* left, |
| 3968 HValue* right); | 4187 HValue* right); |
| 3969 | 4188 |
| 4189 virtual bool CheckRelation(NumericRelation relation, HValue* other); | |
| 4190 | |
| 3970 DECLARE_CONCRETE_INSTRUCTION(Shl) | 4191 DECLARE_CONCRETE_INSTRUCTION(Shl) |
| 3971 | 4192 |
| 3972 protected: | 4193 protected: |
| 3973 virtual bool DataEquals(HValue* other) { return true; } | 4194 virtual bool DataEquals(HValue* other) { return true; } |
| 3974 }; | 4195 }; |
| 3975 | 4196 |
| 3976 | 4197 |
| 3977 class HShr: public HBitwiseBinaryOperation { | 4198 class HShr: public HBitwiseBinaryOperation { |
| 3978 public: | 4199 public: |
| 3979 HShr(HValue* context, HValue* left, HValue* right) | 4200 HShr(HValue* context, HValue* left, HValue* right) |
| 3980 : HBitwiseBinaryOperation(context, left, right) { } | 4201 : HBitwiseBinaryOperation(context, left, right) { } |
| 3981 | 4202 |
| 3982 virtual Range* InferRange(Zone* zone); | 4203 virtual Range* InferRange(Zone* zone); |
| 3983 | 4204 |
| 3984 static HInstruction* NewHShr(Zone* zone, | 4205 static HInstruction* NewHShr(Zone* zone, |
| 3985 HValue* context, | 4206 HValue* context, |
| 3986 HValue* left, | 4207 HValue* left, |
| 3987 HValue* right); | 4208 HValue* right); |
| 3988 | 4209 |
| 4210 virtual bool CheckRelation(NumericRelation relation, HValue* other); | |
| 4211 | |
| 3989 DECLARE_CONCRETE_INSTRUCTION(Shr) | 4212 DECLARE_CONCRETE_INSTRUCTION(Shr) |
| 3990 | 4213 |
| 3991 protected: | 4214 protected: |
| 3992 virtual bool DataEquals(HValue* other) { return true; } | 4215 virtual bool DataEquals(HValue* other) { return true; } |
| 3993 }; | 4216 }; |
| 3994 | 4217 |
| 3995 | 4218 |
| 3996 class HSar: public HBitwiseBinaryOperation { | 4219 class HSar: public HBitwiseBinaryOperation { |
| 3997 public: | 4220 public: |
| 3998 HSar(HValue* context, HValue* left, HValue* right) | 4221 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; } | 6008 virtual bool IsDeletable() const { return true; } |
| 5786 }; | 6009 }; |
| 5787 | 6010 |
| 5788 | 6011 |
| 5789 #undef DECLARE_INSTRUCTION | 6012 #undef DECLARE_INSTRUCTION |
| 5790 #undef DECLARE_CONCRETE_INSTRUCTION | 6013 #undef DECLARE_CONCRETE_INSTRUCTION |
| 5791 | 6014 |
| 5792 } } // namespace v8::internal | 6015 } } // namespace v8::internal |
| 5793 | 6016 |
| 5794 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ | 6017 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ |
| OLD | NEW |