| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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_H_ | 5 #ifndef VM_FLOW_GRAPH_H_ |
| 6 #define VM_FLOW_GRAPH_H_ | 6 #define VM_FLOW_GRAPH_H_ |
| 7 | 7 |
| 8 #include "vm/growable_array.h" | 8 #include "vm/growable_array.h" |
| 9 #include "vm/intermediate_language.h" | 9 #include "vm/intermediate_language.h" |
| 10 #include "vm/parser.h" | 10 #include "vm/parser.h" |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 Definition::UseKind use_kind); | 121 Definition::UseKind use_kind); |
| 122 void InsertAfter(Instruction* prev, | 122 void InsertAfter(Instruction* prev, |
| 123 Instruction* instr, | 123 Instruction* instr, |
| 124 Environment* env, | 124 Environment* env, |
| 125 Definition::UseKind use_kind); | 125 Definition::UseKind use_kind); |
| 126 | 126 |
| 127 // Operations on the flow graph. | 127 // Operations on the flow graph. |
| 128 void ComputeSSA(intptr_t next_virtual_register_number, | 128 void ComputeSSA(intptr_t next_virtual_register_number, |
| 129 ZoneGrowableArray<Definition*>* inlining_parameters); | 129 ZoneGrowableArray<Definition*>* inlining_parameters); |
| 130 | 130 |
| 131 // Finds natural loops in the flow graph and attaches a list of loop | |
| 132 // body blocks for each loop header. | |
| 133 void ComputeLoops(GrowableArray<BlockEntryInstr*>* loop_headers); | |
| 134 | |
| 135 // TODO(zerny): Once the SSA is feature complete this should be removed. | 131 // TODO(zerny): Once the SSA is feature complete this should be removed. |
| 136 void Bailout(const char* reason) const; | 132 void Bailout(const char* reason) const; |
| 137 | 133 |
| 138 #ifdef DEBUG | 134 #ifdef DEBUG |
| 139 // Verification methods for debugging. | 135 // Verification methods for debugging. |
| 140 bool VerifyUseLists(); | 136 bool VerifyUseLists(); |
| 141 #endif // DEBUG | 137 #endif // DEBUG |
| 142 | 138 |
| 143 void DiscoverBlocks(); | 139 void DiscoverBlocks(); |
| 144 | 140 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 160 | 156 |
| 161 // Returns true if every Goto in the graph is expected to have a | 157 // Returns true if every Goto in the graph is expected to have a |
| 162 // deoptimization environment and can be used as deoptimization target | 158 // deoptimization environment and can be used as deoptimization target |
| 163 // for hoisted instructions. | 159 // for hoisted instructions. |
| 164 bool is_licm_allowed() const { return licm_allowed_; } | 160 bool is_licm_allowed() const { return licm_allowed_; } |
| 165 | 161 |
| 166 // Stop preserving environments on Goto instructions. LICM is not allowed | 162 // Stop preserving environments on Goto instructions. LICM is not allowed |
| 167 // after this point. | 163 // after this point. |
| 168 void disallow_licm() { licm_allowed_ = false; } | 164 void disallow_licm() { licm_allowed_ = false; } |
| 169 | 165 |
| 166 const ZoneGrowableArray<BlockEntryInstr*>& loop_headers() { |
| 167 if (loop_headers_ == NULL) { |
| 168 loop_headers_ = ComputeLoops(); |
| 169 } |
| 170 return *loop_headers_; |
| 171 } |
| 172 |
| 173 // Per loop header invariant loads sets. Each set contains load id for |
| 174 // those loads that are not affected by anything in the loop and can be |
| 175 // hoisted out. Sets are computed by LoadOptimizer. |
| 176 ZoneGrowableArray<BitVector*>* loop_invariant_loads() const { |
| 177 return loop_invariant_loads_; |
| 178 } |
| 179 void set_loop_invariant_loads( |
| 180 ZoneGrowableArray<BitVector*>* loop_invariant_loads) { |
| 181 loop_invariant_loads_ = loop_invariant_loads; |
| 182 } |
| 183 |
| 170 private: | 184 private: |
| 171 friend class IfConverter; | 185 friend class IfConverter; |
| 172 friend class BranchSimplifier; | 186 friend class BranchSimplifier; |
| 173 friend class ConstantPropagator; | 187 friend class ConstantPropagator; |
| 174 | 188 |
| 175 // SSA transformation methods and fields. | 189 // SSA transformation methods and fields. |
| 176 void ComputeDominators(GrowableArray<BitVector*>* dominance_frontier); | 190 void ComputeDominators(GrowableArray<BitVector*>* dominance_frontier); |
| 177 | 191 |
| 178 void CompressPath( | 192 void CompressPath( |
| 179 intptr_t start_index, | 193 intptr_t start_index, |
| (...skipping 15 matching lines...) Expand all Loading... |
| 195 void InsertPhis( | 209 void InsertPhis( |
| 196 const GrowableArray<BlockEntryInstr*>& preorder, | 210 const GrowableArray<BlockEntryInstr*>& preorder, |
| 197 const GrowableArray<BitVector*>& assigned_vars, | 211 const GrowableArray<BitVector*>& assigned_vars, |
| 198 const GrowableArray<BitVector*>& dom_frontier); | 212 const GrowableArray<BitVector*>& dom_frontier); |
| 199 | 213 |
| 200 void RemoveDeadPhis(GrowableArray<PhiInstr*>* live_phis); | 214 void RemoveDeadPhis(GrowableArray<PhiInstr*>* live_phis); |
| 201 | 215 |
| 202 void ReplacePredecessor(BlockEntryInstr* old_block, | 216 void ReplacePredecessor(BlockEntryInstr* old_block, |
| 203 BlockEntryInstr* new_block); | 217 BlockEntryInstr* new_block); |
| 204 | 218 |
| 219 // Finds natural loops in the flow graph and attaches a list of loop |
| 220 // body blocks for each loop header. |
| 221 ZoneGrowableArray<BlockEntryInstr*>* ComputeLoops(); |
| 222 |
| 205 // DiscoverBlocks computes parent_ and assigned_vars_ which are then used | 223 // DiscoverBlocks computes parent_ and assigned_vars_ which are then used |
| 206 // if/when computing SSA. | 224 // if/when computing SSA. |
| 207 GrowableArray<intptr_t> parent_; | 225 GrowableArray<intptr_t> parent_; |
| 208 GrowableArray<BitVector*> assigned_vars_; | 226 GrowableArray<BitVector*> assigned_vars_; |
| 209 | 227 |
| 210 intptr_t current_ssa_temp_index_; | 228 intptr_t current_ssa_temp_index_; |
| 211 intptr_t max_block_id_; | 229 intptr_t max_block_id_; |
| 212 | 230 |
| 213 // Flow graph fields. | 231 // Flow graph fields. |
| 214 const ParsedFunction& parsed_function_; | 232 const ParsedFunction& parsed_function_; |
| 215 const intptr_t num_copied_params_; | 233 const intptr_t num_copied_params_; |
| 216 const intptr_t num_non_copied_params_; | 234 const intptr_t num_non_copied_params_; |
| 217 const intptr_t num_stack_locals_; | 235 const intptr_t num_stack_locals_; |
| 218 GraphEntryInstr* graph_entry_; | 236 GraphEntryInstr* graph_entry_; |
| 219 GrowableArray<BlockEntryInstr*> preorder_; | 237 GrowableArray<BlockEntryInstr*> preorder_; |
| 220 GrowableArray<BlockEntryInstr*> postorder_; | 238 GrowableArray<BlockEntryInstr*> postorder_; |
| 221 GrowableArray<BlockEntryInstr*> reverse_postorder_; | 239 GrowableArray<BlockEntryInstr*> reverse_postorder_; |
| 222 ConstantInstr* constant_null_; | 240 ConstantInstr* constant_null_; |
| 223 | 241 |
| 224 BlockEffects* block_effects_; | 242 BlockEffects* block_effects_; |
| 225 bool licm_allowed_; | 243 bool licm_allowed_; |
| 244 |
| 245 ZoneGrowableArray<BlockEntryInstr*>* loop_headers_; |
| 246 ZoneGrowableArray<BitVector*>* loop_invariant_loads_; |
| 226 }; | 247 }; |
| 227 | 248 |
| 228 | 249 |
| 229 class LivenessAnalysis : public ValueObject { | 250 class LivenessAnalysis : public ValueObject { |
| 230 public: | 251 public: |
| 231 LivenessAnalysis(intptr_t variable_count, | 252 LivenessAnalysis(intptr_t variable_count, |
| 232 const GrowableArray<BlockEntryInstr*>& postorder); | 253 const GrowableArray<BlockEntryInstr*>& postorder); |
| 233 | 254 |
| 234 void Analyze(); | 255 void Analyze(); |
| 235 | 256 |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 321 // Per block sets of available blocks. Block A is available at the block B if | 342 // Per block sets of available blocks. Block A is available at the block B if |
| 322 // and only if A dominates B and all paths from A to B are free of side | 343 // and only if A dominates B and all paths from A to B are free of side |
| 323 // effects. | 344 // effects. |
| 324 GrowableArray<BitVector*> available_at_; | 345 GrowableArray<BitVector*> available_at_; |
| 325 }; | 346 }; |
| 326 | 347 |
| 327 | 348 |
| 328 } // namespace dart | 349 } // namespace dart |
| 329 | 350 |
| 330 #endif // VM_FLOW_GRAPH_H_ | 351 #endif // VM_FLOW_GRAPH_H_ |
| OLD | NEW |