| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef V8_HYDROGEN_GVN_H_ | 5 #ifndef V8_HYDROGEN_GVN_H_ |
| 6 #define V8_HYDROGEN_GVN_H_ | 6 #define V8_HYDROGEN_GVN_H_ |
| 7 | 7 |
| 8 #include "src/compiler.h" | 8 #include "src/compiler.h" |
| 9 #include "src/hydrogen.h" | 9 #include "src/hydrogen.h" |
| 10 #include "src/hydrogen-instructions.h" | 10 #include "src/hydrogen-instructions.h" |
| 11 #include "src/zone.h" | 11 #include "src/zone.h" |
| 12 | 12 |
| 13 namespace v8 { | 13 namespace v8 { |
| 14 namespace internal { | 14 namespace internal { |
| 15 | 15 |
| 16 class OStream; | 16 class OStream; |
| 17 | 17 |
| 18 // This class extends GVNFlagSet with additional "special" dynamic side effects, | 18 // This class extends GVNFlagSet with additional "special" dynamic side effects, |
| 19 // which can be used to represent side effects that cannot be expressed using | 19 // which can be used to represent side effects that cannot be expressed using |
| 20 // the GVNFlags of an HInstruction. These special side effects are tracked by a | 20 // the GVNFlags of an HInstruction. These special side effects are tracked by a |
| 21 // SideEffectsTracker (see below). | 21 // SideEffectsTracker (see below). |
| 22 class SideEffects V8_FINAL { | 22 class SideEffects FINAL { |
| 23 public: | 23 public: |
| 24 static const int kNumberOfSpecials = 64 - kNumberOfFlags; | 24 static const int kNumberOfSpecials = 64 - kNumberOfFlags; |
| 25 | 25 |
| 26 SideEffects() : bits_(0) { | 26 SideEffects() : bits_(0) { |
| 27 DCHECK(kNumberOfFlags + kNumberOfSpecials == sizeof(bits_) * CHAR_BIT); | 27 DCHECK(kNumberOfFlags + kNumberOfSpecials == sizeof(bits_) * CHAR_BIT); |
| 28 } | 28 } |
| 29 explicit SideEffects(GVNFlagSet flags) : bits_(flags.ToIntegral()) {} | 29 explicit SideEffects(GVNFlagSet flags) : bits_(flags.ToIntegral()) {} |
| 30 bool IsEmpty() const { return bits_ == 0; } | 30 bool IsEmpty() const { return bits_ == 0; } |
| 31 bool ContainsFlag(GVNFlag flag) const { | 31 bool ContainsFlag(GVNFlag flag) const { |
| 32 return (bits_ & MaskFlag(flag)) != 0; | 32 return (bits_ & MaskFlag(flag)) != 0; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 56 }; | 56 }; |
| 57 | 57 |
| 58 | 58 |
| 59 struct TrackedEffects; | 59 struct TrackedEffects; |
| 60 | 60 |
| 61 // Tracks global variable and inobject field loads/stores in a fine grained | 61 // Tracks global variable and inobject field loads/stores in a fine grained |
| 62 // fashion, and represents them using the "special" dynamic side effects of the | 62 // fashion, and represents them using the "special" dynamic side effects of the |
| 63 // SideEffects class (see above). This way unrelated global variable/inobject | 63 // SideEffects class (see above). This way unrelated global variable/inobject |
| 64 // field stores don't prevent hoisting and merging of global variable/inobject | 64 // field stores don't prevent hoisting and merging of global variable/inobject |
| 65 // field loads. | 65 // field loads. |
| 66 class SideEffectsTracker V8_FINAL BASE_EMBEDDED { | 66 class SideEffectsTracker FINAL BASE_EMBEDDED { |
| 67 public: | 67 public: |
| 68 SideEffectsTracker() : num_global_vars_(0), num_inobject_fields_(0) {} | 68 SideEffectsTracker() : num_global_vars_(0), num_inobject_fields_(0) {} |
| 69 SideEffects ComputeChanges(HInstruction* instr); | 69 SideEffects ComputeChanges(HInstruction* instr); |
| 70 SideEffects ComputeDependsOn(HInstruction* instr); | 70 SideEffects ComputeDependsOn(HInstruction* instr); |
| 71 | 71 |
| 72 private: | 72 private: |
| 73 friend OStream& operator<<(OStream& os, const TrackedEffects& f); | 73 friend OStream& operator<<(OStream& os, const TrackedEffects& f); |
| 74 bool ComputeGlobalVar(Unique<Cell> cell, int* index); | 74 bool ComputeGlobalVar(Unique<Cell> cell, int* index); |
| 75 bool ComputeInobjectField(HObjectAccess access, int* index); | 75 bool ComputeInobjectField(HObjectAccess access, int* index); |
| 76 | 76 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 104 : tracker(t), effects(e) {} | 104 : tracker(t), effects(e) {} |
| 105 SideEffectsTracker* tracker; | 105 SideEffectsTracker* tracker; |
| 106 SideEffects effects; | 106 SideEffects effects; |
| 107 }; | 107 }; |
| 108 | 108 |
| 109 | 109 |
| 110 OStream& operator<<(OStream& os, const TrackedEffects& f); | 110 OStream& operator<<(OStream& os, const TrackedEffects& f); |
| 111 | 111 |
| 112 | 112 |
| 113 // Perform common subexpression elimination and loop-invariant code motion. | 113 // Perform common subexpression elimination and loop-invariant code motion. |
| 114 class HGlobalValueNumberingPhase V8_FINAL : public HPhase { | 114 class HGlobalValueNumberingPhase FINAL : public HPhase { |
| 115 public: | 115 public: |
| 116 explicit HGlobalValueNumberingPhase(HGraph* graph); | 116 explicit HGlobalValueNumberingPhase(HGraph* graph); |
| 117 | 117 |
| 118 void Run(); | 118 void Run(); |
| 119 | 119 |
| 120 private: | 120 private: |
| 121 SideEffects CollectSideEffectsOnPathsToDominatedBlock( | 121 SideEffects CollectSideEffectsOnPathsToDominatedBlock( |
| 122 HBasicBlock* dominator, | 122 HBasicBlock* dominator, |
| 123 HBasicBlock* dominated); | 123 HBasicBlock* dominated); |
| 124 void AnalyzeGraph(); | 124 void AnalyzeGraph(); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 145 // Used when collecting side effects on paths from dominator to | 145 // Used when collecting side effects on paths from dominator to |
| 146 // dominated. | 146 // dominated. |
| 147 BitVector visited_on_paths_; | 147 BitVector visited_on_paths_; |
| 148 | 148 |
| 149 DISALLOW_COPY_AND_ASSIGN(HGlobalValueNumberingPhase); | 149 DISALLOW_COPY_AND_ASSIGN(HGlobalValueNumberingPhase); |
| 150 }; | 150 }; |
| 151 | 151 |
| 152 } } // namespace v8::internal | 152 } } // namespace v8::internal |
| 153 | 153 |
| 154 #endif // V8_HYDROGEN_GVN_H_ | 154 #endif // V8_HYDROGEN_GVN_H_ |
| OLD | NEW |