| 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 27 matching lines...) Expand all Loading... |
| 38 void ApplyICData(); | 38 void ApplyICData(); |
| 39 | 39 |
| 40 // Use propagated class ids to optimize, replace or eliminate instructions. | 40 // Use propagated class ids to optimize, replace or eliminate instructions. |
| 41 void ApplyClassIds(); | 41 void ApplyClassIds(); |
| 42 | 42 |
| 43 // Optimize (a << b) & c pattern: if c is a positive Smi or zero, then the | 43 // Optimize (a << b) & c pattern: if c is a positive Smi or zero, then the |
| 44 // shift can be a truncating Smi shift-left and result is always Smi. | 44 // shift can be a truncating Smi shift-left and result is always Smi. |
| 45 // Merge instructions (only per basic-block). | 45 // Merge instructions (only per basic-block). |
| 46 void TryOptimizePatterns(); | 46 void TryOptimizePatterns(); |
| 47 | 47 |
| 48 // Returns true if any instructions were canonicalized away. | |
| 49 bool Canonicalize(); | |
| 50 | |
| 51 void EliminateDeadPhis(); | |
| 52 | |
| 53 void SelectRepresentations(); | |
| 54 | |
| 55 void WidenSmiToInt32(); | |
| 56 | |
| 57 // Remove environments from the instructions which do not deoptimize. | |
| 58 void EliminateEnvironments(); | |
| 59 | |
| 60 virtual void VisitStaticCall(StaticCallInstr* instr); | 48 virtual void VisitStaticCall(StaticCallInstr* instr); |
| 61 virtual void VisitInstanceCall(InstanceCallInstr* instr); | 49 virtual void VisitInstanceCall(InstanceCallInstr* instr); |
| 62 virtual void VisitStoreInstanceField(StoreInstanceFieldInstr* instr); | 50 virtual void VisitStoreInstanceField(StoreInstanceFieldInstr* instr); |
| 63 virtual void VisitAllocateContext(AllocateContextInstr* instr); | 51 virtual void VisitAllocateContext(AllocateContextInstr* instr); |
| 64 virtual void VisitLoadCodeUnits(LoadCodeUnitsInstr* instr); | 52 virtual void VisitLoadCodeUnits(LoadCodeUnitsInstr* instr); |
| 65 | 53 |
| 66 void InsertBefore(Instruction* next, | 54 void InsertBefore(Instruction* next, |
| 67 Instruction* instr, | 55 Instruction* instr, |
| 68 Environment* env, | 56 Environment* env, |
| 69 FlowGraph::UseKind use_kind) { | 57 FlowGraph::UseKind use_kind) { |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 Environment* deopt_environment, | 119 Environment* deopt_environment, |
| 132 Instruction* insert_before); | 120 Instruction* insert_before); |
| 133 | 121 |
| 134 // Add a class check for a call's first argument immediately before the | 122 // Add a class check for a call's first argument immediately before the |
| 135 // call, using the call's IC data to determine the check, and the call's | 123 // call, using the call's IC data to determine the check, and the call's |
| 136 // deopt ID and deoptimization environment if the check fails. | 124 // deopt ID and deoptimization environment if the check fails. |
| 137 void AddReceiverCheck(InstanceCallInstr* call); | 125 void AddReceiverCheck(InstanceCallInstr* call); |
| 138 | 126 |
| 139 void ReplaceCall(Definition* call, Definition* replacement); | 127 void ReplaceCall(Definition* call, Definition* replacement); |
| 140 | 128 |
| 141 void InsertConversionsFor(Definition* def); | |
| 142 | |
| 143 void ConvertUse(Value* use, Representation from); | |
| 144 void ConvertEnvironmentUse(Value* use, Representation from); | |
| 145 | |
| 146 void InsertConversion(Representation from, | |
| 147 Representation to, | |
| 148 Value* use, | |
| 149 bool is_environment_use); | |
| 150 | 129 |
| 151 bool InstanceCallNeedsClassCheck(InstanceCallInstr* call, | 130 bool InstanceCallNeedsClassCheck(InstanceCallInstr* call, |
| 152 RawFunction::Kind kind) const; | 131 RawFunction::Kind kind) const; |
| 153 | 132 |
| 154 bool InlineFloat32x4Getter(InstanceCallInstr* call, | 133 bool InlineFloat32x4Getter(InstanceCallInstr* call, |
| 155 MethodRecognizer::Kind getter); | 134 MethodRecognizer::Kind getter); |
| 156 bool InlineFloat64x2Getter(InstanceCallInstr* call, | 135 bool InlineFloat64x2Getter(InstanceCallInstr* call, |
| 157 MethodRecognizer::Kind getter); | 136 MethodRecognizer::Kind getter); |
| 158 bool InlineInt32x4Getter(InstanceCallInstr* call, | 137 bool InlineInt32x4Getter(InstanceCallInstr* call, |
| 159 MethodRecognizer::Kind getter); | 138 MethodRecognizer::Kind getter); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 | 179 |
| 201 GrowableArray<intptr_t>* inlining_black_list_; | 180 GrowableArray<intptr_t>* inlining_black_list_; |
| 202 | 181 |
| 203 DISALLOW_COPY_AND_ASSIGN(FlowGraphOptimizer); | 182 DISALLOW_COPY_AND_ASSIGN(FlowGraphOptimizer); |
| 204 }; | 183 }; |
| 205 | 184 |
| 206 | 185 |
| 207 } // namespace dart | 186 } // namespace dart |
| 208 | 187 |
| 209 #endif // VM_FLOW_GRAPH_OPTIMIZER_H_ | 188 #endif // VM_FLOW_GRAPH_OPTIMIZER_H_ |
| OLD | NEW |