| 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 explicit FlowGraphOptimizer(FlowGraph* flow_graph) | 19 FlowGraphOptimizer(FlowGraph* flow_graph, |
| 20 GrowableArray<const Field*>* guarded_fields) |
| 20 : FlowGraphVisitor(flow_graph->reverse_postorder()), | 21 : FlowGraphVisitor(flow_graph->reverse_postorder()), |
| 21 flow_graph_(flow_graph) { } | 22 flow_graph_(flow_graph), |
| 23 guarded_fields_(guarded_fields) { } |
| 22 virtual ~FlowGraphOptimizer() {} | 24 virtual ~FlowGraphOptimizer() {} |
| 23 | 25 |
| 24 FlowGraph* flow_graph() const { return flow_graph_; } | 26 FlowGraph* flow_graph() const { return flow_graph_; } |
| 25 | 27 |
| 26 // Use ICData to optimize, replace or eliminate instructions. | 28 // Use ICData to optimize, replace or eliminate instructions. |
| 27 void ApplyICData(); | 29 void ApplyICData(); |
| 28 | 30 |
| 29 // Use propagated class ids to optimize, replace or eliminate instructions. | 31 // Use propagated class ids to optimize, replace or eliminate instructions. |
| 30 void ApplyClassIds(); | 32 void ApplyClassIds(); |
| 31 | 33 |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 | 189 |
| 188 template <typename T> | 190 template <typename T> |
| 189 bool StrictifyEqualityCompareWithICData(EqualityCompareInstr* compare, | 191 bool StrictifyEqualityCompareWithICData(EqualityCompareInstr* compare, |
| 190 const ICData& unary_ic_data, | 192 const ICData& unary_ic_data, |
| 191 T current_instruction); | 193 T current_instruction); |
| 192 | 194 |
| 193 void OptimizeLeftShiftBitAndSmiOp(Definition* bit_and_instr, | 195 void OptimizeLeftShiftBitAndSmiOp(Definition* bit_and_instr, |
| 194 Definition* left_instr, | 196 Definition* left_instr, |
| 195 Definition* right_instr); | 197 Definition* right_instr); |
| 196 | 198 |
| 199 void AddToGuardedFields(const Field& field); |
| 200 |
| 197 FlowGraph* flow_graph_; | 201 FlowGraph* flow_graph_; |
| 202 GrowableArray<const Field*>* guarded_fields_; |
| 198 | 203 |
| 199 DISALLOW_COPY_AND_ASSIGN(FlowGraphOptimizer); | 204 DISALLOW_COPY_AND_ASSIGN(FlowGraphOptimizer); |
| 200 }; | 205 }; |
| 201 | 206 |
| 202 | 207 |
| 203 // Loop invariant code motion. | 208 // Loop invariant code motion. |
| 204 class LICM : public ValueObject { | 209 class LICM : public ValueObject { |
| 205 public: | 210 public: |
| 206 explicit LICM(FlowGraph* flow_graph); | 211 explicit LICM(FlowGraph* flow_graph); |
| 207 | 212 |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 371 // Optimize spill stores inside try-blocks by identifying values that always | 376 // Optimize spill stores inside try-blocks by identifying values that always |
| 372 // contain a single known constant at catch block entry. | 377 // contain a single known constant at catch block entry. |
| 373 class TryCatchAnalyzer : public AllStatic { | 378 class TryCatchAnalyzer : public AllStatic { |
| 374 public: | 379 public: |
| 375 static void Optimize(FlowGraph* flow_graph); | 380 static void Optimize(FlowGraph* flow_graph); |
| 376 }; | 381 }; |
| 377 | 382 |
| 378 } // namespace dart | 383 } // namespace dart |
| 379 | 384 |
| 380 #endif // VM_FLOW_GRAPH_OPTIMIZER_H_ | 385 #endif // VM_FLOW_GRAPH_OPTIMIZER_H_ |
| OLD | NEW |