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

src/share/vm/opto/memnode.cpp

Print this page




1565     // (Folds up the 2nd indirection in aClassConstant.getModifiers().)
1566     assert(this->Opcode() == Op_LoadI, "must load an int from _modifier_flags");
1567     return TypeInt::make(klass->modifier_flags());
1568   }
1569   if (tkls->offset() == in_bytes(Klass::access_flags_offset())) {
1570     // The field is Klass::_access_flags.  Return its (constant) value.
1571     // (Folds up the 2nd indirection in Reflection.getClassAccessFlags(aClassConstant).)
1572     assert(this->Opcode() == Op_LoadI, "must load an int from _access_flags");
1573     return TypeInt::make(klass->access_flags());
1574   }
1575   if (tkls->offset() == in_bytes(Klass::layout_helper_offset())) {
1576     // The field is Klass::_layout_helper.  Return its constant value if known.
1577     assert(this->Opcode() == Op_LoadI, "must load an int from _layout_helper");
1578     return TypeInt::make(klass->layout_helper());
1579   }
1580 
1581   // No match.
1582   return NULL;
1583 }
1584 

1585 static bool is_mismatched_access(ciConstant con, BasicType loadbt) {
1586   BasicType conbt = con.basic_type();
1587   assert(conbt != T_NARROWOOP, "sanity");
1588   if (loadbt == T_NARROWOOP || loadbt == T_ARRAY) {
1589     loadbt = T_OBJECT;






1590   }
1591   return (conbt != loadbt);
1592 }

1593 
1594 // Try to constant-fold a stable array element.
1595 static const Type* fold_stable_ary_elem(const TypeAryPtr* ary, int off, BasicType loadbt) {
1596   assert(ary->const_oop(), "array should be constant");
1597   assert(ary->is_stable(), "array should be stable");
1598 
1599   // Decode the results of GraphKit::array_element_address.
1600   ciArray* aobj = ary->const_oop()->as_array();
1601   ciConstant con = aobj->element_value_by_offset(off);
1602   if (con.basic_type() != T_ILLEGAL && !is_mismatched_access(con, loadbt) && !con.is_null_or_zero()) {


1603     const Type* con_type = Type::make_from_constant(con);
1604     if (con_type != NULL) {
1605       if (con_type->isa_aryptr()) {
1606         // Join with the array element type, in case it is also stable.
1607         int dim = ary->stable_dimension();
1608         con_type = con_type->is_aryptr()->cast_to_stable(true, dim-1);
1609       }
1610       if (loadbt == T_NARROWOOP && con_type->isa_oopptr()) {
1611         con_type = con_type->make_narrowoop();
1612       }
1613 #ifndef PRODUCT
1614       if (TraceIterativeGVN) {
1615         tty->print("FoldStableValues: array element [off=%d]: con_type=", off);
1616         con_type->dump(); tty->cr();
1617       }
1618 #endif //PRODUCT
1619       return con_type;
1620     }
1621   }
1622   return NULL;




1565     // (Folds up the 2nd indirection in aClassConstant.getModifiers().)
1566     assert(this->Opcode() == Op_LoadI, "must load an int from _modifier_flags");
1567     return TypeInt::make(klass->modifier_flags());
1568   }
1569   if (tkls->offset() == in_bytes(Klass::access_flags_offset())) {
1570     // The field is Klass::_access_flags.  Return its (constant) value.
1571     // (Folds up the 2nd indirection in Reflection.getClassAccessFlags(aClassConstant).)
1572     assert(this->Opcode() == Op_LoadI, "must load an int from _access_flags");
1573     return TypeInt::make(klass->access_flags());
1574   }
1575   if (tkls->offset() == in_bytes(Klass::layout_helper_offset())) {
1576     // The field is Klass::_layout_helper.  Return its constant value if known.
1577     assert(this->Opcode() == Op_LoadI, "must load an int from _layout_helper");
1578     return TypeInt::make(klass->layout_helper());
1579   }
1580 
1581   // No match.
1582   return NULL;
1583 }
1584 
1585 #ifdef ASSERT
1586 static bool is_mismatched_access(ciConstant con, BasicType loadbt) {
1587   BasicType conbt = con.basic_type();
1588   switch (conbt) {
1589     case T_BOOLEAN: conbt = T_BYTE;   break;
1590     case T_ARRAY:   conbt = T_OBJECT; break;
1591   }
1592   switch (loadbt) {
1593     case T_BOOLEAN:   loadbt = T_BYTE;   break;
1594     case T_NARROWOOP: loadbt = T_OBJECT; break;
1595     case T_ARRAY:     loadbt = T_OBJECT; break;
1596     case T_ADDRESS:   loadbt = T_OBJECT; break;
1597   }
1598   return (conbt != loadbt);
1599 }
1600 #endif // ASSERT
1601 
1602 // Try to constant-fold a stable array element.
1603 static const Type* fold_stable_ary_elem(const TypeAryPtr* ary, int off, BasicType loadbt) {
1604   assert(ary->const_oop(), "array should be constant");
1605   assert(ary->is_stable(), "array should be stable");
1606 
1607   // Decode the results of GraphKit::array_element_address.
1608   ciArray* aobj = ary->const_oop()->as_array();
1609   ciConstant con = aobj->element_value_by_offset(off);
1610   if (con.basic_type() != T_ILLEGAL && !con.is_null_or_zero()) {
1611     assert(!is_mismatched_access(con, loadbt),
1612            "conbt=%s; loadbt=%s", type2name(con.basic_type()), type2name(loadbt));
1613     const Type* con_type = Type::make_from_constant(con);
1614     if (con_type != NULL) {
1615       if (con_type->isa_aryptr()) {
1616         // Join with the array element type, in case it is also stable.
1617         int dim = ary->stable_dimension();
1618         con_type = con_type->is_aryptr()->cast_to_stable(true, dim-1);
1619       }
1620       if (loadbt == T_NARROWOOP && con_type->isa_oopptr()) {
1621         con_type = con_type->make_narrowoop();
1622       }
1623 #ifndef PRODUCT
1624       if (TraceIterativeGVN) {
1625         tty->print("FoldStableValues: array element [off=%d]: con_type=", off);
1626         con_type->dump(); tty->cr();
1627       }
1628 #endif //PRODUCT
1629       return con_type;
1630     }
1631   }
1632   return NULL;


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