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 776 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
787 // Track instructions that are dominating side effects. If an instruction | 787 // Track instructions that are dominating side effects. If an instruction |
788 // sets this flag, it must implement SetSideEffectDominator() and should | 788 // sets this flag, it must implement SetSideEffectDominator() and should |
789 // indicate which side effects to track by setting GVN flags. | 789 // indicate which side effects to track by setting GVN flags. |
790 kTrackSideEffectDominators, | 790 kTrackSideEffectDominators, |
791 kCanOverflow, | 791 kCanOverflow, |
792 kBailoutOnMinusZero, | 792 kBailoutOnMinusZero, |
793 kCanBeDivByZero, | 793 kCanBeDivByZero, |
794 kDeoptimizeOnUndefined, | 794 kDeoptimizeOnUndefined, |
795 kIsArguments, | 795 kIsArguments, |
796 kTruncatingToInt32, | 796 kTruncatingToInt32, |
| 797 // Set after an instruction is killed. |
797 kIsDead, | 798 kIsDead, |
798 // Instructions that are allowed to produce full range unsigned integer | 799 // Instructions that are allowed to produce full range unsigned integer |
799 // values are marked with kUint32 flag. If arithmetic shift or a load from | 800 // values are marked with kUint32 flag. If arithmetic shift or a load from |
800 // EXTERNAL_UNSIGNED_INT_ELEMENTS array is not marked with this flag | 801 // EXTERNAL_UNSIGNED_INT_ELEMENTS array is not marked with this flag |
801 // it will deoptimize if result does not fit into signed integer range. | 802 // it will deoptimize if result does not fit into signed integer range. |
802 // HGraph::ComputeSafeUint32Operations is responsible for setting this | 803 // HGraph::ComputeSafeUint32Operations is responsible for setting this |
803 // flag. | 804 // flag. |
804 kUint32, | 805 kUint32, |
805 // If a phi is involved in the evaluation of a numeric constraint the | 806 // If a phi is involved in the evaluation of a numeric constraint the |
806 // recursion can cause an endless cycle: we use this flag to exit the loop. | 807 // recursion can cause an endless cycle: we use this flag to exit the loop. |
807 kNumericConstraintEvaluationInProgress, | 808 kNumericConstraintEvaluationInProgress, |
808 // This flag is set to true after the SetupInformativeDefinitions() pass | 809 // This flag is set to true after the SetupInformativeDefinitions() pass |
809 // has processed this instruction. | 810 // has processed this instruction. |
810 kIDefsProcessingDone, | 811 kIDefsProcessingDone, |
811 kHasNoObservableSideEffects, | 812 kHasNoObservableSideEffects, |
| 813 // Indicates the instruction is live during dead code elimination. |
| 814 kIsLive, |
812 kLastFlag = kIDefsProcessingDone | 815 kLastFlag = kIDefsProcessingDone |
813 }; | 816 }; |
814 | 817 |
815 STATIC_ASSERT(kLastFlag < kBitsPerInt); | 818 STATIC_ASSERT(kLastFlag < kBitsPerInt); |
816 | 819 |
817 static const int kChangesToDependsFlagsLeftShift = 1; | 820 static const int kChangesToDependsFlagsLeftShift = 1; |
818 | 821 |
819 static GVNFlag ChangesFlagFromInt(int x) { | 822 static GVNFlag ChangesFlagFromInt(int x) { |
820 return static_cast<GVNFlag>(x * 2); | 823 return static_cast<GVNFlag>(x * 2); |
821 } | 824 } |
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1064 | 1067 |
1065 virtual HType CalculateInferredType(); | 1068 virtual HType CalculateInferredType(); |
1066 | 1069 |
1067 // This function must be overridden for instructions which have the | 1070 // This function must be overridden for instructions which have the |
1068 // kTrackSideEffectDominators flag set, to track instructions that are | 1071 // kTrackSideEffectDominators flag set, to track instructions that are |
1069 // dominating side effects. | 1072 // dominating side effects. |
1070 virtual void SetSideEffectDominator(GVNFlag side_effect, HValue* dominator) { | 1073 virtual void SetSideEffectDominator(GVNFlag side_effect, HValue* dominator) { |
1071 UNREACHABLE(); | 1074 UNREACHABLE(); |
1072 } | 1075 } |
1073 | 1076 |
1074 bool IsDead() const { | 1077 // Check if this instruction has some reason that prevents elimination. |
1075 return HasNoUses() && !HasObservableSideEffects() && IsDeletable(); | 1078 bool CanBeEliminated() const { |
| 1079 return !HasObservableSideEffects() && IsDeletable(); |
1076 } | 1080 } |
1077 | 1081 |
1078 #ifdef DEBUG | 1082 #ifdef DEBUG |
1079 virtual void Verify() = 0; | 1083 virtual void Verify() = 0; |
1080 #endif | 1084 #endif |
1081 | 1085 |
1082 bool IsRelationTrue(NumericRelation relation, | 1086 bool IsRelationTrue(NumericRelation relation, |
1083 HValue* other, | 1087 HValue* other, |
1084 int offset = 0, | 1088 int offset = 0, |
1085 int scale = 0); | 1089 int scale = 0); |
(...skipping 1876 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2962 virtual bool DataEquals(HValue* other) { return true; } | 2966 virtual bool DataEquals(HValue* other) { return true; } |
2963 }; | 2967 }; |
2964 | 2968 |
2965 | 2969 |
2966 class HPhi: public HValue { | 2970 class HPhi: public HValue { |
2967 public: | 2971 public: |
2968 HPhi(int merged_index, Zone* zone) | 2972 HPhi(int merged_index, Zone* zone) |
2969 : inputs_(2, zone), | 2973 : inputs_(2, zone), |
2970 merged_index_(merged_index), | 2974 merged_index_(merged_index), |
2971 phi_id_(-1), | 2975 phi_id_(-1), |
2972 is_live_(false), | |
2973 is_convertible_to_integer_(true) { | 2976 is_convertible_to_integer_(true) { |
2974 for (int i = 0; i < Representation::kNumRepresentations; i++) { | 2977 for (int i = 0; i < Representation::kNumRepresentations; i++) { |
2975 non_phi_uses_[i] = 0; | 2978 non_phi_uses_[i] = 0; |
2976 indirect_uses_[i] = 0; | 2979 indirect_uses_[i] = 0; |
2977 } | 2980 } |
2978 ASSERT(merged_index >= 0); | 2981 ASSERT(merged_index >= 0); |
2979 SetFlag(kFlexibleRepresentation); | 2982 SetFlag(kFlexibleRepresentation); |
2980 } | 2983 } |
2981 | 2984 |
2982 virtual Representation RepresentationFromInputs(); | 2985 virtual Representation RepresentationFromInputs(); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3022 int tagged_indirect_uses() const { | 3025 int tagged_indirect_uses() const { |
3023 return indirect_uses_[Representation::kTagged]; | 3026 return indirect_uses_[Representation::kTagged]; |
3024 } | 3027 } |
3025 int int32_indirect_uses() const { | 3028 int int32_indirect_uses() const { |
3026 return indirect_uses_[Representation::kInteger32]; | 3029 return indirect_uses_[Representation::kInteger32]; |
3027 } | 3030 } |
3028 int double_indirect_uses() const { | 3031 int double_indirect_uses() const { |
3029 return indirect_uses_[Representation::kDouble]; | 3032 return indirect_uses_[Representation::kDouble]; |
3030 } | 3033 } |
3031 int phi_id() { return phi_id_; } | 3034 int phi_id() { return phi_id_; } |
3032 bool is_live() { return is_live_; } | |
3033 void set_is_live(bool b) { is_live_ = b; } | |
3034 | 3035 |
3035 static HPhi* cast(HValue* value) { | 3036 static HPhi* cast(HValue* value) { |
3036 ASSERT(value->IsPhi()); | 3037 ASSERT(value->IsPhi()); |
3037 return reinterpret_cast<HPhi*>(value); | 3038 return reinterpret_cast<HPhi*>(value); |
3038 } | 3039 } |
3039 virtual Opcode opcode() const { return HValue::kPhi; } | 3040 virtual Opcode opcode() const { return HValue::kPhi; } |
3040 | 3041 |
3041 virtual bool IsConvertibleToInteger() const { | 3042 virtual bool IsConvertibleToInteger() const { |
3042 return is_convertible_to_integer_; | 3043 return is_convertible_to_integer_; |
3043 } | 3044 } |
(...skipping 29 matching lines...) Expand all Loading... |
3073 int offset = 0, | 3074 int offset = 0, |
3074 int scale = 0); | 3075 int scale = 0); |
3075 | 3076 |
3076 private: | 3077 private: |
3077 ZoneList<HValue*> inputs_; | 3078 ZoneList<HValue*> inputs_; |
3078 int merged_index_; | 3079 int merged_index_; |
3079 | 3080 |
3080 int non_phi_uses_[Representation::kNumRepresentations]; | 3081 int non_phi_uses_[Representation::kNumRepresentations]; |
3081 int indirect_uses_[Representation::kNumRepresentations]; | 3082 int indirect_uses_[Representation::kNumRepresentations]; |
3082 int phi_id_; | 3083 int phi_id_; |
3083 bool is_live_; | |
3084 bool is_convertible_to_integer_; | 3084 bool is_convertible_to_integer_; |
3085 }; | 3085 }; |
3086 | 3086 |
3087 | 3087 |
3088 class HInductionVariableAnnotation : public HUnaryOperation { | 3088 class HInductionVariableAnnotation : public HUnaryOperation { |
3089 public: | 3089 public: |
3090 static HInductionVariableAnnotation* AddToGraph(HPhi* phi, | 3090 static HInductionVariableAnnotation* AddToGraph(HPhi* phi, |
3091 NumericRelation relation, | 3091 NumericRelation relation, |
3092 int operand_index); | 3092 int operand_index); |
3093 | 3093 |
(...skipping 3368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6462 virtual bool IsDeletable() const { return true; } | 6462 virtual bool IsDeletable() const { return true; } |
6463 }; | 6463 }; |
6464 | 6464 |
6465 | 6465 |
6466 #undef DECLARE_INSTRUCTION | 6466 #undef DECLARE_INSTRUCTION |
6467 #undef DECLARE_CONCRETE_INSTRUCTION | 6467 #undef DECLARE_CONCRETE_INSTRUCTION |
6468 | 6468 |
6469 } } // namespace v8::internal | 6469 } } // namespace v8::internal |
6470 | 6470 |
6471 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ | 6471 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ |
OLD | NEW |