1.1 --- a/src/share/vm/opto/lcm.cpp Mon Aug 05 15:03:40 2013 -0700 1.2 +++ b/src/share/vm/opto/lcm.cpp Wed Aug 07 17:56:19 2013 +0200 1.3 @@ -237,7 +237,7 @@ 1.4 } 1.5 1.6 // Check ctrl input to see if the null-check dominates the memory op 1.7 - Block *cb = cfg->_bbs[mach->_idx]; 1.8 + Block *cb = cfg->get_block_for_node(mach); 1.9 cb = cb->_idom; // Always hoist at least 1 block 1.10 if( !was_store ) { // Stores can be hoisted only one block 1.11 while( cb->_dom_depth > (_dom_depth + 1)) 1.12 @@ -262,7 +262,7 @@ 1.13 if( is_decoden ) continue; 1.14 } 1.15 // Block of memory-op input 1.16 - Block *inb = cfg->_bbs[mach->in(j)->_idx]; 1.17 + Block *inb = cfg->get_block_for_node(mach->in(j)); 1.18 Block *b = this; // Start from nul check 1.19 while( b != inb && b->_dom_depth > inb->_dom_depth ) 1.20 b = b->_idom; // search upwards for input 1.21 @@ -272,7 +272,7 @@ 1.22 } 1.23 if( j > 0 ) 1.24 continue; 1.25 - Block *mb = cfg->_bbs[mach->_idx]; 1.26 + Block *mb = cfg->get_block_for_node(mach); 1.27 // Hoisting stores requires more checks for the anti-dependence case. 1.28 // Give up hoisting if we have to move the store past any load. 1.29 if( was_store ) { 1.30 @@ -291,7 +291,7 @@ 1.31 break; // Found anti-dependent load 1.32 // Make sure control does not do a merge (would have to check allpaths) 1.33 if( b->num_preds() != 2 ) break; 1.34 - b = cfg->_bbs[b->pred(1)->_idx]; // Move up to predecessor block 1.35 + b = cfg->get_block_for_node(b->pred(1)); // Move up to predecessor block 1.36 } 1.37 if( b != this ) continue; 1.38 } 1.39 @@ -303,15 +303,15 @@ 1.40 1.41 // Found a candidate! Pick one with least dom depth - the highest 1.42 // in the dom tree should be closest to the null check. 1.43 - if( !best || 1.44 - cfg->_bbs[mach->_idx]->_dom_depth < cfg->_bbs[best->_idx]->_dom_depth ) { 1.45 + if (best == NULL || cfg->get_block_for_node(mach)->_dom_depth < cfg->get_block_for_node(best)->_dom_depth) { 1.46 best = mach; 1.47 bidx = vidx; 1.48 - 1.49 } 1.50 } 1.51 // No candidate! 1.52 - if( !best ) return; 1.53 + if (best == NULL) { 1.54 + return; 1.55 + } 1.56 1.57 // ---- Found an implicit null check 1.58 extern int implicit_null_checks; 1.59 @@ -319,29 +319,29 @@ 1.60 1.61 if( is_decoden ) { 1.62 // Check if we need to hoist decodeHeapOop_not_null first. 1.63 - Block *valb = cfg->_bbs[val->_idx]; 1.64 + Block *valb = cfg->get_block_for_node(val); 1.65 if( this != valb && this->_dom_depth < valb->_dom_depth ) { 1.66 // Hoist it up to the end of the test block. 1.67 valb->find_remove(val); 1.68 this->add_inst(val); 1.69 - cfg->_bbs.map(val->_idx,this); 1.70 + cfg->map_node_to_block(val, this); 1.71 // DecodeN on x86 may kill flags. Check for flag-killing projections 1.72 // that also need to be hoisted. 1.73 for (DUIterator_Fast jmax, j = val->fast_outs(jmax); j < jmax; j++) { 1.74 Node* n = val->fast_out(j); 1.75 if( n->is_MachProj() ) { 1.76 - cfg->_bbs[n->_idx]->find_remove(n); 1.77 + cfg->get_block_for_node(n)->find_remove(n); 1.78 this->add_inst(n); 1.79 - cfg->_bbs.map(n->_idx,this); 1.80 + cfg->map_node_to_block(n, this); 1.81 } 1.82 } 1.83 } 1.84 } 1.85 // Hoist the memory candidate up to the end of the test block. 1.86 - Block *old_block = cfg->_bbs[best->_idx]; 1.87 + Block *old_block = cfg->get_block_for_node(best); 1.88 old_block->find_remove(best); 1.89 add_inst(best); 1.90 - cfg->_bbs.map(best->_idx,this); 1.91 + cfg->map_node_to_block(best, this); 1.92 1.93 // Move the control dependence 1.94 if (best->in(0) && best->in(0) == old_block->_nodes[0]) 1.95 @@ -352,9 +352,9 @@ 1.96 for (DUIterator_Fast jmax, j = best->fast_outs(jmax); j < jmax; j++) { 1.97 Node* n = best->fast_out(j); 1.98 if( n->is_MachProj() ) { 1.99 - cfg->_bbs[n->_idx]->find_remove(n); 1.100 + cfg->get_block_for_node(n)->find_remove(n); 1.101 add_inst(n); 1.102 - cfg->_bbs.map(n->_idx,this); 1.103 + cfg->map_node_to_block(n, this); 1.104 } 1.105 } 1.106 1.107 @@ -385,7 +385,7 @@ 1.108 Node *old_tst = proj->in(0); 1.109 MachNode *nul_chk = new (C) MachNullCheckNode(old_tst->in(0),best,bidx); 1.110 _nodes.map(end_idx(),nul_chk); 1.111 - cfg->_bbs.map(nul_chk->_idx,this); 1.112 + cfg->map_node_to_block(nul_chk, this); 1.113 // Redirect users of old_test to nul_chk 1.114 for (DUIterator_Last i2min, i2 = old_tst->last_outs(i2min); i2 >= i2min; --i2) 1.115 old_tst->last_out(i2)->set_req(0, nul_chk); 1.116 @@ -468,7 +468,7 @@ 1.117 Node* use = n->fast_out(j); 1.118 1.119 // The use is a conditional branch, make them adjacent 1.120 - if (use->is_MachIf() && cfg->_bbs[use->_idx]==this ) { 1.121 + if (use->is_MachIf() && cfg->get_block_for_node(use) == this) { 1.122 found_machif = true; 1.123 break; 1.124 } 1.125 @@ -529,13 +529,14 @@ 1.126 1.127 1.128 //------------------------------set_next_call---------------------------------- 1.129 -void Block::set_next_call( Node *n, VectorSet &next_call, Block_Array &bbs ) { 1.130 +void Block::set_next_call( Node *n, VectorSet &next_call, PhaseCFG* cfg) { 1.131 if( next_call.test_set(n->_idx) ) return; 1.132 for( uint i=0; i<n->len(); i++ ) { 1.133 Node *m = n->in(i); 1.134 if( !m ) continue; // must see all nodes in block that precede call 1.135 - if( bbs[m->_idx] == this ) 1.136 - set_next_call( m, next_call, bbs ); 1.137 + if (cfg->get_block_for_node(m) == this) { 1.138 + set_next_call(m, next_call, cfg); 1.139 + } 1.140 } 1.141 } 1.142 1.143 @@ -545,12 +546,12 @@ 1.144 // next subroutine call get priority - basically it moves things NOT needed 1.145 // for the next call till after the call. This prevents me from trying to 1.146 // carry lots of stuff live across a call. 1.147 -void Block::needed_for_next_call(Node *this_call, VectorSet &next_call, Block_Array &bbs) { 1.148 +void Block::needed_for_next_call(Node *this_call, VectorSet &next_call, PhaseCFG* cfg) { 1.149 // Find the next control-defining Node in this block 1.150 Node* call = NULL; 1.151 for (DUIterator_Fast imax, i = this_call->fast_outs(imax); i < imax; i++) { 1.152 Node* m = this_call->fast_out(i); 1.153 - if( bbs[m->_idx] == this && // Local-block user 1.154 + if(cfg->get_block_for_node(m) == this && // Local-block user 1.155 m != this_call && // Not self-start node 1.156 m->is_MachCall() ) 1.157 call = m; 1.158 @@ -558,7 +559,7 @@ 1.159 } 1.160 if (call == NULL) return; // No next call (e.g., block end is near) 1.161 // Set next-call for all inputs to this call 1.162 - set_next_call(call, next_call, bbs); 1.163 + set_next_call(call, next_call, cfg); 1.164 } 1.165 1.166 //------------------------------add_call_kills------------------------------------- 1.167 @@ -578,7 +579,7 @@ 1.168 1.169 1.170 //------------------------------sched_call------------------------------------- 1.171 -uint Block::sched_call( Matcher &matcher, Block_Array &bbs, uint node_cnt, Node_List &worklist, GrowableArray<int> &ready_cnt, MachCallNode *mcall, VectorSet &next_call ) { 1.172 +uint Block::sched_call( Matcher &matcher, PhaseCFG* cfg, uint node_cnt, Node_List &worklist, GrowableArray<int> &ready_cnt, MachCallNode *mcall, VectorSet &next_call ) { 1.173 RegMask regs; 1.174 1.175 // Schedule all the users of the call right now. All the users are 1.176 @@ -597,12 +598,14 @@ 1.177 // Check for scheduling the next control-definer 1.178 if( n->bottom_type() == Type::CONTROL ) 1.179 // Warm up next pile of heuristic bits 1.180 - needed_for_next_call(n, next_call, bbs); 1.181 + needed_for_next_call(n, next_call, cfg); 1.182 1.183 // Children of projections are now all ready 1.184 for (DUIterator_Fast jmax, j = n->fast_outs(jmax); j < jmax; j++) { 1.185 Node* m = n->fast_out(j); // Get user 1.186 - if( bbs[m->_idx] != this ) continue; 1.187 + if(cfg->get_block_for_node(m) != this) { 1.188 + continue; 1.189 + } 1.190 if( m->is_Phi() ) continue; 1.191 int m_cnt = ready_cnt.at(m->_idx)-1; 1.192 ready_cnt.at_put(m->_idx, m_cnt); 1.193 @@ -620,7 +623,7 @@ 1.194 uint r_cnt = mcall->tf()->range()->cnt(); 1.195 int op = mcall->ideal_Opcode(); 1.196 MachProjNode *proj = new (matcher.C) MachProjNode( mcall, r_cnt+1, RegMask::Empty, MachProjNode::fat_proj ); 1.197 - bbs.map(proj->_idx,this); 1.198 + cfg->map_node_to_block(proj, this); 1.199 _nodes.insert(node_cnt++, proj); 1.200 1.201 // Select the right register save policy. 1.202 @@ -708,7 +711,7 @@ 1.203 uint local = 0; 1.204 for( uint j=0; j<cnt; j++ ) { 1.205 Node *m = n->in(j); 1.206 - if( m && cfg->_bbs[m->_idx] == this && !m->is_top() ) 1.207 + if( m && cfg->get_block_for_node(m) == this && !m->is_top() ) 1.208 local++; // One more block-local input 1.209 } 1.210 ready_cnt.at_put(n->_idx, local); // Count em up 1.211 @@ -720,7 +723,7 @@ 1.212 for (uint prec = n->req(); prec < n->len(); prec++) { 1.213 Node* oop_store = n->in(prec); 1.214 if (oop_store != NULL) { 1.215 - assert(cfg->_bbs[oop_store->_idx]->_dom_depth <= this->_dom_depth, "oop_store must dominate card-mark"); 1.216 + assert(cfg->get_block_for_node(oop_store)->_dom_depth <= this->_dom_depth, "oop_store must dominate card-mark"); 1.217 } 1.218 } 1.219 } 1.220 @@ -753,7 +756,7 @@ 1.221 Node *n = _nodes[i3]; // Get pre-scheduled 1.222 for (DUIterator_Fast jmax, j = n->fast_outs(jmax); j < jmax; j++) { 1.223 Node* m = n->fast_out(j); 1.224 - if( cfg->_bbs[m->_idx] ==this ) { // Local-block user 1.225 + if (cfg->get_block_for_node(m) == this) { // Local-block user 1.226 int m_cnt = ready_cnt.at(m->_idx)-1; 1.227 ready_cnt.at_put(m->_idx, m_cnt); // Fix ready count 1.228 } 1.229 @@ -786,7 +789,7 @@ 1.230 } 1.231 1.232 // Warm up the 'next_call' heuristic bits 1.233 - needed_for_next_call(_nodes[0], next_call, cfg->_bbs); 1.234 + needed_for_next_call(_nodes[0], next_call, cfg); 1.235 1.236 #ifndef PRODUCT 1.237 if (cfg->trace_opto_pipelining()) { 1.238 @@ -837,7 +840,7 @@ 1.239 #endif 1.240 if( n->is_MachCall() ) { 1.241 MachCallNode *mcall = n->as_MachCall(); 1.242 - phi_cnt = sched_call(matcher, cfg->_bbs, phi_cnt, worklist, ready_cnt, mcall, next_call); 1.243 + phi_cnt = sched_call(matcher, cfg, phi_cnt, worklist, ready_cnt, mcall, next_call); 1.244 continue; 1.245 } 1.246 1.247 @@ -847,7 +850,7 @@ 1.248 regs.OR(n->out_RegMask()); 1.249 1.250 MachProjNode *proj = new (matcher.C) MachProjNode( n, 1, RegMask::Empty, MachProjNode::fat_proj ); 1.251 - cfg->_bbs.map(proj->_idx,this); 1.252 + cfg->map_node_to_block(proj, this); 1.253 _nodes.insert(phi_cnt++, proj); 1.254 1.255 add_call_kills(proj, regs, matcher._c_reg_save_policy, false); 1.256 @@ -856,7 +859,9 @@ 1.257 // Children are now all ready 1.258 for (DUIterator_Fast i5max, i5 = n->fast_outs(i5max); i5 < i5max; i5++) { 1.259 Node* m = n->fast_out(i5); // Get user 1.260 - if( cfg->_bbs[m->_idx] != this ) continue; 1.261 + if (cfg->get_block_for_node(m) != this) { 1.262 + continue; 1.263 + } 1.264 if( m->is_Phi() ) continue; 1.265 if (m->_idx >= max_idx) { // new node, skip it 1.266 assert(m->is_MachProj() && n->is_Mach() && n->as_Mach()->has_call(), "unexpected node types"); 1.267 @@ -914,7 +919,7 @@ 1.268 } 1.269 1.270 //------------------------------catch_cleanup_find_cloned_def------------------ 1.271 -static Node *catch_cleanup_find_cloned_def(Block *use_blk, Node *def, Block *def_blk, Block_Array &bbs, int n_clone_idx) { 1.272 +static Node *catch_cleanup_find_cloned_def(Block *use_blk, Node *def, Block *def_blk, PhaseCFG* cfg, int n_clone_idx) { 1.273 assert( use_blk != def_blk, "Inter-block cleanup only"); 1.274 1.275 // The use is some block below the Catch. Find and return the clone of the def 1.276 @@ -940,7 +945,8 @@ 1.277 // PhiNode, the PhiNode uses from the def and IT's uses need fixup. 1.278 Node_Array inputs = new Node_List(Thread::current()->resource_area()); 1.279 for(uint k = 1; k < use_blk->num_preds(); k++) { 1.280 - inputs.map(k, catch_cleanup_find_cloned_def(bbs[use_blk->pred(k)->_idx], def, def_blk, bbs, n_clone_idx)); 1.281 + Block* block = cfg->get_block_for_node(use_blk->pred(k)); 1.282 + inputs.map(k, catch_cleanup_find_cloned_def(block, def, def_blk, cfg, n_clone_idx)); 1.283 } 1.284 1.285 // Check to see if the use_blk already has an identical phi inserted. 1.286 @@ -962,7 +968,7 @@ 1.287 if (fixup == NULL) { 1.288 Node *new_phi = PhiNode::make(use_blk->head(), def); 1.289 use_blk->_nodes.insert(1, new_phi); 1.290 - bbs.map(new_phi->_idx, use_blk); 1.291 + cfg->map_node_to_block(new_phi, use_blk); 1.292 for (uint k = 1; k < use_blk->num_preds(); k++) { 1.293 new_phi->set_req(k, inputs[k]); 1.294 } 1.295 @@ -1002,17 +1008,17 @@ 1.296 //------------------------------catch_cleanup_inter_block--------------------- 1.297 // Fix all input edges in use that reference "def". The use is in a different 1.298 // block than the def. 1.299 -static void catch_cleanup_inter_block(Node *use, Block *use_blk, Node *def, Block *def_blk, Block_Array &bbs, int n_clone_idx) { 1.300 +static void catch_cleanup_inter_block(Node *use, Block *use_blk, Node *def, Block *def_blk, PhaseCFG* cfg, int n_clone_idx) { 1.301 if( !use_blk ) return; // Can happen if the use is a precedence edge 1.302 1.303 - Node *new_def = catch_cleanup_find_cloned_def(use_blk, def, def_blk, bbs, n_clone_idx); 1.304 + Node *new_def = catch_cleanup_find_cloned_def(use_blk, def, def_blk, cfg, n_clone_idx); 1.305 catch_cleanup_fix_all_inputs(use, def, new_def); 1.306 } 1.307 1.308 //------------------------------call_catch_cleanup----------------------------- 1.309 // If we inserted any instructions between a Call and his CatchNode, 1.310 // clone the instructions on all paths below the Catch. 1.311 -void Block::call_catch_cleanup(Block_Array &bbs, Compile* C) { 1.312 +void Block::call_catch_cleanup(PhaseCFG* cfg, Compile* C) { 1.313 1.314 // End of region to clone 1.315 uint end = end_idx(); 1.316 @@ -1037,7 +1043,7 @@ 1.317 // since clones dominate on each path. 1.318 Node *clone = _nodes[j-1]->clone(); 1.319 sb->_nodes.insert( 1, clone ); 1.320 - bbs.map(clone->_idx,sb); 1.321 + cfg->map_node_to_block(clone, sb); 1.322 } 1.323 } 1.324 1.325 @@ -1054,18 +1060,19 @@ 1.326 uint max = out->size(); 1.327 for (uint j = 0; j < max; j++) {// For all users 1.328 Node *use = out->pop(); 1.329 - Block *buse = bbs[use->_idx]; 1.330 + Block *buse = cfg->get_block_for_node(use); 1.331 if( use->is_Phi() ) { 1.332 for( uint k = 1; k < use->req(); k++ ) 1.333 if( use->in(k) == n ) { 1.334 - Node *fixup = catch_cleanup_find_cloned_def(bbs[buse->pred(k)->_idx], n, this, bbs, n_clone_idx); 1.335 + Block* block = cfg->get_block_for_node(buse->pred(k)); 1.336 + Node *fixup = catch_cleanup_find_cloned_def(block, n, this, cfg, n_clone_idx); 1.337 use->set_req(k, fixup); 1.338 } 1.339 } else { 1.340 if (this == buse) { 1.341 catch_cleanup_intra_block(use, n, this, beg, n_clone_idx); 1.342 } else { 1.343 - catch_cleanup_inter_block(use, buse, n, this, bbs, n_clone_idx); 1.344 + catch_cleanup_inter_block(use, buse, n, this, cfg, n_clone_idx); 1.345 } 1.346 } 1.347 } // End for all users