| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 VM_FLOW_GRAPH_OPTIMIZER_H_ | 5 #ifndef VM_FLOW_GRAPH_OPTIMIZER_H_ |
| 6 #define VM_FLOW_GRAPH_OPTIMIZER_H_ | 6 #define VM_FLOW_GRAPH_OPTIMIZER_H_ |
| 7 | 7 |
| 8 #include "vm/intermediate_language.h" | 8 #include "vm/intermediate_language.h" |
| 9 #include "vm/flow_graph.h" | 9 #include "vm/flow_graph.h" |
| 10 | 10 |
| 11 namespace dart { | 11 namespace dart { |
| 12 | 12 |
| 13 template <typename T> class GrowableArray; | 13 template <typename T> class GrowableArray; |
| 14 template <typename T> class DirectChainedHashMap; | 14 template <typename T> class DirectChainedHashMap; |
| 15 template <typename T> class PointerKeyValueTrait; |
| 15 | 16 |
| 16 class FlowGraphOptimizer : public FlowGraphVisitor { | 17 class FlowGraphOptimizer : public FlowGraphVisitor { |
| 17 public: | 18 public: |
| 18 explicit FlowGraphOptimizer(FlowGraph* flow_graph) | 19 explicit FlowGraphOptimizer(FlowGraph* flow_graph) |
| 19 : FlowGraphVisitor(flow_graph->reverse_postorder()), | 20 : FlowGraphVisitor(flow_graph->reverse_postorder()), |
| 20 flow_graph_(flow_graph) { } | 21 flow_graph_(flow_graph) { } |
| 21 virtual ~FlowGraphOptimizer() {} | 22 virtual ~FlowGraphOptimizer() {} |
| 22 | 23 |
| 23 // Use ICData to optimize, replace or eliminate instructions. | 24 // Use ICData to optimize, replace or eliminate instructions. |
| 24 void ApplyICData(); | 25 void ApplyICData(); |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 // on the dominator tree. | 157 // on the dominator tree. |
| 157 class DominatorBasedCSE : public AllStatic { | 158 class DominatorBasedCSE : public AllStatic { |
| 158 public: | 159 public: |
| 159 // Return true, if the optimization changed the flow graph. | 160 // Return true, if the optimization changed the flow graph. |
| 160 // False, if nothing changed. | 161 // False, if nothing changed. |
| 161 static bool Optimize(FlowGraph* graph); | 162 static bool Optimize(FlowGraph* graph); |
| 162 | 163 |
| 163 private: | 164 private: |
| 164 static bool OptimizeRecursive( | 165 static bool OptimizeRecursive( |
| 165 BlockEntryInstr* entry, | 166 BlockEntryInstr* entry, |
| 166 DirectChainedHashMap<Instruction*>* map); | 167 DirectChainedHashMap<PointerKeyValueTrait<Instruction> >* map); |
| 167 }; | 168 }; |
| 168 | 169 |
| 169 | 170 |
| 170 // Sparse conditional constant propagation and unreachable code elimination. | 171 // Sparse conditional constant propagation and unreachable code elimination. |
| 171 // Assumes that use lists are computed and preserves them. | 172 // Assumes that use lists are computed and preserves them. |
| 172 class ConstantPropagator : public FlowGraphVisitor { | 173 class ConstantPropagator : public FlowGraphVisitor { |
| 173 public: | 174 public: |
| 174 ConstantPropagator(FlowGraph* graph, | 175 ConstantPropagator(FlowGraph* graph, |
| 175 const GrowableArray<BlockEntryInstr*>& ignored); | 176 const GrowableArray<BlockEntryInstr*>& ignored); |
| 176 | 177 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 | 224 |
| 224 // Worklists of blocks and definitions. | 225 // Worklists of blocks and definitions. |
| 225 GrowableArray<BlockEntryInstr*> block_worklist_; | 226 GrowableArray<BlockEntryInstr*> block_worklist_; |
| 226 GrowableArray<Definition*> definition_worklist_; | 227 GrowableArray<Definition*> definition_worklist_; |
| 227 }; | 228 }; |
| 228 | 229 |
| 229 | 230 |
| 230 } // namespace dart | 231 } // namespace dart |
| 231 | 232 |
| 232 #endif // VM_FLOW_GRAPH_OPTIMIZER_H_ | 233 #endif // VM_FLOW_GRAPH_OPTIMIZER_H_ |
| OLD | NEW |