99 Block *pb = get_block_for_node(in0); // Block-projection already has basic block 100 uint j = 0; 101 if (pb->_num_succs != 1) { // More then 1 successor? 102 // Search for successor 103 uint max = pb->number_of_nodes(); 104 assert( max > 1, "" ); 105 uint start = max - pb->_num_succs; 106 // Find which output path belongs to projection 107 for (j = start; j < max; j++) { 108 if( pb->get_node(j) == in0 ) 109 break; 110 } 111 assert( j < max, "must find" ); 112 // Change control to match head of successor basic block 113 j -= start; 114 } 115 n->set_req(0, pb->_succs[j]->head()); 116 } 117 } 118 119 120 //------------------------------schedule_pinned_nodes-------------------------- 121 // Set the basic block for Nodes pinned into blocks 122 void PhaseCFG::schedule_pinned_nodes(VectorSet &visited) { 123 // Allocate node stack of size C->live_nodes()+8 to avoid frequent realloc 124 GrowableArray <Node *> spstack(C->live_nodes() + 8); 125 spstack.push(_root); 126 while (spstack.is_nonempty()) { 127 Node* node = spstack.pop(); 128 if (!visited.test_set(node->_idx)) { // Test node and flag it as visited 129 if (node->pinned() && !has_block(node)) { // Pinned? Nail it down! 130 assert(node->in(0), "pinned Node must have Control"); 131 // Before setting block replace block_proj control edge 132 replace_block_proj_ctrl(node); 133 Node* input = node->in(0); 134 while (!input->is_block_start()) { 135 input = input->in(0); 136 } 137 Block* block = get_block_for_node(input); // Basic block of controlling input 138 schedule_node_into_block(node, block); 139 } 140 141 // process all inputs that are non NULL 142 for (int i = node->req() - 1; i >= 0; --i) { 143 if (node->in(i) != NULL) { 144 spstack.push(node->in(i)); 145 } 146 } 147 } 148 } 149 } 150 151 #ifdef ASSERT 152 // Assert that new input b2 is dominated by all previous inputs. 153 // Check this by by seeing that it is dominated by b1, the deepest 154 // input observed until b2. 155 static void assert_dom(Block* b1, Block* b2, Node* n, const PhaseCFG* cfg) { 156 if (b1 == NULL) return; 157 assert(b1->_dom_depth < b2->_dom_depth, "sanity"); 158 Block* tmp = b2; | 99 Block *pb = get_block_for_node(in0); // Block-projection already has basic block 100 uint j = 0; 101 if (pb->_num_succs != 1) { // More then 1 successor? 102 // Search for successor 103 uint max = pb->number_of_nodes(); 104 assert( max > 1, "" ); 105 uint start = max - pb->_num_succs; 106 // Find which output path belongs to projection 107 for (j = start; j < max; j++) { 108 if( pb->get_node(j) == in0 ) 109 break; 110 } 111 assert( j < max, "must find" ); 112 // Change control to match head of successor basic block 113 j -= start; 114 } 115 n->set_req(0, pb->_succs[j]->head()); 116 } 117 } 118 119 static bool is_dominator(Block* d, Block* n) { 120 return d->dom_lca(n) == d; 121 } 122 123 //------------------------------schedule_pinned_nodes-------------------------- 124 // Set the basic block for Nodes pinned into blocks 125 void PhaseCFG::schedule_pinned_nodes(VectorSet &visited) { 126 // Allocate node stack of size C->live_nodes()+8 to avoid frequent realloc 127 GrowableArray <Node *> spstack(C->live_nodes() + 8); 128 spstack.push(_root); 129 while (spstack.is_nonempty()) { 130 Node* node = spstack.pop(); 131 if (!visited.test_set(node->_idx)) { // Test node and flag it as visited 132 if (node->pinned() && !has_block(node)) { // Pinned? Nail it down! 133 assert(node->in(0), "pinned Node must have Control"); 134 // Before setting block replace block_proj control edge 135 replace_block_proj_ctrl(node); 136 Node* input = node->in(0); 137 while (!input->is_block_start()) { 138 input = input->in(0); 139 } 140 Block* block = get_block_for_node(input); // Basic block of controlling input 141 schedule_node_into_block(node, block); 142 } 143 144 // If the node has precedence edges (added when CastPP nodes are 145 // removed in final_graph_reshaping), fix the control of the 146 // node to cover the precedence edges and remove the 147 // dependencies. 148 Node* n = NULL; 149 for (uint i = node->len()-1; i >= node->req(); i--) { 150 Node* m = node->in(i); 151 if (m == NULL) continue; 152 // Skip the precedence edge if the test that guarded a CastPP: 153 // - was optimized out during escape analysis 154 // (OptimizePtrCompare): the CastPP's control isn't an end of 155 // block. 156 // - is moved in the branch of a dominating If: the control of 157 // the CastPP is then a Region. 158 if (m->is_block_proj() || m->is_block_start()) { 159 node->rm_prec(i); 160 if (n == NULL) { 161 n = m; 162 } else { 163 Block* bn = get_block_for_node(n); 164 Block* bm = get_block_for_node(m); 165 assert(is_dominator(bn, bm) || is_dominator(bm, bn), "one must dominate the other"); 166 n = is_dominator(bn, bm) ? m : n; 167 } 168 } 169 } 170 if (n != NULL) { 171 assert(node->in(0), "control should have been set"); 172 Block* bn = get_block_for_node(n); 173 Block* bnode = get_block_for_node(node->in(0)); 174 assert(is_dominator(bn, bnode) || is_dominator(bnode, bn), "one must dominate the other"); 175 if (!is_dominator(bn, bnode)) { 176 node->set_req(0, n); 177 } 178 } 179 180 // process all inputs that are non NULL 181 for (int i = node->req() - 1; i >= 0; --i) { 182 if (node->in(i) != NULL) { 183 spstack.push(node->in(i)); 184 } 185 } 186 } 187 } 188 } 189 190 #ifdef ASSERT 191 // Assert that new input b2 is dominated by all previous inputs. 192 // Check this by by seeing that it is dominated by b1, the deepest 193 // input observed until b2. 194 static void assert_dom(Block* b1, Block* b2, Node* n, const PhaseCFG* cfg) { 195 if (b1 == NULL) return; 196 assert(b1->_dom_depth < b2->_dom_depth, "sanity"); 197 Block* tmp = b2; |