| 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 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 | 176 |
| 179 template <typename T> | 177 template <typename T> |
| 180 bool StrictifyEqualityCompareWithICData(EqualityCompareInstr* compare, | 178 bool StrictifyEqualityCompareWithICData(EqualityCompareInstr* compare, |
| 181 const ICData& unary_ic_data, | 179 const ICData& unary_ic_data, |
| 182 T current_instruction); | 180 T current_instruction); |
| 183 | 181 |
| 184 void OptimizeLeftShiftBitAndSmiOp(Definition* bit_and_instr, | 182 void OptimizeLeftShiftBitAndSmiOp(Definition* bit_and_instr, |
| 185 Definition* left_instr, | 183 Definition* left_instr, |
| 186 Definition* right_instr); | 184 Definition* right_instr); |
| 187 | 185 |
| 188 void AddToGuardedFields(const Field& field); | |
| 189 | |
| 190 FlowGraph* flow_graph_; | 186 FlowGraph* flow_graph_; |
| 191 GrowableArray<const Field*>* guarded_fields_; | |
| 192 | 187 |
| 193 DISALLOW_COPY_AND_ASSIGN(FlowGraphOptimizer); | 188 DISALLOW_COPY_AND_ASSIGN(FlowGraphOptimizer); |
| 194 }; | 189 }; |
| 195 | 190 |
| 196 | 191 |
| 197 // Loop invariant code motion. | 192 // Loop invariant code motion. |
| 198 class LICM : public ValueObject { | 193 class LICM : public ValueObject { |
| 199 public: | 194 public: |
| 200 explicit LICM(FlowGraph* flow_graph); | 195 explicit LICM(FlowGraph* flow_graph); |
| 201 | 196 |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 365 // Optimize spill stores inside try-blocks by identifying values that always | 360 // Optimize spill stores inside try-blocks by identifying values that always |
| 366 // contain a single known constant at catch block entry. | 361 // contain a single known constant at catch block entry. |
| 367 class TryCatchAnalyzer : public AllStatic { | 362 class TryCatchAnalyzer : public AllStatic { |
| 368 public: | 363 public: |
| 369 static void Optimize(FlowGraph* flow_graph); | 364 static void Optimize(FlowGraph* flow_graph); |
| 370 }; | 365 }; |
| 371 | 366 |
| 372 } // namespace dart | 367 } // namespace dart |
| 373 | 368 |
| 374 #endif // VM_FLOW_GRAPH_OPTIMIZER_H_ | 369 #endif // VM_FLOW_GRAPH_OPTIMIZER_H_ |
| OLD | NEW |