src/share/vm/opto/node.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File 8039298 Sdiff src/share/vm/opto

src/share/vm/opto/node.cpp

Print this page




  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "libadt/vectset.hpp"
  27 #include "memory/allocation.inline.hpp"
  28 #include "opto/cfgnode.hpp"
  29 #include "opto/connode.hpp"

  30 #include "opto/machnode.hpp"
  31 #include "opto/matcher.hpp"
  32 #include "opto/node.hpp"
  33 #include "opto/opcodes.hpp"
  34 #include "opto/regmask.hpp"
  35 #include "opto/type.hpp"
  36 #include "utilities/copy.hpp"
  37 
  38 class RegMask;
  39 // #include "phase.hpp"
  40 class PhaseTransform;
  41 class PhaseGVN;
  42 
  43 // Arena we are currently building Nodes in
  44 const uint Node::NotAMachineReg = 0xffff0000;
  45 
  46 #ifndef PRODUCT
  47 extern int nodes_created;
  48 #endif
  49 


1246   // Did not meet Root or Start node in pred. chain.
1247   // Conservative answer for dead code.
1248   return false;
1249 }
1250 
1251 //------------------------------remove_dead_region-----------------------------
1252 // This control node is dead.  Follow the subgraph below it making everything
1253 // using it dead as well.  This will happen normally via the usual IterGVN
1254 // worklist but this call is more efficient.  Do not update use-def info
1255 // inside the dead region, just at the borders.
1256 static void kill_dead_code( Node *dead, PhaseIterGVN *igvn ) {
1257   // Con's are a popular node to re-hit in the hash table again.
1258   if( dead->is_Con() ) return;
1259 
1260   // Can't put ResourceMark here since igvn->_worklist uses the same arena
1261   // for verify pass with +VerifyOpto and we add/remove elements in it here.
1262   Node_List  nstack(Thread::current()->resource_area());
1263 
1264   Node *top = igvn->C->top();
1265   nstack.push(dead);

1266 
1267   while (nstack.size() > 0) {
1268     dead = nstack.pop();
1269     if (dead->outcnt() > 0) {
1270       // Keep dead node on stack until all uses are processed.
1271       nstack.push(dead);
1272       // For all Users of the Dead...    ;-)
1273       for (DUIterator_Last kmin, k = dead->last_outs(kmin); k >= kmin; ) {
1274         Node* use = dead->last_out(k);
1275         igvn->hash_delete(use);       // Yank from hash table prior to mod
1276         if (use->in(0) == dead) {     // Found another dead node
1277           assert (!use->is_Con(), "Control for Con node should be Root node.");
1278           use->set_req(0, top);       // Cut dead edge to prevent processing
1279           nstack.push(use);           // the dead node again.






1280         } else {                      // Else found a not-dead user


1281           for (uint j = 1; j < use->req(); j++) {
1282             if (use->in(j) == dead) { // Turn all dead inputs into TOP

1283               use->set_req(j, top);


1284             }
1285           }






1286           igvn->_worklist.push(use);
1287         }

1288         // Refresh the iterator, since any number of kills might have happened.
1289         k = dead->last_outs(kmin);
1290       }
1291     } else { // (dead->outcnt() == 0)
1292       // Done with outputs.
1293       igvn->hash_delete(dead);
1294       igvn->_worklist.remove(dead);
1295       igvn->set_type(dead, Type::TOP);
1296       if (dead->is_macro()) {
1297         igvn->C->remove_macro_node(dead);
1298       }
1299       if (dead->is_expensive()) {
1300         igvn->C->remove_expensive_node(dead);
1301       }
1302       igvn->C->record_dead_node(dead->_idx);
1303       // Kill all inputs to the dead guy
1304       for (uint i=0; i < dead->req(); i++) {
1305         Node *n = dead->in(i);      // Get input to dead guy
1306         if (n != NULL && !n->is_top()) { // Input is valid?
1307           dead->set_req(i, top);    // Smash input away




  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "libadt/vectset.hpp"
  27 #include "memory/allocation.inline.hpp"
  28 #include "opto/cfgnode.hpp"
  29 #include "opto/connode.hpp"
  30 #include "opto/loopnode.hpp"
  31 #include "opto/machnode.hpp"
  32 #include "opto/matcher.hpp"
  33 #include "opto/node.hpp"
  34 #include "opto/opcodes.hpp"
  35 #include "opto/regmask.hpp"
  36 #include "opto/type.hpp"
  37 #include "utilities/copy.hpp"
  38 
  39 class RegMask;
  40 // #include "phase.hpp"
  41 class PhaseTransform;
  42 class PhaseGVN;
  43 
  44 // Arena we are currently building Nodes in
  45 const uint Node::NotAMachineReg = 0xffff0000;
  46 
  47 #ifndef PRODUCT
  48 extern int nodes_created;
  49 #endif
  50 


1247   // Did not meet Root or Start node in pred. chain.
1248   // Conservative answer for dead code.
1249   return false;
1250 }
1251 
1252 //------------------------------remove_dead_region-----------------------------
1253 // This control node is dead.  Follow the subgraph below it making everything
1254 // using it dead as well.  This will happen normally via the usual IterGVN
1255 // worklist but this call is more efficient.  Do not update use-def info
1256 // inside the dead region, just at the borders.
1257 static void kill_dead_code( Node *dead, PhaseIterGVN *igvn ) {
1258   // Con's are a popular node to re-hit in the hash table again.
1259   if( dead->is_Con() ) return;
1260 
1261   // Can't put ResourceMark here since igvn->_worklist uses the same arena
1262   // for verify pass with +VerifyOpto and we add/remove elements in it here.
1263   Node_List  nstack(Thread::current()->resource_area());
1264 
1265   Node *top = igvn->C->top();
1266   nstack.push(dead);
1267   bool has_irreducible_loop = igvn->C->has_irreducible_loop();
1268 
1269   while (nstack.size() > 0) {
1270     dead = nstack.pop();
1271     if (dead->outcnt() > 0) {
1272       // Keep dead node on stack until all uses are processed.
1273       nstack.push(dead);
1274       // For all Users of the Dead...    ;-)
1275       for (DUIterator_Last kmin, k = dead->last_outs(kmin); k >= kmin; ) {
1276         Node* use = dead->last_out(k);
1277         igvn->hash_delete(use);       // Yank from hash table prior to mod
1278         if (use->in(0) == dead) {     // Found another dead node
1279           assert (!use->is_Con(), "Control for Con node should be Root node.");
1280           use->set_req(0, top);       // Cut dead edge to prevent processing
1281           nstack.push(use);           // the dead node again.
1282         } else if (!has_irreducible_loop && // Backedge could be alive in irreducible loop
1283                    use->is_Loop() && !use->is_Root() &&       // Root is also Loop
1284                    use->in(LoopNode::EntryControl) == dead) { // Dead loop if its entry is dead
1285           use->set_req(LoopNode::EntryControl, top);          // Cut dead edge to prevent processing
1286           use->set_req(0, top);       // Cut self edge
1287           nstack.push(use);
1288         } else {                      // Else found a not-dead user
1289           // Dead if all inputs are top or null
1290           bool dead_use = !use->is_Root(); // Keep empty graph alive
1291           for (uint j = 1; j < use->req(); j++) {
1292             Node* in = use->in(j);
1293             if (in == dead) {         // Turn all dead inputs into TOP
1294               use->set_req(j, top);
1295             } else if (in != NULL && !in->is_top()) {
1296               dead_use = false;
1297             }
1298           }
1299           if (dead_use) {
1300             if (use->is_Region()) {
1301               use->set_req(0, top);   // Cut self edge
1302             }
1303             nstack.push(use);
1304           } else {
1305             igvn->_worklist.push(use);
1306           }
1307         }
1308         // Refresh the iterator, since any number of kills might have happened.
1309         k = dead->last_outs(kmin);
1310       }
1311     } else { // (dead->outcnt() == 0)
1312       // Done with outputs.
1313       igvn->hash_delete(dead);
1314       igvn->_worklist.remove(dead);
1315       igvn->set_type(dead, Type::TOP);
1316       if (dead->is_macro()) {
1317         igvn->C->remove_macro_node(dead);
1318       }
1319       if (dead->is_expensive()) {
1320         igvn->C->remove_expensive_node(dead);
1321       }
1322       igvn->C->record_dead_node(dead->_idx);
1323       // Kill all inputs to the dead guy
1324       for (uint i=0; i < dead->req(); i++) {
1325         Node *n = dead->in(i);      // Get input to dead guy
1326         if (n != NULL && !n->is_top()) { // Input is valid?
1327           dead->set_req(i, top);    // Smash input away


src/share/vm/opto/node.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File