1200 } |
1200 } |
1201 |
1201 |
1202 // Oop pointers need some flattening |
1202 // Oop pointers need some flattening |
1203 const TypeInstPtr *to = tj->isa_instptr(); |
1203 const TypeInstPtr *to = tj->isa_instptr(); |
1204 if( to && _AliasLevel >= 2 && to != TypeOopPtr::BOTTOM ) { |
1204 if( to && _AliasLevel >= 2 && to != TypeOopPtr::BOTTOM ) { |
|
1205 ciInstanceKlass *k = to->klass()->as_instance_klass(); |
1205 if( ptr == TypePtr::Constant ) { |
1206 if( ptr == TypePtr::Constant ) { |
1206 // No constant oop pointers (such as Strings); they alias with |
1207 if (to->klass() != ciEnv::current()->Class_klass() || |
1207 // unknown strings. |
1208 offset < k->size_helper() * wordSize) { |
1208 assert(!is_known_inst, "not scalarizable allocation"); |
1209 // No constant oop pointers (such as Strings); they alias with |
1209 tj = to = TypeInstPtr::make(TypePtr::BotPTR,to->klass(),false,0,offset); |
1210 // unknown strings. |
|
1211 assert(!is_known_inst, "not scalarizable allocation"); |
|
1212 tj = to = TypeInstPtr::make(TypePtr::BotPTR,to->klass(),false,0,offset); |
|
1213 } |
1210 } else if( is_known_inst ) { |
1214 } else if( is_known_inst ) { |
1211 tj = to; // Keep NotNull and klass_is_exact for instance type |
1215 tj = to; // Keep NotNull and klass_is_exact for instance type |
1212 } else if( ptr == TypePtr::NotNull || to->klass_is_exact() ) { |
1216 } else if( ptr == TypePtr::NotNull || to->klass_is_exact() ) { |
1213 // During the 2nd round of IterGVN, NotNull castings are removed. |
1217 // During the 2nd round of IterGVN, NotNull castings are removed. |
1214 // Make sure the Bottom and NotNull variants alias the same. |
1218 // Make sure the Bottom and NotNull variants alias the same. |
1215 // Also, make sure exact and non-exact variants alias the same. |
1219 // Also, make sure exact and non-exact variants alias the same. |
1216 tj = to = TypeInstPtr::make(TypePtr::BotPTR,to->klass(),false,0,offset); |
1220 tj = to = TypeInstPtr::make(TypePtr::BotPTR,to->klass(),false,0,offset); |
1217 } |
1221 } |
1218 // Canonicalize the holder of this field |
1222 // Canonicalize the holder of this field |
1219 ciInstanceKlass *k = to->klass()->as_instance_klass(); |
|
1220 if (offset >= 0 && offset < instanceOopDesc::base_offset_in_bytes()) { |
1223 if (offset >= 0 && offset < instanceOopDesc::base_offset_in_bytes()) { |
1221 // First handle header references such as a LoadKlassNode, even if the |
1224 // First handle header references such as a LoadKlassNode, even if the |
1222 // object's klass is unloaded at compile time (4965979). |
1225 // object's klass is unloaded at compile time (4965979). |
1223 if (!is_known_inst) { // Do it only for non-instance types |
1226 if (!is_known_inst) { // Do it only for non-instance types |
1224 tj = to = TypeInstPtr::make(TypePtr::BotPTR, env()->Object_klass(), false, NULL, offset); |
1227 tj = to = TypeInstPtr::make(TypePtr::BotPTR, env()->Object_klass(), false, NULL, offset); |
1225 } |
1228 } |
1226 } else if (offset < 0 || offset >= k->size_helper() * wordSize) { |
1229 } else if (offset < 0 || offset >= k->size_helper() * wordSize) { |
1227 to = NULL; |
1230 // Static fields are in the space above the normal instance |
1228 tj = TypeOopPtr::BOTTOM; |
1231 // fields in the java.lang.Class instance. |
1229 offset = tj->offset(); |
1232 if (to->klass() != ciEnv::current()->Class_klass()) { |
|
1233 to = NULL; |
|
1234 tj = TypeOopPtr::BOTTOM; |
|
1235 offset = tj->offset(); |
|
1236 } |
1230 } else { |
1237 } else { |
1231 ciInstanceKlass *canonical_holder = k->get_canonical_holder(offset); |
1238 ciInstanceKlass *canonical_holder = k->get_canonical_holder(offset); |
1232 if (!k->equals(canonical_holder) || tj->offset() != offset) { |
1239 if (!k->equals(canonical_holder) || tj->offset() != offset) { |
1233 if( is_known_inst ) { |
1240 if( is_known_inst ) { |
1234 tj = to = TypeInstPtr::make(to->ptr(), canonical_holder, true, NULL, offset, to->instance_id()); |
1241 tj = to = TypeInstPtr::make(to->ptr(), canonical_holder, true, NULL, offset, to->instance_id()); |
1462 } |
1469 } |
1463 // %%% (We would like to finalize JavaThread::threadObj_offset(), |
1470 // %%% (We would like to finalize JavaThread::threadObj_offset(), |
1464 // but the base pointer type is not distinctive enough to identify |
1471 // but the base pointer type is not distinctive enough to identify |
1465 // references into JavaThread.) |
1472 // references into JavaThread.) |
1466 |
1473 |
1467 // Check for final instance fields. |
1474 // Check for final fields. |
1468 const TypeInstPtr* tinst = flat->isa_instptr(); |
1475 const TypeInstPtr* tinst = flat->isa_instptr(); |
1469 if (tinst && tinst->offset() >= instanceOopDesc::base_offset_in_bytes()) { |
1476 if (tinst && tinst->offset() >= instanceOopDesc::base_offset_in_bytes()) { |
1470 ciInstanceKlass *k = tinst->klass()->as_instance_klass(); |
1477 ciField* field; |
1471 ciField* field = k->get_field_by_offset(tinst->offset(), false); |
1478 if (tinst->const_oop() != NULL && |
|
1479 tinst->klass() == ciEnv::current()->Class_klass() && |
|
1480 tinst->offset() >= (tinst->klass()->as_instance_klass()->size_helper() * wordSize)) { |
|
1481 // static field |
|
1482 ciInstanceKlass* k = tinst->const_oop()->as_instance()->java_lang_Class_klass()->as_instance_klass(); |
|
1483 field = k->get_field_by_offset(tinst->offset(), true); |
|
1484 } else { |
|
1485 ciInstanceKlass *k = tinst->klass()->as_instance_klass(); |
|
1486 field = k->get_field_by_offset(tinst->offset(), false); |
|
1487 } |
|
1488 assert(field == NULL || |
|
1489 original_field == NULL || |
|
1490 (field->holder() == original_field->holder() && |
|
1491 field->offset() == original_field->offset() && |
|
1492 field->is_static() == original_field->is_static()), "wrong field?"); |
1472 // Set field() and is_rewritable() attributes. |
1493 // Set field() and is_rewritable() attributes. |
1473 if (field != NULL) alias_type(idx)->set_field(field); |
1494 if (field != NULL) alias_type(idx)->set_field(field); |
1474 } |
|
1475 const TypeKlassPtr* tklass = flat->isa_klassptr(); |
|
1476 // Check for final static fields. |
|
1477 if (tklass && tklass->klass()->is_instance_klass()) { |
|
1478 ciInstanceKlass *k = tklass->klass()->as_instance_klass(); |
|
1479 ciField* field = k->get_field_by_offset(tklass->offset(), true); |
|
1480 // Set field() and is_rewritable() attributes. |
|
1481 if (field != NULL) alias_type(idx)->set_field(field); |
|
1482 } |
1495 } |
1483 } |
1496 } |
1484 |
1497 |
1485 // Fill the cache for next time. |
1498 // Fill the cache for next time. |
1486 ace->_adr_type = adr_type; |
1499 ace->_adr_type = adr_type; |
1520 |
1533 |
1521 // Handle special cases. |
1534 // Handle special cases. |
1522 if (adr_type == NULL) return true; |
1535 if (adr_type == NULL) return true; |
1523 if (adr_type == TypePtr::BOTTOM) return true; |
1536 if (adr_type == TypePtr::BOTTOM) return true; |
1524 |
1537 |
1525 return find_alias_type(adr_type, true) != NULL; |
1538 return find_alias_type(adr_type, true, NULL) != NULL; |
1526 } |
1539 } |
1527 |
1540 |
1528 //-----------------------------must_alias-------------------------------------- |
1541 //-----------------------------must_alias-------------------------------------- |
1529 // True if all values of the given address type are in the given alias category. |
1542 // True if all values of the given address type are in the given alias category. |
1530 bool Compile::must_alias(const TypePtr* adr_type, int alias_idx) { |
1543 bool Compile::must_alias(const TypePtr* adr_type, int alias_idx) { |