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/bit_vector.h" | 8 #include "vm/bit_vector.h" |
9 #include "vm/growable_array.h" | 9 #include "vm/growable_array.h" |
10 #include "vm/hash_map.h" | 10 #include "vm/hash_map.h" |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 intptr_t num_stack_locals() const { | 104 intptr_t num_stack_locals() const { |
105 return num_stack_locals_; | 105 return num_stack_locals_; |
106 } | 106 } |
107 intptr_t num_copied_params() const { | 107 intptr_t num_copied_params() const { |
108 return num_copied_params_; | 108 return num_copied_params_; |
109 } | 109 } |
110 intptr_t num_non_copied_params() const { | 110 intptr_t num_non_copied_params() const { |
111 return num_non_copied_params_; | 111 return num_non_copied_params_; |
112 } | 112 } |
113 | 113 |
| 114 LocalVariable* CurrentContextVar() const { |
| 115 return parsed_function().current_context_var(); |
| 116 } |
| 117 |
| 118 intptr_t CurrentContextEnvIndex() const { |
| 119 return parsed_function().current_context_var()->BitIndexIn( |
| 120 num_non_copied_params_); |
| 121 } |
| 122 |
114 // Flow graph orders. | 123 // Flow graph orders. |
115 const GrowableArray<BlockEntryInstr*>& preorder() const { | 124 const GrowableArray<BlockEntryInstr*>& preorder() const { |
116 return preorder_; | 125 return preorder_; |
117 } | 126 } |
118 const GrowableArray<BlockEntryInstr*>& postorder() const { | 127 const GrowableArray<BlockEntryInstr*>& postorder() const { |
119 return postorder_; | 128 return postorder_; |
120 } | 129 } |
121 const GrowableArray<BlockEntryInstr*>& reverse_postorder() const { | 130 const GrowableArray<BlockEntryInstr*>& reverse_postorder() const { |
122 return reverse_postorder_; | 131 return reverse_postorder_; |
123 } | 132 } |
(...skipping 28 matching lines...) Expand all Loading... |
152 } | 161 } |
153 | 162 |
154 ConstantInstr* constant_null() const { | 163 ConstantInstr* constant_null() const { |
155 return constant_null_; | 164 return constant_null_; |
156 } | 165 } |
157 | 166 |
158 ConstantInstr* constant_dead() const { | 167 ConstantInstr* constant_dead() const { |
159 return constant_dead_; | 168 return constant_dead_; |
160 } | 169 } |
161 | 170 |
| 171 ConstantInstr* constant_empty_context() const { |
| 172 return constant_empty_context_; |
| 173 } |
| 174 |
162 intptr_t alloc_ssa_temp_index() { return current_ssa_temp_index_++; } | 175 intptr_t alloc_ssa_temp_index() { return current_ssa_temp_index_++; } |
163 | 176 |
164 void AllocateSSAIndexes(Definition* def) { | 177 void AllocateSSAIndexes(Definition* def) { |
165 ASSERT(def); | 178 ASSERT(def); |
166 def->set_ssa_temp_index(alloc_ssa_temp_index()); | 179 def->set_ssa_temp_index(alloc_ssa_temp_index()); |
167 // Always allocate a second index. This index is unused except | 180 // Always allocate a second index. This index is unused except |
168 // for Definitions with register pair outputs. | 181 // for Definitions with register pair outputs. |
169 alloc_ssa_temp_index(); | 182 alloc_ssa_temp_index(); |
170 } | 183 } |
171 | 184 |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
289 BlockEntryInstr* block_entry, | 302 BlockEntryInstr* block_entry, |
290 GrowableArray<Definition*>* env, | 303 GrowableArray<Definition*>* env, |
291 GrowableArray<PhiInstr*>* live_phis, | 304 GrowableArray<PhiInstr*>* live_phis, |
292 VariableLivenessAnalysis* variable_liveness); | 305 VariableLivenessAnalysis* variable_liveness); |
293 | 306 |
294 void AttachEnvironment(Instruction* instr, GrowableArray<Definition*>* env); | 307 void AttachEnvironment(Instruction* instr, GrowableArray<Definition*>* env); |
295 | 308 |
296 void InsertPhis( | 309 void InsertPhis( |
297 const GrowableArray<BlockEntryInstr*>& preorder, | 310 const GrowableArray<BlockEntryInstr*>& preorder, |
298 const GrowableArray<BitVector*>& assigned_vars, | 311 const GrowableArray<BitVector*>& assigned_vars, |
299 const GrowableArray<BitVector*>& dom_frontier); | 312 const GrowableArray<BitVector*>& dom_frontier, |
| 313 GrowableArray<PhiInstr*>* live_phis); |
300 | 314 |
301 void RemoveDeadPhis(GrowableArray<PhiInstr*>* live_phis); | 315 void RemoveDeadPhis(GrowableArray<PhiInstr*>* live_phis); |
302 | 316 |
303 void ReplacePredecessor(BlockEntryInstr* old_block, | 317 void ReplacePredecessor(BlockEntryInstr* old_block, |
304 BlockEntryInstr* new_block); | 318 BlockEntryInstr* new_block); |
305 | 319 |
306 // Find the natural loop for the back edge m->n and attach loop | 320 // Find the natural loop for the back edge m->n and attach loop |
307 // information to block n (loop header). The algorithm is described in | 321 // information to block n (loop header). The algorithm is described in |
308 // "Advanced Compiler Design & Implementation" (Muchnick) p192. | 322 // "Advanced Compiler Design & Implementation" (Muchnick) p192. |
309 // Returns a BitVector indexed by block pre-order number where each bit | 323 // Returns a BitVector indexed by block pre-order number where each bit |
(...skipping 16 matching lines...) Expand all Loading... |
326 const intptr_t num_copied_params_; | 340 const intptr_t num_copied_params_; |
327 const intptr_t num_non_copied_params_; | 341 const intptr_t num_non_copied_params_; |
328 const intptr_t num_stack_locals_; | 342 const intptr_t num_stack_locals_; |
329 GraphEntryInstr* graph_entry_; | 343 GraphEntryInstr* graph_entry_; |
330 GrowableArray<BlockEntryInstr*> preorder_; | 344 GrowableArray<BlockEntryInstr*> preorder_; |
331 GrowableArray<BlockEntryInstr*> postorder_; | 345 GrowableArray<BlockEntryInstr*> postorder_; |
332 GrowableArray<BlockEntryInstr*> reverse_postorder_; | 346 GrowableArray<BlockEntryInstr*> reverse_postorder_; |
333 GrowableArray<BlockEntryInstr*> optimized_block_order_; | 347 GrowableArray<BlockEntryInstr*> optimized_block_order_; |
334 ConstantInstr* constant_null_; | 348 ConstantInstr* constant_null_; |
335 ConstantInstr* constant_dead_; | 349 ConstantInstr* constant_dead_; |
| 350 ConstantInstr* constant_empty_context_; |
336 | 351 |
337 BlockEffects* block_effects_; | 352 BlockEffects* block_effects_; |
338 bool licm_allowed_; | 353 bool licm_allowed_; |
339 | 354 |
340 ZoneGrowableArray<BlockEntryInstr*>* loop_headers_; | 355 ZoneGrowableArray<BlockEntryInstr*>* loop_headers_; |
341 ZoneGrowableArray<BitVector*>* loop_invariant_loads_; | 356 ZoneGrowableArray<BitVector*>* loop_invariant_loads_; |
342 ZoneGrowableArray<const Field*>* guarded_fields_; | 357 ZoneGrowableArray<const Field*>* guarded_fields_; |
343 ZoneGrowableArray<const LibraryPrefix*>* deferred_prefixes_; | 358 ZoneGrowableArray<const LibraryPrefix*>* deferred_prefixes_; |
344 DirectChainedHashMap<ConstantPoolTrait> constant_instr_pool_; | 359 DirectChainedHashMap<ConstantPoolTrait> constant_instr_pool_; |
345 BitVector* captured_parameters_; | 360 BitVector* captured_parameters_; |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
491 | 506 |
492 private: | 507 private: |
493 GrowableArray<Definition*> defs_; | 508 GrowableArray<Definition*> defs_; |
494 BitVector* contains_vector_; | 509 BitVector* contains_vector_; |
495 }; | 510 }; |
496 | 511 |
497 | 512 |
498 } // namespace dart | 513 } // namespace dart |
499 | 514 |
500 #endif // VM_FLOW_GRAPH_H_ | 515 #endif // VM_FLOW_GRAPH_H_ |
OLD | NEW |