src/share/vm/opto/cfgnode.cpp

Print this page
rev 3688 : 7054512: Compress class pointers after perm gen removal
Summary: support of compress class pointers in the compilers.
Reviewed-by:


1369   // Now I can point to the new node.
1370   n->add_req(newn);
1371   igvn->_worklist.push(n);
1372 }
1373 
1374 //------------------------------split_flow_path--------------------------------
1375 // Check for merging identical values and split flow paths
1376 static Node* split_flow_path(PhaseGVN *phase, PhiNode *phi) {
1377   BasicType bt = phi->type()->basic_type();
1378   if( bt == T_ILLEGAL || type2size[bt] <= 0 )
1379     return NULL;                // Bail out on funny non-value stuff
1380   if( phi->req() <= 3 )         // Need at least 2 matched inputs and a
1381     return NULL;                // third unequal input to be worth doing
1382 
1383   // Scan for a constant
1384   uint i;
1385   for( i = 1; i < phi->req()-1; i++ ) {
1386     Node *n = phi->in(i);
1387     if( !n ) return NULL;
1388     if( phase->type(n) == Type::TOP ) return NULL;
1389     if( n->Opcode() == Op_ConP || n->Opcode() == Op_ConN )
1390       break;
1391   }
1392   if( i >= phi->req() )         // Only split for constants
1393     return NULL;
1394 
1395   Node *val = phi->in(i);       // Constant to split for
1396   uint hit = 0;                 // Number of times it occurs
1397   Node *r = phi->region();
1398 
1399   for( ; i < phi->req(); i++ ){ // Count occurrences of constant
1400     Node *n = phi->in(i);
1401     if( !n ) return NULL;
1402     if( phase->type(n) == Type::TOP ) return NULL;
1403     if( phi->in(i) == val ) {
1404       hit++;
1405       if (PhaseIdealLoop::find_predicate(r->in(i)) != NULL) {
1406         return NULL;            // don't split loop entry path
1407       }
1408     }
1409   }


1858         }
1859         // Replace self with the result.
1860         return result;
1861       }
1862     }
1863     //
1864     // Other optimizations on the memory chain
1865     //
1866     const TypePtr* at = adr_type();
1867     for( uint i=1; i<req(); ++i ) {// For all paths in
1868       Node *ii = in(i);
1869       Node *new_in = MemNode::optimize_memory_chain(ii, at, phase);
1870       if (ii != new_in ) {
1871         set_req(i, new_in);
1872         progress = this;
1873       }
1874     }
1875   }
1876 
1877 #ifdef _LP64
1878   // Push DecodeN down through phi.
1879   // The rest of phi graph will transform by split EncodeP node though phis up.
1880   if (UseCompressedOops && can_reshape && progress == NULL) {
1881     bool may_push = true;
1882     bool has_decodeN = false;

1883     for (uint i=1; i<req(); ++i) {// For all paths in
1884       Node *ii = in(i);
1885       if (ii->is_DecodeN() && ii->bottom_type() == bottom_type()) {
1886         // Do optimization if a non dead path exist.
1887         if (ii->in(1)->bottom_type() != Type::TOP) {
1888           has_decodeN = true;

1889         }
1890       } else if (!ii->is_Phi()) {
1891         may_push = false;
1892       }
1893     }
1894 
1895     if (has_decodeN && may_push) {
1896       PhaseIterGVN *igvn = phase->is_IterGVN();
1897       // Make narrow type for new phi.
1898       const Type* narrow_t = TypeNarrowOop::make(this->bottom_type()->is_ptr());





1899       PhiNode* new_phi = new (phase->C) PhiNode(r, narrow_t);
1900       uint orig_cnt = req();
1901       for (uint i=1; i<req(); ++i) {// For all paths in
1902         Node *ii = in(i);
1903         Node* new_ii = NULL;
1904         if (ii->is_DecodeN()) {
1905           assert(ii->bottom_type() == bottom_type(), "sanity");
1906           new_ii = ii->in(1);
1907         } else {
1908           assert(ii->is_Phi(), "sanity");
1909           if (ii->as_Phi() == this) {
1910             new_ii = new_phi;
1911           } else {

1912             new_ii = new (phase->C) EncodePNode(ii, narrow_t);



1913             igvn->register_new_node_with_optimizer(new_ii);
1914           }
1915         }
1916         new_phi->set_req(i, new_ii);
1917       }
1918       igvn->register_new_node_with_optimizer(new_phi, this);

1919       progress = new (phase->C) DecodeNNode(new_phi, bottom_type());



1920     }
1921   }
1922 #endif
1923 
1924   return progress;              // Return any progress
1925 }
1926 
1927 //------------------------------is_tripcount-----------------------------------
1928 bool PhiNode::is_tripcount() const {
1929   return (in(0) != NULL && in(0)->is_CountedLoop() &&
1930           in(0)->as_CountedLoop()->phi() == this);
1931 }
1932 
1933 //------------------------------out_RegMask------------------------------------
1934 const RegMask &PhiNode::in_RegMask(uint i) const {
1935   return i ? out_RegMask() : RegMask::Empty;
1936 }
1937 
1938 const RegMask &PhiNode::out_RegMask() const {
1939   uint ideal_reg = _type->ideal_reg();




1369   // Now I can point to the new node.
1370   n->add_req(newn);
1371   igvn->_worklist.push(n);
1372 }
1373 
1374 //------------------------------split_flow_path--------------------------------
1375 // Check for merging identical values and split flow paths
1376 static Node* split_flow_path(PhaseGVN *phase, PhiNode *phi) {
1377   BasicType bt = phi->type()->basic_type();
1378   if( bt == T_ILLEGAL || type2size[bt] <= 0 )
1379     return NULL;                // Bail out on funny non-value stuff
1380   if( phi->req() <= 3 )         // Need at least 2 matched inputs and a
1381     return NULL;                // third unequal input to be worth doing
1382 
1383   // Scan for a constant
1384   uint i;
1385   for( i = 1; i < phi->req()-1; i++ ) {
1386     Node *n = phi->in(i);
1387     if( !n ) return NULL;
1388     if( phase->type(n) == Type::TOP ) return NULL;
1389     if( n->Opcode() == Op_ConP || n->Opcode() == Op_ConN || n->Opcode() == Op_ConNKlass )
1390       break;
1391   }
1392   if( i >= phi->req() )         // Only split for constants
1393     return NULL;
1394 
1395   Node *val = phi->in(i);       // Constant to split for
1396   uint hit = 0;                 // Number of times it occurs
1397   Node *r = phi->region();
1398 
1399   for( ; i < phi->req(); i++ ){ // Count occurrences of constant
1400     Node *n = phi->in(i);
1401     if( !n ) return NULL;
1402     if( phase->type(n) == Type::TOP ) return NULL;
1403     if( phi->in(i) == val ) {
1404       hit++;
1405       if (PhaseIdealLoop::find_predicate(r->in(i)) != NULL) {
1406         return NULL;            // don't split loop entry path
1407       }
1408     }
1409   }


1858         }
1859         // Replace self with the result.
1860         return result;
1861       }
1862     }
1863     //
1864     // Other optimizations on the memory chain
1865     //
1866     const TypePtr* at = adr_type();
1867     for( uint i=1; i<req(); ++i ) {// For all paths in
1868       Node *ii = in(i);
1869       Node *new_in = MemNode::optimize_memory_chain(ii, at, phase);
1870       if (ii != new_in ) {
1871         set_req(i, new_in);
1872         progress = this;
1873       }
1874     }
1875   }
1876 
1877 #ifdef _LP64
1878   // Push DecodeN/DecodeNKlass down through phi.
1879   // The rest of phi graph will transform by split EncodeP node though phis up.
1880   if ((UseCompressedOops || UseCompressedKlassPointers) && can_reshape && progress == NULL) {
1881     bool may_push = true;
1882     bool has_decodeN = false;
1883     bool is_decodeN = false;
1884     for (uint i=1; i<req(); ++i) {// For all paths in
1885       Node *ii = in(i);
1886       if (ii->is_DecodeNarrowPtr() && ii->bottom_type() == bottom_type()) {
1887         // Do optimization if a non dead path exist.
1888         if (ii->in(1)->bottom_type() != Type::TOP) {
1889           has_decodeN = true;
1890           is_decodeN = ii->is_DecodeN();
1891         }
1892       } else if (!ii->is_Phi()) {
1893         may_push = false;
1894       }
1895     }
1896 
1897     if (has_decodeN && may_push) {
1898       PhaseIterGVN *igvn = phase->is_IterGVN();
1899       // Make narrow type for new phi.
1900       const Type* narrow_t;
1901       if (is_decodeN) {
1902         narrow_t = TypeNarrowOop::make(this->bottom_type()->is_ptr());
1903       } else {
1904         narrow_t = TypeNarrowKlass::make(this->bottom_type()->is_ptr());
1905       }
1906       PhiNode* new_phi = new (phase->C) PhiNode(r, narrow_t);
1907       uint orig_cnt = req();
1908       for (uint i=1; i<req(); ++i) {// For all paths in
1909         Node *ii = in(i);
1910         Node* new_ii = NULL;
1911         if (ii->is_DecodeNarrowPtr()) {
1912           assert(ii->bottom_type() == bottom_type(), "sanity");
1913           new_ii = ii->in(1);
1914         } else {
1915           assert(ii->is_Phi(), "sanity");
1916           if (ii->as_Phi() == this) {
1917             new_ii = new_phi;
1918           } else {
1919             if (is_decodeN) {
1920               new_ii = new (phase->C) EncodePNode(ii, narrow_t);
1921             } else {
1922               new_ii = new (phase->C) EncodePKlassNode(ii, narrow_t);
1923             }
1924             igvn->register_new_node_with_optimizer(new_ii);
1925           }
1926         }
1927         new_phi->set_req(i, new_ii);
1928       }
1929       igvn->register_new_node_with_optimizer(new_phi, this);
1930       if (is_decodeN) {
1931         progress = new (phase->C) DecodeNNode(new_phi, bottom_type());
1932       } else {
1933         progress = new (phase->C) DecodeNKlassNode(new_phi, bottom_type());
1934       }
1935     }
1936   }
1937 #endif
1938 
1939   return progress;              // Return any progress
1940 }
1941 
1942 //------------------------------is_tripcount-----------------------------------
1943 bool PhiNode::is_tripcount() const {
1944   return (in(0) != NULL && in(0)->is_CountedLoop() &&
1945           in(0)->as_CountedLoop()->phi() == this);
1946 }
1947 
1948 //------------------------------out_RegMask------------------------------------
1949 const RegMask &PhiNode::in_RegMask(uint i) const {
1950   return i ? out_RegMask() : RegMask::Empty;
1951 }
1952 
1953 const RegMask &PhiNode::out_RegMask() const {
1954   uint ideal_reg = _type->ideal_reg();