src/share/vm/opto/lcm.cpp

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

mercurial