| 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 <iosfwd> |
| 9 |
| 8 #include "src/compiler.h" | 10 #include "src/compiler.h" |
| 9 #include "src/hydrogen.h" | 11 #include "src/hydrogen.h" |
| 10 #include "src/hydrogen-instructions.h" | 12 #include "src/hydrogen-instructions.h" |
| 11 #include "src/zone.h" | 13 #include "src/zone.h" |
| 12 | 14 |
| 13 namespace v8 { | 15 namespace v8 { |
| 14 namespace internal { | 16 namespace internal { |
| 15 | 17 |
| 16 class OStream; | |
| 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 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); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 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 std::ostream& operator<<(std::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 |
| 77 static int GlobalVar(int index) { | 77 static int GlobalVar(int index) { |
| 78 DCHECK(index >= 0); | 78 DCHECK(index >= 0); |
| 79 DCHECK(index < kNumberOfGlobalVars); | 79 DCHECK(index < kNumberOfGlobalVars); |
| 80 return index; | 80 return index; |
| 81 } | 81 } |
| 82 static int InobjectField(int index) { | 82 static int InobjectField(int index) { |
| 83 DCHECK(index >= 0); | 83 DCHECK(index >= 0); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 100 | 100 |
| 101 // Helper class for printing, because the effects don't know their tracker. | 101 // Helper class for printing, because the effects don't know their tracker. |
| 102 struct TrackedEffects { | 102 struct TrackedEffects { |
| 103 TrackedEffects(SideEffectsTracker* t, SideEffects e) | 103 TrackedEffects(SideEffectsTracker* t, SideEffects e) |
| 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 std::ostream& operator<<(std::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 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: |
| (...skipping 24 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 |