| 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 11 matching lines...) Expand all Loading... |
| 22 virtual ~FlowGraphOptimizer() {} | 22 virtual ~FlowGraphOptimizer() {} |
| 23 | 23 |
| 24 FlowGraph* flow_graph() const { return flow_graph_; } | 24 FlowGraph* flow_graph() const { return flow_graph_; } |
| 25 | 25 |
| 26 // Use ICData to optimize, replace or eliminate instructions. | 26 // Use ICData to optimize, replace or eliminate instructions. |
| 27 void ApplyICData(); | 27 void ApplyICData(); |
| 28 | 28 |
| 29 // Use propagated class ids to optimize, replace or eliminate instructions. | 29 // Use propagated class ids to optimize, replace or eliminate instructions. |
| 30 void ApplyClassIds(); | 30 void ApplyClassIds(); |
| 31 | 31 |
| 32 // Optimize (a << b) & c pattern: if c is a positive Smi or zero, then the |
| 33 // shift can be a truncating Smi shift-left and result is always Smi. |
| 34 void TryOptimizeLeftShiftWithBitAndPattern(); |
| 35 |
| 32 void Canonicalize(); | 36 void Canonicalize(); |
| 33 | 37 |
| 34 void EliminateDeadPhis(); | 38 void EliminateDeadPhis(); |
| 35 | 39 |
| 36 void SelectRepresentations(); | 40 void SelectRepresentations(); |
| 37 | 41 |
| 38 void PropagateSminess(); | 42 void PropagateSminess(); |
| 39 | 43 |
| 40 void InferSmiRanges(); | 44 void InferSmiRanges(); |
| 41 | 45 |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 // Insert a check of 'to_check' determined by 'unary_checks'. If the | 94 // Insert a check of 'to_check' determined by 'unary_checks'. If the |
| 91 // check fails it will deoptimize to 'deopt_id' using the deoptimization | 95 // check fails it will deoptimize to 'deopt_id' using the deoptimization |
| 92 // environment 'deopt_environment'. The check is inserted immediately | 96 // environment 'deopt_environment'. The check is inserted immediately |
| 93 // before 'insert_before'. | 97 // before 'insert_before'. |
| 94 void AddCheckClass(Definition* to_check, | 98 void AddCheckClass(Definition* to_check, |
| 95 const ICData& unary_checks, | 99 const ICData& unary_checks, |
| 96 intptr_t deopt_id, | 100 intptr_t deopt_id, |
| 97 Environment* deopt_environment, | 101 Environment* deopt_environment, |
| 98 Instruction* insert_before); | 102 Instruction* insert_before); |
| 99 | 103 |
| 104 // Insert a Smi check if needed. |
| 105 void AddCheckSmi(Definition* to_check, |
| 106 intptr_t deopt_id, |
| 107 Environment* deopt_environment, |
| 108 Instruction* insert_before); |
| 109 |
| 100 // Add a class check for a call's first argument immediately before the | 110 // Add a class check for a call's first argument immediately before the |
| 101 // call, using the call's IC data to determine the check, and the call's | 111 // call, using the call's IC data to determine the check, and the call's |
| 102 // deopt ID and deoptimization environment if the check fails. | 112 // deopt ID and deoptimization environment if the check fails. |
| 103 void AddReceiverCheck(InstanceCallInstr* call); | 113 void AddReceiverCheck(InstanceCallInstr* call); |
| 104 | 114 |
| 105 void ReplaceCall(Definition* call, Definition* replacement); | 115 void ReplaceCall(Definition* call, Definition* replacement); |
| 106 | 116 |
| 107 void InsertConversionsFor(Definition* def); | 117 void InsertConversionsFor(Definition* def); |
| 108 | 118 |
| 109 void InsertConversion(Representation from, | 119 void InsertConversion(Representation from, |
| (...skipping 21 matching lines...) Expand all Loading... |
| 131 MethodRecognizer::Kind recognized_kind); | 141 MethodRecognizer::Kind recognized_kind); |
| 132 | 142 |
| 133 void HandleRelationalOp(RelationalOpInstr* comp); | 143 void HandleRelationalOp(RelationalOpInstr* comp); |
| 134 | 144 |
| 135 // Visit an equality compare. The current instruction can be the | 145 // Visit an equality compare. The current instruction can be the |
| 136 // comparison itself or a branch on the comparison. | 146 // comparison itself or a branch on the comparison. |
| 137 template <typename T> | 147 template <typename T> |
| 138 void HandleEqualityCompare(EqualityCompareInstr* comp, | 148 void HandleEqualityCompare(EqualityCompareInstr* comp, |
| 139 T current_instruction); | 149 T current_instruction); |
| 140 | 150 |
| 151 void OptimizeLeftShiftBitAndSmiOp(Definition* bit_and_instr, |
| 152 Definition* left_instr, |
| 153 Definition* right_instr); |
| 154 |
| 141 FlowGraph* flow_graph_; | 155 FlowGraph* flow_graph_; |
| 142 | 156 |
| 143 DISALLOW_COPY_AND_ASSIGN(FlowGraphOptimizer); | 157 DISALLOW_COPY_AND_ASSIGN(FlowGraphOptimizer); |
| 144 }; | 158 }; |
| 145 | 159 |
| 146 | 160 |
| 147 class ParsedFunction; | 161 class ParsedFunction; |
| 148 | 162 |
| 149 | 163 |
| 150 // Loop invariant code motion. | 164 // Loop invariant code motion. |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 | 250 |
| 237 // Worklists of blocks and definitions. | 251 // Worklists of blocks and definitions. |
| 238 GrowableArray<BlockEntryInstr*> block_worklist_; | 252 GrowableArray<BlockEntryInstr*> block_worklist_; |
| 239 GrowableArray<Definition*> definition_worklist_; | 253 GrowableArray<Definition*> definition_worklist_; |
| 240 }; | 254 }; |
| 241 | 255 |
| 242 | 256 |
| 243 } // namespace dart | 257 } // namespace dart |
| 244 | 258 |
| 245 #endif // VM_FLOW_GRAPH_OPTIMIZER_H_ | 259 #endif // VM_FLOW_GRAPH_OPTIMIZER_H_ |
| OLD | NEW |