hotspot/src/share/vm/opto/postaloc.cpp
changeset 22838 82c7497fbad4
parent 21200 5f7a5282462d
child 22234 da823d78ad65
equal deleted inserted replaced
22837:feba5d4126b8 22838:82c7497fbad4
    95 
    95 
    96 #ifdef ASSERT
    96 #ifdef ASSERT
    97 static bool expected_yanked_node(Node *old, Node *orig_old) {
    97 static bool expected_yanked_node(Node *old, Node *orig_old) {
    98   // This code is expected only next original nodes:
    98   // This code is expected only next original nodes:
    99   // - load from constant table node which may have next data input nodes:
    99   // - load from constant table node which may have next data input nodes:
   100   //     MachConstantBase, Phi, MachTemp, MachSpillCopy
   100   //     MachConstantBase, MachTemp, MachSpillCopy
       
   101   // - Phi nodes that are considered Junk
   101   // - load constant node which may have next data input nodes:
   102   // - load constant node which may have next data input nodes:
   102   //     MachTemp, MachSpillCopy
   103   //     MachTemp, MachSpillCopy
   103   // - MachSpillCopy
   104   // - MachSpillCopy
   104   // - MachProj and Copy dead nodes
   105   // - MachProj and Copy dead nodes
   105   if (old->is_MachSpillCopy()) {
   106   if (old->is_MachSpillCopy()) {
   110     return (old == orig_old);
   111     return (old == orig_old);
   111   } else if (old->is_Copy()) {     // Dead copy of a callee-save value
   112   } else if (old->is_Copy()) {     // Dead copy of a callee-save value
   112     return (old == orig_old);
   113     return (old == orig_old);
   113   } else if (old->is_MachTemp()) {
   114   } else if (old->is_MachTemp()) {
   114     return orig_old->is_Con();
   115     return orig_old->is_Con();
   115   } else if (old->is_Phi() || old->is_MachConstantBase()) {
   116   } else if (old->is_Phi()) { // Junk phi's
       
   117     return true;
       
   118   } else if (old->is_MachConstantBase()) {
   116     return (orig_old->is_Con() && orig_old->is_MachConstant());
   119     return (orig_old->is_Con() && orig_old->is_MachConstant());
   117   }
   120   }
   118   return false;
   121   return false;
   119 }
   122 }
   120 #endif
   123 #endif
   421     uint j;
   424     uint j;
   422     Block* block = _cfg.get_block(i);
   425     Block* block = _cfg.get_block(i);
   423 
   426 
   424     // Count of Phis in block
   427     // Count of Phis in block
   425     uint phi_dex;
   428     uint phi_dex;
   426     for (phi_dex = 1; phi_dex < block->_nodes.size(); phi_dex++) {
   429     for (phi_dex = 1; phi_dex < block->number_of_nodes(); phi_dex++) {
   427       Node* phi = block->_nodes[phi_dex];
   430       Node* phi = block->get_node(phi_dex);
   428       if (!phi->is_Phi()) {
   431       if (!phi->is_Phi()) {
   429         break;
   432         break;
   430       }
   433       }
   431     }
   434     }
   432 
   435 
   437     Block *freed = NULL;
   440     Block *freed = NULL;
   438     for (j = 1; j < block->num_preds(); j++) {
   441     for (j = 1; j < block->num_preds(); j++) {
   439       Block* pb = _cfg.get_block_for_node(block->pred(j));
   442       Block* pb = _cfg.get_block_for_node(block->pred(j));
   440       // Remove copies along phi edges
   443       // Remove copies along phi edges
   441       for (uint k = 1; k < phi_dex; k++) {
   444       for (uint k = 1; k < phi_dex; k++) {
   442         elide_copy(block->_nodes[k], j, block, *blk2value[pb->_pre_order], *blk2regnd[pb->_pre_order], false);
   445         elide_copy(block->get_node(k), j, block, *blk2value[pb->_pre_order], *blk2regnd[pb->_pre_order], false);
   443       }
   446       }
   444       if (blk2value[pb->_pre_order]) { // Have a mapping on this edge?
   447       if (blk2value[pb->_pre_order]) { // Have a mapping on this edge?
   445         // See if this predecessor's mappings have been used by everybody
   448         // See if this predecessor's mappings have been used by everybody
   446         // who wants them.  If so, free 'em.
   449         // who wants them.  If so, free 'em.
   447         uint k;
   450         uint k;
   508     }
   511     }
   509 
   512 
   510     // For all Phi's
   513     // For all Phi's
   511     for (j = 1; j < phi_dex; j++) {
   514     for (j = 1; j < phi_dex; j++) {
   512       uint k;
   515       uint k;
   513       Node *phi = block->_nodes[j];
   516       Node *phi = block->get_node(j);
   514       uint pidx = _lrg_map.live_range_id(phi);
   517       uint pidx = _lrg_map.live_range_id(phi);
   515       OptoReg::Name preg = lrgs(_lrg_map.live_range_id(phi)).reg();
   518       OptoReg::Name preg = lrgs(_lrg_map.live_range_id(phi)).reg();
   516 
   519 
   517       // Remove copies remaining on edges.  Check for junk phi.
   520       // Remove copies remaining on edges.  Check for junk phi.
   518       Node *u = NULL;
   521       Node *u = NULL;
   520         Node *x = phi->in(k);
   523         Node *x = phi->in(k);
   521         if( phi != x && u != x ) // Found a different input
   524         if( phi != x && u != x ) // Found a different input
   522           u = u ? NodeSentinel : x; // Capture unique input, or NodeSentinel for 2nd input
   525           u = u ? NodeSentinel : x; // Capture unique input, or NodeSentinel for 2nd input
   523       }
   526       }
   524       if (u != NodeSentinel) {    // Junk Phi.  Remove
   527       if (u != NodeSentinel) {    // Junk Phi.  Remove
   525         block->_nodes.remove(j--);
   528         phi->replace_by(u);
       
   529         j -= yank_if_dead(phi, block, &value, &regnd);
   526         phi_dex--;
   530         phi_dex--;
   527         _cfg.unmap_node_from_block(phi);
       
   528         phi->replace_by(u);
       
   529         phi->disconnect_inputs(NULL, C);
       
   530         continue;
   531         continue;
   531       }
   532       }
   532       // Note that if value[pidx] exists, then we merged no new values here
   533       // Note that if value[pidx] exists, then we merged no new values here
   533       // and the phi is useless.  This can happen even with the above phi
   534       // and the phi is useless.  This can happen even with the above phi
   534       // removal for complex flows.  I cannot keep the better known value here
   535       // removal for complex flows.  I cannot keep the better known value here
   550         }
   551         }
   551       }
   552       }
   552     }
   553     }
   553 
   554 
   554     // For all remaining instructions
   555     // For all remaining instructions
   555     for (j = phi_dex; j < block->_nodes.size(); j++) {
   556     for (j = phi_dex; j < block->number_of_nodes(); j++) {
   556       Node* n = block->_nodes[j];
   557       Node* n = block->get_node(j);
   557 
   558 
   558       if(n->outcnt() == 0 &&   // Dead?
   559       if(n->outcnt() == 0 &&   // Dead?
   559          n != C->top() &&      // (ignore TOP, it has no du info)
   560          n != C->top() &&      // (ignore TOP, it has no du info)
   560          !n->is_Proj() ) {     // fat-proj kills
   561          !n->is_Proj() ) {     // fat-proj kills
   561         j -= yank_if_dead(n, block, &value, &regnd);
   562         j -= yank_if_dead(n, block, &value, &regnd);