src/share/vm/opto/block.cpp

changeset 5635
650868c062a9
parent 5539
adb9a7d94cb5
child 5639
4b078f877b56
     1.1 --- a/src/share/vm/opto/block.cpp	Mon Aug 26 16:12:20 2013 +0200
     1.2 +++ b/src/share/vm/opto/block.cpp	Mon Aug 26 12:50:23 2013 +0200
     1.3 @@ -112,9 +112,9 @@
     1.4  // exceeds OptoLoopAlignment.
     1.5  uint Block::compute_first_inst_size(uint& sum_size, uint inst_cnt,
     1.6                                      PhaseRegAlloc* ra) {
     1.7 -  uint last_inst = _nodes.size();
     1.8 +  uint last_inst = number_of_nodes();
     1.9    for( uint j = 0; j < last_inst && inst_cnt > 0; j++ ) {
    1.10 -    uint inst_size = _nodes[j]->size(ra);
    1.11 +    uint inst_size = get_node(j)->size(ra);
    1.12      if( inst_size > 0 ) {
    1.13        inst_cnt--;
    1.14        uint sz = sum_size + inst_size;
    1.15 @@ -131,8 +131,8 @@
    1.16  }
    1.17  
    1.18  uint Block::find_node( const Node *n ) const {
    1.19 -  for( uint i = 0; i < _nodes.size(); i++ ) {
    1.20 -    if( _nodes[i] == n )
    1.21 +  for( uint i = 0; i < number_of_nodes(); i++ ) {
    1.22 +    if( get_node(i) == n )
    1.23        return i;
    1.24    }
    1.25    ShouldNotReachHere();
    1.26 @@ -141,7 +141,7 @@
    1.27  
    1.28  // Find and remove n from block list
    1.29  void Block::find_remove( const Node *n ) {
    1.30 -  _nodes.remove(find_node(n));
    1.31 +  remove_node(find_node(n));
    1.32  }
    1.33  
    1.34  // Return empty status of a block.  Empty blocks contain only the head, other
    1.35 @@ -154,10 +154,10 @@
    1.36    }
    1.37  
    1.38    int success_result = completely_empty;
    1.39 -  int end_idx = _nodes.size()-1;
    1.40 +  int end_idx = number_of_nodes() - 1;
    1.41  
    1.42    // Check for ending goto
    1.43 -  if ((end_idx > 0) && (_nodes[end_idx]->is_MachGoto())) {
    1.44 +  if ((end_idx > 0) && (get_node(end_idx)->is_MachGoto())) {
    1.45      success_result = empty_with_goto;
    1.46      end_idx--;
    1.47    }
    1.48 @@ -170,7 +170,7 @@
    1.49    // Ideal nodes are allowable in empty blocks: skip them  Only MachNodes
    1.50    // turn directly into code, because only MachNodes have non-trivial
    1.51    // emit() functions.
    1.52 -  while ((end_idx > 0) && !_nodes[end_idx]->is_Mach()) {
    1.53 +  while ((end_idx > 0) && !get_node(end_idx)->is_Mach()) {
    1.54      end_idx--;
    1.55    }
    1.56  
    1.57 @@ -344,8 +344,8 @@
    1.58  
    1.59  void Block::dump(const PhaseCFG* cfg) const {
    1.60    dump_head(cfg);
    1.61 -  for (uint i=0; i< _nodes.size(); i++) {
    1.62 -    _nodes[i]->dump();
    1.63 +  for (uint i=0; i< number_of_nodes(); i++) {
    1.64 +    get_node(i)->dump();
    1.65    }
    1.66    tty->print("\n");
    1.67  }
    1.68 @@ -434,7 +434,7 @@
    1.69        map_node_to_block(p, bb);
    1.70        map_node_to_block(x, bb);
    1.71        if( x != p ) {                // Only for root is x == p
    1.72 -        bb->_nodes.push((Node*)x);
    1.73 +        bb->push_node((Node*)x);
    1.74        }
    1.75        // Now handle predecessors
    1.76        ++sum;                        // Count 1 for self block
    1.77 @@ -469,11 +469,11 @@
    1.78          assert( x != proj, "" );
    1.79          // Map basic block of projection
    1.80          map_node_to_block(proj, pb);
    1.81 -        pb->_nodes.push(proj);
    1.82 +        pb->push_node(proj);
    1.83        }
    1.84        // Insert self as a child of my predecessor block
    1.85        pb->_succs.map(pb->_num_succs++, get_block_for_node(np));
    1.86 -      assert( pb->_nodes[ pb->_nodes.size() - pb->_num_succs ]->is_block_proj(),
    1.87 +      assert( pb->get_node(pb->number_of_nodes() - pb->_num_succs)->is_block_proj(),
    1.88                "too many control users, not a CFG?" );
    1.89      }
    1.90    }
    1.91 @@ -495,7 +495,7 @@
    1.92    // surrounding blocks.
    1.93    float freq = in->_freq * in->succ_prob(succ_no);
    1.94    // get ProjNode corresponding to the succ_no'th successor of the in block
    1.95 -  ProjNode* proj = in->_nodes[in->_nodes.size() - in->_num_succs + succ_no]->as_Proj();
    1.96 +  ProjNode* proj = in->get_node(in->number_of_nodes() - in->_num_succs + succ_no)->as_Proj();
    1.97    // create region for basic block
    1.98    RegionNode* region = new (C) RegionNode(2);
    1.99    region->init_req(1, proj);
   1.100 @@ -507,7 +507,7 @@
   1.101    Node* gto = _goto->clone(); // get a new goto node
   1.102    gto->set_req(0, region);
   1.103    // add it to the basic block
   1.104 -  block->_nodes.push(gto);
   1.105 +  block->push_node(gto);
   1.106    map_node_to_block(gto, block);
   1.107    C->regalloc()->set_bad(gto->_idx);
   1.108    // hook up successor block
   1.109 @@ -527,9 +527,9 @@
   1.110  // Does this block end in a multiway branch that cannot have the default case
   1.111  // flipped for another case?
   1.112  static bool no_flip_branch( Block *b ) {
   1.113 -  int branch_idx = b->_nodes.size() - b->_num_succs-1;
   1.114 +  int branch_idx = b->number_of_nodes() - b->_num_succs-1;
   1.115    if( branch_idx < 1 ) return false;
   1.116 -  Node *bra = b->_nodes[branch_idx];
   1.117 +  Node *bra = b->get_node(branch_idx);
   1.118    if( bra->is_Catch() )
   1.119      return true;
   1.120    if( bra->is_Mach() ) {
   1.121 @@ -550,16 +550,16 @@
   1.122  void PhaseCFG::convert_NeverBranch_to_Goto(Block *b) {
   1.123    // Find true target
   1.124    int end_idx = b->end_idx();
   1.125 -  int idx = b->_nodes[end_idx+1]->as_Proj()->_con;
   1.126 +  int idx = b->get_node(end_idx+1)->as_Proj()->_con;
   1.127    Block *succ = b->_succs[idx];
   1.128    Node* gto = _goto->clone(); // get a new goto node
   1.129    gto->set_req(0, b->head());
   1.130 -  Node *bp = b->_nodes[end_idx];
   1.131 -  b->_nodes.map(end_idx,gto); // Slam over NeverBranch
   1.132 +  Node *bp = b->get_node(end_idx);
   1.133 +  b->map_node(gto, end_idx); // Slam over NeverBranch
   1.134    map_node_to_block(gto, b);
   1.135    C->regalloc()->set_bad(gto->_idx);
   1.136 -  b->_nodes.pop();              // Yank projections
   1.137 -  b->_nodes.pop();              // Yank projections
   1.138 +  b->pop_node();              // Yank projections
   1.139 +  b->pop_node();              // Yank projections
   1.140    b->_succs.map(0,succ);        // Map only successor
   1.141    b->_num_succs = 1;
   1.142    // remap successor's predecessors if necessary
   1.143 @@ -575,8 +575,8 @@
   1.144    // Scan through block, yanking dead path from
   1.145    // all regions and phis.
   1.146    dead->head()->del_req(j);
   1.147 -  for( int k = 1; dead->_nodes[k]->is_Phi(); k++ )
   1.148 -    dead->_nodes[k]->del_req(j);
   1.149 +  for( int k = 1; dead->get_node(k)->is_Phi(); k++ )
   1.150 +    dead->get_node(k)->del_req(j);
   1.151  }
   1.152  
   1.153  // Helper function to move block bx to the slot following b_index. Return
   1.154 @@ -620,7 +620,7 @@
   1.155    if (e != Block::not_empty) {
   1.156      if (e == Block::empty_with_goto) {
   1.157        // Remove the goto, but leave the block.
   1.158 -      b->_nodes.pop();
   1.159 +      b->pop_node();
   1.160      }
   1.161      // Mark this block as a connector block, which will cause it to be
   1.162      // ignored in certain functions such as non_connector_successor().
   1.163 @@ -663,7 +663,7 @@
   1.164      // to give a fake exit path to infinite loops.  At this late stage they
   1.165      // need to turn into Goto's so that when you enter the infinite loop you
   1.166      // indeed hang.
   1.167 -    if (block->_nodes[block->end_idx()]->Opcode() == Op_NeverBranch) {
   1.168 +    if (block->get_node(block->end_idx())->Opcode() == Op_NeverBranch) {
   1.169        convert_NeverBranch_to_Goto(block);
   1.170      }
   1.171  
   1.172 @@ -720,9 +720,9 @@
   1.173      // exchange the true and false targets.
   1.174      if (no_flip_branch(block)) {
   1.175        // Find fall through case - if must fall into its target
   1.176 -      int branch_idx = block->_nodes.size() - block->_num_succs;
   1.177 +      int branch_idx = block->number_of_nodes() - block->_num_succs;
   1.178        for (uint j2 = 0; j2 < block->_num_succs; j2++) {
   1.179 -        const ProjNode* p = block->_nodes[branch_idx + j2]->as_Proj();
   1.180 +        const ProjNode* p = block->get_node(branch_idx + j2)->as_Proj();
   1.181          if (p->_con == 0) {
   1.182            // successor j2 is fall through case
   1.183            if (block->non_connector_successor(j2) != bnext) {
   1.184 @@ -743,14 +743,14 @@
   1.185  
   1.186        // Remove all CatchProjs
   1.187        for (uint j = 0; j < block->_num_succs; j++) {
   1.188 -        block->_nodes.pop();
   1.189 +        block->pop_node();
   1.190        }
   1.191  
   1.192      } else if (block->_num_succs == 1) {
   1.193        // Block ends in a Goto?
   1.194        if (bnext == bs0) {
   1.195          // We fall into next block; remove the Goto
   1.196 -        block->_nodes.pop();
   1.197 +        block->pop_node();
   1.198        }
   1.199  
   1.200      } else if(block->_num_succs == 2) { // Block ends in a If?
   1.201 @@ -759,9 +759,9 @@
   1.202        //       be projections (in any order), the 3rd last node must be
   1.203        //       the IfNode (we have excluded other 2-way exits such as
   1.204        //       CatchNodes already).
   1.205 -      MachNode* iff   = block->_nodes[block->_nodes.size() - 3]->as_Mach();
   1.206 -      ProjNode* proj0 = block->_nodes[block->_nodes.size() - 2]->as_Proj();
   1.207 -      ProjNode* proj1 = block->_nodes[block->_nodes.size() - 1]->as_Proj();
   1.208 +      MachNode* iff   = block->get_node(block->number_of_nodes() - 3)->as_Mach();
   1.209 +      ProjNode* proj0 = block->get_node(block->number_of_nodes() - 2)->as_Proj();
   1.210 +      ProjNode* proj1 = block->get_node(block->number_of_nodes() - 1)->as_Proj();
   1.211  
   1.212        // Assert that proj0 and succs[0] match up. Similarly for proj1 and succs[1].
   1.213        assert(proj0->raw_out(0) == block->_succs[0]->head(), "Mismatch successor 0");
   1.214 @@ -833,8 +833,8 @@
   1.215          iff->as_MachIf()->negate();
   1.216        }
   1.217  
   1.218 -      block->_nodes.pop();          // Remove IfFalse & IfTrue projections
   1.219 -      block->_nodes.pop();
   1.220 +      block->pop_node();          // Remove IfFalse & IfTrue projections
   1.221 +      block->pop_node();
   1.222  
   1.223      } else {
   1.224        // Multi-exit block, e.g. a switch statement
   1.225 @@ -895,13 +895,13 @@
   1.226    // Verify sane CFG
   1.227    for (uint i = 0; i < number_of_blocks(); i++) {
   1.228      Block* block = get_block(i);
   1.229 -    uint cnt = block->_nodes.size();
   1.230 +    uint cnt = block->number_of_nodes();
   1.231      uint j;
   1.232      for (j = 0; j < cnt; j++)  {
   1.233 -      Node *n = block->_nodes[j];
   1.234 +      Node *n = block->get_node(j);
   1.235        assert(get_block_for_node(n) == block, "");
   1.236        if (j >= 1 && n->is_Mach() && n->as_Mach()->ideal_Opcode() == Op_CreateEx) {
   1.237 -        assert(j == 1 || block->_nodes[j-1]->is_Phi(), "CreateEx must be first instruction in block");
   1.238 +        assert(j == 1 || block->get_node(j-1)->is_Phi(), "CreateEx must be first instruction in block");
   1.239        }
   1.240        for (uint k = 0; k < n->req(); k++) {
   1.241          Node *def = n->in(k);
   1.242 @@ -930,14 +930,14 @@
   1.243      }
   1.244  
   1.245      j = block->end_idx();
   1.246 -    Node* bp = (Node*)block->_nodes[block->_nodes.size() - 1]->is_block_proj();
   1.247 +    Node* bp = (Node*)block->get_node(block->number_of_nodes() - 1)->is_block_proj();
   1.248      assert(bp, "last instruction must be a block proj");
   1.249 -    assert(bp == block->_nodes[j], "wrong number of successors for this block");
   1.250 +    assert(bp == block->get_node(j), "wrong number of successors for this block");
   1.251      if (bp->is_Catch()) {
   1.252 -      while (block->_nodes[--j]->is_MachProj()) {
   1.253 +      while (block->get_node(--j)->is_MachProj()) {
   1.254          ;
   1.255        }
   1.256 -      assert(block->_nodes[j]->is_MachCall(), "CatchProj must follow call");
   1.257 +      assert(block->get_node(j)->is_MachCall(), "CatchProj must follow call");
   1.258      } else if (bp->is_Mach() && bp->as_Mach()->ideal_Opcode() == Op_If) {
   1.259        assert(block->_num_succs == 2, "Conditional branch must have two targets");
   1.260      }
   1.261 @@ -1440,9 +1440,9 @@
   1.262            Block *bnext = next(b);
   1.263            Block *bs0 = b->non_connector_successor(0);
   1.264  
   1.265 -          MachNode *iff = b->_nodes[b->_nodes.size()-3]->as_Mach();
   1.266 -          ProjNode *proj0 = b->_nodes[b->_nodes.size()-2]->as_Proj();
   1.267 -          ProjNode *proj1 = b->_nodes[b->_nodes.size()-1]->as_Proj();
   1.268 +          MachNode *iff = b->get_node(b->number_of_nodes() - 3)->as_Mach();
   1.269 +          ProjNode *proj0 = b->get_node(b->number_of_nodes() - 2)->as_Proj();
   1.270 +          ProjNode *proj1 = b->get_node(b->number_of_nodes() - 1)->as_Proj();
   1.271  
   1.272            if (bnext == bs0) {
   1.273              // Fall-thru case in succs[0], should be in succs[1]
   1.274 @@ -1454,8 +1454,8 @@
   1.275              b->_succs.map( 1, tbs0 );
   1.276  
   1.277              // Flip projections to match targets
   1.278 -            b->_nodes.map(b->_nodes.size()-2, proj1);
   1.279 -            b->_nodes.map(b->_nodes.size()-1, proj0);
   1.280 +            b->map_node(proj1, b->number_of_nodes() - 2);
   1.281 +            b->map_node(proj0, b->number_of_nodes() - 1);
   1.282            }
   1.283          }
   1.284        }

mercurial