< prev index next >

src/share/vm/opto/compile.cpp

Print this page




1396 
1397   // Process weird unsafe references.
1398   if (offset == Type::OffsetBot && (tj->isa_instptr() /*|| tj->isa_klassptr()*/)) {
1399     assert(InlineUnsafeOps, "indeterminate pointers come only from unsafe ops");
1400     assert(!is_known_inst, "scalarizable allocation should not have unsafe references");
1401     tj = TypeOopPtr::BOTTOM;
1402     ptr = tj->ptr();
1403     offset = tj->offset();
1404   }
1405 
1406   // Array pointers need some flattening
1407   const TypeAryPtr *ta = tj->isa_aryptr();
1408   if (ta && ta->is_stable()) {
1409     // Erase stability property for alias analysis.
1410     tj = ta = ta->cast_to_stable(false);
1411   }
1412   if( ta && is_known_inst ) {
1413     if ( offset != Type::OffsetBot &&
1414          offset > arrayOopDesc::length_offset_in_bytes() ) {
1415       offset = Type::OffsetBot; // Flatten constant access into array body only
1416       tj = ta = TypeAryPtr::make(ptr, ta->ary(), ta->klass(), true, Type::Offset(offset), ta->_field_offset, ta->instance_id());
1417     }
1418   } else if( ta && _AliasLevel >= 2 ) {
1419     // For arrays indexed by constant indices, we flatten the alias
1420     // space to include all of the array body.  Only the header, klass
1421     // and array length can be accessed un-aliased.
1422     // For flattened value type array, each field has its own slice so
1423     // we must include the field offset.
1424     if( offset != Type::OffsetBot ) {
1425       if( ta->const_oop() ) { // MethodData* or Method*
1426         offset = Type::OffsetBot;   // Flatten constant access into array body
1427         tj = ta = TypeAryPtr::make(ptr,ta->const_oop(),ta->ary(),ta->klass(),false,Type::Offset(offset), ta->_field_offset);
1428       } else if( offset == arrayOopDesc::length_offset_in_bytes() ) {
1429         // range is OK as-is.
1430         tj = ta = TypeAryPtr::RANGE;
1431       } else if( offset == oopDesc::klass_offset_in_bytes() ) {
1432         tj = TypeInstPtr::KLASS; // all klass loads look alike
1433         ta = TypeAryPtr::RANGE; // generic ignored junk
1434         ptr = TypePtr::BotPTR;
1435       } else if( offset == oopDesc::mark_offset_in_bytes() ) {
1436         tj = TypeInstPtr::MARK;
1437         ta = TypeAryPtr::RANGE; // generic ignored junk
1438         ptr = TypePtr::BotPTR;
1439       } else {                  // Random constant offset into array body
1440         offset = Type::OffsetBot;   // Flatten constant access into array body
1441         tj = ta = TypeAryPtr::make(ptr,ta->ary(),ta->klass(),false,Type::Offset(offset), ta->_field_offset);
1442       }
1443     }
1444     // Arrays of fixed size alias with arrays of unknown size.
1445     if (ta->size() != TypeInt::POS) {
1446       const TypeAry *tary = TypeAry::make(ta->elem(), TypeInt::POS);
1447       tj = ta = TypeAryPtr::make(ptr,ta->const_oop(),tary,ta->klass(),false,Type::Offset(offset), ta->_field_offset);
1448     }
1449     // Arrays of known objects become arrays of unknown objects.
1450     if (ta->elem()->isa_narrowoop() && ta->elem() != TypeNarrowOop::BOTTOM) {
1451       const TypeAry *tary = TypeAry::make(TypeNarrowOop::BOTTOM, ta->size());
1452       tj = ta = TypeAryPtr::make(ptr,ta->const_oop(),tary,NULL,false,Type::Offset(offset), ta->_field_offset);
1453     }
1454     if (ta->elem()->isa_oopptr() && ta->elem() != TypeInstPtr::BOTTOM) {
1455       const TypeAry *tary = TypeAry::make(TypeInstPtr::BOTTOM, ta->size());
1456       tj = ta = TypeAryPtr::make(ptr,ta->const_oop(),tary,NULL,false,Type::Offset(offset), ta->_field_offset);
1457     }
1458     // Arrays of bytes and of booleans both use 'bastore' and 'baload' so
1459     // cannot be distinguished by bytecode alone.
1460     if (ta->elem() == TypeInt::BOOL) {
1461       const TypeAry *tary = TypeAry::make(TypeInt::BYTE, ta->size());
1462       ciKlass* aklass = ciTypeArrayKlass::make(T_BYTE);
1463       tj = ta = TypeAryPtr::make(ptr,ta->const_oop(),tary,aklass,false,Type::Offset(offset), ta->_field_offset);
1464     }
1465     // During the 2nd round of IterGVN, NotNull castings are removed.
1466     // Make sure the Bottom and NotNull variants alias the same.
1467     // Also, make sure exact and non-exact variants alias the same.
1468     if (ptr == TypePtr::NotNull || ta->klass_is_exact() || ta->speculative() != NULL) {
1469       tj = ta = TypeAryPtr::make(TypePtr::BotPTR,ta->ary(),ta->klass(),false,Type::Offset(offset), ta->_field_offset);
1470     }
1471   }
1472 
1473   // Oop pointers need some flattening
1474   const TypeInstPtr *to = tj->isa_instptr();
1475   if( to && _AliasLevel >= 2 && to != TypeOopPtr::BOTTOM ) {
1476     ciInstanceKlass *k = to->klass()->as_instance_klass();
1477     if( ptr == TypePtr::Constant ) {
1478       if (to->klass() != ciEnv::current()->Class_klass() ||
1479           offset < k->size_helper() * wordSize) {
1480         // No constant oop pointers (such as Strings); they alias with
1481         // unknown strings.
1482         assert(!is_known_inst, "not scalarizable allocation");
1483         tj = to = TypeInstPtr::make(TypePtr::BotPTR,to->klass(),false,0,Type::Offset(offset));
1484       }
1485     } else if( is_known_inst ) {
1486       tj = to; // Keep NotNull and klass_is_exact for instance type
1487     } else if( ptr == TypePtr::NotNull || to->klass_is_exact() ) {
1488       // During the 2nd round of IterGVN, NotNull castings are removed.
1489       // Make sure the Bottom and NotNull variants alias the same.




1396 
1397   // Process weird unsafe references.
1398   if (offset == Type::OffsetBot && (tj->isa_instptr() /*|| tj->isa_klassptr()*/)) {
1399     assert(InlineUnsafeOps, "indeterminate pointers come only from unsafe ops");
1400     assert(!is_known_inst, "scalarizable allocation should not have unsafe references");
1401     tj = TypeOopPtr::BOTTOM;
1402     ptr = tj->ptr();
1403     offset = tj->offset();
1404   }
1405 
1406   // Array pointers need some flattening
1407   const TypeAryPtr *ta = tj->isa_aryptr();
1408   if (ta && ta->is_stable()) {
1409     // Erase stability property for alias analysis.
1410     tj = ta = ta->cast_to_stable(false);
1411   }
1412   if( ta && is_known_inst ) {
1413     if ( offset != Type::OffsetBot &&
1414          offset > arrayOopDesc::length_offset_in_bytes() ) {
1415       offset = Type::OffsetBot; // Flatten constant access into array body only
1416       tj = ta = TypeAryPtr::make(ptr, ta->ary(), ta->klass(), true, Type::Offset(offset), ta->field_offset(), ta->instance_id());
1417     }
1418   } else if( ta && _AliasLevel >= 2 ) {
1419     // For arrays indexed by constant indices, we flatten the alias
1420     // space to include all of the array body.  Only the header, klass
1421     // and array length can be accessed un-aliased.
1422     // For flattened value type array, each field has its own slice so
1423     // we must include the field offset.
1424     if( offset != Type::OffsetBot ) {
1425       if( ta->const_oop() ) { // MethodData* or Method*
1426         offset = Type::OffsetBot;   // Flatten constant access into array body
1427         tj = ta = TypeAryPtr::make(ptr,ta->const_oop(),ta->ary(),ta->klass(),false,Type::Offset(offset), ta->field_offset());
1428       } else if( offset == arrayOopDesc::length_offset_in_bytes() ) {
1429         // range is OK as-is.
1430         tj = ta = TypeAryPtr::RANGE;
1431       } else if( offset == oopDesc::klass_offset_in_bytes() ) {
1432         tj = TypeInstPtr::KLASS; // all klass loads look alike
1433         ta = TypeAryPtr::RANGE; // generic ignored junk
1434         ptr = TypePtr::BotPTR;
1435       } else if( offset == oopDesc::mark_offset_in_bytes() ) {
1436         tj = TypeInstPtr::MARK;
1437         ta = TypeAryPtr::RANGE; // generic ignored junk
1438         ptr = TypePtr::BotPTR;
1439       } else {                  // Random constant offset into array body
1440         offset = Type::OffsetBot;   // Flatten constant access into array body
1441         tj = ta = TypeAryPtr::make(ptr,ta->ary(),ta->klass(),false,Type::Offset(offset), ta->field_offset());
1442       }
1443     }
1444     // Arrays of fixed size alias with arrays of unknown size.
1445     if (ta->size() != TypeInt::POS) {
1446       const TypeAry *tary = TypeAry::make(ta->elem(), TypeInt::POS);
1447       tj = ta = TypeAryPtr::make(ptr,ta->const_oop(),tary,ta->klass(),false,Type::Offset(offset), ta->field_offset());
1448     }
1449     // Arrays of known objects become arrays of unknown objects.
1450     if (ta->elem()->isa_narrowoop() && ta->elem() != TypeNarrowOop::BOTTOM) {
1451       const TypeAry *tary = TypeAry::make(TypeNarrowOop::BOTTOM, ta->size());
1452       tj = ta = TypeAryPtr::make(ptr,ta->const_oop(),tary,NULL,false,Type::Offset(offset), ta->field_offset());
1453     }
1454     if (ta->elem()->isa_oopptr() && ta->elem() != TypeInstPtr::BOTTOM) {
1455       const TypeAry *tary = TypeAry::make(TypeInstPtr::BOTTOM, ta->size());
1456       tj = ta = TypeAryPtr::make(ptr,ta->const_oop(),tary,NULL,false,Type::Offset(offset), ta->field_offset());
1457     }
1458     // Arrays of bytes and of booleans both use 'bastore' and 'baload' so
1459     // cannot be distinguished by bytecode alone.
1460     if (ta->elem() == TypeInt::BOOL) {
1461       const TypeAry *tary = TypeAry::make(TypeInt::BYTE, ta->size());
1462       ciKlass* aklass = ciTypeArrayKlass::make(T_BYTE);
1463       tj = ta = TypeAryPtr::make(ptr,ta->const_oop(),tary,aklass,false,Type::Offset(offset), ta->field_offset());
1464     }
1465     // During the 2nd round of IterGVN, NotNull castings are removed.
1466     // Make sure the Bottom and NotNull variants alias the same.
1467     // Also, make sure exact and non-exact variants alias the same.
1468     if (ptr == TypePtr::NotNull || ta->klass_is_exact() || ta->speculative() != NULL) {
1469       tj = ta = TypeAryPtr::make(TypePtr::BotPTR,ta->ary(),ta->klass(),false,Type::Offset(offset), ta->field_offset());
1470     }
1471   }
1472 
1473   // Oop pointers need some flattening
1474   const TypeInstPtr *to = tj->isa_instptr();
1475   if( to && _AliasLevel >= 2 && to != TypeOopPtr::BOTTOM ) {
1476     ciInstanceKlass *k = to->klass()->as_instance_klass();
1477     if( ptr == TypePtr::Constant ) {
1478       if (to->klass() != ciEnv::current()->Class_klass() ||
1479           offset < k->size_helper() * wordSize) {
1480         // No constant oop pointers (such as Strings); they alias with
1481         // unknown strings.
1482         assert(!is_known_inst, "not scalarizable allocation");
1483         tj = to = TypeInstPtr::make(TypePtr::BotPTR,to->klass(),false,0,Type::Offset(offset));
1484       }
1485     } else if( is_known_inst ) {
1486       tj = to; // Keep NotNull and klass_is_exact for instance type
1487     } else if( ptr == TypePtr::NotNull || to->klass_is_exact() ) {
1488       // During the 2nd round of IterGVN, NotNull castings are removed.
1489       // Make sure the Bottom and NotNull variants alias the same.


< prev index next >