| 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_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/parser.h" | 9 #include "vm/parser.h" |
| 10 | 10 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 | 33 |
| 34 private: | 34 private: |
| 35 const GrowableArray<BlockEntryInstr*>& block_order_; | 35 const GrowableArray<BlockEntryInstr*>& block_order_; |
| 36 intptr_t current_; | 36 intptr_t current_; |
| 37 }; | 37 }; |
| 38 | 38 |
| 39 | 39 |
| 40 // Class to incapsulate the construction and manipulation of the flow graph. | 40 // Class to incapsulate the construction and manipulation of the flow graph. |
| 41 class FlowGraph : public ZoneAllocated { | 41 class FlowGraph : public ZoneAllocated { |
| 42 public: | 42 public: |
| 43 FlowGraph(const FlowGraphBuilder& builder, GraphEntryInstr* graph_entry); | 43 FlowGraph(const FlowGraphBuilder& builder, |
| 44 GraphEntryInstr* graph_entry, |
| 45 intptr_t max_block_id); |
| 44 | 46 |
| 45 // Function properties. | 47 // Function properties. |
| 46 const ParsedFunction& parsed_function() const { | 48 const ParsedFunction& parsed_function() const { |
| 47 return parsed_function_; | 49 return parsed_function_; |
| 48 } | 50 } |
| 49 intptr_t parameter_count() const { | 51 intptr_t parameter_count() const { |
| 50 return num_copied_params_ + num_non_copied_params_; | 52 return num_copied_params_ + num_non_copied_params_; |
| 51 } | 53 } |
| 52 intptr_t variable_count() const { | 54 intptr_t variable_count() const { |
| 53 return parameter_count() + num_stack_locals_; | 55 return parameter_count() + num_stack_locals_; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 80 BlockIterator postorder_iterator() const { | 82 BlockIterator postorder_iterator() const { |
| 81 return BlockIterator(postorder()); | 83 return BlockIterator(postorder()); |
| 82 } | 84 } |
| 83 | 85 |
| 84 intptr_t current_ssa_temp_index() const { return current_ssa_temp_index_; } | 86 intptr_t current_ssa_temp_index() const { return current_ssa_temp_index_; } |
| 85 | 87 |
| 86 intptr_t max_virtual_register_number() const { | 88 intptr_t max_virtual_register_number() const { |
| 87 return current_ssa_temp_index(); | 89 return current_ssa_temp_index(); |
| 88 } | 90 } |
| 89 | 91 |
| 92 intptr_t max_block_id() const { |
| 93 return max_block_id_; |
| 94 } |
| 95 |
| 90 GraphEntryInstr* graph_entry() const { | 96 GraphEntryInstr* graph_entry() const { |
| 91 return graph_entry_; | 97 return graph_entry_; |
| 92 } | 98 } |
| 93 | 99 |
| 94 ZoneGrowableArray<ReturnInstr*>* exits() const { return exits_; } | 100 ZoneGrowableArray<ReturnInstr*>* exits() const { return exits_; } |
| 95 void set_exits(ZoneGrowableArray<ReturnInstr*>* exits) { exits_ = exits; } | 101 void set_exits(ZoneGrowableArray<ReturnInstr*>* exits) { exits_ = exits; } |
| 96 | 102 |
| 97 intptr_t alloc_ssa_temp_index() { return current_ssa_temp_index_++; } | 103 intptr_t alloc_ssa_temp_index() { return current_ssa_temp_index_++; } |
| 98 | 104 |
| 105 intptr_t InstructionCount() const; |
| 106 |
| 99 // Operations on the flow graph. | 107 // Operations on the flow graph. |
| 100 void ComputeSSA(intptr_t next_virtual_register_number); | 108 void ComputeSSA(intptr_t next_virtual_register_number); |
| 101 void ComputeUseLists(); | 109 void ComputeUseLists(); |
| 102 | 110 |
| 103 // Finds natural loops in the flow graph and attaches a list of loop | 111 // Finds natural loops in the flow graph and attaches a list of loop |
| 104 // body blocks for each loop header. | 112 // body blocks for each loop header. |
| 105 void ComputeLoops(GrowableArray<BlockEntryInstr*>* loop_headers); | 113 void ComputeLoops(GrowableArray<BlockEntryInstr*>* loop_headers); |
| 106 | 114 |
| 107 void InlineCall(Definition* call, FlowGraph* callee_graph); | 115 void InlineCall(Definition* call, FlowGraph* callee_graph); |
| 108 | 116 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 const GrowableArray<BitVector*>& dom_frontier); | 149 const GrowableArray<BitVector*>& dom_frontier); |
| 142 | 150 |
| 143 void MarkLivePhis(GrowableArray<PhiInstr*>* live_phis); | 151 void MarkLivePhis(GrowableArray<PhiInstr*>* live_phis); |
| 144 | 152 |
| 145 // DiscoverBlocks computes parent_ and assigned_vars_ which are then used | 153 // DiscoverBlocks computes parent_ and assigned_vars_ which are then used |
| 146 // if/when computing SSA. | 154 // if/when computing SSA. |
| 147 GrowableArray<intptr_t> parent_; | 155 GrowableArray<intptr_t> parent_; |
| 148 GrowableArray<BitVector*> assigned_vars_; | 156 GrowableArray<BitVector*> assigned_vars_; |
| 149 | 157 |
| 150 intptr_t current_ssa_temp_index_; | 158 intptr_t current_ssa_temp_index_; |
| 159 intptr_t max_block_id_; |
| 151 | 160 |
| 152 // Flow graph fields. | 161 // Flow graph fields. |
| 153 const ParsedFunction& parsed_function_; | 162 const ParsedFunction& parsed_function_; |
| 154 const intptr_t num_copied_params_; | 163 const intptr_t num_copied_params_; |
| 155 const intptr_t num_non_copied_params_; | 164 const intptr_t num_non_copied_params_; |
| 156 const intptr_t num_stack_locals_; | 165 const intptr_t num_stack_locals_; |
| 157 GraphEntryInstr* graph_entry_; | 166 GraphEntryInstr* graph_entry_; |
| 158 GrowableArray<BlockEntryInstr*> preorder_; | 167 GrowableArray<BlockEntryInstr*> preorder_; |
| 159 GrowableArray<BlockEntryInstr*> postorder_; | 168 GrowableArray<BlockEntryInstr*> postorder_; |
| 160 GrowableArray<BlockEntryInstr*> reverse_postorder_; | 169 GrowableArray<BlockEntryInstr*> reverse_postorder_; |
| 161 ZoneGrowableArray<ReturnInstr*>* exits_; | 170 ZoneGrowableArray<ReturnInstr*>* exits_; |
| 162 }; | 171 }; |
| 163 | 172 |
| 164 } // namespace dart | 173 } // namespace dart |
| 165 | 174 |
| 166 #endif // VM_FLOW_GRAPH_H_ | 175 #endif // VM_FLOW_GRAPH_H_ |
| OLD | NEW |