8036667: "assert(adr->is_AddP() && adr->in(AddPNode::Offset)->is_Con()) failed: offset is a constant" with FoldStableValues on

Fri, 28 Mar 2014 10:04:07 -0700

author
vlivanov
date
Fri, 28 Mar 2014 10:04:07 -0700
changeset 6526
75ad4240c15c
parent 6523
23262dd70c13
child 6527
f47fa50d9b9c

8036667: "assert(adr->is_AddP() && adr->in(AddPNode::Offset)->is_Con()) failed: offset is a constant" with FoldStableValues on
Reviewed-by: kvn

src/share/vm/opto/memnode.cpp file | annotate | diff | comparison | revisions
     1.1 --- a/src/share/vm/opto/memnode.cpp	Tue Jan 28 10:19:45 2014 -0800
     1.2 +++ b/src/share/vm/opto/memnode.cpp	Fri Mar 28 10:04:07 2014 -0700
     1.3 @@ -1593,35 +1593,33 @@
     1.4  
     1.5  // Try to constant-fold a stable array element.
     1.6  static const Type* fold_stable_ary_elem(const TypeAryPtr* ary, int off, BasicType loadbt) {
     1.7 +  assert(ary->const_oop(), "array should be constant");
     1.8    assert(ary->is_stable(), "array should be stable");
     1.9  
    1.10 -  if (ary->const_oop() != NULL) {
    1.11 -    // Decode the results of GraphKit::array_element_address.
    1.12 -    ciArray* aobj = ary->const_oop()->as_array();
    1.13 -    ciConstant con = aobj->element_value_by_offset(off);
    1.14 -
    1.15 -    if (con.basic_type() != T_ILLEGAL && !con.is_null_or_zero()) {
    1.16 -      const Type* con_type = Type::make_from_constant(con);
    1.17 -      if (con_type != NULL) {
    1.18 -        if (con_type->isa_aryptr()) {
    1.19 -          // Join with the array element type, in case it is also stable.
    1.20 -          int dim = ary->stable_dimension();
    1.21 -          con_type = con_type->is_aryptr()->cast_to_stable(true, dim-1);
    1.22 -        }
    1.23 -        if (loadbt == T_NARROWOOP && con_type->isa_oopptr()) {
    1.24 -          con_type = con_type->make_narrowoop();
    1.25 -        }
    1.26 +  // Decode the results of GraphKit::array_element_address.
    1.27 +  ciArray* aobj = ary->const_oop()->as_array();
    1.28 +  ciConstant con = aobj->element_value_by_offset(off);
    1.29 +
    1.30 +  if (con.basic_type() != T_ILLEGAL && !con.is_null_or_zero()) {
    1.31 +    const Type* con_type = Type::make_from_constant(con);
    1.32 +    if (con_type != NULL) {
    1.33 +      if (con_type->isa_aryptr()) {
    1.34 +        // Join with the array element type, in case it is also stable.
    1.35 +        int dim = ary->stable_dimension();
    1.36 +        con_type = con_type->is_aryptr()->cast_to_stable(true, dim-1);
    1.37 +      }
    1.38 +      if (loadbt == T_NARROWOOP && con_type->isa_oopptr()) {
    1.39 +        con_type = con_type->make_narrowoop();
    1.40 +      }
    1.41  #ifndef PRODUCT
    1.42 -        if (TraceIterativeGVN) {
    1.43 -          tty->print("FoldStableValues: array element [off=%d]: con_type=", off);
    1.44 -          con_type->dump(); tty->cr();
    1.45 -        }
    1.46 +      if (TraceIterativeGVN) {
    1.47 +        tty->print("FoldStableValues: array element [off=%d]: con_type=", off);
    1.48 +        con_type->dump(); tty->cr();
    1.49 +      }
    1.50  #endif //PRODUCT
    1.51 -        return con_type;
    1.52 -      }
    1.53 +      return con_type;
    1.54      }
    1.55    }
    1.56 -
    1.57    return NULL;
    1.58  }
    1.59  
    1.60 @@ -1641,7 +1639,7 @@
    1.61    // Try to guess loaded type from pointer type
    1.62    if (tp->isa_aryptr()) {
    1.63      const TypeAryPtr* ary = tp->is_aryptr();
    1.64 -    const Type *t = ary->elem();
    1.65 +    const Type* t = ary->elem();
    1.66  
    1.67      // Determine whether the reference is beyond the header or not, by comparing
    1.68      // the offset against the offset of the start of the array's data.
    1.69 @@ -1653,10 +1651,9 @@
    1.70      const bool off_beyond_header = ((uint)off >= (uint)min_base_off);
    1.71  
    1.72      // Try to constant-fold a stable array element.
    1.73 -    if (FoldStableValues && ary->is_stable()) {
    1.74 -      // Make sure the reference is not into the header
    1.75 -      if (off_beyond_header && off != Type::OffsetBot) {
    1.76 -        assert(adr->is_AddP() && adr->in(AddPNode::Offset)->is_Con(), "offset is a constant");
    1.77 +    if (FoldStableValues && ary->is_stable() && ary->const_oop() != NULL) {
    1.78 +      // Make sure the reference is not into the header and the offset is constant
    1.79 +      if (off_beyond_header && adr->is_AddP() && off != Type::OffsetBot) {
    1.80          const Type* con_type = fold_stable_ary_elem(ary, off, memory_type());
    1.81          if (con_type != NULL) {
    1.82            return con_type;

mercurial