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 class CSEInstructionMap; | 13 class CSEInstructionMap; |
14 template <typename T> class GrowableArray; | 14 template <typename T> class GrowableArray; |
15 class ParsedFunction; | 15 class ParsedFunction; |
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<const 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 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 | 187 |
190 template <typename T> | 188 template <typename T> |
191 bool StrictifyEqualityCompareWithICData(EqualityCompareInstr* compare, | 189 bool StrictifyEqualityCompareWithICData(EqualityCompareInstr* compare, |
192 const ICData& unary_ic_data, | 190 const ICData& unary_ic_data, |
193 T current_instruction); | 191 T current_instruction); |
194 | 192 |
195 void OptimizeLeftShiftBitAndSmiOp(Definition* bit_and_instr, | 193 void OptimizeLeftShiftBitAndSmiOp(Definition* bit_and_instr, |
196 Definition* left_instr, | 194 Definition* left_instr, |
197 Definition* right_instr); | 195 Definition* right_instr); |
198 | 196 |
199 void AddToGuardedFields(const Field& field); | |
200 | |
201 FlowGraph* flow_graph_; | 197 FlowGraph* flow_graph_; |
202 GrowableArray<const Field*>* guarded_fields_; | |
203 | 198 |
204 DISALLOW_COPY_AND_ASSIGN(FlowGraphOptimizer); | 199 DISALLOW_COPY_AND_ASSIGN(FlowGraphOptimizer); |
205 }; | 200 }; |
206 | 201 |
207 | 202 |
208 // Loop invariant code motion. | 203 // Loop invariant code motion. |
209 class LICM : public ValueObject { | 204 class LICM : public ValueObject { |
210 public: | 205 public: |
211 explicit LICM(FlowGraph* flow_graph); | 206 explicit LICM(FlowGraph* flow_graph); |
212 | 207 |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
376 // Optimize spill stores inside try-blocks by identifying values that always | 371 // Optimize spill stores inside try-blocks by identifying values that always |
377 // contain a single known constant at catch block entry. | 372 // contain a single known constant at catch block entry. |
378 class TryCatchAnalyzer : public AllStatic { | 373 class TryCatchAnalyzer : public AllStatic { |
379 public: | 374 public: |
380 static void Optimize(FlowGraph* flow_graph); | 375 static void Optimize(FlowGraph* flow_graph); |
381 }; | 376 }; |
382 | 377 |
383 } // namespace dart | 378 } // namespace dart |
384 | 379 |
385 #endif // VM_FLOW_GRAPH_OPTIMIZER_H_ | 380 #endif // VM_FLOW_GRAPH_OPTIMIZER_H_ |
OLD | NEW |