< prev index next >

src/hotspot/share/opto/phaseX.cpp

Print this page




  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "gc/shared/barrierSet.hpp"
  27 #include "gc/shared/c2/barrierSetC2.hpp"
  28 #include "memory/allocation.inline.hpp"
  29 #include "memory/resourceArea.hpp"
  30 #include "opto/block.hpp"
  31 #include "opto/callnode.hpp"
  32 #include "opto/castnode.hpp"
  33 #include "opto/cfgnode.hpp"
  34 #include "opto/idealGraphPrinter.hpp"
  35 #include "opto/loopnode.hpp"
  36 #include "opto/machnode.hpp"
  37 #include "opto/opcodes.hpp"
  38 #include "opto/phaseX.hpp"
  39 #include "opto/regalloc.hpp"
  40 #include "opto/rootnode.hpp"
  41 #include "utilities/macros.hpp"



  42 
  43 //=============================================================================
  44 #define NODE_HASH_MINIMUM_SIZE    255
  45 //------------------------------NodeHash---------------------------------------
  46 NodeHash::NodeHash(uint est_max_size) :
  47   _max( round_up(est_max_size < NODE_HASH_MINIMUM_SIZE ? NODE_HASH_MINIMUM_SIZE : est_max_size) ),
  48   _a(Thread::current()->resource_area()),
  49   _table( NEW_ARENA_ARRAY( _a , Node* , _max ) ), // (Node**)_a->Amalloc(_max * sizeof(Node*)) ),
  50   _inserts(0), _insert_limit( insert_limit() )
  51 #ifndef PRODUCT
  52   ,_look_probes(0), _lookup_hits(0), _lookup_misses(0),
  53   _delete_probes(0), _delete_hits(0), _delete_misses(0),
  54   _total_insert_probes(0), _total_inserts(0),
  55   _insert_probes(0), _grows(0)
  56 #endif
  57 {
  58   // _sentinel must be in the current node space
  59   _sentinel = new ProjNode(NULL, TypeFunc::Control);
  60   memset(_table,0,sizeof(Node*)*_max);
  61 }


1358             assert((nrep > 0), "sanity");
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         }


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 )


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       }
2083     }




  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "gc/shared/barrierSet.hpp"
  27 #include "gc/shared/c2/barrierSetC2.hpp"
  28 #include "memory/allocation.inline.hpp"
  29 #include "memory/resourceArea.hpp"
  30 #include "opto/block.hpp"
  31 #include "opto/callnode.hpp"
  32 #include "opto/castnode.hpp"
  33 #include "opto/cfgnode.hpp"
  34 #include "opto/idealGraphPrinter.hpp"
  35 #include "opto/loopnode.hpp"
  36 #include "opto/machnode.hpp"
  37 #include "opto/opcodes.hpp"
  38 #include "opto/phaseX.hpp"
  39 #include "opto/regalloc.hpp"
  40 #include "opto/rootnode.hpp"
  41 #include "utilities/macros.hpp"
  42 #if INCLUDE_SHENANDOAHGC
  43 #include "gc/shenandoah/c2/shenandoahBarrierSetC2.hpp"
  44 #endif
  45 
  46 //=============================================================================
  47 #define NODE_HASH_MINIMUM_SIZE    255
  48 //------------------------------NodeHash---------------------------------------
  49 NodeHash::NodeHash(uint est_max_size) :
  50   _max( round_up(est_max_size < NODE_HASH_MINIMUM_SIZE ? NODE_HASH_MINIMUM_SIZE : est_max_size) ),
  51   _a(Thread::current()->resource_area()),
  52   _table( NEW_ARENA_ARRAY( _a , Node* , _max ) ), // (Node**)_a->Amalloc(_max * sizeof(Node*)) ),
  53   _inserts(0), _insert_limit( insert_limit() )
  54 #ifndef PRODUCT
  55   ,_look_probes(0), _lookup_hits(0), _lookup_misses(0),
  56   _delete_probes(0), _delete_hits(0), _delete_misses(0),
  57   _total_insert_probes(0), _total_inserts(0),
  58   _insert_probes(0), _grows(0)
  59 #endif
  60 {
  61   // _sentinel must be in the current node space
  62   _sentinel = new ProjNode(NULL, TypeFunc::Control);
  63   memset(_table,0,sizeof(Node*)*_max);
  64 }


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


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


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


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


< prev index next >