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; | 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 static bool is_dominator(Block* d, Block* n) { 121 return d->dom_lca(n) == d; 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 // If the node has precedence edges (added when CastPP nodes are 144 // removed in final_graph_reshaping), fix the control of the 145 // node to cover the precedence edges and remove the 146 // dependencies. 147 Node* n = NULL; 148 for (uint i = node->len()-1; i >= node->req(); i--) { 149 Node* m = node->in(i); 150 if (m == NULL) continue; 151 // Skip the precedence edge if the test that guarded a CastPP: 152 // - was optimized out during escape analysis 153 // (OptimizePtrCompare): the CastPP's control isn't an end of 154 // block. 155 // - is moved in the branch of a dominating If: the control of 156 // the CastPP is then a Region. 157 if (m->is_block_proj() || m->is_block_start()) { 158 node->rm_prec(i); 159 if (n == NULL) { 160 n = m; 161 } else { 162 Block* bn = get_block_for_node(n); 163 Block* bm = get_block_for_node(m); 164 assert(is_dominator(bn, bm) || is_dominator(bm, bn), "one must dominate the other"); 165 n = is_dominator(bn, bm) ? m : n; 166 } 167 } 168 } 169 if (n != NULL) { 170 assert(node->in(0), "control should have been set"); 171 Block* bn = get_block_for_node(n); 172 Block* bnode = get_block_for_node(node->in(0)); 173 assert(is_dominator(bn, bnode) || is_dominator(bnode, bn), "one must dominate the other"); 174 if (!is_dominator(bn, bnode)) { 175 node->set_req(0, n); 176 } 177 } 178 179 // process all inputs that are non NULL 180 for (int i = node->req() - 1; i >= 0; --i) { 181 if (node->in(i) != NULL) { 182 spstack.push(node->in(i)); 183 } 184 } 185 } 186 } 187 } 188 189 #ifdef ASSERT 190 // Assert that new input b2 is dominated by all previous inputs. 191 // Check this by by seeing that it is dominated by b1, the deepest 192 // input observed until b2. 193 static void assert_dom(Block* b1, Block* b2, Node* n, const PhaseCFG* cfg) { 194 if (b1 == NULL) return; 195 assert(b1->_dom_depth < b2->_dom_depth, "sanity"); 196 Block* tmp = b2; |