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 |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 | 114 |
115 FlowGraph* flow_graph_; | 115 FlowGraph* flow_graph_; |
116 | 116 |
117 DISALLOW_COPY_AND_ASSIGN(FlowGraphOptimizer); | 117 DISALLOW_COPY_AND_ASSIGN(FlowGraphOptimizer); |
118 }; | 118 }; |
119 | 119 |
120 | 120 |
121 class ParsedFunction; | 121 class ParsedFunction; |
122 | 122 |
123 | 123 |
124 class FlowGraphTypePropagator : public FlowGraphVisitor { | |
125 public: | |
126 explicit FlowGraphTypePropagator(FlowGraph* flow_graph) | |
127 : FlowGraphVisitor(flow_graph->reverse_postorder()), | |
128 parsed_function_(flow_graph->parsed_function()), | |
129 flow_graph_(flow_graph), | |
130 still_changing_(false) { } | |
131 virtual ~FlowGraphTypePropagator() { } | |
132 | |
133 const ParsedFunction& parsed_function() const { return parsed_function_; } | |
134 | |
135 void PropagateTypes(); | |
136 | |
137 private: | |
138 virtual void VisitBlocks(); | |
139 | |
140 virtual void VisitAssertAssignable(AssertAssignableInstr* instr); | |
141 virtual void VisitAssertBoolean(AssertBooleanInstr* instr); | |
142 virtual void VisitInstanceOf(InstanceOfInstr* instr); | |
143 | |
144 virtual void VisitGraphEntry(GraphEntryInstr* graph_entry); | |
145 virtual void VisitJoinEntry(JoinEntryInstr* join_entry); | |
146 virtual void VisitPhi(PhiInstr* phi); | |
147 virtual void VisitParameter(ParameterInstr* param); | |
148 virtual void VisitPushArgument(PushArgumentInstr* bind); | |
149 | |
150 const ParsedFunction& parsed_function_; | |
151 FlowGraph* flow_graph_; | |
152 bool still_changing_; | |
153 DISALLOW_COPY_AND_ASSIGN(FlowGraphTypePropagator); | |
154 }; | |
155 | |
156 | |
157 // Loop invariant code motion. | 124 // Loop invariant code motion. |
158 class LICM : public AllStatic { | 125 class LICM : public AllStatic { |
159 public: | 126 public: |
160 static void Optimize(FlowGraph* flow_graph); | 127 static void Optimize(FlowGraph* flow_graph); |
161 | 128 |
162 private: | 129 private: |
163 static void Hoist(ForwardInstructionIterator* it, | 130 static void Hoist(ForwardInstructionIterator* it, |
164 BlockEntryInstr* pre_header, | 131 BlockEntryInstr* pre_header, |
165 Instruction* current); | 132 Instruction* current); |
166 | 133 |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
243 | 210 |
244 // Worklists of blocks and definitions. | 211 // Worklists of blocks and definitions. |
245 GrowableArray<BlockEntryInstr*> block_worklist_; | 212 GrowableArray<BlockEntryInstr*> block_worklist_; |
246 GrowableArray<Definition*> definition_worklist_; | 213 GrowableArray<Definition*> definition_worklist_; |
247 }; | 214 }; |
248 | 215 |
249 | 216 |
250 } // namespace dart | 217 } // namespace dart |
251 | 218 |
252 #endif // VM_FLOW_GRAPH_OPTIMIZER_H_ | 219 #endif // VM_FLOW_GRAPH_OPTIMIZER_H_ |
OLD | NEW |