1580 |
1580 |
1581 // No match. |
1581 // No match. |
1582 return NULL; |
1582 return NULL; |
1583 } |
1583 } |
1584 |
1584 |
|
1585 #ifdef ASSERT |
1585 static bool is_mismatched_access(ciConstant con, BasicType loadbt) { |
1586 static bool is_mismatched_access(ciConstant con, BasicType loadbt) { |
1586 BasicType conbt = con.basic_type(); |
1587 BasicType conbt = con.basic_type(); |
1587 assert(conbt != T_NARROWOOP, "sanity"); |
1588 switch (conbt) { |
1588 if (loadbt == T_NARROWOOP || loadbt == T_ARRAY) { |
1589 case T_BOOLEAN: conbt = T_BYTE; break; |
1589 loadbt = T_OBJECT; |
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; |
1590 } |
1597 } |
1591 return (conbt != loadbt); |
1598 return (conbt != loadbt); |
1592 } |
1599 } |
|
1600 #endif // ASSERT |
1593 |
1601 |
1594 // Try to constant-fold a stable array element. |
1602 // Try to constant-fold a stable array element. |
1595 static const Type* fold_stable_ary_elem(const TypeAryPtr* ary, int off, BasicType loadbt) { |
1603 static const Type* fold_stable_ary_elem(const TypeAryPtr* ary, int off, BasicType loadbt) { |
1596 assert(ary->const_oop(), "array should be constant"); |
1604 assert(ary->const_oop(), "array should be constant"); |
1597 assert(ary->is_stable(), "array should be stable"); |
1605 assert(ary->is_stable(), "array should be stable"); |
1598 |
1606 |
1599 // Decode the results of GraphKit::array_element_address. |
1607 // Decode the results of GraphKit::array_element_address. |
1600 ciArray* aobj = ary->const_oop()->as_array(); |
1608 ciArray* aobj = ary->const_oop()->as_array(); |
1601 ciConstant con = aobj->element_value_by_offset(off); |
1609 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()) { |
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)); |
1603 const Type* con_type = Type::make_from_constant(con); |
1613 const Type* con_type = Type::make_from_constant(con); |
1604 if (con_type != NULL) { |
1614 if (con_type != NULL) { |
1605 if (con_type->isa_aryptr()) { |
1615 if (con_type->isa_aryptr()) { |
1606 // Join with the array element type, in case it is also stable. |
1616 // Join with the array element type, in case it is also stable. |
1607 int dim = ary->stable_dimension(); |
1617 int dim = ary->stable_dimension(); |