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; | |
15 | 14 |
16 class FlowGraphOptimizer : public FlowGraphVisitor { | 15 class FlowGraphOptimizer : public FlowGraphVisitor { |
17 public: | 16 public: |
18 explicit FlowGraphOptimizer(const FlowGraph& flow_graph) | 17 explicit FlowGraphOptimizer(const FlowGraph& flow_graph) |
19 : FlowGraphVisitor(flow_graph.reverse_postorder()) {} | 18 : FlowGraphVisitor(flow_graph.reverse_postorder()) {} |
20 virtual ~FlowGraphOptimizer() {} | 19 virtual ~FlowGraphOptimizer() {} |
21 | 20 |
22 void ApplyICData(); | 21 void ApplyICData(); |
23 | 22 |
24 void OptimizeComputations(); | 23 void OptimizeComputations(); |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 virtual void VisitParameter(ParameterInstr* param); | 98 virtual void VisitParameter(ParameterInstr* param); |
100 virtual void VisitPushArgument(PushArgumentInstr* bind); | 99 virtual void VisitPushArgument(PushArgumentInstr* bind); |
101 | 100 |
102 private: | 101 private: |
103 const ParsedFunction& parsed_function_; | 102 const ParsedFunction& parsed_function_; |
104 bool still_changing_; | 103 bool still_changing_; |
105 DISALLOW_COPY_AND_ASSIGN(FlowGraphTypePropagator); | 104 DISALLOW_COPY_AND_ASSIGN(FlowGraphTypePropagator); |
106 }; | 105 }; |
107 | 106 |
108 | 107 |
109 // A simple common subexpression elimination based | 108 class LocalCSE : public ValueObject { |
110 // on the dominator tree. | |
111 class DominatorBasedCSE : public AllStatic { | |
112 public: | 109 public: |
113 static void Optimize(BlockEntryInstr* graph_entry); | 110 explicit LocalCSE(const FlowGraph& flow_graph) |
| 111 : blocks_(flow_graph.reverse_postorder()) { } |
| 112 |
| 113 void Optimize(); |
114 | 114 |
115 private: | 115 private: |
116 static void OptimizeRecursive( | 116 const GrowableArray<BlockEntryInstr*>& blocks_; |
117 BlockEntryInstr* entry, | 117 |
118 DirectChainedHashMap<BindInstr*>* map); | 118 DISALLOW_COPY_AND_ASSIGN(LocalCSE); |
119 }; | 119 }; |
120 | 120 |
121 | 121 |
122 } // namespace dart | 122 } // namespace dart |
123 | 123 |
124 #endif // VM_FLOW_GRAPH_OPTIMIZER_H_ | 124 #endif // VM_FLOW_GRAPH_OPTIMIZER_H_ |
OLD | NEW |