Mercurial > hg > truffle
comparison src/share/vm/opto/compile.cpp @ 247:02a35ad4adf8
6723160: Nightly failure: Error: meet not symmetric
Summary: Add missing _instance_id settings and other EA fixes.
Reviewed-by: rasbold
author | kvn |
---|---|
date | Wed, 16 Jul 2008 16:04:39 -0700 |
parents | 4a4c365f777d |
children | b0fe4deeb9fb |
comparison
equal
deleted
inserted
replaced
246:9b66e6287f4a | 247:02a35ad4adf8 |
---|---|
997 //------------------------------flatten_alias_type----------------------------- | 997 //------------------------------flatten_alias_type----------------------------- |
998 const TypePtr *Compile::flatten_alias_type( const TypePtr *tj ) const { | 998 const TypePtr *Compile::flatten_alias_type( const TypePtr *tj ) const { |
999 int offset = tj->offset(); | 999 int offset = tj->offset(); |
1000 TypePtr::PTR ptr = tj->ptr(); | 1000 TypePtr::PTR ptr = tj->ptr(); |
1001 | 1001 |
1002 // Known instance (scalarizable allocation) alias only with itself. | |
1003 bool is_known_inst = tj->isa_oopptr() != NULL && | |
1004 tj->is_oopptr()->is_known_instance(); | |
1005 | |
1002 // Process weird unsafe references. | 1006 // Process weird unsafe references. |
1003 if (offset == Type::OffsetBot && (tj->isa_instptr() /*|| tj->isa_klassptr()*/)) { | 1007 if (offset == Type::OffsetBot && (tj->isa_instptr() /*|| tj->isa_klassptr()*/)) { |
1004 assert(InlineUnsafeOps, "indeterminate pointers come only from unsafe ops"); | 1008 assert(InlineUnsafeOps, "indeterminate pointers come only from unsafe ops"); |
1009 assert(!is_known_inst, "scalarizable allocation should not have unsafe references"); | |
1005 tj = TypeOopPtr::BOTTOM; | 1010 tj = TypeOopPtr::BOTTOM; |
1006 ptr = tj->ptr(); | 1011 ptr = tj->ptr(); |
1007 offset = tj->offset(); | 1012 offset = tj->offset(); |
1008 } | 1013 } |
1009 | 1014 |
1010 // Array pointers need some flattening | 1015 // Array pointers need some flattening |
1011 const TypeAryPtr *ta = tj->isa_aryptr(); | 1016 const TypeAryPtr *ta = tj->isa_aryptr(); |
1012 if( ta && _AliasLevel >= 2 ) { | 1017 if( ta && is_known_inst ) { |
1018 if ( offset != Type::OffsetBot && | |
1019 offset > arrayOopDesc::length_offset_in_bytes() ) { | |
1020 offset = Type::OffsetBot; // Flatten constant access into array body only | |
1021 tj = ta = TypeAryPtr::make(ptr, ta->ary(), ta->klass(), true, offset, ta->instance_id()); | |
1022 } | |
1023 } else if( ta && _AliasLevel >= 2 ) { | |
1013 // For arrays indexed by constant indices, we flatten the alias | 1024 // For arrays indexed by constant indices, we flatten the alias |
1014 // space to include all of the array body. Only the header, klass | 1025 // space to include all of the array body. Only the header, klass |
1015 // and array length can be accessed un-aliased. | 1026 // and array length can be accessed un-aliased. |
1016 if( offset != Type::OffsetBot ) { | 1027 if( offset != Type::OffsetBot ) { |
1017 if( ta->const_oop() ) { // methodDataOop or methodOop | 1028 if( ta->const_oop() ) { // methodDataOop or methodOop |
1018 offset = Type::OffsetBot; // Flatten constant access into array body | 1029 offset = Type::OffsetBot; // Flatten constant access into array body |
1019 tj = ta = TypeAryPtr::make(ptr,ta->const_oop(),ta->ary(),ta->klass(),false,Type::OffsetBot, ta->instance_id()); | 1030 tj = ta = TypeAryPtr::make(ptr,ta->const_oop(),ta->ary(),ta->klass(),false,offset); |
1020 } else if( offset == arrayOopDesc::length_offset_in_bytes() ) { | 1031 } else if( offset == arrayOopDesc::length_offset_in_bytes() ) { |
1021 // range is OK as-is. | 1032 // range is OK as-is. |
1022 tj = ta = TypeAryPtr::RANGE; | 1033 tj = ta = TypeAryPtr::RANGE; |
1023 } else if( offset == oopDesc::klass_offset_in_bytes() ) { | 1034 } else if( offset == oopDesc::klass_offset_in_bytes() ) { |
1024 tj = TypeInstPtr::KLASS; // all klass loads look alike | 1035 tj = TypeInstPtr::KLASS; // all klass loads look alike |
1028 tj = TypeInstPtr::MARK; | 1039 tj = TypeInstPtr::MARK; |
1029 ta = TypeAryPtr::RANGE; // generic ignored junk | 1040 ta = TypeAryPtr::RANGE; // generic ignored junk |
1030 ptr = TypePtr::BotPTR; | 1041 ptr = TypePtr::BotPTR; |
1031 } else { // Random constant offset into array body | 1042 } else { // Random constant offset into array body |
1032 offset = Type::OffsetBot; // Flatten constant access into array body | 1043 offset = Type::OffsetBot; // Flatten constant access into array body |
1033 tj = ta = TypeAryPtr::make(ptr,ta->ary(),ta->klass(),false,Type::OffsetBot, ta->instance_id()); | 1044 tj = ta = TypeAryPtr::make(ptr,ta->ary(),ta->klass(),false,offset); |
1034 } | 1045 } |
1035 } | 1046 } |
1036 // Arrays of fixed size alias with arrays of unknown size. | 1047 // Arrays of fixed size alias with arrays of unknown size. |
1037 if (ta->size() != TypeInt::POS) { | 1048 if (ta->size() != TypeInt::POS) { |
1038 const TypeAry *tary = TypeAry::make(ta->elem(), TypeInt::POS); | 1049 const TypeAry *tary = TypeAry::make(ta->elem(), TypeInt::POS); |
1039 tj = ta = TypeAryPtr::make(ptr,ta->const_oop(),tary,ta->klass(),false,offset, ta->instance_id()); | 1050 tj = ta = TypeAryPtr::make(ptr,ta->const_oop(),tary,ta->klass(),false,offset); |
1040 } | 1051 } |
1041 // Arrays of known objects become arrays of unknown objects. | 1052 // Arrays of known objects become arrays of unknown objects. |
1042 if (ta->elem()->isa_narrowoop() && ta->elem() != TypeNarrowOop::BOTTOM) { | 1053 if (ta->elem()->isa_narrowoop() && ta->elem() != TypeNarrowOop::BOTTOM) { |
1043 const TypeAry *tary = TypeAry::make(TypeNarrowOop::BOTTOM, ta->size()); | 1054 const TypeAry *tary = TypeAry::make(TypeNarrowOop::BOTTOM, ta->size()); |
1044 tj = ta = TypeAryPtr::make(ptr,ta->const_oop(),tary,NULL,false,offset, ta->instance_id()); | 1055 tj = ta = TypeAryPtr::make(ptr,ta->const_oop(),tary,NULL,false,offset); |
1045 } | 1056 } |
1046 if (ta->elem()->isa_oopptr() && ta->elem() != TypeInstPtr::BOTTOM) { | 1057 if (ta->elem()->isa_oopptr() && ta->elem() != TypeInstPtr::BOTTOM) { |
1047 const TypeAry *tary = TypeAry::make(TypeInstPtr::BOTTOM, ta->size()); | 1058 const TypeAry *tary = TypeAry::make(TypeInstPtr::BOTTOM, ta->size()); |
1048 tj = ta = TypeAryPtr::make(ptr,ta->const_oop(),tary,NULL,false,offset, ta->instance_id()); | 1059 tj = ta = TypeAryPtr::make(ptr,ta->const_oop(),tary,NULL,false,offset); |
1049 } | 1060 } |
1050 // Arrays of bytes and of booleans both use 'bastore' and 'baload' so | 1061 // Arrays of bytes and of booleans both use 'bastore' and 'baload' so |
1051 // cannot be distinguished by bytecode alone. | 1062 // cannot be distinguished by bytecode alone. |
1052 if (ta->elem() == TypeInt::BOOL) { | 1063 if (ta->elem() == TypeInt::BOOL) { |
1053 const TypeAry *tary = TypeAry::make(TypeInt::BYTE, ta->size()); | 1064 const TypeAry *tary = TypeAry::make(TypeInt::BYTE, ta->size()); |
1054 ciKlass* aklass = ciTypeArrayKlass::make(T_BYTE); | 1065 ciKlass* aklass = ciTypeArrayKlass::make(T_BYTE); |
1055 tj = ta = TypeAryPtr::make(ptr,ta->const_oop(),tary,aklass,false,offset, ta->instance_id()); | 1066 tj = ta = TypeAryPtr::make(ptr,ta->const_oop(),tary,aklass,false,offset); |
1056 } | 1067 } |
1057 // During the 2nd round of IterGVN, NotNull castings are removed. | 1068 // During the 2nd round of IterGVN, NotNull castings are removed. |
1058 // Make sure the Bottom and NotNull variants alias the same. | 1069 // Make sure the Bottom and NotNull variants alias the same. |
1059 // Also, make sure exact and non-exact variants alias the same. | 1070 // Also, make sure exact and non-exact variants alias the same. |
1060 if( ptr == TypePtr::NotNull || ta->klass_is_exact() ) { | 1071 if( ptr == TypePtr::NotNull || ta->klass_is_exact() ) { |
1070 const TypeInstPtr *to = tj->isa_instptr(); | 1081 const TypeInstPtr *to = tj->isa_instptr(); |
1071 if( to && _AliasLevel >= 2 && to != TypeOopPtr::BOTTOM ) { | 1082 if( to && _AliasLevel >= 2 && to != TypeOopPtr::BOTTOM ) { |
1072 if( ptr == TypePtr::Constant ) { | 1083 if( ptr == TypePtr::Constant ) { |
1073 // No constant oop pointers (such as Strings); they alias with | 1084 // No constant oop pointers (such as Strings); they alias with |
1074 // unknown strings. | 1085 // unknown strings. |
1086 assert(!is_known_inst, "not scalarizable allocation"); | |
1075 tj = to = TypeInstPtr::make(TypePtr::BotPTR,to->klass(),false,0,offset); | 1087 tj = to = TypeInstPtr::make(TypePtr::BotPTR,to->klass(),false,0,offset); |
1076 } else if( to->is_known_instance_field() ) { | 1088 } else if( is_known_inst ) { |
1077 tj = to; // Keep NotNull and klass_is_exact for instance type | 1089 tj = to; // Keep NotNull and klass_is_exact for instance type |
1078 } else if( ptr == TypePtr::NotNull || to->klass_is_exact() ) { | 1090 } else if( ptr == TypePtr::NotNull || to->klass_is_exact() ) { |
1079 // During the 2nd round of IterGVN, NotNull castings are removed. | 1091 // During the 2nd round of IterGVN, NotNull castings are removed. |
1080 // Make sure the Bottom and NotNull variants alias the same. | 1092 // Make sure the Bottom and NotNull variants alias the same. |
1081 // Also, make sure exact and non-exact variants alias the same. | 1093 // Also, make sure exact and non-exact variants alias the same. |
1082 tj = to = TypeInstPtr::make(TypePtr::BotPTR,to->klass(),false,0,offset, to->instance_id()); | 1094 tj = to = TypeInstPtr::make(TypePtr::BotPTR,to->klass(),false,0,offset); |
1083 } | 1095 } |
1084 // Canonicalize the holder of this field | 1096 // Canonicalize the holder of this field |
1085 ciInstanceKlass *k = to->klass()->as_instance_klass(); | 1097 ciInstanceKlass *k = to->klass()->as_instance_klass(); |
1086 if (offset >= 0 && offset < instanceOopDesc::base_offset_in_bytes()) { | 1098 if (offset >= 0 && offset < instanceOopDesc::base_offset_in_bytes()) { |
1087 // First handle header references such as a LoadKlassNode, even if the | 1099 // First handle header references such as a LoadKlassNode, even if the |
1088 // object's klass is unloaded at compile time (4965979). | 1100 // object's klass is unloaded at compile time (4965979). |
1089 tj = to = TypeInstPtr::make(TypePtr::BotPTR, env()->Object_klass(), false, NULL, offset, to->instance_id()); | 1101 if (!is_known_inst) { // Do it only for non-instance types |
1102 tj = to = TypeInstPtr::make(TypePtr::BotPTR, env()->Object_klass(), false, NULL, offset); | |
1103 } | |
1090 } else if (offset < 0 || offset >= k->size_helper() * wordSize) { | 1104 } else if (offset < 0 || offset >= k->size_helper() * wordSize) { |
1091 to = NULL; | 1105 to = NULL; |
1092 tj = TypeOopPtr::BOTTOM; | 1106 tj = TypeOopPtr::BOTTOM; |
1093 offset = tj->offset(); | 1107 offset = tj->offset(); |
1094 } else { | 1108 } else { |
1095 ciInstanceKlass *canonical_holder = k->get_canonical_holder(offset); | 1109 ciInstanceKlass *canonical_holder = k->get_canonical_holder(offset); |
1096 if (!k->equals(canonical_holder) || tj->offset() != offset) { | 1110 if (!k->equals(canonical_holder) || tj->offset() != offset) { |
1097 tj = to = TypeInstPtr::make(to->ptr(), canonical_holder, false, NULL, offset, to->instance_id()); | 1111 if( is_known_inst ) { |
1112 tj = to = TypeInstPtr::make(to->ptr(), canonical_holder, true, NULL, offset, to->instance_id()); | |
1113 } else { | |
1114 tj = to = TypeInstPtr::make(to->ptr(), canonical_holder, false, NULL, offset); | |
1115 } | |
1098 } | 1116 } |
1099 } | 1117 } |
1100 } | 1118 } |
1101 | 1119 |
1102 // Klass pointers to object array klasses need some flattening | 1120 // Klass pointers to object array klasses need some flattening |
1278 #ifdef ASSERT | 1296 #ifdef ASSERT |
1279 assert(flat == flatten_alias_type(flat), "idempotent"); | 1297 assert(flat == flatten_alias_type(flat), "idempotent"); |
1280 assert(flat != TypePtr::BOTTOM, "cannot alias-analyze an untyped ptr"); | 1298 assert(flat != TypePtr::BOTTOM, "cannot alias-analyze an untyped ptr"); |
1281 if (flat->isa_oopptr() && !flat->isa_klassptr()) { | 1299 if (flat->isa_oopptr() && !flat->isa_klassptr()) { |
1282 const TypeOopPtr* foop = flat->is_oopptr(); | 1300 const TypeOopPtr* foop = flat->is_oopptr(); |
1283 const TypePtr* xoop = foop->cast_to_exactness(!foop->klass_is_exact())->is_ptr(); | 1301 // Scalarizable allocations have exact klass always. |
1302 bool exact = !foop->klass_is_exact() || foop->is_known_instance(); | |
1303 const TypePtr* xoop = foop->cast_to_exactness(exact)->is_ptr(); | |
1284 assert(foop == flatten_alias_type(xoop), "exactness must not affect alias type"); | 1304 assert(foop == flatten_alias_type(xoop), "exactness must not affect alias type"); |
1285 } | 1305 } |
1286 assert(flat == flatten_alias_type(flat), "exact bit doesn't matter"); | 1306 assert(flat == flatten_alias_type(flat), "exact bit doesn't matter"); |
1287 #endif | 1307 #endif |
1288 | 1308 |