hotspot/src/share/vm/opto/compile.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File hotspot-comp Sdiff hotspot/src/share/vm/opto

hotspot/src/share/vm/opto/compile.cpp

Print this page
rev 4966 : imported patch webrev.01


1280 //------------------------------flatten_alias_type-----------------------------
1281 const TypePtr *Compile::flatten_alias_type( const TypePtr *tj ) const {
1282   int offset = tj->offset();
1283   TypePtr::PTR ptr = tj->ptr();
1284 
1285   // Known instance (scalarizable allocation) alias only with itself.
1286   bool is_known_inst = tj->isa_oopptr() != NULL &&
1287                        tj->is_oopptr()->is_known_instance();
1288 
1289   // Process weird unsafe references.
1290   if (offset == Type::OffsetBot && (tj->isa_instptr() /*|| tj->isa_klassptr()*/)) {
1291     assert(InlineUnsafeOps, "indeterminate pointers come only from unsafe ops");
1292     assert(!is_known_inst, "scalarizable allocation should not have unsafe references");
1293     tj = TypeOopPtr::BOTTOM;
1294     ptr = tj->ptr();
1295     offset = tj->offset();
1296   }
1297 
1298   // Array pointers need some flattening
1299   const TypeAryPtr *ta = tj->isa_aryptr();




1300   if( ta && is_known_inst ) {
1301     if ( offset != Type::OffsetBot &&
1302          offset > arrayOopDesc::length_offset_in_bytes() ) {
1303       offset = Type::OffsetBot; // Flatten constant access into array body only
1304       tj = ta = TypeAryPtr::make(ptr, ta->ary(), ta->klass(), true, offset, ta->instance_id());
1305     }
1306   } else if( ta && _AliasLevel >= 2 ) {
1307     // For arrays indexed by constant indices, we flatten the alias
1308     // space to include all of the array body.  Only the header, klass
1309     // and array length can be accessed un-aliased.
1310     if( offset != Type::OffsetBot ) {
1311       if( ta->const_oop() ) { // MethodData* or Method*
1312         offset = Type::OffsetBot;   // Flatten constant access into array body
1313         tj = ta = TypeAryPtr::make(ptr,ta->const_oop(),ta->ary(),ta->klass(),false,offset);
1314       } else if( offset == arrayOopDesc::length_offset_in_bytes() ) {
1315         // range is OK as-is.
1316         tj = ta = TypeAryPtr::RANGE;
1317       } else if( offset == oopDesc::klass_offset_in_bytes() ) {
1318         tj = TypeInstPtr::KLASS; // all klass loads look alike
1319         ta = TypeAryPtr::RANGE; // generic ignored junk


1480           (offset == Type::OffsetBot && tj == TypeOopPtr::BOTTOM) ||
1481           (offset == Type::OffsetBot && tj == TypePtr::BOTTOM) ||
1482           (offset == oopDesc::mark_offset_in_bytes() && tj->base() == Type::AryPtr) ||
1483           (offset == oopDesc::klass_offset_in_bytes() && tj->base() == Type::AryPtr) ||
1484           (offset == arrayOopDesc::length_offset_in_bytes() && tj->base() == Type::AryPtr)  ,
1485           "For oops, klasses, raw offset must be constant; for arrays the offset is never known" );
1486   assert( tj->ptr() != TypePtr::TopPTR &&
1487           tj->ptr() != TypePtr::AnyNull &&
1488           tj->ptr() != TypePtr::Null, "No imprecise addresses" );
1489 //    assert( tj->ptr() != TypePtr::Constant ||
1490 //            tj->base() == Type::RawPtr ||
1491 //            tj->base() == Type::KlassPtr, "No constant oop addresses" );
1492 
1493   return tj;
1494 }
1495 
1496 void Compile::AliasType::Init(int i, const TypePtr* at) {
1497   _index = i;
1498   _adr_type = at;
1499   _field = NULL;

1500   _is_rewritable = true; // default
1501   const TypeOopPtr *atoop = (at != NULL) ? at->isa_oopptr() : NULL;
1502   if (atoop != NULL && atoop->is_known_instance()) {
1503     const TypeOopPtr *gt = atoop->cast_to_instance_id(TypeOopPtr::InstanceBot);
1504     _general_index = Compile::current()->get_alias_index(gt);
1505   } else {
1506     _general_index = 0;
1507   }
1508 }
1509 
1510 //---------------------------------print_on------------------------------------
1511 #ifndef PRODUCT
1512 void Compile::AliasType::print_on(outputStream* st) {
1513   if (index() < 10)
1514         st->print("@ <%d> ", index());
1515   else  st->print("@ <%d>",  index());
1516   st->print(is_rewritable() ? "   " : " RO");
1517   int offset = adr_type()->offset();
1518   if (offset == Type::OffsetBot)
1519         st->print(" +any");


1598     if (alias_type(i)->adr_type() == flat) {
1599       idx = i;
1600       break;
1601     }
1602   }
1603 
1604   if (idx == AliasIdxTop) {
1605     if (no_create)  return NULL;
1606     // Grow the array if necessary.
1607     if (_num_alias_types == _max_alias_types)  grow_alias_types();
1608     // Add a new alias type.
1609     idx = _num_alias_types++;
1610     _alias_types[idx]->Init(idx, flat);
1611     if (flat == TypeInstPtr::KLASS)  alias_type(idx)->set_rewritable(false);
1612     if (flat == TypeAryPtr::RANGE)   alias_type(idx)->set_rewritable(false);
1613     if (flat->isa_instptr()) {
1614       if (flat->offset() == java_lang_Class::klass_offset_in_bytes()
1615           && flat->is_instptr()->klass() == env()->Class_klass())
1616         alias_type(idx)->set_rewritable(false);
1617     }









1618     if (flat->isa_klassptr()) {
1619       if (flat->offset() == in_bytes(Klass::super_check_offset_offset()))
1620         alias_type(idx)->set_rewritable(false);
1621       if (flat->offset() == in_bytes(Klass::modifier_flags_offset()))
1622         alias_type(idx)->set_rewritable(false);
1623       if (flat->offset() == in_bytes(Klass::access_flags_offset()))
1624         alias_type(idx)->set_rewritable(false);
1625       if (flat->offset() == in_bytes(Klass::java_mirror_offset()))
1626         alias_type(idx)->set_rewritable(false);
1627     }
1628     // %%% (We would like to finalize JavaThread::threadObj_offset(),
1629     // but the base pointer type is not distinctive enough to identify
1630     // references into JavaThread.)
1631 
1632     // Check for final fields.
1633     const TypeInstPtr* tinst = flat->isa_instptr();
1634     if (tinst && tinst->offset() >= instanceOopDesc::base_offset_in_bytes()) {
1635       ciField* field;
1636       if (tinst->const_oop() != NULL &&
1637           tinst->klass() == ciEnv::current()->Class_klass() &&


1660 
1661   // Might as well try to fill the cache for the flattened version, too.
1662   AliasCacheEntry* face = probe_alias_cache(flat);
1663   if (face->_adr_type == NULL) {
1664     face->_adr_type = flat;
1665     face->_index    = idx;
1666     assert(alias_type(flat) == alias_type(idx), "flat type must work too");
1667   }
1668 
1669   return alias_type(idx);
1670 }
1671 
1672 
1673 Compile::AliasType* Compile::alias_type(ciField* field) {
1674   const TypeOopPtr* t;
1675   if (field->is_static())
1676     t = TypeInstPtr::make(field->holder()->java_mirror());
1677   else
1678     t = TypeOopPtr::make_from_klass_raw(field->holder());
1679   AliasType* atp = alias_type(t->add_offset(field->offset_in_bytes()), field);
1680   assert(field->is_final() == !atp->is_rewritable(), "must get the rewritable bits correct");
1681   return atp;
1682 }
1683 
1684 
1685 //------------------------------have_alias_type--------------------------------
1686 bool Compile::have_alias_type(const TypePtr* adr_type) {
1687   AliasCacheEntry* ace = probe_alias_cache(adr_type);
1688   if (ace->_adr_type == adr_type) {
1689     return true;
1690   }
1691 
1692   // Handle special cases.
1693   if (adr_type == NULL)             return true;
1694   if (adr_type == TypePtr::BOTTOM)  return true;
1695 
1696   return find_alias_type(adr_type, true, NULL) != NULL;
1697 }
1698 
1699 //-----------------------------must_alias--------------------------------------
1700 // True if all values of the given address type are in the given alias category.




1280 //------------------------------flatten_alias_type-----------------------------
1281 const TypePtr *Compile::flatten_alias_type( const TypePtr *tj ) const {
1282   int offset = tj->offset();
1283   TypePtr::PTR ptr = tj->ptr();
1284 
1285   // Known instance (scalarizable allocation) alias only with itself.
1286   bool is_known_inst = tj->isa_oopptr() != NULL &&
1287                        tj->is_oopptr()->is_known_instance();
1288 
1289   // Process weird unsafe references.
1290   if (offset == Type::OffsetBot && (tj->isa_instptr() /*|| tj->isa_klassptr()*/)) {
1291     assert(InlineUnsafeOps, "indeterminate pointers come only from unsafe ops");
1292     assert(!is_known_inst, "scalarizable allocation should not have unsafe references");
1293     tj = TypeOopPtr::BOTTOM;
1294     ptr = tj->ptr();
1295     offset = tj->offset();
1296   }
1297 
1298   // Array pointers need some flattening
1299   const TypeAryPtr *ta = tj->isa_aryptr();
1300   if (ta && ta->is_stable()) {
1301     // Erase stability property for alias analysis.
1302     tj = ta = ta->cast_to_stable(false);
1303   }
1304   if( ta && is_known_inst ) {
1305     if ( offset != Type::OffsetBot &&
1306          offset > arrayOopDesc::length_offset_in_bytes() ) {
1307       offset = Type::OffsetBot; // Flatten constant access into array body only
1308       tj = ta = TypeAryPtr::make(ptr, ta->ary(), ta->klass(), true, offset, ta->instance_id());
1309     }
1310   } else if( ta && _AliasLevel >= 2 ) {
1311     // For arrays indexed by constant indices, we flatten the alias
1312     // space to include all of the array body.  Only the header, klass
1313     // and array length can be accessed un-aliased.
1314     if( offset != Type::OffsetBot ) {
1315       if( ta->const_oop() ) { // MethodData* or Method*
1316         offset = Type::OffsetBot;   // Flatten constant access into array body
1317         tj = ta = TypeAryPtr::make(ptr,ta->const_oop(),ta->ary(),ta->klass(),false,offset);
1318       } else if( offset == arrayOopDesc::length_offset_in_bytes() ) {
1319         // range is OK as-is.
1320         tj = ta = TypeAryPtr::RANGE;
1321       } else if( offset == oopDesc::klass_offset_in_bytes() ) {
1322         tj = TypeInstPtr::KLASS; // all klass loads look alike
1323         ta = TypeAryPtr::RANGE; // generic ignored junk


1484           (offset == Type::OffsetBot && tj == TypeOopPtr::BOTTOM) ||
1485           (offset == Type::OffsetBot && tj == TypePtr::BOTTOM) ||
1486           (offset == oopDesc::mark_offset_in_bytes() && tj->base() == Type::AryPtr) ||
1487           (offset == oopDesc::klass_offset_in_bytes() && tj->base() == Type::AryPtr) ||
1488           (offset == arrayOopDesc::length_offset_in_bytes() && tj->base() == Type::AryPtr)  ,
1489           "For oops, klasses, raw offset must be constant; for arrays the offset is never known" );
1490   assert( tj->ptr() != TypePtr::TopPTR &&
1491           tj->ptr() != TypePtr::AnyNull &&
1492           tj->ptr() != TypePtr::Null, "No imprecise addresses" );
1493 //    assert( tj->ptr() != TypePtr::Constant ||
1494 //            tj->base() == Type::RawPtr ||
1495 //            tj->base() == Type::KlassPtr, "No constant oop addresses" );
1496 
1497   return tj;
1498 }
1499 
1500 void Compile::AliasType::Init(int i, const TypePtr* at) {
1501   _index = i;
1502   _adr_type = at;
1503   _field = NULL;
1504   _element = NULL;
1505   _is_rewritable = true; // default
1506   const TypeOopPtr *atoop = (at != NULL) ? at->isa_oopptr() : NULL;
1507   if (atoop != NULL && atoop->is_known_instance()) {
1508     const TypeOopPtr *gt = atoop->cast_to_instance_id(TypeOopPtr::InstanceBot);
1509     _general_index = Compile::current()->get_alias_index(gt);
1510   } else {
1511     _general_index = 0;
1512   }
1513 }
1514 
1515 //---------------------------------print_on------------------------------------
1516 #ifndef PRODUCT
1517 void Compile::AliasType::print_on(outputStream* st) {
1518   if (index() < 10)
1519         st->print("@ <%d> ", index());
1520   else  st->print("@ <%d>",  index());
1521   st->print(is_rewritable() ? "   " : " RO");
1522   int offset = adr_type()->offset();
1523   if (offset == Type::OffsetBot)
1524         st->print(" +any");


1603     if (alias_type(i)->adr_type() == flat) {
1604       idx = i;
1605       break;
1606     }
1607   }
1608 
1609   if (idx == AliasIdxTop) {
1610     if (no_create)  return NULL;
1611     // Grow the array if necessary.
1612     if (_num_alias_types == _max_alias_types)  grow_alias_types();
1613     // Add a new alias type.
1614     idx = _num_alias_types++;
1615     _alias_types[idx]->Init(idx, flat);
1616     if (flat == TypeInstPtr::KLASS)  alias_type(idx)->set_rewritable(false);
1617     if (flat == TypeAryPtr::RANGE)   alias_type(idx)->set_rewritable(false);
1618     if (flat->isa_instptr()) {
1619       if (flat->offset() == java_lang_Class::klass_offset_in_bytes()
1620           && flat->is_instptr()->klass() == env()->Class_klass())
1621         alias_type(idx)->set_rewritable(false);
1622     }
1623     if (flat->isa_aryptr()) {
1624 #ifdef ASSERT
1625       const int header_size_min  = arrayOopDesc::base_offset_in_bytes(T_BYTE);
1626       // (T_BYTE has the weakest alignment and size restrictions...)
1627       assert(flat->offset() < header_size_min, "array body reference must be OffsetBot");
1628 #endif
1629       if (flat->offset() == TypePtr::OffsetBot)
1630         alias_type(idx)->set_element(flat->is_aryptr()->elem());
1631     }
1632     if (flat->isa_klassptr()) {
1633       if (flat->offset() == in_bytes(Klass::super_check_offset_offset()))
1634         alias_type(idx)->set_rewritable(false);
1635       if (flat->offset() == in_bytes(Klass::modifier_flags_offset()))
1636         alias_type(idx)->set_rewritable(false);
1637       if (flat->offset() == in_bytes(Klass::access_flags_offset()))
1638         alias_type(idx)->set_rewritable(false);
1639       if (flat->offset() == in_bytes(Klass::java_mirror_offset()))
1640         alias_type(idx)->set_rewritable(false);
1641     }
1642     // %%% (We would like to finalize JavaThread::threadObj_offset(),
1643     // but the base pointer type is not distinctive enough to identify
1644     // references into JavaThread.)
1645 
1646     // Check for final fields.
1647     const TypeInstPtr* tinst = flat->isa_instptr();
1648     if (tinst && tinst->offset() >= instanceOopDesc::base_offset_in_bytes()) {
1649       ciField* field;
1650       if (tinst->const_oop() != NULL &&
1651           tinst->klass() == ciEnv::current()->Class_klass() &&


1674 
1675   // Might as well try to fill the cache for the flattened version, too.
1676   AliasCacheEntry* face = probe_alias_cache(flat);
1677   if (face->_adr_type == NULL) {
1678     face->_adr_type = flat;
1679     face->_index    = idx;
1680     assert(alias_type(flat) == alias_type(idx), "flat type must work too");
1681   }
1682 
1683   return alias_type(idx);
1684 }
1685 
1686 
1687 Compile::AliasType* Compile::alias_type(ciField* field) {
1688   const TypeOopPtr* t;
1689   if (field->is_static())
1690     t = TypeInstPtr::make(field->holder()->java_mirror());
1691   else
1692     t = TypeOopPtr::make_from_klass_raw(field->holder());
1693   AliasType* atp = alias_type(t->add_offset(field->offset_in_bytes()), field);
1694   assert((field->is_final() || field->is_stable()) == !atp->is_rewritable(), "must get the rewritable bits correct");
1695   return atp;
1696 }
1697 
1698 
1699 //------------------------------have_alias_type--------------------------------
1700 bool Compile::have_alias_type(const TypePtr* adr_type) {
1701   AliasCacheEntry* ace = probe_alias_cache(adr_type);
1702   if (ace->_adr_type == adr_type) {
1703     return true;
1704   }
1705 
1706   // Handle special cases.
1707   if (adr_type == NULL)             return true;
1708   if (adr_type == TypePtr::BOTTOM)  return true;
1709 
1710   return find_alias_type(adr_type, true, NULL) != NULL;
1711 }
1712 
1713 //-----------------------------must_alias--------------------------------------
1714 // True if all values of the given address type are in the given alias category.


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