OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #ifndef RUNTIME_VM_REDUNDANCY_ELIMINATION_H_ | 5 #ifndef RUNTIME_VM_REDUNDANCY_ELIMINATION_H_ |
6 #define RUNTIME_VM_REDUNDANCY_ELIMINATION_H_ | 6 #define RUNTIME_VM_REDUNDANCY_ELIMINATION_H_ |
7 | 7 |
| 8 #include "vm/flow_graph.h" |
8 #include "vm/intermediate_language.h" | 9 #include "vm/intermediate_language.h" |
9 #include "vm/flow_graph.h" | |
10 | 10 |
11 namespace dart { | 11 namespace dart { |
12 | 12 |
13 class CSEInstructionMap; | 13 class CSEInstructionMap; |
14 | 14 |
15 class AllocationSinking : public ZoneAllocated { | 15 class AllocationSinking : public ZoneAllocated { |
16 public: | 16 public: |
17 explicit AllocationSinking(FlowGraph* flow_graph) | 17 explicit AllocationSinking(FlowGraph* flow_graph) |
18 : flow_graph_(flow_graph), candidates_(5), materializations_(5) {} | 18 : flow_graph_(flow_graph), candidates_(5), materializations_(5) {} |
19 | 19 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 Zone* zone() const { return flow_graph_->zone(); } | 72 Zone* zone() const { return flow_graph_->zone(); } |
73 | 73 |
74 FlowGraph* flow_graph_; | 74 FlowGraph* flow_graph_; |
75 | 75 |
76 GrowableArray<Definition*> candidates_; | 76 GrowableArray<Definition*> candidates_; |
77 GrowableArray<MaterializeObjectInstr*> materializations_; | 77 GrowableArray<MaterializeObjectInstr*> materializations_; |
78 | 78 |
79 ExitsCollector exits_collector_; | 79 ExitsCollector exits_collector_; |
80 }; | 80 }; |
81 | 81 |
82 | |
83 // A simple common subexpression elimination based | 82 // A simple common subexpression elimination based |
84 // on the dominator tree. | 83 // on the dominator tree. |
85 class DominatorBasedCSE : public AllStatic { | 84 class DominatorBasedCSE : public AllStatic { |
86 public: | 85 public: |
87 // Return true, if the optimization changed the flow graph. | 86 // Return true, if the optimization changed the flow graph. |
88 // False, if nothing changed. | 87 // False, if nothing changed. |
89 static bool Optimize(FlowGraph* graph); | 88 static bool Optimize(FlowGraph* graph); |
90 | 89 |
91 private: | 90 private: |
92 static bool OptimizeRecursive(FlowGraph* graph, | 91 static bool OptimizeRecursive(FlowGraph* graph, |
93 BlockEntryInstr* entry, | 92 BlockEntryInstr* entry, |
94 CSEInstructionMap* map); | 93 CSEInstructionMap* map); |
95 }; | 94 }; |
96 | 95 |
97 | |
98 class DeadStoreElimination : public AllStatic { | 96 class DeadStoreElimination : public AllStatic { |
99 public: | 97 public: |
100 static void Optimize(FlowGraph* graph); | 98 static void Optimize(FlowGraph* graph); |
101 }; | 99 }; |
102 | 100 |
103 | |
104 class DeadCodeElimination : public AllStatic { | 101 class DeadCodeElimination : public AllStatic { |
105 public: | 102 public: |
106 static void EliminateDeadPhis(FlowGraph* graph); | 103 static void EliminateDeadPhis(FlowGraph* graph); |
107 }; | 104 }; |
108 | 105 |
109 | |
110 // Optimize spill stores inside try-blocks by identifying values that always | 106 // Optimize spill stores inside try-blocks by identifying values that always |
111 // contain a single known constant at catch block entry. | 107 // contain a single known constant at catch block entry. |
112 class TryCatchAnalyzer : public AllStatic { | 108 class TryCatchAnalyzer : public AllStatic { |
113 public: | 109 public: |
114 static void Optimize(FlowGraph* flow_graph); | 110 static void Optimize(FlowGraph* flow_graph); |
115 }; | 111 }; |
116 | 112 |
117 | |
118 // Loop invariant code motion. | 113 // Loop invariant code motion. |
119 class LICM : public ValueObject { | 114 class LICM : public ValueObject { |
120 public: | 115 public: |
121 explicit LICM(FlowGraph* flow_graph); | 116 explicit LICM(FlowGraph* flow_graph); |
122 | 117 |
123 void Optimize(); | 118 void Optimize(); |
124 | 119 |
125 void OptimisticallySpecializeSmiPhis(); | 120 void OptimisticallySpecializeSmiPhis(); |
126 | 121 |
127 private: | 122 private: |
128 FlowGraph* flow_graph() const { return flow_graph_; } | 123 FlowGraph* flow_graph() const { return flow_graph_; } |
129 | 124 |
130 void Hoist(ForwardInstructionIterator* it, | 125 void Hoist(ForwardInstructionIterator* it, |
131 BlockEntryInstr* pre_header, | 126 BlockEntryInstr* pre_header, |
132 Instruction* current); | 127 Instruction* current); |
133 | 128 |
134 void TrySpecializeSmiPhi(PhiInstr* phi, | 129 void TrySpecializeSmiPhi(PhiInstr* phi, |
135 BlockEntryInstr* header, | 130 BlockEntryInstr* header, |
136 BlockEntryInstr* pre_header); | 131 BlockEntryInstr* pre_header); |
137 | 132 |
138 FlowGraph* const flow_graph_; | 133 FlowGraph* const flow_graph_; |
139 }; | 134 }; |
140 | 135 |
141 } // namespace dart | 136 } // namespace dart |
142 | 137 |
143 #endif // RUNTIME_VM_REDUNDANCY_ELIMINATION_H_ | 138 #endif // RUNTIME_VM_REDUNDANCY_ELIMINATION_H_ |
OLD | NEW |