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




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;
1633 }
1634 




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     bool is_mismatched = is_mismatched_access(con, loadbt);
1612     assert(!is_mismatched, "conbt=%s; loadbt=%s", type2name(con.basic_type()), type2name(loadbt));
1613     const Type* con_type = Type::make_from_constant(con);
1614     // Guard against erroneous constant folding.
1615     if (!is_mismatched && con_type != NULL) {
1616       if (con_type->isa_aryptr()) {
1617         // Join with the array element type, in case it is also stable.
1618         int dim = ary->stable_dimension();
1619         con_type = con_type->is_aryptr()->cast_to_stable(true, dim-1);
1620       }
1621       if (loadbt == T_NARROWOOP && con_type->isa_oopptr()) {
1622         con_type = con_type->make_narrowoop();
1623       }
1624 #ifndef PRODUCT
1625       if (TraceIterativeGVN) {
1626         tty->print("FoldStableValues: array element [off=%d]: con_type=", off);
1627         con_type->dump(); tty->cr();
1628       }
1629 #endif //PRODUCT
1630       return con_type;
1631     }
1632   }
1633   return NULL;
1634 }
1635 


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