1.1 --- a/src/share/vm/opto/lcm.cpp Wed Oct 16 10:52:41 2013 +0200 1.2 +++ b/src/share/vm/opto/lcm.cpp Tue Nov 05 17:38:04 2013 -0800 1.3 @@ -61,14 +61,14 @@ 1.4 // The proj is the control projection for the not-null case. 1.5 // The val is the pointer being checked for nullness or 1.6 // decodeHeapOop_not_null node if it did not fold into address. 1.7 -void Block::implicit_null_check(PhaseCFG *cfg, Node *proj, Node *val, int allowed_reasons) { 1.8 +void PhaseCFG::implicit_null_check(Block* block, Node *proj, Node *val, int allowed_reasons) { 1.9 // Assume if null check need for 0 offset then always needed 1.10 // Intel solaris doesn't support any null checks yet and no 1.11 // mechanism exists (yet) to set the switches at an os_cpu level 1.12 if( !ImplicitNullChecks || MacroAssembler::needs_explicit_null_check(0)) return; 1.13 1.14 // Make sure the ptr-is-null path appears to be uncommon! 1.15 - float f = end()->as_MachIf()->_prob; 1.16 + float f = block->end()->as_MachIf()->_prob; 1.17 if( proj->Opcode() == Op_IfTrue ) f = 1.0f - f; 1.18 if( f > PROB_UNLIKELY_MAG(4) ) return; 1.19 1.20 @@ -78,13 +78,13 @@ 1.21 // Get the successor block for if the test ptr is non-null 1.22 Block* not_null_block; // this one goes with the proj 1.23 Block* null_block; 1.24 - if (_nodes[_nodes.size()-1] == proj) { 1.25 - null_block = _succs[0]; 1.26 - not_null_block = _succs[1]; 1.27 + if (block->get_node(block->number_of_nodes()-1) == proj) { 1.28 + null_block = block->_succs[0]; 1.29 + not_null_block = block->_succs[1]; 1.30 } else { 1.31 - assert(_nodes[_nodes.size()-2] == proj, "proj is one or the other"); 1.32 - not_null_block = _succs[0]; 1.33 - null_block = _succs[1]; 1.34 + assert(block->get_node(block->number_of_nodes()-2) == proj, "proj is one or the other"); 1.35 + not_null_block = block->_succs[0]; 1.36 + null_block = block->_succs[1]; 1.37 } 1.38 while (null_block->is_Empty() == Block::empty_with_goto) { 1.39 null_block = null_block->_succs[0]; 1.40 @@ -96,8 +96,8 @@ 1.41 // detect failure of this optimization, as in 6366351.) 1.42 { 1.43 bool found_trap = false; 1.44 - for (uint i1 = 0; i1 < null_block->_nodes.size(); i1++) { 1.45 - Node* nn = null_block->_nodes[i1]; 1.46 + for (uint i1 = 0; i1 < null_block->number_of_nodes(); i1++) { 1.47 + Node* nn = null_block->get_node(i1); 1.48 if (nn->is_MachCall() && 1.49 nn->as_MachCall()->entry_point() == SharedRuntime::uncommon_trap_blob()->entry_point()) { 1.50 const Type* trtype = nn->in(TypeFunc::Parms)->bottom_type(); 1.51 @@ -240,20 +240,20 @@ 1.52 } 1.53 1.54 // Check ctrl input to see if the null-check dominates the memory op 1.55 - Block *cb = cfg->get_block_for_node(mach); 1.56 + Block *cb = get_block_for_node(mach); 1.57 cb = cb->_idom; // Always hoist at least 1 block 1.58 if( !was_store ) { // Stores can be hoisted only one block 1.59 - while( cb->_dom_depth > (_dom_depth + 1)) 1.60 + while( cb->_dom_depth > (block->_dom_depth + 1)) 1.61 cb = cb->_idom; // Hoist loads as far as we want 1.62 // The non-null-block should dominate the memory op, too. Live 1.63 // range spilling will insert a spill in the non-null-block if it is 1.64 // needs to spill the memory op for an implicit null check. 1.65 - if (cb->_dom_depth == (_dom_depth + 1)) { 1.66 + if (cb->_dom_depth == (block->_dom_depth + 1)) { 1.67 if (cb != not_null_block) continue; 1.68 cb = cb->_idom; 1.69 } 1.70 } 1.71 - if( cb != this ) continue; 1.72 + if( cb != block ) continue; 1.73 1.74 // Found a memory user; see if it can be hoisted to check-block 1.75 uint vidx = 0; // Capture index of value into memop 1.76 @@ -265,8 +265,8 @@ 1.77 if( is_decoden ) continue; 1.78 } 1.79 // Block of memory-op input 1.80 - Block *inb = cfg->get_block_for_node(mach->in(j)); 1.81 - Block *b = this; // Start from nul check 1.82 + Block *inb = get_block_for_node(mach->in(j)); 1.83 + Block *b = block; // Start from nul check 1.84 while( b != inb && b->_dom_depth > inb->_dom_depth ) 1.85 b = b->_idom; // search upwards for input 1.86 // See if input dominates null check 1.87 @@ -275,28 +275,28 @@ 1.88 } 1.89 if( j > 0 ) 1.90 continue; 1.91 - Block *mb = cfg->get_block_for_node(mach); 1.92 + Block *mb = get_block_for_node(mach); 1.93 // Hoisting stores requires more checks for the anti-dependence case. 1.94 // Give up hoisting if we have to move the store past any load. 1.95 if( was_store ) { 1.96 Block *b = mb; // Start searching here for a local load 1.97 // mach use (faulting) trying to hoist 1.98 // n might be blocker to hoisting 1.99 - while( b != this ) { 1.100 + while( b != block ) { 1.101 uint k; 1.102 - for( k = 1; k < b->_nodes.size(); k++ ) { 1.103 - Node *n = b->_nodes[k]; 1.104 + for( k = 1; k < b->number_of_nodes(); k++ ) { 1.105 + Node *n = b->get_node(k); 1.106 if( n->needs_anti_dependence_check() && 1.107 n->in(LoadNode::Memory) == mach->in(StoreNode::Memory) ) 1.108 break; // Found anti-dependent load 1.109 } 1.110 - if( k < b->_nodes.size() ) 1.111 + if( k < b->number_of_nodes() ) 1.112 break; // Found anti-dependent load 1.113 // Make sure control does not do a merge (would have to check allpaths) 1.114 if( b->num_preds() != 2 ) break; 1.115 - b = cfg->get_block_for_node(b->pred(1)); // Move up to predecessor block 1.116 + b = get_block_for_node(b->pred(1)); // Move up to predecessor block 1.117 } 1.118 - if( b != this ) continue; 1.119 + if( b != block ) continue; 1.120 } 1.121 1.122 // Make sure this memory op is not already being used for a NullCheck 1.123 @@ -306,7 +306,7 @@ 1.124 1.125 // Found a candidate! Pick one with least dom depth - the highest 1.126 // in the dom tree should be closest to the null check. 1.127 - if (best == NULL || cfg->get_block_for_node(mach)->_dom_depth < cfg->get_block_for_node(best)->_dom_depth) { 1.128 + if (best == NULL || get_block_for_node(mach)->_dom_depth < get_block_for_node(best)->_dom_depth) { 1.129 best = mach; 1.130 bidx = vidx; 1.131 } 1.132 @@ -322,46 +322,45 @@ 1.133 1.134 if( is_decoden ) { 1.135 // Check if we need to hoist decodeHeapOop_not_null first. 1.136 - Block *valb = cfg->get_block_for_node(val); 1.137 - if( this != valb && this->_dom_depth < valb->_dom_depth ) { 1.138 + Block *valb = get_block_for_node(val); 1.139 + if( block != valb && block->_dom_depth < valb->_dom_depth ) { 1.140 // Hoist it up to the end of the test block. 1.141 valb->find_remove(val); 1.142 - this->add_inst(val); 1.143 - cfg->map_node_to_block(val, this); 1.144 + block->add_inst(val); 1.145 + map_node_to_block(val, block); 1.146 // DecodeN on x86 may kill flags. Check for flag-killing projections 1.147 // that also need to be hoisted. 1.148 for (DUIterator_Fast jmax, j = val->fast_outs(jmax); j < jmax; j++) { 1.149 Node* n = val->fast_out(j); 1.150 if( n->is_MachProj() ) { 1.151 - cfg->get_block_for_node(n)->find_remove(n); 1.152 - this->add_inst(n); 1.153 - cfg->map_node_to_block(n, this); 1.154 + get_block_for_node(n)->find_remove(n); 1.155 + block->add_inst(n); 1.156 + map_node_to_block(n, block); 1.157 } 1.158 } 1.159 } 1.160 } 1.161 // Hoist the memory candidate up to the end of the test block. 1.162 - Block *old_block = cfg->get_block_for_node(best); 1.163 + Block *old_block = get_block_for_node(best); 1.164 old_block->find_remove(best); 1.165 - add_inst(best); 1.166 - cfg->map_node_to_block(best, this); 1.167 + block->add_inst(best); 1.168 + map_node_to_block(best, block); 1.169 1.170 // Move the control dependence 1.171 - if (best->in(0) && best->in(0) == old_block->_nodes[0]) 1.172 - best->set_req(0, _nodes[0]); 1.173 + if (best->in(0) && best->in(0) == old_block->head()) 1.174 + best->set_req(0, block->head()); 1.175 1.176 // Check for flag-killing projections that also need to be hoisted 1.177 // Should be DU safe because no edge updates. 1.178 for (DUIterator_Fast jmax, j = best->fast_outs(jmax); j < jmax; j++) { 1.179 Node* n = best->fast_out(j); 1.180 if( n->is_MachProj() ) { 1.181 - cfg->get_block_for_node(n)->find_remove(n); 1.182 - add_inst(n); 1.183 - cfg->map_node_to_block(n, this); 1.184 + get_block_for_node(n)->find_remove(n); 1.185 + block->add_inst(n); 1.186 + map_node_to_block(n, block); 1.187 } 1.188 } 1.189 1.190 - Compile *C = cfg->C; 1.191 // proj==Op_True --> ne test; proj==Op_False --> eq test. 1.192 // One of two graph shapes got matched: 1.193 // (IfTrue (If (Bool NE (CmpP ptr NULL)))) 1.194 @@ -371,10 +370,10 @@ 1.195 // We need to flip the projections to keep the same semantics. 1.196 if( proj->Opcode() == Op_IfTrue ) { 1.197 // Swap order of projections in basic block to swap branch targets 1.198 - Node *tmp1 = _nodes[end_idx()+1]; 1.199 - Node *tmp2 = _nodes[end_idx()+2]; 1.200 - _nodes.map(end_idx()+1, tmp2); 1.201 - _nodes.map(end_idx()+2, tmp1); 1.202 + Node *tmp1 = block->get_node(block->end_idx()+1); 1.203 + Node *tmp2 = block->get_node(block->end_idx()+2); 1.204 + block->map_node(tmp2, block->end_idx()+1); 1.205 + block->map_node(tmp1, block->end_idx()+2); 1.206 Node *tmp = new (C) Node(C->top()); // Use not NULL input 1.207 tmp1->replace_by(tmp); 1.208 tmp2->replace_by(tmp1); 1.209 @@ -387,8 +386,8 @@ 1.210 // it as well. 1.211 Node *old_tst = proj->in(0); 1.212 MachNode *nul_chk = new (C) MachNullCheckNode(old_tst->in(0),best,bidx); 1.213 - _nodes.map(end_idx(),nul_chk); 1.214 - cfg->map_node_to_block(nul_chk, this); 1.215 + block->map_node(nul_chk, block->end_idx()); 1.216 + map_node_to_block(nul_chk, block); 1.217 // Redirect users of old_test to nul_chk 1.218 for (DUIterator_Last i2min, i2 = old_tst->last_outs(i2min); i2 >= i2min; --i2) 1.219 old_tst->last_out(i2)->set_req(0, nul_chk); 1.220 @@ -396,8 +395,8 @@ 1.221 for (uint i3 = 0; i3 < old_tst->req(); i3++) 1.222 old_tst->set_req(i3, NULL); 1.223 1.224 - cfg->latency_from_uses(nul_chk); 1.225 - cfg->latency_from_uses(best); 1.226 + latency_from_uses(nul_chk); 1.227 + latency_from_uses(best); 1.228 } 1.229 1.230 1.231 @@ -411,7 +410,7 @@ 1.232 // remaining cases (most), choose the instruction with the greatest latency 1.233 // (that is, the most number of pseudo-cycles required to the end of the 1.234 // routine). If there is a tie, choose the instruction with the most inputs. 1.235 -Node *Block::select(PhaseCFG *cfg, Node_List &worklist, GrowableArray<int> &ready_cnt, VectorSet &next_call, uint sched_slot) { 1.236 +Node* PhaseCFG::select(Block* block, Node_List &worklist, GrowableArray<int> &ready_cnt, VectorSet &next_call, uint sched_slot) { 1.237 1.238 // If only a single entry on the stack, use it 1.239 uint cnt = worklist.size(); 1.240 @@ -445,7 +444,7 @@ 1.241 } 1.242 1.243 // Final call in a block must be adjacent to 'catch' 1.244 - Node *e = end(); 1.245 + Node *e = block->end(); 1.246 if( e->is_Catch() && e->in(0)->in(0) == n ) 1.247 continue; 1.248 1.249 @@ -471,7 +470,14 @@ 1.250 Node* use = n->fast_out(j); 1.251 1.252 // The use is a conditional branch, make them adjacent 1.253 - if (use->is_MachIf() && cfg->get_block_for_node(use) == this) { 1.254 + if (use->is_MachIf() && get_block_for_node(use) == block) { 1.255 + found_machif = true; 1.256 + break; 1.257 + } 1.258 + 1.259 + // For nodes that produce a FlagsProj, make the node adjacent to the 1.260 + // use of the FlagsProj 1.261 + if (use->is_FlagsProj() && get_block_for_node(use) == block) { 1.262 found_machif = true; 1.263 break; 1.264 } 1.265 @@ -504,7 +510,7 @@ 1.266 n_choice = 1; 1.267 } 1.268 1.269 - uint n_latency = cfg->get_latency_for_node(n); 1.270 + uint n_latency = get_latency_for_node(n); 1.271 uint n_score = n->req(); // Many inputs get high score to break ties 1.272 1.273 // Keep best latency found 1.274 @@ -532,13 +538,13 @@ 1.275 1.276 1.277 //------------------------------set_next_call---------------------------------- 1.278 -void Block::set_next_call( Node *n, VectorSet &next_call, PhaseCFG* cfg) { 1.279 +void PhaseCFG::set_next_call(Block* block, Node* n, VectorSet& next_call) { 1.280 if( next_call.test_set(n->_idx) ) return; 1.281 for( uint i=0; i<n->len(); i++ ) { 1.282 Node *m = n->in(i); 1.283 if( !m ) continue; // must see all nodes in block that precede call 1.284 - if (cfg->get_block_for_node(m) == this) { 1.285 - set_next_call(m, next_call, cfg); 1.286 + if (get_block_for_node(m) == block) { 1.287 + set_next_call(block, m, next_call); 1.288 } 1.289 } 1.290 } 1.291 @@ -549,24 +555,26 @@ 1.292 // next subroutine call get priority - basically it moves things NOT needed 1.293 // for the next call till after the call. This prevents me from trying to 1.294 // carry lots of stuff live across a call. 1.295 -void Block::needed_for_next_call(Node *this_call, VectorSet &next_call, PhaseCFG* cfg) { 1.296 +void PhaseCFG::needed_for_next_call(Block* block, Node* this_call, VectorSet& next_call) { 1.297 // Find the next control-defining Node in this block 1.298 Node* call = NULL; 1.299 for (DUIterator_Fast imax, i = this_call->fast_outs(imax); i < imax; i++) { 1.300 Node* m = this_call->fast_out(i); 1.301 - if(cfg->get_block_for_node(m) == this && // Local-block user 1.302 + if (get_block_for_node(m) == block && // Local-block user 1.303 m != this_call && // Not self-start node 1.304 - m->is_MachCall() ) 1.305 + m->is_MachCall()) { 1.306 call = m; 1.307 break; 1.308 + } 1.309 } 1.310 if (call == NULL) return; // No next call (e.g., block end is near) 1.311 // Set next-call for all inputs to this call 1.312 - set_next_call(call, next_call, cfg); 1.313 + set_next_call(block, call, next_call); 1.314 } 1.315 1.316 //------------------------------add_call_kills------------------------------------- 1.317 -void Block::add_call_kills(MachProjNode *proj, RegMask& regs, const char* save_policy, bool exclude_soe) { 1.318 +// helper function that adds caller save registers to MachProjNode 1.319 +static void add_call_kills(MachProjNode *proj, RegMask& regs, const char* save_policy, bool exclude_soe) { 1.320 // Fill in the kill mask for the call 1.321 for( OptoReg::Name r = OptoReg::Name(0); r < _last_Mach_Reg; r=OptoReg::add(r,1) ) { 1.322 if( !regs.Member(r) ) { // Not already defined by the call 1.323 @@ -582,7 +590,7 @@ 1.324 1.325 1.326 //------------------------------sched_call------------------------------------- 1.327 -uint Block::sched_call( Matcher &matcher, PhaseCFG* cfg, uint node_cnt, Node_List &worklist, GrowableArray<int> &ready_cnt, MachCallNode *mcall, VectorSet &next_call ) { 1.328 +uint PhaseCFG::sched_call(Block* block, uint node_cnt, Node_List& worklist, GrowableArray<int>& ready_cnt, MachCallNode* mcall, VectorSet& next_call) { 1.329 RegMask regs; 1.330 1.331 // Schedule all the users of the call right now. All the users are 1.332 @@ -595,18 +603,18 @@ 1.333 ready_cnt.at_put(n->_idx, n_cnt); 1.334 assert( n_cnt == 0, "" ); 1.335 // Schedule next to call 1.336 - _nodes.map(node_cnt++, n); 1.337 + block->map_node(n, node_cnt++); 1.338 // Collect defined registers 1.339 regs.OR(n->out_RegMask()); 1.340 // Check for scheduling the next control-definer 1.341 if( n->bottom_type() == Type::CONTROL ) 1.342 // Warm up next pile of heuristic bits 1.343 - needed_for_next_call(n, next_call, cfg); 1.344 + needed_for_next_call(block, n, next_call); 1.345 1.346 // Children of projections are now all ready 1.347 for (DUIterator_Fast jmax, j = n->fast_outs(jmax); j < jmax; j++) { 1.348 Node* m = n->fast_out(j); // Get user 1.349 - if(cfg->get_block_for_node(m) != this) { 1.350 + if(get_block_for_node(m) != block) { 1.351 continue; 1.352 } 1.353 if( m->is_Phi() ) continue; 1.354 @@ -620,14 +628,14 @@ 1.355 1.356 // Act as if the call defines the Frame Pointer. 1.357 // Certainly the FP is alive and well after the call. 1.358 - regs.Insert(matcher.c_frame_pointer()); 1.359 + regs.Insert(_matcher.c_frame_pointer()); 1.360 1.361 // Set all registers killed and not already defined by the call. 1.362 uint r_cnt = mcall->tf()->range()->cnt(); 1.363 int op = mcall->ideal_Opcode(); 1.364 - MachProjNode *proj = new (matcher.C) MachProjNode( mcall, r_cnt+1, RegMask::Empty, MachProjNode::fat_proj ); 1.365 - cfg->map_node_to_block(proj, this); 1.366 - _nodes.insert(node_cnt++, proj); 1.367 + MachProjNode *proj = new (C) MachProjNode( mcall, r_cnt+1, RegMask::Empty, MachProjNode::fat_proj ); 1.368 + map_node_to_block(proj, block); 1.369 + block->insert_node(proj, node_cnt++); 1.370 1.371 // Select the right register save policy. 1.372 const char * save_policy; 1.373 @@ -636,13 +644,13 @@ 1.374 case Op_CallLeaf: 1.375 case Op_CallLeafNoFP: 1.376 // Calling C code so use C calling convention 1.377 - save_policy = matcher._c_reg_save_policy; 1.378 + save_policy = _matcher._c_reg_save_policy; 1.379 break; 1.380 1.381 case Op_CallStaticJava: 1.382 case Op_CallDynamicJava: 1.383 // Calling Java code so use Java calling convention 1.384 - save_policy = matcher._register_save_policy; 1.385 + save_policy = _matcher._register_save_policy; 1.386 break; 1.387 1.388 default: 1.389 @@ -677,44 +685,46 @@ 1.390 1.391 //------------------------------schedule_local--------------------------------- 1.392 // Topological sort within a block. Someday become a real scheduler. 1.393 -bool Block::schedule_local(PhaseCFG *cfg, Matcher &matcher, GrowableArray<int> &ready_cnt, VectorSet &next_call) { 1.394 +bool PhaseCFG::schedule_local(Block* block, GrowableArray<int>& ready_cnt, VectorSet& next_call) { 1.395 // Already "sorted" are the block start Node (as the first entry), and 1.396 // the block-ending Node and any trailing control projections. We leave 1.397 // these alone. PhiNodes and ParmNodes are made to follow the block start 1.398 // Node. Everything else gets topo-sorted. 1.399 1.400 #ifndef PRODUCT 1.401 - if (cfg->trace_opto_pipelining()) { 1.402 - tty->print_cr("# --- schedule_local B%d, before: ---", _pre_order); 1.403 - for (uint i = 0;i < _nodes.size();i++) { 1.404 + if (trace_opto_pipelining()) { 1.405 + tty->print_cr("# --- schedule_local B%d, before: ---", block->_pre_order); 1.406 + for (uint i = 0;i < block->number_of_nodes(); i++) { 1.407 tty->print("# "); 1.408 - _nodes[i]->fast_dump(); 1.409 + block->get_node(i)->fast_dump(); 1.410 } 1.411 tty->print_cr("#"); 1.412 } 1.413 #endif 1.414 1.415 // RootNode is already sorted 1.416 - if( _nodes.size() == 1 ) return true; 1.417 + if (block->number_of_nodes() == 1) { 1.418 + return true; 1.419 + } 1.420 1.421 // Move PhiNodes and ParmNodes from 1 to cnt up to the start 1.422 - uint node_cnt = end_idx(); 1.423 + uint node_cnt = block->end_idx(); 1.424 uint phi_cnt = 1; 1.425 uint i; 1.426 for( i = 1; i<node_cnt; i++ ) { // Scan for Phi 1.427 - Node *n = _nodes[i]; 1.428 + Node *n = block->get_node(i); 1.429 if( n->is_Phi() || // Found a PhiNode or ParmNode 1.430 - (n->is_Proj() && n->in(0) == head()) ) { 1.431 + (n->is_Proj() && n->in(0) == block->head()) ) { 1.432 // Move guy at 'phi_cnt' to the end; makes a hole at phi_cnt 1.433 - _nodes.map(i,_nodes[phi_cnt]); 1.434 - _nodes.map(phi_cnt++,n); // swap Phi/Parm up front 1.435 + block->map_node(block->get_node(phi_cnt), i); 1.436 + block->map_node(n, phi_cnt++); // swap Phi/Parm up front 1.437 } else { // All others 1.438 // Count block-local inputs to 'n' 1.439 uint cnt = n->len(); // Input count 1.440 uint local = 0; 1.441 for( uint j=0; j<cnt; j++ ) { 1.442 Node *m = n->in(j); 1.443 - if( m && cfg->get_block_for_node(m) == this && !m->is_top() ) 1.444 + if( m && get_block_for_node(m) == block && !m->is_top() ) 1.445 local++; // One more block-local input 1.446 } 1.447 ready_cnt.at_put(n->_idx, local); // Count em up 1.448 @@ -726,7 +736,7 @@ 1.449 for (uint prec = n->req(); prec < n->len(); prec++) { 1.450 Node* oop_store = n->in(prec); 1.451 if (oop_store != NULL) { 1.452 - assert(cfg->get_block_for_node(oop_store)->_dom_depth <= this->_dom_depth, "oop_store must dominate card-mark"); 1.453 + assert(get_block_for_node(oop_store)->_dom_depth <= block->_dom_depth, "oop_store must dominate card-mark"); 1.454 } 1.455 } 1.456 } 1.457 @@ -750,16 +760,16 @@ 1.458 } 1.459 } 1.460 } 1.461 - for(uint i2=i; i2<_nodes.size(); i2++ ) // Trailing guys get zapped count 1.462 - ready_cnt.at_put(_nodes[i2]->_idx, 0); 1.463 + for(uint i2=i; i2< block->number_of_nodes(); i2++ ) // Trailing guys get zapped count 1.464 + ready_cnt.at_put(block->get_node(i2)->_idx, 0); 1.465 1.466 // All the prescheduled guys do not hold back internal nodes 1.467 uint i3; 1.468 for(i3 = 0; i3<phi_cnt; i3++ ) { // For all pre-scheduled 1.469 - Node *n = _nodes[i3]; // Get pre-scheduled 1.470 + Node *n = block->get_node(i3); // Get pre-scheduled 1.471 for (DUIterator_Fast jmax, j = n->fast_outs(jmax); j < jmax; j++) { 1.472 Node* m = n->fast_out(j); 1.473 - if (cfg->get_block_for_node(m) == this) { // Local-block user 1.474 + if (get_block_for_node(m) == block) { // Local-block user 1.475 int m_cnt = ready_cnt.at(m->_idx)-1; 1.476 ready_cnt.at_put(m->_idx, m_cnt); // Fix ready count 1.477 } 1.478 @@ -770,7 +780,7 @@ 1.479 // Make a worklist 1.480 Node_List worklist; 1.481 for(uint i4=i3; i4<node_cnt; i4++ ) { // Put ready guys on worklist 1.482 - Node *m = _nodes[i4]; 1.483 + Node *m = block->get_node(i4); 1.484 if( !ready_cnt.at(m->_idx) ) { // Zero ready count? 1.485 if (m->is_iteratively_computed()) { 1.486 // Push induction variable increments last to allow other uses 1.487 @@ -792,15 +802,15 @@ 1.488 } 1.489 1.490 // Warm up the 'next_call' heuristic bits 1.491 - needed_for_next_call(_nodes[0], next_call, cfg); 1.492 + needed_for_next_call(block, block->head(), next_call); 1.493 1.494 #ifndef PRODUCT 1.495 - if (cfg->trace_opto_pipelining()) { 1.496 - for (uint j=0; j<_nodes.size(); j++) { 1.497 - Node *n = _nodes[j]; 1.498 + if (trace_opto_pipelining()) { 1.499 + for (uint j=0; j< block->number_of_nodes(); j++) { 1.500 + Node *n = block->get_node(j); 1.501 int idx = n->_idx; 1.502 tty->print("# ready cnt:%3d ", ready_cnt.at(idx)); 1.503 - tty->print("latency:%3d ", cfg->get_latency_for_node(n)); 1.504 + tty->print("latency:%3d ", get_latency_for_node(n)); 1.505 tty->print("%4d: %s\n", idx, n->Name()); 1.506 } 1.507 } 1.508 @@ -811,7 +821,7 @@ 1.509 while( worklist.size() ) { // Worklist is not ready 1.510 1.511 #ifndef PRODUCT 1.512 - if (cfg->trace_opto_pipelining()) { 1.513 + if (trace_opto_pipelining()) { 1.514 tty->print("# ready list:"); 1.515 for( uint i=0; i<worklist.size(); i++ ) { // Inspect entire worklist 1.516 Node *n = worklist[i]; // Get Node on worklist 1.517 @@ -822,13 +832,13 @@ 1.518 #endif 1.519 1.520 // Select and pop a ready guy from worklist 1.521 - Node* n = select(cfg, worklist, ready_cnt, next_call, phi_cnt); 1.522 - _nodes.map(phi_cnt++,n); // Schedule him next 1.523 + Node* n = select(block, worklist, ready_cnt, next_call, phi_cnt); 1.524 + block->map_node(n, phi_cnt++); // Schedule him next 1.525 1.526 #ifndef PRODUCT 1.527 - if (cfg->trace_opto_pipelining()) { 1.528 + if (trace_opto_pipelining()) { 1.529 tty->print("# select %d: %s", n->_idx, n->Name()); 1.530 - tty->print(", latency:%d", cfg->get_latency_for_node(n)); 1.531 + tty->print(", latency:%d", get_latency_for_node(n)); 1.532 n->dump(); 1.533 if (Verbose) { 1.534 tty->print("# ready list:"); 1.535 @@ -843,26 +853,26 @@ 1.536 #endif 1.537 if( n->is_MachCall() ) { 1.538 MachCallNode *mcall = n->as_MachCall(); 1.539 - phi_cnt = sched_call(matcher, cfg, phi_cnt, worklist, ready_cnt, mcall, next_call); 1.540 + phi_cnt = sched_call(block, phi_cnt, worklist, ready_cnt, mcall, next_call); 1.541 continue; 1.542 } 1.543 1.544 if (n->is_Mach() && n->as_Mach()->has_call()) { 1.545 RegMask regs; 1.546 - regs.Insert(matcher.c_frame_pointer()); 1.547 + regs.Insert(_matcher.c_frame_pointer()); 1.548 regs.OR(n->out_RegMask()); 1.549 1.550 - MachProjNode *proj = new (matcher.C) MachProjNode( n, 1, RegMask::Empty, MachProjNode::fat_proj ); 1.551 - cfg->map_node_to_block(proj, this); 1.552 - _nodes.insert(phi_cnt++, proj); 1.553 + MachProjNode *proj = new (C) MachProjNode( n, 1, RegMask::Empty, MachProjNode::fat_proj ); 1.554 + map_node_to_block(proj, block); 1.555 + block->insert_node(proj, phi_cnt++); 1.556 1.557 - add_call_kills(proj, regs, matcher._c_reg_save_policy, false); 1.558 + add_call_kills(proj, regs, _matcher._c_reg_save_policy, false); 1.559 } 1.560 1.561 // Children are now all ready 1.562 for (DUIterator_Fast i5max, i5 = n->fast_outs(i5max); i5 < i5max; i5++) { 1.563 Node* m = n->fast_out(i5); // Get user 1.564 - if (cfg->get_block_for_node(m) != this) { 1.565 + if (get_block_for_node(m) != block) { 1.566 continue; 1.567 } 1.568 if( m->is_Phi() ) continue; 1.569 @@ -877,9 +887,8 @@ 1.570 } 1.571 } 1.572 1.573 - if( phi_cnt != end_idx() ) { 1.574 + if( phi_cnt != block->end_idx() ) { 1.575 // did not schedule all. Retry, Bailout, or Die 1.576 - Compile* C = matcher.C; 1.577 if (C->subsume_loads() == true && !C->failing()) { 1.578 // Retry with subsume_loads == false 1.579 // If this is the first failure, the sentinel string will "stick" 1.580 @@ -891,12 +900,12 @@ 1.581 } 1.582 1.583 #ifndef PRODUCT 1.584 - if (cfg->trace_opto_pipelining()) { 1.585 + if (trace_opto_pipelining()) { 1.586 tty->print_cr("#"); 1.587 tty->print_cr("# after schedule_local"); 1.588 - for (uint i = 0;i < _nodes.size();i++) { 1.589 + for (uint i = 0;i < block->number_of_nodes();i++) { 1.590 tty->print("# "); 1.591 - _nodes[i]->fast_dump(); 1.592 + block->get_node(i)->fast_dump(); 1.593 } 1.594 tty->cr(); 1.595 } 1.596 @@ -922,7 +931,7 @@ 1.597 } 1.598 1.599 //------------------------------catch_cleanup_find_cloned_def------------------ 1.600 -static Node *catch_cleanup_find_cloned_def(Block *use_blk, Node *def, Block *def_blk, PhaseCFG* cfg, int n_clone_idx) { 1.601 +Node* PhaseCFG::catch_cleanup_find_cloned_def(Block *use_blk, Node *def, Block *def_blk, int n_clone_idx) { 1.602 assert( use_blk != def_blk, "Inter-block cleanup only"); 1.603 1.604 // The use is some block below the Catch. Find and return the clone of the def 1.605 @@ -948,14 +957,14 @@ 1.606 // PhiNode, the PhiNode uses from the def and IT's uses need fixup. 1.607 Node_Array inputs = new Node_List(Thread::current()->resource_area()); 1.608 for(uint k = 1; k < use_blk->num_preds(); k++) { 1.609 - Block* block = cfg->get_block_for_node(use_blk->pred(k)); 1.610 - inputs.map(k, catch_cleanup_find_cloned_def(block, def, def_blk, cfg, n_clone_idx)); 1.611 + Block* block = get_block_for_node(use_blk->pred(k)); 1.612 + inputs.map(k, catch_cleanup_find_cloned_def(block, def, def_blk, n_clone_idx)); 1.613 } 1.614 1.615 // Check to see if the use_blk already has an identical phi inserted. 1.616 // If it exists, it will be at the first position since all uses of a 1.617 // def are processed together. 1.618 - Node *phi = use_blk->_nodes[1]; 1.619 + Node *phi = use_blk->get_node(1); 1.620 if( phi->is_Phi() ) { 1.621 fixup = phi; 1.622 for (uint k = 1; k < use_blk->num_preds(); k++) { 1.623 @@ -970,8 +979,8 @@ 1.624 // If an existing PhiNode was not found, make a new one. 1.625 if (fixup == NULL) { 1.626 Node *new_phi = PhiNode::make(use_blk->head(), def); 1.627 - use_blk->_nodes.insert(1, new_phi); 1.628 - cfg->map_node_to_block(new_phi, use_blk); 1.629 + use_blk->insert_node(new_phi, 1); 1.630 + map_node_to_block(new_phi, use_blk); 1.631 for (uint k = 1; k < use_blk->num_preds(); k++) { 1.632 new_phi->set_req(k, inputs[k]); 1.633 } 1.634 @@ -980,7 +989,7 @@ 1.635 1.636 } else { 1.637 // Found the use just below the Catch. Make it use the clone. 1.638 - fixup = use_blk->_nodes[n_clone_idx]; 1.639 + fixup = use_blk->get_node(n_clone_idx); 1.640 } 1.641 1.642 return fixup; 1.643 @@ -1000,36 +1009,36 @@ 1.644 for( uint k = 0; k < blk->_num_succs; k++ ) { 1.645 // Get clone in each successor block 1.646 Block *sb = blk->_succs[k]; 1.647 - Node *clone = sb->_nodes[offset_idx+1]; 1.648 + Node *clone = sb->get_node(offset_idx+1); 1.649 assert( clone->Opcode() == use->Opcode(), "" ); 1.650 1.651 // Make use-clone reference the def-clone 1.652 - catch_cleanup_fix_all_inputs(clone, def, sb->_nodes[n_clone_idx]); 1.653 + catch_cleanup_fix_all_inputs(clone, def, sb->get_node(n_clone_idx)); 1.654 } 1.655 } 1.656 1.657 //------------------------------catch_cleanup_inter_block--------------------- 1.658 // Fix all input edges in use that reference "def". The use is in a different 1.659 // block than the def. 1.660 -static void catch_cleanup_inter_block(Node *use, Block *use_blk, Node *def, Block *def_blk, PhaseCFG* cfg, int n_clone_idx) { 1.661 +void PhaseCFG::catch_cleanup_inter_block(Node *use, Block *use_blk, Node *def, Block *def_blk, int n_clone_idx) { 1.662 if( !use_blk ) return; // Can happen if the use is a precedence edge 1.663 1.664 - Node *new_def = catch_cleanup_find_cloned_def(use_blk, def, def_blk, cfg, n_clone_idx); 1.665 + Node *new_def = catch_cleanup_find_cloned_def(use_blk, def, def_blk, n_clone_idx); 1.666 catch_cleanup_fix_all_inputs(use, def, new_def); 1.667 } 1.668 1.669 //------------------------------call_catch_cleanup----------------------------- 1.670 // If we inserted any instructions between a Call and his CatchNode, 1.671 // clone the instructions on all paths below the Catch. 1.672 -void Block::call_catch_cleanup(PhaseCFG* cfg, Compile* C) { 1.673 +void PhaseCFG::call_catch_cleanup(Block* block) { 1.674 1.675 // End of region to clone 1.676 - uint end = end_idx(); 1.677 - if( !_nodes[end]->is_Catch() ) return; 1.678 + uint end = block->end_idx(); 1.679 + if( !block->get_node(end)->is_Catch() ) return; 1.680 // Start of region to clone 1.681 uint beg = end; 1.682 - while(!_nodes[beg-1]->is_MachProj() || 1.683 - !_nodes[beg-1]->in(0)->is_MachCall() ) { 1.684 + while(!block->get_node(beg-1)->is_MachProj() || 1.685 + !block->get_node(beg-1)->in(0)->is_MachCall() ) { 1.686 beg--; 1.687 assert(beg > 0,"Catch cleanup walking beyond block boundary"); 1.688 } 1.689 @@ -1038,15 +1047,15 @@ 1.690 1.691 // Clone along all Catch output paths. Clone area between the 'beg' and 1.692 // 'end' indices. 1.693 - for( uint i = 0; i < _num_succs; i++ ) { 1.694 - Block *sb = _succs[i]; 1.695 + for( uint i = 0; i < block->_num_succs; i++ ) { 1.696 + Block *sb = block->_succs[i]; 1.697 // Clone the entire area; ignoring the edge fixup for now. 1.698 for( uint j = end; j > beg; j-- ) { 1.699 // It is safe here to clone a node with anti_dependence 1.700 // since clones dominate on each path. 1.701 - Node *clone = _nodes[j-1]->clone(); 1.702 - sb->_nodes.insert( 1, clone ); 1.703 - cfg->map_node_to_block(clone, sb); 1.704 + Node *clone = block->get_node(j-1)->clone(); 1.705 + sb->insert_node(clone, 1); 1.706 + map_node_to_block(clone, sb); 1.707 } 1.708 } 1.709 1.710 @@ -1054,7 +1063,7 @@ 1.711 // Fixup edges. Check the def-use info per cloned Node 1.712 for(uint i2 = beg; i2 < end; i2++ ) { 1.713 uint n_clone_idx = i2-beg+1; // Index of clone of n in each successor block 1.714 - Node *n = _nodes[i2]; // Node that got cloned 1.715 + Node *n = block->get_node(i2); // Node that got cloned 1.716 // Need DU safe iterator because of edge manipulation in calls. 1.717 Unique_Node_List *out = new Unique_Node_List(Thread::current()->resource_area()); 1.718 for (DUIterator_Fast j1max, j1 = n->fast_outs(j1max); j1 < j1max; j1++) { 1.719 @@ -1063,19 +1072,19 @@ 1.720 uint max = out->size(); 1.721 for (uint j = 0; j < max; j++) {// For all users 1.722 Node *use = out->pop(); 1.723 - Block *buse = cfg->get_block_for_node(use); 1.724 + Block *buse = get_block_for_node(use); 1.725 if( use->is_Phi() ) { 1.726 for( uint k = 1; k < use->req(); k++ ) 1.727 if( use->in(k) == n ) { 1.728 - Block* block = cfg->get_block_for_node(buse->pred(k)); 1.729 - Node *fixup = catch_cleanup_find_cloned_def(block, n, this, cfg, n_clone_idx); 1.730 + Block* b = get_block_for_node(buse->pred(k)); 1.731 + Node *fixup = catch_cleanup_find_cloned_def(b, n, block, n_clone_idx); 1.732 use->set_req(k, fixup); 1.733 } 1.734 } else { 1.735 - if (this == buse) { 1.736 - catch_cleanup_intra_block(use, n, this, beg, n_clone_idx); 1.737 + if (block == buse) { 1.738 + catch_cleanup_intra_block(use, n, block, beg, n_clone_idx); 1.739 } else { 1.740 - catch_cleanup_inter_block(use, buse, n, this, cfg, n_clone_idx); 1.741 + catch_cleanup_inter_block(use, buse, n, block, n_clone_idx); 1.742 } 1.743 } 1.744 } // End for all users 1.745 @@ -1084,30 +1093,30 @@ 1.746 1.747 // Remove the now-dead cloned ops 1.748 for(uint i3 = beg; i3 < end; i3++ ) { 1.749 - _nodes[beg]->disconnect_inputs(NULL, C); 1.750 - _nodes.remove(beg); 1.751 + block->get_node(beg)->disconnect_inputs(NULL, C); 1.752 + block->remove_node(beg); 1.753 } 1.754 1.755 // If the successor blocks have a CreateEx node, move it back to the top 1.756 - for(uint i4 = 0; i4 < _num_succs; i4++ ) { 1.757 - Block *sb = _succs[i4]; 1.758 + for(uint i4 = 0; i4 < block->_num_succs; i4++ ) { 1.759 + Block *sb = block->_succs[i4]; 1.760 uint new_cnt = end - beg; 1.761 // Remove any newly created, but dead, nodes. 1.762 for( uint j = new_cnt; j > 0; j-- ) { 1.763 - Node *n = sb->_nodes[j]; 1.764 + Node *n = sb->get_node(j); 1.765 if (n->outcnt() == 0 && 1.766 (!n->is_Proj() || n->as_Proj()->in(0)->outcnt() == 1) ){ 1.767 n->disconnect_inputs(NULL, C); 1.768 - sb->_nodes.remove(j); 1.769 + sb->remove_node(j); 1.770 new_cnt--; 1.771 } 1.772 } 1.773 // If any newly created nodes remain, move the CreateEx node to the top 1.774 if (new_cnt > 0) { 1.775 - Node *cex = sb->_nodes[1+new_cnt]; 1.776 + Node *cex = sb->get_node(1+new_cnt); 1.777 if( cex->is_Mach() && cex->as_Mach()->ideal_Opcode() == Op_CreateEx ) { 1.778 - sb->_nodes.remove(1+new_cnt); 1.779 - sb->_nodes.insert(1,cex); 1.780 + sb->remove_node(1+new_cnt); 1.781 + sb->insert_node(cex, 1); 1.782 } 1.783 } 1.784 }