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