comparison src/share/vm/opto/block.hpp @ 12167:650868c062a9

8023691: Create interface for nodes in class Block Summary: Create public methods for accessing the nodes in a block Reviewed-by: kvn, roland
author adlertz
date Mon, 26 Aug 2013 12:50:23 +0200
parents adb9a7d94cb5
children 4b078f877b56
comparison
equal deleted inserted replaced
12161:e1fbb86b47e4 12167:650868c062a9
103 // This class defines a Basic Block. 103 // This class defines a Basic Block.
104 // Basic blocks are used during the output routines, and are not used during 104 // Basic blocks are used during the output routines, and are not used during
105 // any optimization pass. They are created late in the game. 105 // any optimization pass. They are created late in the game.
106 class Block : public CFGElement { 106 class Block : public CFGElement {
107 friend class VMStructs; 107 friend class VMStructs;
108 public: 108
109 private:
109 // Nodes in this block, in order 110 // Nodes in this block, in order
110 Node_List _nodes; 111 Node_List _nodes;
112
113 public:
114
115 // Get the node at index 'at_index', if 'at_index' is out of bounds return NULL
116 Node* get_node(uint at_index) const {
117 return _nodes[at_index];
118 }
119
120 // Get the number of nodes in this block
121 uint number_of_nodes() const {
122 return _nodes.size();
123 }
124
125 // Map a node 'node' to index 'to_index' in the block, if the index is out of bounds the size of the node list is increased
126 void map_node(Node* node, uint to_index) {
127 _nodes.map(to_index, node);
128 }
129
130 // Insert a node 'node' at index 'at_index', moving all nodes that are on a higher index one step, if 'at_index' is out of bounds we crash
131 void insert_node(Node* node, uint at_index) {
132 _nodes.insert(at_index, node);
133 }
134
135 // Remove a node at index 'at_index'
136 void remove_node(uint at_index) {
137 _nodes.remove(at_index);
138 }
139
140 // Push a node 'node' onto the node list
141 void push_node(Node* node) {
142 _nodes.push(node);
143 }
144
145 // Pop the last node off the node list
146 Node* pop_node() {
147 return _nodes.pop();
148 }
111 149
112 // Basic blocks have a Node which defines Control for all Nodes pinned in 150 // Basic blocks have a Node which defines Control for all Nodes pinned in
113 // this block. This Node is a RegionNode. Exception-causing Nodes 151 // this block. This Node is a RegionNode. Exception-causing Nodes
114 // (division, subroutines) and Phi functions are always pinned. Later, 152 // (division, subroutines) and Phi functions are always pinned. Later,
115 // every Node will get pinned to some block. 153 // every Node will get pinned to some block.
116 Node *head() const { return _nodes[0]; } 154 Node *head() const { return get_node(0); }
117 155
118 // CAUTION: num_preds() is ONE based, so that predecessor numbers match 156 // CAUTION: num_preds() is ONE based, so that predecessor numbers match
119 // input edges to Regions and Phis. 157 // input edges to Regions and Phis.
120 uint num_preds() const { return head()->req(); } 158 uint num_preds() const { return head()->req(); }
121 Node *pred(uint i) const { return head()->in(i); } 159 Node *pred(uint i) const { return head()->in(i); }
272 // IfNode, a GotoNode, a JmpNode, or a ReturnNode. 310 // IfNode, a GotoNode, a JmpNode, or a ReturnNode.
273 Node *end() const { return _nodes[end_idx()]; } 311 Node *end() const { return _nodes[end_idx()]; }
274 312
275 // Add an instruction to an existing block. It must go after the head 313 // Add an instruction to an existing block. It must go after the head
276 // instruction and before the end instruction. 314 // instruction and before the end instruction.
277 void add_inst( Node *n ) { _nodes.insert(end_idx(),n); } 315 void add_inst( Node *n ) { insert_node(n, end_idx()); }
278 // Find node in block 316 // Find node in block
279 uint find_node( const Node *n ) const; 317 uint find_node( const Node *n ) const;
280 // Find and remove n from block list 318 // Find and remove n from block list
281 void find_remove( const Node *n ); 319 void find_remove( const Node *n );
282 320
548 void remove_empty_blocks(); 586 void remove_empty_blocks();
549 void fixup_flow(); 587 void fixup_flow();
550 588
551 // Insert a node into a block at index and map the node to the block 589 // Insert a node into a block at index and map the node to the block
552 void insert(Block *b, uint idx, Node *n) { 590 void insert(Block *b, uint idx, Node *n) {
553 b->_nodes.insert( idx, n ); 591 b->insert_node(n , idx);
554 map_node_to_block(n, b); 592 map_node_to_block(n, b);
555 } 593 }
556 594
557 #ifndef PRODUCT 595 #ifndef PRODUCT
558 bool trace_opto_pipelining() const { return _trace_opto_pipelining; } 596 bool trace_opto_pipelining() const { return _trace_opto_pipelining; }