hotspot/src/share/vm/opto/node.cpp
changeset 1067 f82e0a8cd438
parent 781 e1baa9c8f16f
child 2131 98f9cef66a34
equal deleted inserted replaced
1066:717c3345024f 1067:f82e0a8cd438
  1164 //------------------------------remove_dead_region-----------------------------
  1164 //------------------------------remove_dead_region-----------------------------
  1165 // This control node is dead.  Follow the subgraph below it making everything
  1165 // This control node is dead.  Follow the subgraph below it making everything
  1166 // using it dead as well.  This will happen normally via the usual IterGVN
  1166 // using it dead as well.  This will happen normally via the usual IterGVN
  1167 // worklist but this call is more efficient.  Do not update use-def info
  1167 // worklist but this call is more efficient.  Do not update use-def info
  1168 // inside the dead region, just at the borders.
  1168 // inside the dead region, just at the borders.
  1169 static bool kill_dead_code( Node *dead, PhaseIterGVN *igvn ) {
  1169 static void kill_dead_code( Node *dead, PhaseIterGVN *igvn ) {
  1170   // Con's are a popular node to re-hit in the hash table again.
  1170   // Con's are a popular node to re-hit in the hash table again.
  1171   if( dead->is_Con() ) return false;
  1171   if( dead->is_Con() ) return;
  1172 
  1172 
  1173   // Can't put ResourceMark here since igvn->_worklist uses the same arena
  1173   // Can't put ResourceMark here since igvn->_worklist uses the same arena
  1174   // for verify pass with +VerifyOpto and we add/remove elements in it here.
  1174   // for verify pass with +VerifyOpto and we add/remove elements in it here.
  1175   Node_List  nstack(Thread::current()->resource_area());
  1175   Node_List  nstack(Thread::current()->resource_area());
  1176 
  1176 
  1177   Node *top = igvn->C->top();
  1177   Node *top = igvn->C->top();
  1178   bool progress = false;
       
  1179   nstack.push(dead);
  1178   nstack.push(dead);
  1180 
  1179 
  1181   while (nstack.size() > 0) {
  1180   while (nstack.size() > 0) {
  1182     dead = nstack.pop();
  1181     dead = nstack.pop();
  1183     if (dead->outcnt() > 0) {
  1182     if (dead->outcnt() > 0) {
  1212       }
  1211       }
  1213       // Kill all inputs to the dead guy
  1212       // Kill all inputs to the dead guy
  1214       for (uint i=0; i < dead->req(); i++) {
  1213       for (uint i=0; i < dead->req(); i++) {
  1215         Node *n = dead->in(i);      // Get input to dead guy
  1214         Node *n = dead->in(i);      // Get input to dead guy
  1216         if (n != NULL && !n->is_top()) { // Input is valid?
  1215         if (n != NULL && !n->is_top()) { // Input is valid?
  1217           progress = true;
       
  1218           dead->set_req(i, top);    // Smash input away
  1216           dead->set_req(i, top);    // Smash input away
  1219           if (n->outcnt() == 0) {   // Input also goes dead?
  1217           if (n->outcnt() == 0) {   // Input also goes dead?
  1220             if (!n->is_Con())
  1218             if (!n->is_Con())
  1221               nstack.push(n);       // Clear it out as well
  1219               nstack.push(n);       // Clear it out as well
  1222           } else if (n->outcnt() == 1 &&
  1220           } else if (n->outcnt() == 1 &&
  1231           }
  1229           }
  1232         }
  1230         }
  1233       }
  1231       }
  1234     } // (dead->outcnt() == 0)
  1232     } // (dead->outcnt() == 0)
  1235   }   // while (nstack.size() > 0) for outputs
  1233   }   // while (nstack.size() > 0) for outputs
  1236   return progress;
  1234   return;
  1237 }
  1235 }
  1238 
  1236 
  1239 //------------------------------remove_dead_region-----------------------------
  1237 //------------------------------remove_dead_region-----------------------------
  1240 bool Node::remove_dead_region(PhaseGVN *phase, bool can_reshape) {
  1238 bool Node::remove_dead_region(PhaseGVN *phase, bool can_reshape) {
  1241   Node *n = in(0);
  1239   Node *n = in(0);
  1242   if( !n ) return false;
  1240   if( !n ) return false;
  1243   // Lost control into this guy?  I.e., it became unreachable?
  1241   // Lost control into this guy?  I.e., it became unreachable?
  1244   // Aggressively kill all unreachable code.
  1242   // Aggressively kill all unreachable code.
  1245   if (can_reshape && n->is_top()) {
  1243   if (can_reshape && n->is_top()) {
  1246     return kill_dead_code(this, phase->is_IterGVN());
  1244     kill_dead_code(this, phase->is_IterGVN());
       
  1245     return false; // Node is dead.
  1247   }
  1246   }
  1248 
  1247 
  1249   if( n->is_Region() && n->as_Region()->is_copy() ) {
  1248   if( n->is_Region() && n->as_Region()->is_copy() ) {
  1250     Node *m = n->nonnull_req();
  1249     Node *m = n->nonnull_req();
  1251     set_req(0, m);
  1250     set_req(0, m);