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