< prev index next >

src/hotspot/share/opto/memnode.cpp

Print this page
rev 52415 : 8213371: GC/C2 abstraction and cleanup to handle custom offset for GC memory accesses


1680   if (t1 == Type::TOP)  return Type::TOP;
1681   Node* adr = in(MemNode::Address);
1682   const TypePtr* tp = phase->type(adr)->isa_ptr();
1683   if (tp == NULL || tp->empty())  return Type::TOP;
1684   int off = tp->offset();
1685   assert(off != Type::OffsetTop, "case covered by TypePtr::empty");
1686   Compile* C = phase->C;
1687 
1688   // Try to guess loaded type from pointer type
1689   if (tp->isa_aryptr()) {
1690     const TypeAryPtr* ary = tp->is_aryptr();
1691     const Type* t = ary->elem();
1692 
1693     // Determine whether the reference is beyond the header or not, by comparing
1694     // the offset against the offset of the start of the array's data.
1695     // Different array types begin at slightly different offsets (12 vs. 16).
1696     // We choose T_BYTE as an example base type that is least restrictive
1697     // as to alignment, which will therefore produce the smallest
1698     // possible base offset.
1699     const int min_base_off = arrayOopDesc::base_offset_in_bytes(T_BYTE);
1700     const bool off_beyond_header = ((uint)off >= (uint)min_base_off);
1701 
1702     // Try to constant-fold a stable array element.
1703     if (FoldStableValues && !is_mismatched_access() && ary->is_stable()) {
1704       // Make sure the reference is not into the header and the offset is constant
1705       ciObject* aobj = ary->const_oop();
1706       if (aobj != NULL && off_beyond_header && adr->is_AddP() && off != Type::OffsetBot) {
1707         int stable_dimension = (ary->stable_dimension() > 0 ? ary->stable_dimension() - 1 : 0);
1708         const Type* con_type = Type::make_constant_from_array_element(aobj->as_array(), off,
1709                                                                       stable_dimension,
1710                                                                       memory_type(), is_unsigned());
1711         if (con_type != NULL) {
1712           return con_type;
1713         }
1714       }
1715     }
1716 
1717     // Don't do this for integer types. There is only potential profit if
1718     // the element type t is lower than _type; that is, for int types, if _type is
1719     // more restrictive than t.  This only happens here if one is short and the other
1720     // char (both 16 bits), and in those cases we've made an intentional decision




1680   if (t1 == Type::TOP)  return Type::TOP;
1681   Node* adr = in(MemNode::Address);
1682   const TypePtr* tp = phase->type(adr)->isa_ptr();
1683   if (tp == NULL || tp->empty())  return Type::TOP;
1684   int off = tp->offset();
1685   assert(off != Type::OffsetTop, "case covered by TypePtr::empty");
1686   Compile* C = phase->C;
1687 
1688   // Try to guess loaded type from pointer type
1689   if (tp->isa_aryptr()) {
1690     const TypeAryPtr* ary = tp->is_aryptr();
1691     const Type* t = ary->elem();
1692 
1693     // Determine whether the reference is beyond the header or not, by comparing
1694     // the offset against the offset of the start of the array's data.
1695     // Different array types begin at slightly different offsets (12 vs. 16).
1696     // We choose T_BYTE as an example base type that is least restrictive
1697     // as to alignment, which will therefore produce the smallest
1698     // possible base offset.
1699     const int min_base_off = arrayOopDesc::base_offset_in_bytes(T_BYTE);
1700     const bool off_beyond_header = (off >= min_base_off);
1701 
1702     // Try to constant-fold a stable array element.
1703     if (FoldStableValues && !is_mismatched_access() && ary->is_stable()) {
1704       // Make sure the reference is not into the header and the offset is constant
1705       ciObject* aobj = ary->const_oop();
1706       if (aobj != NULL && off_beyond_header && adr->is_AddP() && off != Type::OffsetBot) {
1707         int stable_dimension = (ary->stable_dimension() > 0 ? ary->stable_dimension() - 1 : 0);
1708         const Type* con_type = Type::make_constant_from_array_element(aobj->as_array(), off,
1709                                                                       stable_dimension,
1710                                                                       memory_type(), is_unsigned());
1711         if (con_type != NULL) {
1712           return con_type;
1713         }
1714       }
1715     }
1716 
1717     // Don't do this for integer types. There is only potential profit if
1718     // the element type t is lower than _type; that is, for int types, if _type is
1719     // more restrictive than t.  This only happens here if one is short and the other
1720     // char (both 16 bits), and in those cases we've made an intentional decision


< prev index next >