< prev index next >

src/hotspot/share/opto/compile.cpp

Print this page
rev 53149 : [mq]: flatten-alias-types.patch


1453     }
1454   } else if( ta && _AliasLevel >= 2 ) {
1455     // For arrays indexed by constant indices, we flatten the alias
1456     // space to include all of the array body.  Only the header, klass
1457     // and array length can be accessed un-aliased.
1458     if( offset != Type::OffsetBot ) {
1459       if( ta->const_oop() ) { // MethodData* or Method*
1460         offset = Type::OffsetBot;   // Flatten constant access into array body
1461         tj = ta = TypeAryPtr::make(ptr,ta->const_oop(),ta->ary(),ta->klass(),false,offset);
1462       } else if( offset == arrayOopDesc::length_offset_in_bytes() ) {
1463         // range is OK as-is.
1464         tj = ta = TypeAryPtr::RANGE;
1465       } else if( offset == oopDesc::klass_offset_in_bytes() ) {
1466         tj = TypeInstPtr::KLASS; // all klass loads look alike
1467         ta = TypeAryPtr::RANGE; // generic ignored junk
1468         ptr = TypePtr::BotPTR;
1469       } else if( offset == oopDesc::mark_offset_in_bytes() ) {
1470         tj = TypeInstPtr::MARK;
1471         ta = TypeAryPtr::RANGE; // generic ignored junk
1472         ptr = TypePtr::BotPTR;
1473 #if INCLUDE_SHENANDOAHGC
1474       } else if (offset == BrooksPointer::byte_offset() && UseShenandoahGC) {
1475         // Need to distinguish brooks ptr as is.
1476         tj = ta = TypeAryPtr::make(ptr,ta->ary(),ta->klass(),false,offset);
1477 #endif
1478       } else {                  // Random constant offset into array body
1479         offset = Type::OffsetBot;   // Flatten constant access into array body
1480         tj = ta = TypeAryPtr::make(ptr,ta->ary(),ta->klass(),false,offset);
1481       }
1482     }
1483     // Arrays of fixed size alias with arrays of unknown size.
1484     if (ta->size() != TypeInt::POS) {
1485       const TypeAry *tary = TypeAry::make(ta->elem(), TypeInt::POS);
1486       tj = ta = TypeAryPtr::make(ptr,ta->const_oop(),tary,ta->klass(),false,offset);
1487     }
1488     // Arrays of known objects become arrays of unknown objects.
1489     if (ta->elem()->isa_narrowoop() && ta->elem() != TypeNarrowOop::BOTTOM) {
1490       const TypeAry *tary = TypeAry::make(TypeNarrowOop::BOTTOM, ta->size());
1491       tj = ta = TypeAryPtr::make(ptr,ta->const_oop(),tary,NULL,false,offset);
1492     }
1493     if (ta->elem()->isa_oopptr() && ta->elem() != TypeInstPtr::BOTTOM) {
1494       const TypeAry *tary = TypeAry::make(TypeInstPtr::BOTTOM, ta->size());
1495       tj = ta = TypeAryPtr::make(ptr,ta->const_oop(),tary,NULL,false,offset);
1496     }
1497     // Arrays of bytes and of booleans both use 'bastore' and 'baload' so


1522         tj = to = TypeInstPtr::make(TypePtr::BotPTR,to->klass(),false,0,offset);
1523       }
1524     } else if( is_known_inst ) {
1525       tj = to; // Keep NotNull and klass_is_exact for instance type
1526     } else if( ptr == TypePtr::NotNull || to->klass_is_exact() ) {
1527       // During the 2nd round of IterGVN, NotNull castings are removed.
1528       // Make sure the Bottom and NotNull variants alias the same.
1529       // Also, make sure exact and non-exact variants alias the same.
1530       tj = to = TypeInstPtr::make(TypePtr::BotPTR,to->klass(),false,0,offset);
1531     }
1532     if (to->speculative() != NULL) {
1533       tj = to = TypeInstPtr::make(to->ptr(),to->klass(),to->klass_is_exact(),to->const_oop(),to->offset(), to->instance_id());
1534     }
1535     // Canonicalize the holder of this field
1536     if (offset >= 0 && offset < instanceOopDesc::base_offset_in_bytes()) {
1537       // First handle header references such as a LoadKlassNode, even if the
1538       // object's klass is unloaded at compile time (4965979).
1539       if (!is_known_inst) { // Do it only for non-instance types
1540         tj = to = TypeInstPtr::make(TypePtr::BotPTR, env()->Object_klass(), false, NULL, offset);
1541       }
1542     } else if (SHENANDOAHGC_ONLY((offset != BrooksPointer::byte_offset() || !UseShenandoahGC) &&) (offset < 0 || offset >= k->size_helper() * wordSize)) {
1543       // Static fields are in the space above the normal instance
1544       // fields in the java.lang.Class instance.
1545       if (to->klass() != ciEnv::current()->Class_klass()) {
1546         to = NULL;
1547         tj = TypeOopPtr::BOTTOM;
1548         offset = tj->offset();
1549       }


1550     } else {
1551       ciInstanceKlass *canonical_holder = k->get_canonical_holder(offset);
1552       if (!k->equals(canonical_holder) || tj->offset() != offset) {
1553         if( is_known_inst ) {
1554           tj = to = TypeInstPtr::make(to->ptr(), canonical_holder, true, NULL, offset, to->instance_id());
1555         } else {
1556           tj = to = TypeInstPtr::make(to->ptr(), canonical_holder, false, NULL, offset);
1557         }
1558       }
1559     }
1560   }
1561 
1562   // Klass pointers to object array klasses need some flattening
1563   const TypeKlassPtr *tk = tj->isa_klassptr();
1564   if( tk ) {
1565     // If we are referencing a field within a Klass, we need
1566     // to assume the worst case of an Object.  Both exact and
1567     // inexact types must flatten to the same alias class so
1568     // use NotNull as the PTR.
1569     if ( offset == Type::OffsetBot || (offset >= 0 && (size_t)offset < sizeof(Klass)) ) {




1453     }
1454   } else if( ta && _AliasLevel >= 2 ) {
1455     // For arrays indexed by constant indices, we flatten the alias
1456     // space to include all of the array body.  Only the header, klass
1457     // and array length can be accessed un-aliased.
1458     if( offset != Type::OffsetBot ) {
1459       if( ta->const_oop() ) { // MethodData* or Method*
1460         offset = Type::OffsetBot;   // Flatten constant access into array body
1461         tj = ta = TypeAryPtr::make(ptr,ta->const_oop(),ta->ary(),ta->klass(),false,offset);
1462       } else if( offset == arrayOopDesc::length_offset_in_bytes() ) {
1463         // range is OK as-is.
1464         tj = ta = TypeAryPtr::RANGE;
1465       } else if( offset == oopDesc::klass_offset_in_bytes() ) {
1466         tj = TypeInstPtr::KLASS; // all klass loads look alike
1467         ta = TypeAryPtr::RANGE; // generic ignored junk
1468         ptr = TypePtr::BotPTR;
1469       } else if( offset == oopDesc::mark_offset_in_bytes() ) {
1470         tj = TypeInstPtr::MARK;
1471         ta = TypeAryPtr::RANGE; // generic ignored junk
1472         ptr = TypePtr::BotPTR;
1473       } else if (BarrierSet::barrier_set()->barrier_set_c2()->flatten_gc_alias_type(tj)) {
1474         ta = tj->isa_aryptr();



1475       } else {                  // Random constant offset into array body
1476         offset = Type::OffsetBot;   // Flatten constant access into array body
1477         tj = ta = TypeAryPtr::make(ptr,ta->ary(),ta->klass(),false,offset);
1478       }
1479     }
1480     // Arrays of fixed size alias with arrays of unknown size.
1481     if (ta->size() != TypeInt::POS) {
1482       const TypeAry *tary = TypeAry::make(ta->elem(), TypeInt::POS);
1483       tj = ta = TypeAryPtr::make(ptr,ta->const_oop(),tary,ta->klass(),false,offset);
1484     }
1485     // Arrays of known objects become arrays of unknown objects.
1486     if (ta->elem()->isa_narrowoop() && ta->elem() != TypeNarrowOop::BOTTOM) {
1487       const TypeAry *tary = TypeAry::make(TypeNarrowOop::BOTTOM, ta->size());
1488       tj = ta = TypeAryPtr::make(ptr,ta->const_oop(),tary,NULL,false,offset);
1489     }
1490     if (ta->elem()->isa_oopptr() && ta->elem() != TypeInstPtr::BOTTOM) {
1491       const TypeAry *tary = TypeAry::make(TypeInstPtr::BOTTOM, ta->size());
1492       tj = ta = TypeAryPtr::make(ptr,ta->const_oop(),tary,NULL,false,offset);
1493     }
1494     // Arrays of bytes and of booleans both use 'bastore' and 'baload' so


1519         tj = to = TypeInstPtr::make(TypePtr::BotPTR,to->klass(),false,0,offset);
1520       }
1521     } else if( is_known_inst ) {
1522       tj = to; // Keep NotNull and klass_is_exact for instance type
1523     } else if( ptr == TypePtr::NotNull || to->klass_is_exact() ) {
1524       // During the 2nd round of IterGVN, NotNull castings are removed.
1525       // Make sure the Bottom and NotNull variants alias the same.
1526       // Also, make sure exact and non-exact variants alias the same.
1527       tj = to = TypeInstPtr::make(TypePtr::BotPTR,to->klass(),false,0,offset);
1528     }
1529     if (to->speculative() != NULL) {
1530       tj = to = TypeInstPtr::make(to->ptr(),to->klass(),to->klass_is_exact(),to->const_oop(),to->offset(), to->instance_id());
1531     }
1532     // Canonicalize the holder of this field
1533     if (offset >= 0 && offset < instanceOopDesc::base_offset_in_bytes()) {
1534       // First handle header references such as a LoadKlassNode, even if the
1535       // object's klass is unloaded at compile time (4965979).
1536       if (!is_known_inst) { // Do it only for non-instance types
1537         tj = to = TypeInstPtr::make(TypePtr::BotPTR, env()->Object_klass(), false, NULL, offset);
1538       }
1539     } else if (offset >= k->size_helper() * wordSize) {
1540       // Static fields are in the space above the normal instance
1541       // fields in the java.lang.Class instance.
1542       if (to->klass() != ciEnv::current()->Class_klass()) {
1543         to = NULL;
1544         tj = TypeOopPtr::BOTTOM;
1545         offset = tj->offset();
1546       }
1547     } else if (BarrierSet::barrier_set()->barrier_set_c2()->flatten_gc_alias_type(tj)) {
1548       to = tj->is_instptr();
1549     } else {
1550       ciInstanceKlass *canonical_holder = k->get_canonical_holder(offset);
1551       if (!k->equals(canonical_holder) || tj->offset() != offset) {
1552         if( is_known_inst ) {
1553           tj = to = TypeInstPtr::make(to->ptr(), canonical_holder, true, NULL, offset, to->instance_id());
1554         } else {
1555           tj = to = TypeInstPtr::make(to->ptr(), canonical_holder, false, NULL, offset);
1556         }
1557       }
1558     }
1559   }
1560 
1561   // Klass pointers to object array klasses need some flattening
1562   const TypeKlassPtr *tk = tj->isa_klassptr();
1563   if( tk ) {
1564     // If we are referencing a field within a Klass, we need
1565     // to assume the worst case of an Object.  Both exact and
1566     // inexact types must flatten to the same alias class so
1567     // use NotNull as the PTR.
1568     if ( offset == Type::OffsetBot || (offset >= 0 && (size_t)offset < sizeof(Klass)) ) {


< prev index next >