< prev index next >

src/hotspot/share/opto/phaseX.cpp

Print this page




 754   if (l >= _lcon_min && l <= _lcon_max)
 755     _lcons[l-_lcon_min] = lcon;      // Cache small integers
 756   return lcon;
 757 }
 758 
 759 //------------------------------zerocon-----------------------------------------
 760 // Fast zero or null constant. Same as "transform(ConNode::make(Type::get_zero_type(bt)))"
 761 ConNode* PhaseTransform::zerocon(BasicType bt) {
 762   assert((uint)bt <= _zcon_max, "domain check");
 763   ConNode* zcon = _zcons[bt];
 764   if (zcon != NULL && zcon->in(TypeFunc::Control) != NULL)
 765     return zcon;
 766   zcon = (ConNode*) uncached_makecon(Type::get_zero_type(bt));
 767   _zcons[bt] = zcon;
 768   return zcon;
 769 }
 770 
 771 
 772 
 773 //=============================================================================

















 774 //------------------------------transform--------------------------------------
 775 // Return a node which computes the same function as this node, but in a
 776 // faster or cheaper fashion.
 777 Node *PhaseGVN::transform( Node *n ) {
 778   return transform_no_reclaim(n);
 779 }
 780 
 781 //------------------------------transform--------------------------------------
 782 // Return a node which computes the same function as this node, but
 783 // in a faster or cheaper fashion.
 784 Node *PhaseGVN::transform_no_reclaim( Node *n ) {
 785   NOT_PRODUCT( set_transforms(); )
 786 
 787   // Apply the Ideal call in a loop until it no longer applies
 788   Node *k = n;
 789   NOT_PRODUCT( uint loop_count = 0; )
 790   while( 1 ) {
 791     Node *i = k->Ideal(this, /*can_reshape=*/false);
 792     if( !i ) break;
 793     assert( i->_idx >= k->_idx, "Idealize should return new nodes, use Identity to return old nodes" );
 794     k = i;
 795     assert(loop_count++ < K, "infinite loop in PhaseGVN::transform");
 796   }
 797   NOT_PRODUCT( if( loop_count != 0 ) { set_progress(); } )
 798 
 799 
 800   // If brand new node, make space in type array.
 801   ensure_type_or_null(k);
 802 
 803   // Since I just called 'Value' to compute the set of run-time values
 804   // for this Node, and 'Value' is non-local (and therefore expensive) I'll
 805   // cache Value.  Later requests for the local phase->type of this Node can
 806   // use the cached Value instead of suffering with 'bottom_type'.
 807   const Type *t = k->Value(this); // Get runtime Value set
 808   assert(t != NULL, "value sanity");
 809   if (type_or_null(k) != t) {
 810 #ifndef PRODUCT
 811     // Do not count initial visit to node as a transformation
 812     if (type_or_null(k) == NULL) {
 813       inc_new_values();
 814       set_progress();
 815     }
 816 #endif
 817     set_type(k, t);
 818     // If k is a TypeNode, capture any more-precise type permanently into Node
 819     k->raise_bottom_type(t);
 820   }
 821 
 822   if( t->singleton() && !k->is_Con() ) {
 823     NOT_PRODUCT( set_progress(); )
 824     return makecon(t);          // Turn into a constant
 825   }
 826 
 827   // Now check for Identities
 828   Node *i = k->Identity(this);  // Look for a nearby replacement
 829   if( i != k ) {                // Found? Return replacement!
 830     NOT_PRODUCT( set_progress(); )
 831     return i;
 832   }
 833 
 834   // Global Value Numbering
 835   i = hash_find_insert(k);      // Insert if new
 836   if( i && (i != k) ) {
 837     // Return the pre-existing node
 838     NOT_PRODUCT( set_progress(); )
 839     return i;
 840   }
 841 
 842   // Return Idealized original
 843   return k;
 844 }
 845 
 846 bool PhaseGVN::is_dominator_helper(Node *d, Node *n, bool linear_only) {
 847   if (d->is_top() || n->is_top()) {
 848     return false;


1197   }
1198 
1199   return transform_old(n);
1200 }
1201 
1202 Node *PhaseIterGVN::transform_old(Node* n) {
1203   DEBUG_ONLY(uint loop_count = 0;);
1204   NOT_PRODUCT(set_transforms());
1205 
1206   // Remove 'n' from hash table in case it gets modified
1207   _table.hash_delete(n);
1208   if (VerifyIterativeGVN) {
1209    assert(!_table.find_index(n->_idx), "found duplicate entry in table");
1210   }
1211 
1212   // Apply the Ideal call in a loop until it no longer applies
1213   Node* k = n;
1214   DEBUG_ONLY(dead_loop_check(k);)
1215   DEBUG_ONLY(bool is_new = (k->outcnt() == 0);)
1216   C->remove_modified_node(k);
1217   Node* i = k->Ideal(this, /*can_reshape=*/true);
1218   assert(i != k || is_new || i->outcnt() > 0, "don't return dead nodes");
1219 #ifndef PRODUCT
1220   verify_step(k);
1221   if (i && VerifyOpto ) {
1222     if (!allow_progress()) {
1223       if (i->is_Add() && (i->outcnt() == 1)) {
1224         // Switched input to left side because this is the only use
1225       } else if (i->is_If() && (i->in(0) == NULL)) {
1226         // This IF is dead because it is dominated by an equivalent IF When
1227         // dominating if changed, info is not propagated sparsely to 'this'
1228         // Propagating this info further will spuriously identify other
1229         // progress.
1230         return i;
1231       } else
1232         set_progress();
1233     } else {
1234       set_progress();
1235     }
1236   }
1237 #endif


1239   while (i != NULL) {
1240 #ifdef ASSERT
1241     if (loop_count >= K) {
1242       dump_infinite_loop_info(i);
1243     }
1244     loop_count++;
1245 #endif
1246     assert((i->_idx >= k->_idx) || i->is_top(), "Idealize should return new nodes, use Identity to return old nodes");
1247     // Made a change; put users of original Node on worklist
1248     add_users_to_worklist(k);
1249     // Replacing root of transform tree?
1250     if (k != i) {
1251       // Make users of old Node now use new.
1252       subsume_node(k, i);
1253       k = i;
1254     }
1255     DEBUG_ONLY(dead_loop_check(k);)
1256     // Try idealizing again
1257     DEBUG_ONLY(is_new = (k->outcnt() == 0);)
1258     C->remove_modified_node(k);
1259     i = k->Ideal(this, /*can_reshape=*/true);
1260     assert(i != k || is_new || (i->outcnt() > 0), "don't return dead nodes");
1261 #ifndef PRODUCT
1262     verify_step(k);
1263     if (i && VerifyOpto) {
1264       set_progress();
1265     }
1266 #endif
1267   }
1268 
1269   // If brand new node, make space in type array.
1270   ensure_type_or_null(k);
1271 
1272   // See what kind of values 'k' takes on at runtime
1273   const Type* t = k->Value(this);
1274   assert(t != NULL, "value sanity");
1275 
1276   // Since I just called 'Value' to compute the set of run-time values
1277   // for this Node, and 'Value' is non-local (and therefore expensive) I'll
1278   // cache Value.  Later requests for the local phase->type of this Node can
1279   // use the cached Value instead of suffering with 'bottom_type'.


1281 #ifndef PRODUCT
1282     inc_new_values();
1283     set_progress();
1284 #endif
1285     set_type(k, t);
1286     // If k is a TypeNode, capture any more-precise type permanently into Node
1287     k->raise_bottom_type(t);
1288     // Move users of node to worklist
1289     add_users_to_worklist(k);
1290   }
1291   // If 'k' computes a constant, replace it with a constant
1292   if (t->singleton() && !k->is_Con()) {
1293     NOT_PRODUCT(set_progress();)
1294     Node* con = makecon(t);     // Make a constant
1295     add_users_to_worklist(k);
1296     subsume_node(k, con);       // Everybody using k now uses con
1297     return con;
1298   }
1299 
1300   // Now check for Identities
1301   i = k->Identity(this);      // Look for a nearby replacement
1302   if (i != k) {                // Found? Return replacement!
1303     NOT_PRODUCT(set_progress();)
1304     add_users_to_worklist(k);
1305     subsume_node(k, i);       // Everybody using k now uses i
1306     return i;
1307   }
1308 
1309   // Global Value Numbering
1310   i = hash_find_insert(k);      // Check for pre-existing node
1311   if (i && (i != k)) {
1312     // Return the pre-existing node if it isn't dead
1313     NOT_PRODUCT(set_progress();)
1314     add_users_to_worklist(k);
1315     subsume_node(k, i);       // Everybody using k now uses i
1316     return i;
1317   }
1318 
1319   // Return Idealized original
1320   return k;
1321 }


1359             if (in->outcnt() == 0) { // Made input go dead?
1360               _stack.push(in, PROCESS_INPUTS); // Recursively remove
1361               recurse = true;
1362             } else if (in->outcnt() == 1 &&
1363                        in->has_special_unique_user()) {
1364               _worklist.push(in->unique_out());
1365             } else if (in->outcnt() <= 2 && dead->is_Phi()) {
1366               if (in->Opcode() == Op_Region) {
1367                 _worklist.push(in);
1368               } else if (in->is_Store()) {
1369                 DUIterator_Fast imax, i = in->fast_outs(imax);
1370                 _worklist.push(in->fast_out(i));
1371                 i++;
1372                 if (in->outcnt() == 2) {
1373                   _worklist.push(in->fast_out(i));
1374                   i++;
1375                 }
1376                 assert(!(i < imax), "sanity");
1377               }
1378             } else {
1379               BarrierSet::barrier_set()->barrier_set_c2()->enqueue_useful_gc_barrier(_worklist, in);
1380             }
1381             if (ReduceFieldZeroing && dead->is_Load() && i == MemNode::Memory &&
1382                 in->is_Proj() && in->in(0) != NULL && in->in(0)->is_Initialize()) {
1383               // A Load that directly follows an InitializeNode is
1384               // going away. The Stores that follow are candidates
1385               // again to be captured by the InitializeNode.
1386               for (DUIterator_Fast jmax, j = in->fast_outs(jmax); j < jmax; j++) {
1387                 Node *n = in->fast_out(j);
1388                 if (n->is_Store()) {
1389                   _worklist.push(n);
1390                 }
1391               }
1392             }
1393           } // if (in != NULL && in != C->top())
1394         } // for (uint i = 0; i < dead->req(); i++)
1395         if (recurse) {
1396           continue;
1397         }
1398       } // if (!dead->is_Con())
1399     } // if (progress_state == PROCESS_INPUTS)


1635       }
1636     }
1637     if (use_op == Op_Initialize) {
1638       Node* imem = use->as_Initialize()->proj_out_or_null(TypeFunc::Memory);
1639       if (imem != NULL)  add_users_to_worklist0(imem);
1640     }
1641     // Loading the java mirror from a Klass requires two loads and the type
1642     // of the mirror load depends on the type of 'n'. See LoadNode::Value().
1643     // If the code pattern requires a barrier for
1644     //   mirror = ((OopHandle)mirror)->resolve();
1645     // this won't match.
1646     if (use_op == Op_LoadP && use->bottom_type()->isa_rawptr()) {
1647       for (DUIterator_Fast i2max, i2 = use->fast_outs(i2max); i2 < i2max; i2++) {
1648         Node* u = use->fast_out(i2);
1649         const Type* ut = u->bottom_type();
1650         if (u->Opcode() == Op_LoadP && ut->isa_instptr()) {
1651           _worklist.push(u);
1652         }
1653       }
1654     }







1655   }
1656 }
1657 
1658 /**
1659  * Remove the speculative part of all types that we know of
1660  */
1661 void PhaseIterGVN::remove_speculative_types()  {
1662   assert(UseTypeSpeculation, "speculation is off");
1663   for (uint i = 0; i < _types.Size(); i++)  {
1664     const Type* t = _types.fast_lookup(i);
1665     if (t != NULL) {
1666       _types.map(i, t->remove_speculative());
1667     }
1668   }
1669   _table.check_no_speculative_types();
1670 }
1671 
1672 //=============================================================================
1673 #ifndef PRODUCT
1674 uint PhaseCCP::_total_invokes   = 0;


1784         if (m_op == Op_CmpI) {
1785           PhiNode* phi = countedloop_phi_from_cmp((CmpINode*)m, n);
1786           if (phi != NULL) {
1787             worklist.push(phi);
1788           }
1789         }
1790         // Loading the java mirror from a Klass requires two loads and the type
1791         // of the mirror load depends on the type of 'n'. See LoadNode::Value().
1792         // If the code pattern requires a barrier for
1793         //   mirror = ((OopHandle)mirror)->resolve();
1794         // this won't match.
1795         if (m_op == Op_LoadP && m->bottom_type()->isa_rawptr()) {
1796           for (DUIterator_Fast i2max, i2 = m->fast_outs(i2max); i2 < i2max; i2++) {
1797             Node* u = m->fast_out(i2);
1798             const Type* ut = u->bottom_type();
1799             if (u->Opcode() == Op_LoadP && ut->isa_instptr() && ut != type(u)) {
1800               worklist.push(u);
1801             }
1802           }
1803         }



















1804       }
1805     }
1806   }
1807 }
1808 
1809 //------------------------------do_transform-----------------------------------
1810 // Top level driver for the recursive transformer
1811 void PhaseCCP::do_transform() {
1812   // Correct leaves of new-space Nodes; they point to old-space.
1813   C->set_root( transform(C->root())->as_Root() );
1814   assert( C->top(),  "missing TOP node" );
1815   assert( C->root(), "missing root" );
1816 }
1817 
1818 //------------------------------transform--------------------------------------
1819 // Given a Node in old-space, clone him into new-space.
1820 // Convert any of his old-space children into new-space children.
1821 Node *PhaseCCP::transform( Node *n ) {
1822   Node *new_node = _nodes[n->_idx]; // Check for transformed node
1823   if( new_node != NULL )


2043         igvn->_worklist.push( old );
2044       break;
2045     case 1:
2046       if( old->is_Store() || old->has_special_unique_user() )
2047         igvn->add_users_to_worklist( old );
2048       break;
2049     case 2:
2050       if( old->is_Store() )
2051         igvn->add_users_to_worklist( old );
2052       if( old->Opcode() == Op_Region )
2053         igvn->_worklist.push(old);
2054       break;
2055     case 3:
2056       if( old->Opcode() == Op_Region ) {
2057         igvn->_worklist.push(old);
2058         igvn->add_users_to_worklist( old );
2059       }
2060       break;
2061     default:
2062       break;




2063     }
2064   }
2065 
2066 }
2067 
2068 //-------------------------------replace_by-----------------------------------
2069 // Using def-use info, replace one node for another.  Follow the def-use info
2070 // to all users of the OLD node.  Then make all uses point to the NEW node.
2071 void Node::replace_by(Node *new_node) {
2072   assert(!is_top(), "top node has no DU info");
2073   for (DUIterator_Last imin, i = last_outs(imin); i >= imin; ) {
2074     Node* use = last_out(i);
2075     uint uses_found = 0;
2076     for (uint j = 0; j < use->len(); j++) {
2077       if (use->in(j) == this) {
2078         if (j < use->req())
2079               use->set_req(j, new_node);
2080         else  use->set_prec(j, new_node);
2081         uses_found++;
2082       }




 754   if (l >= _lcon_min && l <= _lcon_max)
 755     _lcons[l-_lcon_min] = lcon;      // Cache small integers
 756   return lcon;
 757 }
 758 
 759 //------------------------------zerocon-----------------------------------------
 760 // Fast zero or null constant. Same as "transform(ConNode::make(Type::get_zero_type(bt)))"
 761 ConNode* PhaseTransform::zerocon(BasicType bt) {
 762   assert((uint)bt <= _zcon_max, "domain check");
 763   ConNode* zcon = _zcons[bt];
 764   if (zcon != NULL && zcon->in(TypeFunc::Control) != NULL)
 765     return zcon;
 766   zcon = (ConNode*) uncached_makecon(Type::get_zero_type(bt));
 767   _zcons[bt] = zcon;
 768   return zcon;
 769 }
 770 
 771 
 772 
 773 //=============================================================================
 774 Node* PhaseGVN::apply_ideal(Node* k, bool can_reshape) {
 775   Node* i = BarrierSet::barrier_set()->barrier_set_c2()->ideal_node(this, k, can_reshape);
 776   if (i == NULL) {
 777     i = k->Ideal(this, can_reshape);
 778   }
 779   return i;
 780 }
 781 
 782 Node* PhaseGVN::apply_identity(Node* k) {
 783   Node* i = BarrierSet::barrier_set()->barrier_set_c2()->identity_node(this, k);
 784   if (i == k) {
 785     i = k->Identity(this);
 786   }
 787   return i;
 788 }
 789 
 790 //=============================================================================
 791 //------------------------------transform--------------------------------------
 792 // Return a node which computes the same function as this node, but in a
 793 // faster or cheaper fashion.
 794 Node *PhaseGVN::transform( Node *n ) {
 795   return transform_no_reclaim(n);
 796 }
 797 
 798 //------------------------------transform--------------------------------------
 799 // Return a node which computes the same function as this node, but
 800 // in a faster or cheaper fashion.
 801 Node *PhaseGVN::transform_no_reclaim( Node *n ) {
 802   NOT_PRODUCT( set_transforms(); )
 803 
 804   // Apply the Ideal call in a loop until it no longer applies
 805   Node *k = n;
 806   NOT_PRODUCT( uint loop_count = 0; )
 807   while( 1 ) {
 808     Node *i = apply_ideal(k, /*can_reshape=*/false);
 809     if( !i ) break;
 810     assert( i->_idx >= k->_idx, "Idealize should return new nodes, use Identity to return old nodes" );
 811     k = i;
 812     assert(loop_count++ < K, "infinite loop in PhaseGVN::transform");
 813   }
 814   NOT_PRODUCT( if( loop_count != 0 ) { set_progress(); } )
 815 
 816 
 817   // If brand new node, make space in type array.
 818   ensure_type_or_null(k);
 819 
 820   // Since I just called 'Value' to compute the set of run-time values
 821   // for this Node, and 'Value' is non-local (and therefore expensive) I'll
 822   // cache Value.  Later requests for the local phase->type of this Node can
 823   // use the cached Value instead of suffering with 'bottom_type'.
 824   const Type *t = k->Value(this); // Get runtime Value set
 825   assert(t != NULL, "value sanity");
 826   if (type_or_null(k) != t) {
 827 #ifndef PRODUCT
 828     // Do not count initial visit to node as a transformation
 829     if (type_or_null(k) == NULL) {
 830       inc_new_values();
 831       set_progress();
 832     }
 833 #endif
 834     set_type(k, t);
 835     // If k is a TypeNode, capture any more-precise type permanently into Node
 836     k->raise_bottom_type(t);
 837   }
 838 
 839   if( t->singleton() && !k->is_Con() ) {
 840     NOT_PRODUCT( set_progress(); )
 841     return makecon(t);          // Turn into a constant
 842   }
 843 
 844   // Now check for Identities
 845   Node *i = apply_identity(k);  // Look for a nearby replacement
 846   if( i != k ) {                // Found? Return replacement!
 847     NOT_PRODUCT( set_progress(); )
 848     return i;
 849   }
 850 
 851   // Global Value Numbering
 852   i = hash_find_insert(k);      // Insert if new
 853   if( i && (i != k) ) {
 854     // Return the pre-existing node
 855     NOT_PRODUCT( set_progress(); )
 856     return i;
 857   }
 858 
 859   // Return Idealized original
 860   return k;
 861 }
 862 
 863 bool PhaseGVN::is_dominator_helper(Node *d, Node *n, bool linear_only) {
 864   if (d->is_top() || n->is_top()) {
 865     return false;


1214   }
1215 
1216   return transform_old(n);
1217 }
1218 
1219 Node *PhaseIterGVN::transform_old(Node* n) {
1220   DEBUG_ONLY(uint loop_count = 0;);
1221   NOT_PRODUCT(set_transforms());
1222 
1223   // Remove 'n' from hash table in case it gets modified
1224   _table.hash_delete(n);
1225   if (VerifyIterativeGVN) {
1226    assert(!_table.find_index(n->_idx), "found duplicate entry in table");
1227   }
1228 
1229   // Apply the Ideal call in a loop until it no longer applies
1230   Node* k = n;
1231   DEBUG_ONLY(dead_loop_check(k);)
1232   DEBUG_ONLY(bool is_new = (k->outcnt() == 0);)
1233   C->remove_modified_node(k);
1234   Node* i = apply_ideal(k, /*can_reshape=*/true);
1235   assert(i != k || is_new || i->outcnt() > 0, "don't return dead nodes");
1236 #ifndef PRODUCT
1237   verify_step(k);
1238   if (i && VerifyOpto ) {
1239     if (!allow_progress()) {
1240       if (i->is_Add() && (i->outcnt() == 1)) {
1241         // Switched input to left side because this is the only use
1242       } else if (i->is_If() && (i->in(0) == NULL)) {
1243         // This IF is dead because it is dominated by an equivalent IF When
1244         // dominating if changed, info is not propagated sparsely to 'this'
1245         // Propagating this info further will spuriously identify other
1246         // progress.
1247         return i;
1248       } else
1249         set_progress();
1250     } else {
1251       set_progress();
1252     }
1253   }
1254 #endif


1256   while (i != NULL) {
1257 #ifdef ASSERT
1258     if (loop_count >= K) {
1259       dump_infinite_loop_info(i);
1260     }
1261     loop_count++;
1262 #endif
1263     assert((i->_idx >= k->_idx) || i->is_top(), "Idealize should return new nodes, use Identity to return old nodes");
1264     // Made a change; put users of original Node on worklist
1265     add_users_to_worklist(k);
1266     // Replacing root of transform tree?
1267     if (k != i) {
1268       // Make users of old Node now use new.
1269       subsume_node(k, i);
1270       k = i;
1271     }
1272     DEBUG_ONLY(dead_loop_check(k);)
1273     // Try idealizing again
1274     DEBUG_ONLY(is_new = (k->outcnt() == 0);)
1275     C->remove_modified_node(k);
1276     i = apply_ideal(k, /*can_reshape=*/true);
1277     assert(i != k || is_new || (i->outcnt() > 0), "don't return dead nodes");
1278 #ifndef PRODUCT
1279     verify_step(k);
1280     if (i && VerifyOpto) {
1281       set_progress();
1282     }
1283 #endif
1284   }
1285 
1286   // If brand new node, make space in type array.
1287   ensure_type_or_null(k);
1288 
1289   // See what kind of values 'k' takes on at runtime
1290   const Type* t = k->Value(this);
1291   assert(t != NULL, "value sanity");
1292 
1293   // Since I just called 'Value' to compute the set of run-time values
1294   // for this Node, and 'Value' is non-local (and therefore expensive) I'll
1295   // cache Value.  Later requests for the local phase->type of this Node can
1296   // use the cached Value instead of suffering with 'bottom_type'.


1298 #ifndef PRODUCT
1299     inc_new_values();
1300     set_progress();
1301 #endif
1302     set_type(k, t);
1303     // If k is a TypeNode, capture any more-precise type permanently into Node
1304     k->raise_bottom_type(t);
1305     // Move users of node to worklist
1306     add_users_to_worklist(k);
1307   }
1308   // If 'k' computes a constant, replace it with a constant
1309   if (t->singleton() && !k->is_Con()) {
1310     NOT_PRODUCT(set_progress();)
1311     Node* con = makecon(t);     // Make a constant
1312     add_users_to_worklist(k);
1313     subsume_node(k, con);       // Everybody using k now uses con
1314     return con;
1315   }
1316 
1317   // Now check for Identities
1318   i = apply_identity(k);      // Look for a nearby replacement
1319   if (i != k) {                // Found? Return replacement!
1320     NOT_PRODUCT(set_progress();)
1321     add_users_to_worklist(k);
1322     subsume_node(k, i);       // Everybody using k now uses i
1323     return i;
1324   }
1325 
1326   // Global Value Numbering
1327   i = hash_find_insert(k);      // Check for pre-existing node
1328   if (i && (i != k)) {
1329     // Return the pre-existing node if it isn't dead
1330     NOT_PRODUCT(set_progress();)
1331     add_users_to_worklist(k);
1332     subsume_node(k, i);       // Everybody using k now uses i
1333     return i;
1334   }
1335 
1336   // Return Idealized original
1337   return k;
1338 }


1376             if (in->outcnt() == 0) { // Made input go dead?
1377               _stack.push(in, PROCESS_INPUTS); // Recursively remove
1378               recurse = true;
1379             } else if (in->outcnt() == 1 &&
1380                        in->has_special_unique_user()) {
1381               _worklist.push(in->unique_out());
1382             } else if (in->outcnt() <= 2 && dead->is_Phi()) {
1383               if (in->Opcode() == Op_Region) {
1384                 _worklist.push(in);
1385               } else if (in->is_Store()) {
1386                 DUIterator_Fast imax, i = in->fast_outs(imax);
1387                 _worklist.push(in->fast_out(i));
1388                 i++;
1389                 if (in->outcnt() == 2) {
1390                   _worklist.push(in->fast_out(i));
1391                   i++;
1392                 }
1393                 assert(!(i < imax), "sanity");
1394               }
1395             } else {
1396               BarrierSet::barrier_set()->barrier_set_c2()->enqueue_useful_gc_barrier(this, in);
1397             }
1398             if (ReduceFieldZeroing && dead->is_Load() && i == MemNode::Memory &&
1399                 in->is_Proj() && in->in(0) != NULL && in->in(0)->is_Initialize()) {
1400               // A Load that directly follows an InitializeNode is
1401               // going away. The Stores that follow are candidates
1402               // again to be captured by the InitializeNode.
1403               for (DUIterator_Fast jmax, j = in->fast_outs(jmax); j < jmax; j++) {
1404                 Node *n = in->fast_out(j);
1405                 if (n->is_Store()) {
1406                   _worklist.push(n);
1407                 }
1408               }
1409             }
1410           } // if (in != NULL && in != C->top())
1411         } // for (uint i = 0; i < dead->req(); i++)
1412         if (recurse) {
1413           continue;
1414         }
1415       } // if (!dead->is_Con())
1416     } // if (progress_state == PROCESS_INPUTS)


1652       }
1653     }
1654     if (use_op == Op_Initialize) {
1655       Node* imem = use->as_Initialize()->proj_out_or_null(TypeFunc::Memory);
1656       if (imem != NULL)  add_users_to_worklist0(imem);
1657     }
1658     // Loading the java mirror from a Klass requires two loads and the type
1659     // of the mirror load depends on the type of 'n'. See LoadNode::Value().
1660     // If the code pattern requires a barrier for
1661     //   mirror = ((OopHandle)mirror)->resolve();
1662     // this won't match.
1663     if (use_op == Op_LoadP && use->bottom_type()->isa_rawptr()) {
1664       for (DUIterator_Fast i2max, i2 = use->fast_outs(i2max); i2 < i2max; i2++) {
1665         Node* u = use->fast_out(i2);
1666         const Type* ut = u->bottom_type();
1667         if (u->Opcode() == Op_LoadP && ut->isa_instptr()) {
1668           _worklist.push(u);
1669         }
1670       }
1671     }
1672 
1673     if (use->is_ShenandoahBarrier()) {
1674       Node* cmp = use->find_out_with(Op_CmpP);
1675       if (cmp != NULL) {
1676         _worklist.push(cmp);
1677       }
1678     }
1679   }
1680 }
1681 
1682 /**
1683  * Remove the speculative part of all types that we know of
1684  */
1685 void PhaseIterGVN::remove_speculative_types()  {
1686   assert(UseTypeSpeculation, "speculation is off");
1687   for (uint i = 0; i < _types.Size(); i++)  {
1688     const Type* t = _types.fast_lookup(i);
1689     if (t != NULL) {
1690       _types.map(i, t->remove_speculative());
1691     }
1692   }
1693   _table.check_no_speculative_types();
1694 }
1695 
1696 //=============================================================================
1697 #ifndef PRODUCT
1698 uint PhaseCCP::_total_invokes   = 0;


1808         if (m_op == Op_CmpI) {
1809           PhiNode* phi = countedloop_phi_from_cmp((CmpINode*)m, n);
1810           if (phi != NULL) {
1811             worklist.push(phi);
1812           }
1813         }
1814         // Loading the java mirror from a Klass requires two loads and the type
1815         // of the mirror load depends on the type of 'n'. See LoadNode::Value().
1816         // If the code pattern requires a barrier for
1817         //   mirror = ((OopHandle)mirror)->resolve();
1818         // this won't match.
1819         if (m_op == Op_LoadP && m->bottom_type()->isa_rawptr()) {
1820           for (DUIterator_Fast i2max, i2 = m->fast_outs(i2max); i2 < i2max; i2++) {
1821             Node* u = m->fast_out(i2);
1822             const Type* ut = u->bottom_type();
1823             if (u->Opcode() == Op_LoadP && ut->isa_instptr() && ut != type(u)) {
1824               worklist.push(u);
1825             }
1826           }
1827         }
1828         if (m->is_ShenandoahBarrier()) {
1829           for (DUIterator_Fast i2max, i2 = m->fast_outs(i2max); i2 < i2max; i2++) {
1830             Node* p = m->fast_out(i2);
1831             if (p->Opcode() == Op_CmpP) {
1832               if(p->bottom_type() != type(p)) {
1833                 worklist.push(p);
1834               }
1835             } else if (p->Opcode() == Op_AddP) {
1836               for (DUIterator_Fast i3max, i3 = p->fast_outs(i3max); i3 < i3max; i3++) {
1837                 Node* q = p->fast_out(i3);
1838                 if (q->is_Load()) {
1839                   if(q->bottom_type() != type(q)) {
1840                     worklist.push(q);
1841                   }
1842                 }
1843               }
1844             }
1845           }
1846         }
1847       }
1848     }
1849   }
1850 }
1851 
1852 //------------------------------do_transform-----------------------------------
1853 // Top level driver for the recursive transformer
1854 void PhaseCCP::do_transform() {
1855   // Correct leaves of new-space Nodes; they point to old-space.
1856   C->set_root( transform(C->root())->as_Root() );
1857   assert( C->top(),  "missing TOP node" );
1858   assert( C->root(), "missing root" );
1859 }
1860 
1861 //------------------------------transform--------------------------------------
1862 // Given a Node in old-space, clone him into new-space.
1863 // Convert any of his old-space children into new-space children.
1864 Node *PhaseCCP::transform( Node *n ) {
1865   Node *new_node = _nodes[n->_idx]; // Check for transformed node
1866   if( new_node != NULL )


2086         igvn->_worklist.push( old );
2087       break;
2088     case 1:
2089       if( old->is_Store() || old->has_special_unique_user() )
2090         igvn->add_users_to_worklist( old );
2091       break;
2092     case 2:
2093       if( old->is_Store() )
2094         igvn->add_users_to_worklist( old );
2095       if( old->Opcode() == Op_Region )
2096         igvn->_worklist.push(old);
2097       break;
2098     case 3:
2099       if( old->Opcode() == Op_Region ) {
2100         igvn->_worklist.push(old);
2101         igvn->add_users_to_worklist( old );
2102       }
2103       break;
2104     default:
2105       break;
2106     }
2107     if (UseShenandoahGC) {
2108       // TODO: Should we call this for ZGC as well?
2109       BarrierSet::barrier_set()->barrier_set_c2()->enqueue_useful_gc_barrier(igvn, old);
2110     }
2111   }
2112 
2113 }
2114 
2115 //-------------------------------replace_by-----------------------------------
2116 // Using def-use info, replace one node for another.  Follow the def-use info
2117 // to all users of the OLD node.  Then make all uses point to the NEW node.
2118 void Node::replace_by(Node *new_node) {
2119   assert(!is_top(), "top node has no DU info");
2120   for (DUIterator_Last imin, i = last_outs(imin); i >= imin; ) {
2121     Node* use = last_out(i);
2122     uint uses_found = 0;
2123     for (uint j = 0; j < use->len(); j++) {
2124       if (use->in(j) == this) {
2125         if (j < use->req())
2126               use->set_req(j, new_node);
2127         else  use->set_prec(j, new_node);
2128         uses_found++;
2129       }


< prev index next >