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