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 template <typename T> class PointerKeyValueTrait; |
16 | 16 |
17 class FlowGraphOptimizer : public FlowGraphVisitor { | 17 class FlowGraphOptimizer : public FlowGraphVisitor { |
18 public: | 18 public: |
19 FlowGraphOptimizer(FlowGraph* flow_graph, | 19 explicit FlowGraphOptimizer(FlowGraph* flow_graph) |
20 GrowableArray<Field*>* guarded_fields) | |
21 : FlowGraphVisitor(flow_graph->reverse_postorder()), | 20 : FlowGraphVisitor(flow_graph->reverse_postorder()), |
22 flow_graph_(flow_graph), | 21 flow_graph_(flow_graph) { } |
23 guarded_fields_(guarded_fields) { } | |
24 virtual ~FlowGraphOptimizer() {} | 22 virtual ~FlowGraphOptimizer() {} |
25 | 23 |
26 FlowGraph* flow_graph() const { return flow_graph_; } | 24 FlowGraph* flow_graph() const { return flow_graph_; } |
27 | 25 |
28 // Use ICData to optimize, replace or eliminate instructions. | 26 // Use ICData to optimize, replace or eliminate instructions. |
29 void ApplyICData(); | 27 void ApplyICData(); |
30 | 28 |
31 // Use propagated class ids to optimize, replace or eliminate instructions. | 29 // Use propagated class ids to optimize, replace or eliminate instructions. |
32 void ApplyClassIds(); | 30 void ApplyClassIds(); |
33 | 31 |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 // comparison itself or a branch on the comparison. | 151 // comparison itself or a branch on the comparison. |
154 template <typename T> | 152 template <typename T> |
155 void HandleEqualityCompare(EqualityCompareInstr* comp, | 153 void HandleEqualityCompare(EqualityCompareInstr* comp, |
156 T current_instruction); | 154 T current_instruction); |
157 | 155 |
158 void OptimizeLeftShiftBitAndSmiOp(Definition* bit_and_instr, | 156 void OptimizeLeftShiftBitAndSmiOp(Definition* bit_and_instr, |
159 Definition* left_instr, | 157 Definition* left_instr, |
160 Definition* right_instr); | 158 Definition* right_instr); |
161 | 159 |
162 FlowGraph* flow_graph_; | 160 FlowGraph* flow_graph_; |
163 GrowableArray<Field*>* guarded_fields_; | |
164 | 161 |
165 DISALLOW_COPY_AND_ASSIGN(FlowGraphOptimizer); | 162 DISALLOW_COPY_AND_ASSIGN(FlowGraphOptimizer); |
166 }; | 163 }; |
167 | 164 |
168 | 165 |
169 class ParsedFunction; | 166 class ParsedFunction; |
170 | 167 |
171 | 168 |
172 // Loop invariant code motion. | 169 // Loop invariant code motion. |
173 class LICM : public ValueObject { | 170 class LICM : public ValueObject { |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
298 // inputs. | 295 // inputs. |
299 static BranchInstr* CloneBranch(BranchInstr* branch, | 296 static BranchInstr* CloneBranch(BranchInstr* branch, |
300 Value* left, | 297 Value* left, |
301 Value* right); | 298 Value* right); |
302 }; | 299 }; |
303 | 300 |
304 | 301 |
305 } // namespace dart | 302 } // namespace dart |
306 | 303 |
307 #endif // VM_FLOW_GRAPH_OPTIMIZER_H_ | 304 #endif // VM_FLOW_GRAPH_OPTIMIZER_H_ |
OLD | NEW |