1.1 --- a/src/share/vm/opto/type.cpp Fri Aug 31 16:39:35 2012 -0700 1.2 +++ b/src/share/vm/opto/type.cpp Sat Sep 01 13:25:18 2012 -0400 1.3 @@ -23,6 +23,7 @@ 1.4 */ 1.5 1.6 #include "precompiled.hpp" 1.7 +#include "ci/ciMethodData.hpp" 1.8 #include "ci/ciTypeFlow.hpp" 1.9 #include "classfile/symbolTable.hpp" 1.10 #include "classfile/systemDictionary.hpp" 1.11 @@ -33,7 +34,6 @@ 1.12 #include "memory/resourceArea.hpp" 1.13 #include "oops/instanceKlass.hpp" 1.14 #include "oops/instanceMirrorKlass.hpp" 1.15 -#include "oops/klassKlass.hpp" 1.16 #include "oops/objArrayKlass.hpp" 1.17 #include "oops/typeArrayKlass.hpp" 1.18 #include "opto/matcher.hpp" 1.19 @@ -49,40 +49,46 @@ 1.20 Dict* Type::_shared_type_dict = NULL; 1.21 1.22 // Array which maps compiler types to Basic Types 1.23 -const BasicType Type::_basic_type[Type::lastype] = { 1.24 - T_ILLEGAL, // Bad 1.25 - T_ILLEGAL, // Control 1.26 - T_VOID, // Top 1.27 - T_INT, // Int 1.28 - T_LONG, // Long 1.29 - T_VOID, // Half 1.30 - T_NARROWOOP, // NarrowOop 1.31 - 1.32 - T_ILLEGAL, // Tuple 1.33 - T_ARRAY, // Array 1.34 - T_ILLEGAL, // VectorS 1.35 - T_ILLEGAL, // VectorD 1.36 - T_ILLEGAL, // VectorX 1.37 - T_ILLEGAL, // VectorY 1.38 - 1.39 - T_ADDRESS, // AnyPtr // shows up in factory methods for NULL_PTR 1.40 - T_ADDRESS, // RawPtr 1.41 - T_OBJECT, // OopPtr 1.42 - T_OBJECT, // InstPtr 1.43 - T_OBJECT, // AryPtr 1.44 - T_OBJECT, // KlassPtr 1.45 - 1.46 - T_OBJECT, // Function 1.47 - T_ILLEGAL, // Abio 1.48 - T_ADDRESS, // Return_Address 1.49 - T_ILLEGAL, // Memory 1.50 - T_FLOAT, // FloatTop 1.51 - T_FLOAT, // FloatCon 1.52 - T_FLOAT, // FloatBot 1.53 - T_DOUBLE, // DoubleTop 1.54 - T_DOUBLE, // DoubleCon 1.55 - T_DOUBLE, // DoubleBot 1.56 - T_ILLEGAL, // Bottom 1.57 +Type::TypeInfo Type::_type_info[Type::lastype] = { 1.58 + { Bad, T_ILLEGAL, "bad", false, Node::NotAMachineReg, relocInfo::none }, // Bad 1.59 + { Control, T_ILLEGAL, "control", false, 0, relocInfo::none }, // Control 1.60 + { Bottom, T_VOID, "top", false, 0, relocInfo::none }, // Top 1.61 + { Bad, T_INT, "int:", false, Op_RegI, relocInfo::none }, // Int 1.62 + { Bad, T_LONG, "long:", false, Op_RegL, relocInfo::none }, // Long 1.63 + { Half, T_VOID, "half", false, 0, relocInfo::none }, // Half 1.64 + { Bad, T_NARROWOOP, "narrowoop:", false, Op_RegN, relocInfo::none }, // NarrowOop 1.65 + { Bad, T_ILLEGAL, "tuple:", false, Node::NotAMachineReg, relocInfo::none }, // Tuple 1.66 + { Bad, T_ARRAY, "array:", false, Node::NotAMachineReg, relocInfo::none }, // Array 1.67 + 1.68 +#if defined(IA32) || defined(AMD64) 1.69 + { Bad, T_ILLEGAL, "vectors:", false, Op_VecS, relocInfo::none }, // VectorS 1.70 + { Bad, T_ILLEGAL, "vectord:", false, Op_VecD, relocInfo::none }, // VectorD 1.71 + { Bad, T_ILLEGAL, "vectorx:", false, Op_VecX, relocInfo::none }, // VectorX 1.72 + { Bad, T_ILLEGAL, "vectory:", false, Op_VecY, relocInfo::none }, // VectorY 1.73 +#else 1.74 + { Bad, T_ILLEGAL, "vectors:", false, 0, relocInfo::none }, // VectorS 1.75 + { Bad, T_ILLEGAL, "vectord:", false, Op_RegD, relocInfo::none }, // VectorD 1.76 + { Bad, T_ILLEGAL, "vectorx:", false, 0, relocInfo::none }, // VectorX 1.77 + { Bad, T_ILLEGAL, "vectory:", false, 0, relocInfo::none }, // VectorY 1.78 +#endif // IA32 || AMD64 1.79 + { Bad, T_ADDRESS, "anyptr:", false, Op_RegP, relocInfo::none }, // AnyPtr 1.80 + { Bad, T_ADDRESS, "rawptr:", false, Op_RegP, relocInfo::none }, // RawPtr 1.81 + { Bad, T_OBJECT, "oop:", true, Op_RegP, relocInfo::oop_type }, // OopPtr 1.82 + { Bad, T_OBJECT, "inst:", true, Op_RegP, relocInfo::oop_type }, // InstPtr 1.83 + { Bad, T_OBJECT, "ary:", true, Op_RegP, relocInfo::oop_type }, // AryPtr 1.84 + { Bad, T_METADATA, "metadata:", false, Op_RegP, relocInfo::metadata_type }, // MetadataPtr 1.85 + { Bad, T_METADATA, "klass:", false, Op_RegP, relocInfo::metadata_type }, // KlassPtr 1.86 + { Bad, T_OBJECT, "func", false, 0, relocInfo::none }, // Function 1.87 + { Abio, T_ILLEGAL, "abIO", false, 0, relocInfo::none }, // Abio 1.88 + { Return_Address, T_ADDRESS, "return_address",false, Op_RegP, relocInfo::none }, // Return_Address 1.89 + { Memory, T_ILLEGAL, "memory", false, 0, relocInfo::none }, // Memory 1.90 + { FloatBot, T_FLOAT, "float_top", false, Op_RegF, relocInfo::none }, // FloatTop 1.91 + { FloatCon, T_FLOAT, "ftcon:", false, Op_RegF, relocInfo::none }, // FloatCon 1.92 + { FloatTop, T_FLOAT, "float", false, Op_RegF, relocInfo::none }, // FloatBot 1.93 + { DoubleBot, T_DOUBLE, "double_top", false, Op_RegD, relocInfo::none }, // DoubleTop 1.94 + { DoubleCon, T_DOUBLE, "dblcon:", false, Op_RegD, relocInfo::none }, // DoubleCon 1.95 + { DoubleTop, T_DOUBLE, "double", false, Op_RegD, relocInfo::none }, // DoubleBot 1.96 + { Top, T_ILLEGAL, "bottom", false, 0, relocInfo::none } // Bottom 1.97 }; 1.98 1.99 // Map ideal registers (machine types) to ideal types 1.100 @@ -321,6 +327,8 @@ 1.101 false, 0, oopDesc::klass_offset_in_bytes()); 1.102 TypeOopPtr::BOTTOM = TypeOopPtr::make(TypePtr::BotPTR, OffsetBot, TypeOopPtr::InstanceBot); 1.103 1.104 + TypeMetadataPtr::BOTTOM = TypeMetadataPtr::make(TypePtr::BotPTR, NULL, OffsetBot); 1.105 + 1.106 TypeNarrowOop::NULL_PTR = TypeNarrowOop::make( TypePtr::NULL_PTR ); 1.107 TypeNarrowOop::BOTTOM = TypeNarrowOop::make( TypeInstPtr::BOTTOM ); 1.108 1.109 @@ -340,6 +348,7 @@ 1.110 1.111 #ifdef _LP64 1.112 if (UseCompressedOops) { 1.113 + assert(TypeAryPtr::NARROWOOPS->is_ptr_to_narrowoop(), "array of narrow oops must be ptr to narrow oop"); 1.114 TypeAryPtr::OOPS = TypeAryPtr::NARROWOOPS; 1.115 } else 1.116 #endif 1.117 @@ -372,7 +381,7 @@ 1.118 TypeKlassPtr::OBJECT_OR_NULL = TypeKlassPtr::make( TypePtr::BotPTR, current->env()->Object_klass(), 0 ); 1.119 1.120 const Type **fi2c = TypeTuple::fields(2); 1.121 - fi2c[TypeFunc::Parms+0] = TypeInstPtr::BOTTOM; // methodOop 1.122 + fi2c[TypeFunc::Parms+0] = TypeInstPtr::BOTTOM; // Method* 1.123 fi2c[TypeFunc::Parms+1] = TypeRawPtr::BOTTOM; // argument pointer 1.124 TypeTuple::START_I2C = TypeTuple::make(TypeFunc::Parms+2, fi2c); 1.125 1.126 @@ -461,10 +470,6 @@ 1.127 Type* t = (Type*)i._value; 1.128 tdic->Insert(t,t); // New Type, insert into Type table 1.129 } 1.130 - 1.131 -#ifdef ASSERT 1.132 - verify_lastype(); 1.133 -#endif 1.134 } 1.135 1.136 //------------------------------hashcons--------------------------------------- 1.137 @@ -620,6 +625,7 @@ 1.138 case InstPtr: 1.139 return t->xmeet(this); 1.140 1.141 + case MetadataPtr: 1.142 case KlassPtr: 1.143 return t->xmeet(this); 1.144 1.145 @@ -700,6 +706,8 @@ 1.146 Bad, // OopPtr - handled in v-call 1.147 Bad, // InstPtr - handled in v-call 1.148 Bad, // AryPtr - handled in v-call 1.149 + 1.150 + Bad, // MetadataPtr - handled in v-call 1.151 Bad, // KlassPtr - handled in v-call 1.152 1.153 Bad, // Function - handled in v-call 1.154 @@ -717,8 +725,8 @@ 1.155 1.156 const Type *Type::xdual() const { 1.157 // Note: the base() accessor asserts the sanity of _base. 1.158 - assert(dual_type[base()] != Bad, "implement with v-call"); 1.159 - return new Type(dual_type[_base]); 1.160 + assert(_type_info[base()].dual_type != Bad, "implement with v-call"); 1.161 + return new Type(_type_info[_base].dual_type); 1.162 } 1.163 1.164 //------------------------------has_memory------------------------------------- 1.165 @@ -738,7 +746,7 @@ 1.166 #ifndef PRODUCT 1.167 //------------------------------dump2------------------------------------------ 1.168 void Type::dump2( Dict &d, uint depth, outputStream *st ) const { 1.169 - st->print(msg[_base]); 1.170 + st->print(_type_info[_base].msg); 1.171 } 1.172 1.173 //------------------------------dump------------------------------------------- 1.174 @@ -750,17 +758,6 @@ 1.175 st->print(" [narrow]"); 1.176 } 1.177 } 1.178 - 1.179 -//------------------------------data------------------------------------------- 1.180 -const char * const Type::msg[Type::lastype] = { 1.181 - "bad","control","top","int:","long:","half", "narrowoop:", 1.182 - "tuple:", "array:", "vectors:", "vectord:", "vectorx:", "vectory:", 1.183 - "anyptr:", "rawptr:", "java:", "inst:", "aryptr:", "klass:", 1.184 - "func", "abIO", "return_address", "memory", 1.185 - "float_top", "ftcon:", "float", 1.186 - "double_top", "dblcon:", "double", 1.187 - "bottom" 1.188 -}; 1.189 #endif 1.190 1.191 //------------------------------singleton-------------------------------------- 1.192 @@ -813,31 +810,6 @@ 1.193 ShouldNotReachHere(); 1.194 } 1.195 1.196 -//------------------------------isa_oop_ptr------------------------------------ 1.197 -// Return true if type is an oop pointer type. False for raw pointers. 1.198 -static char isa_oop_ptr_tbl[Type::lastype] = { 1.199 - 0,0,0,0,0,0,0/*narrowoop*/,0/*tuple*/, 0/*array*/, 0, 0, 0, 0/*vector*/, 1.200 - 0/*anyptr*/,0/*rawptr*/,1/*OopPtr*/,1/*InstPtr*/,1/*AryPtr*/,1/*KlassPtr*/, 1.201 - 0/*func*/,0,0/*return_address*/,0, 1.202 - /*floats*/0,0,0, /*doubles*/0,0,0, 1.203 - 0 1.204 -}; 1.205 -bool Type::isa_oop_ptr() const { 1.206 - return isa_oop_ptr_tbl[_base] != 0; 1.207 -} 1.208 - 1.209 -//------------------------------dump_stats------------------------------------- 1.210 -// // Check that arrays match type enum 1.211 -#ifndef PRODUCT 1.212 -void Type::verify_lastype() { 1.213 - // Check that arrays match enumeration 1.214 - assert( Type::dual_type [Type::lastype - 1] == Type::Top, "did not update array"); 1.215 - assert( strcmp(Type::msg [Type::lastype - 1],"bottom") == 0, "did not update array"); 1.216 - // assert( PhiNode::tbl [Type::lastype - 1] == NULL, "did not update array"); 1.217 - assert( Matcher::base2reg[Type::lastype - 1] == 0, "did not update array"); 1.218 - assert( isa_oop_ptr_tbl [Type::lastype - 1] == (char)0, "did not update array"); 1.219 -} 1.220 -#endif 1.221 1.222 //============================================================================= 1.223 // Convenience common pre-built types. 1.224 @@ -862,8 +834,9 @@ 1.225 case RawPtr: // reuses local variables 1.226 case OopPtr: 1.227 case InstPtr: 1.228 + case AryPtr: 1.229 + case MetadataPtr: 1.230 case KlassPtr: 1.231 - case AryPtr: 1.232 case NarrowOop: 1.233 case Int: 1.234 case Long: 1.235 @@ -978,8 +951,9 @@ 1.236 case RawPtr: // reuses local variables 1.237 case OopPtr: 1.238 case InstPtr: 1.239 + case AryPtr: 1.240 + case MetadataPtr: 1.241 case KlassPtr: 1.242 - case AryPtr: 1.243 case NarrowOop: 1.244 case Int: 1.245 case Long: 1.246 @@ -1131,8 +1105,9 @@ 1.247 case RawPtr: // reuses local variables 1.248 case OopPtr: 1.249 case InstPtr: 1.250 + case AryPtr: 1.251 + case MetadataPtr: 1.252 case KlassPtr: 1.253 - case AryPtr: 1.254 case NarrowOop: 1.255 case Long: 1.256 case FloatTop: 1.257 @@ -1387,8 +1362,9 @@ 1.258 case RawPtr: // reuses local variables 1.259 case OopPtr: 1.260 case InstPtr: 1.261 + case AryPtr: 1.262 + case MetadataPtr: 1.263 case KlassPtr: 1.264 - case AryPtr: 1.265 case NarrowOop: 1.266 case Int: 1.267 case FloatTop: 1.268 @@ -2132,8 +2108,9 @@ 1.269 case RawPtr: // For these, flip the call around to cut down 1.270 case OopPtr: 1.271 case InstPtr: // on the cases I have to handle. 1.272 + case AryPtr: 1.273 + case MetadataPtr: 1.274 case KlassPtr: 1.275 - case AryPtr: 1.276 return t->xmeet(this); // Call in reverse direction 1.277 default: // All else is a mistake 1.278 typerr(t); 1.279 @@ -2288,8 +2265,9 @@ 1.280 1.281 case OopPtr: 1.282 case InstPtr: 1.283 + case AryPtr: 1.284 + case MetadataPtr: 1.285 case KlassPtr: 1.286 - case AryPtr: 1.287 return TypePtr::BOTTOM; // Oop meet raw is not well defined 1.288 default: // All else is a mistake 1.289 typerr(t); 1.290 @@ -2375,11 +2353,12 @@ 1.291 _instance_id(instance_id) { 1.292 #ifdef _LP64 1.293 if (UseCompressedOops && _offset != 0) { 1.294 - if (klass() == NULL) { 1.295 + if (_offset == oopDesc::klass_offset_in_bytes()) { 1.296 + _is_ptr_to_narrowoop = UseCompressedKlassPointers; 1.297 + } else if (klass() == NULL) { 1.298 + // Array with unknown body type 1.299 assert(this->isa_aryptr(), "only arrays without klass"); 1.300 _is_ptr_to_narrowoop = true; 1.301 - } else if (_offset == oopDesc::klass_offset_in_bytes()) { 1.302 - _is_ptr_to_narrowoop = true; 1.303 } else if (this->isa_aryptr()) { 1.304 _is_ptr_to_narrowoop = (klass()->is_obj_array_klass() && 1.305 _offset != arrayOopDesc::length_offset_in_bytes()); 1.306 @@ -2399,7 +2378,7 @@ 1.307 _offset == java_lang_Class::array_klass_offset_in_bytes())) { 1.308 // Special hidden fields from the Class. 1.309 assert(this->isa_instptr(), "must be an instance ptr."); 1.310 - _is_ptr_to_narrowoop = true; 1.311 + _is_ptr_to_narrowoop = false; 1.312 } else if (klass() == ciEnv::current()->Class_klass() && 1.313 _offset >= instanceMirrorKlass::offset_of_static_fields()) { 1.314 // Static fields 1.315 @@ -2423,7 +2402,6 @@ 1.316 _is_ptr_to_narrowoop = true; 1.317 } else { 1.318 // Type for the copy start in LibraryCallKit::inline_native_clone(). 1.319 - assert(!klass_is_exact(), "only non-exact klass"); 1.320 _is_ptr_to_narrowoop = true; 1.321 } 1.322 } 1.323 @@ -2437,7 +2415,7 @@ 1.324 const TypeOopPtr *TypeOopPtr::make(PTR ptr, 1.325 int offset, int instance_id) { 1.326 assert(ptr != Constant, "no constant generic pointers"); 1.327 - ciKlass* k = ciKlassKlass::make(); 1.328 + ciKlass* k = Compile::current()->env()->Object_klass(); 1.329 bool xk = false; 1.330 ciObject* o = NULL; 1.331 return (TypeOopPtr*)(new TypeOopPtr(OopPtr, ptr, k, xk, o, offset, instance_id))->hashcons(); 1.332 @@ -2472,7 +2450,7 @@ 1.333 const TypeKlassPtr* TypeOopPtr::as_klass_type() const { 1.334 ciKlass* k = klass(); 1.335 bool xk = klass_is_exact(); 1.336 - if (k == NULL || !k->is_java_klass()) 1.337 + if (k == NULL) 1.338 return TypeKlassPtr::OBJECT; 1.339 else 1.340 return TypeKlassPtr::make(xk? Constant: NotNull, k, 0); 1.341 @@ -2506,6 +2484,8 @@ 1.342 typerr(t); 1.343 1.344 case RawPtr: 1.345 + case MetadataPtr: 1.346 + case KlassPtr: 1.347 return TypePtr::BOTTOM; // Oop meet raw is not well defined 1.348 1.349 case AnyPtr: { 1.350 @@ -2536,7 +2516,6 @@ 1.351 } 1.352 1.353 case InstPtr: // For these, flip the call around to cut down 1.354 - case KlassPtr: // on the cases I have to handle. 1.355 case AryPtr: 1.356 return t->xmeet(this); // Call in reverse direction 1.357 1.358 @@ -2548,7 +2527,7 @@ 1.359 //------------------------------xdual------------------------------------------ 1.360 // Dual of a pure heap pointer. No relevant klass or oop information. 1.361 const Type *TypeOopPtr::xdual() const { 1.362 - assert(klass() == ciKlassKlass::make(), "no klasses here"); 1.363 + assert(klass() == Compile::current()->env()->Object_klass(), "no klasses here"); 1.364 assert(const_oop() == NULL, "no constants here"); 1.365 return new TypeOopPtr(_base, dual_ptr(), klass(), klass_is_exact(), const_oop(), dual_offset(), dual_instance_id() ); 1.366 } 1.367 @@ -2556,7 +2535,6 @@ 1.368 //--------------------------make_from_klass_common----------------------------- 1.369 // Computes the element-type given a klass. 1.370 const TypeOopPtr* TypeOopPtr::make_from_klass_common(ciKlass *klass, bool klass_change, bool try_for_exact) { 1.371 - assert(klass->is_java_klass(), "must be java language klass"); 1.372 if (klass->is_instance_klass()) { 1.373 Compile* C = Compile::current(); 1.374 Dependencies* deps = C->dependencies(); 1.375 @@ -2613,24 +2591,6 @@ 1.376 //------------------------------make_from_constant----------------------------- 1.377 // Make a java pointer from an oop constant 1.378 const TypeOopPtr* TypeOopPtr::make_from_constant(ciObject* o, bool require_constant) { 1.379 - if (o->is_method_data() || o->is_method()) { 1.380 - // Treat much like a typeArray of bytes, like below, but fake the type... 1.381 - const BasicType bt = T_BYTE; 1.382 - const Type* etype = get_const_basic_type(bt); 1.383 - const TypeAry* arr0 = TypeAry::make(etype, TypeInt::POS); 1.384 - ciKlass* klass = ciArrayKlass::make(ciType::make(bt)); 1.385 - assert(o->can_be_constant(), "should be tenured"); 1.386 - return TypeAryPtr::make(TypePtr::Constant, o, arr0, klass, true, 0); 1.387 - } else if (o->is_cpcache()) { 1.388 - // Treat much like a objArray, like below, but fake the type... 1.389 - const BasicType bt = T_OBJECT; 1.390 - const Type* etype = get_const_basic_type(bt); 1.391 - const TypeAry* arr0 = TypeAry::make(etype, TypeInt::POS); 1.392 - ciKlass* klass = ciArrayKlass::make(ciType::make(bt)); 1.393 - assert(o->can_be_constant(), "should be tenured"); 1.394 - return TypeAryPtr::make(TypePtr::Constant, o, arr0, klass, true, 0); 1.395 - } else { 1.396 - assert(o->is_java_object(), "must be java language object"); 1.397 assert(!o->is_null_object(), "null object not yet handled here."); 1.398 ciKlass* klass = o->klass(); 1.399 if (klass->is_instance_klass()) { 1.400 @@ -2643,7 +2603,8 @@ 1.401 return TypeInstPtr::make(o); 1.402 } else if (klass->is_obj_array_klass()) { 1.403 // Element is an object array. Recursively call ourself. 1.404 - const Type *etype = make_from_klass_raw(klass->as_obj_array_klass()->element_klass()); 1.405 + const Type *etype = 1.406 + TypeOopPtr::make_from_klass_raw(klass->as_obj_array_klass()->element_klass()); 1.407 const TypeAry* arr0 = TypeAry::make(etype, TypeInt::make(o->as_array()->length())); 1.408 // We used to pass NotNull in here, asserting that the sub-arrays 1.409 // are all not-null. This is not true in generally, as code can 1.410 @@ -2653,10 +2614,12 @@ 1.411 } else if (!o->should_be_constant()) { 1.412 return TypeAryPtr::make(TypePtr::NotNull, arr0, klass, true, 0); 1.413 } 1.414 - return TypeAryPtr::make(TypePtr::Constant, o, arr0, klass, true, 0); 1.415 + const TypeAryPtr* arr = TypeAryPtr::make(TypePtr::Constant, o, arr0, klass, true, 0); 1.416 + return arr; 1.417 } else if (klass->is_type_array_klass()) { 1.418 // Element is an typeArray 1.419 - const Type* etype = get_const_basic_type(klass->as_type_array_klass()->element_type()); 1.420 + const Type* etype = 1.421 + (Type*)get_const_basic_type(klass->as_type_array_klass()->element_type()); 1.422 const TypeAry* arr0 = TypeAry::make(etype, TypeInt::make(o->as_array()->length())); 1.423 // We used to pass NotNull in here, asserting that the array pointer 1.424 // is not-null. That was not true in general. 1.425 @@ -2665,8 +2628,8 @@ 1.426 } else if (!o->should_be_constant()) { 1.427 return TypeAryPtr::make(TypePtr::NotNull, arr0, klass, true, 0); 1.428 } 1.429 - return TypeAryPtr::make(TypePtr::Constant, o, arr0, klass, true, 0); 1.430 - } 1.431 + const TypeAryPtr* arr = TypeAryPtr::make(TypePtr::Constant, o, arr0, klass, true, 0); 1.432 + return arr; 1.433 } 1.434 1.435 fatal("unhandled object type"); 1.436 @@ -2845,8 +2808,7 @@ 1.437 ciObject* o, 1.438 int offset, 1.439 int instance_id) { 1.440 - assert( !k->is_loaded() || k->is_instance_klass() || 1.441 - k->is_method_klass(), "Must be for instance or method"); 1.442 + assert( !k->is_loaded() || k->is_instance_klass(), "Must be for instance"); 1.443 // Either const_oop() is NULL or else ptr is Constant 1.444 assert( (!o && ptr != Constant) || (o && ptr == Constant), 1.445 "constant pointers must have a value supplied" ); 1.446 @@ -2971,6 +2933,8 @@ 1.447 default: // All else is a mistake 1.448 typerr(t); 1.449 1.450 + case MetadataPtr: 1.451 + case KlassPtr: 1.452 case RawPtr: return TypePtr::BOTTOM; 1.453 1.454 case AryPtr: { // All arrays inherit from Object class 1.455 @@ -3237,9 +3201,6 @@ 1.456 return make( ptr, k, false, NULL, off, instance_id ); 1.457 } // End of case InstPtr 1.458 1.459 - case KlassPtr: 1.460 - return TypeInstPtr::BOTTOM; 1.461 - 1.462 } // End of switch 1.463 return this; // Return the double constant 1.464 } 1.465 @@ -3516,6 +3477,8 @@ 1.466 } 1.467 } 1.468 1.469 + case MetadataPtr: 1.470 + case KlassPtr: 1.471 case RawPtr: return TypePtr::BOTTOM; 1.472 1.473 case AryPtr: { // Meeting 2 references? 1.474 @@ -3634,10 +3597,6 @@ 1.475 default: typerr(t); 1.476 } 1.477 } 1.478 - 1.479 - case KlassPtr: 1.480 - return TypeInstPtr::BOTTOM; 1.481 - 1.482 } 1.483 return this; // Lint noise 1.484 } 1.485 @@ -3768,8 +3727,9 @@ 1.486 case RawPtr: 1.487 case OopPtr: 1.488 case InstPtr: 1.489 + case AryPtr: 1.490 + case MetadataPtr: 1.491 case KlassPtr: 1.492 - case AryPtr: 1.493 1.494 case Bottom: // Ye Olde Default 1.495 return Type::BOTTOM; 1.496 @@ -3829,6 +3789,183 @@ 1.497 #endif 1.498 1.499 1.500 + 1.501 +//------------------------------eq--------------------------------------------- 1.502 +// Structural equality check for Type representations 1.503 +bool TypeMetadataPtr::eq( const Type *t ) const { 1.504 + const TypeMetadataPtr *a = (const TypeMetadataPtr*)t; 1.505 + ciMetadata* one = metadata(); 1.506 + ciMetadata* two = a->metadata(); 1.507 + if (one == NULL || two == NULL) { 1.508 + return (one == two) && TypePtr::eq(t); 1.509 + } else { 1.510 + return one->equals(two) && TypePtr::eq(t); 1.511 + } 1.512 +} 1.513 + 1.514 +//------------------------------hash------------------------------------------- 1.515 +// Type-specific hashing function. 1.516 +int TypeMetadataPtr::hash(void) const { 1.517 + return 1.518 + (metadata() ? metadata()->hash() : 0) + 1.519 + TypePtr::hash(); 1.520 +} 1.521 + 1.522 +//------------------------------singleton-------------------------------------- 1.523 +// TRUE if Type is a singleton type, FALSE otherwise. Singletons are simple 1.524 +// constants 1.525 +bool TypeMetadataPtr::singleton(void) const { 1.526 + // detune optimizer to not generate constant metadta + constant offset as a constant! 1.527 + // TopPTR, Null, AnyNull, Constant are all singletons 1.528 + return (_offset == 0) && !below_centerline(_ptr); 1.529 +} 1.530 + 1.531 +//------------------------------add_offset------------------------------------- 1.532 +const TypePtr *TypeMetadataPtr::add_offset( intptr_t offset ) const { 1.533 + return make( _ptr, _metadata, xadd_offset(offset)); 1.534 +} 1.535 + 1.536 +//-----------------------------filter------------------------------------------ 1.537 +// Do not allow interface-vs.-noninterface joins to collapse to top. 1.538 +const Type *TypeMetadataPtr::filter( const Type *kills ) const { 1.539 + const TypeMetadataPtr* ft = join(kills)->isa_metadataptr(); 1.540 + if (ft == NULL || ft->empty()) 1.541 + return Type::TOP; // Canonical empty value 1.542 + return ft; 1.543 +} 1.544 + 1.545 + //------------------------------get_con---------------------------------------- 1.546 +intptr_t TypeMetadataPtr::get_con() const { 1.547 + assert( _ptr == Null || _ptr == Constant, "" ); 1.548 + assert( _offset >= 0, "" ); 1.549 + 1.550 + if (_offset != 0) { 1.551 + // After being ported to the compiler interface, the compiler no longer 1.552 + // directly manipulates the addresses of oops. Rather, it only has a pointer 1.553 + // to a handle at compile time. This handle is embedded in the generated 1.554 + // code and dereferenced at the time the nmethod is made. Until that time, 1.555 + // it is not reasonable to do arithmetic with the addresses of oops (we don't 1.556 + // have access to the addresses!). This does not seem to currently happen, 1.557 + // but this assertion here is to help prevent its occurence. 1.558 + tty->print_cr("Found oop constant with non-zero offset"); 1.559 + ShouldNotReachHere(); 1.560 + } 1.561 + 1.562 + return (intptr_t)metadata()->constant_encoding(); 1.563 +} 1.564 + 1.565 +//------------------------------cast_to_ptr_type------------------------------- 1.566 +const Type *TypeMetadataPtr::cast_to_ptr_type(PTR ptr) const { 1.567 + if( ptr == _ptr ) return this; 1.568 + return make(ptr, metadata(), _offset); 1.569 +} 1.570 + 1.571 +//------------------------------meet------------------------------------------- 1.572 +// Compute the MEET of two types. It returns a new Type object. 1.573 +const Type *TypeMetadataPtr::xmeet( const Type *t ) const { 1.574 + // Perform a fast test for common case; meeting the same types together. 1.575 + if( this == t ) return this; // Meeting same type-rep? 1.576 + 1.577 + // Current "this->_base" is OopPtr 1.578 + switch (t->base()) { // switch on original type 1.579 + 1.580 + case Int: // Mixing ints & oops happens when javac 1.581 + case Long: // reuses local variables 1.582 + case FloatTop: 1.583 + case FloatCon: 1.584 + case FloatBot: 1.585 + case DoubleTop: 1.586 + case DoubleCon: 1.587 + case DoubleBot: 1.588 + case NarrowOop: 1.589 + case Bottom: // Ye Olde Default 1.590 + return Type::BOTTOM; 1.591 + case Top: 1.592 + return this; 1.593 + 1.594 + default: // All else is a mistake 1.595 + typerr(t); 1.596 + 1.597 + case AnyPtr: { 1.598 + // Found an AnyPtr type vs self-OopPtr type 1.599 + const TypePtr *tp = t->is_ptr(); 1.600 + int offset = meet_offset(tp->offset()); 1.601 + PTR ptr = meet_ptr(tp->ptr()); 1.602 + switch (tp->ptr()) { 1.603 + case Null: 1.604 + if (ptr == Null) return TypePtr::make(AnyPtr, ptr, offset); 1.605 + // else fall through: 1.606 + case TopPTR: 1.607 + case AnyNull: { 1.608 + return make(ptr, NULL, offset); 1.609 + } 1.610 + case BotPTR: 1.611 + case NotNull: 1.612 + return TypePtr::make(AnyPtr, ptr, offset); 1.613 + default: typerr(t); 1.614 + } 1.615 + } 1.616 + 1.617 + case RawPtr: 1.618 + case KlassPtr: 1.619 + case OopPtr: 1.620 + case InstPtr: 1.621 + case AryPtr: 1.622 + return TypePtr::BOTTOM; // Oop meet raw is not well defined 1.623 + 1.624 + case MetadataPtr: 1.625 + ShouldNotReachHere(); 1.626 + break; 1.627 + 1.628 + } // End of switch 1.629 + return this; // Return the double constant 1.630 +} 1.631 + 1.632 + 1.633 +//------------------------------xdual------------------------------------------ 1.634 +// Dual of a pure metadata pointer. 1.635 +const Type *TypeMetadataPtr::xdual() const { 1.636 + return new TypeMetadataPtr(dual_ptr(), metadata(), dual_offset()); 1.637 +} 1.638 + 1.639 +//------------------------------dump2------------------------------------------ 1.640 +#ifndef PRODUCT 1.641 +void TypeMetadataPtr::dump2( Dict &d, uint depth, outputStream *st ) const { 1.642 + st->print("metadataptr:%s", ptr_msg[_ptr]); 1.643 + if( metadata() ) st->print(INTPTR_FORMAT, metadata()); 1.644 + switch( _offset ) { 1.645 + case OffsetTop: st->print("+top"); break; 1.646 + case OffsetBot: st->print("+any"); break; 1.647 + case 0: break; 1.648 + default: st->print("+%d",_offset); break; 1.649 + } 1.650 +} 1.651 +#endif 1.652 + 1.653 + 1.654 +//============================================================================= 1.655 +// Convenience common pre-built type. 1.656 +const TypeMetadataPtr *TypeMetadataPtr::BOTTOM; 1.657 + 1.658 +TypeMetadataPtr::TypeMetadataPtr(PTR ptr, ciMetadata* metadata, int offset): 1.659 + TypePtr(MetadataPtr, ptr, offset), _metadata(metadata) { 1.660 +} 1.661 + 1.662 +const TypeMetadataPtr* TypeMetadataPtr::make(ciMethod* m) { 1.663 + return make(Constant, m, 0); 1.664 +} 1.665 +const TypeMetadataPtr* TypeMetadataPtr::make(ciMethodData* m) { 1.666 + return make(Constant, m, 0); 1.667 +} 1.668 + 1.669 +//------------------------------make------------------------------------------- 1.670 +// Create a meta data constant 1.671 +const TypeMetadataPtr *TypeMetadataPtr::make(PTR ptr, ciMetadata* m, int offset) { 1.672 + assert(m == NULL || !m->is_klass(), "wrong type"); 1.673 + return (TypeMetadataPtr*)(new TypeMetadataPtr(ptr, m, offset))->hashcons(); 1.674 +} 1.675 + 1.676 + 1.677 //============================================================================= 1.678 // Convenience common pre-built types. 1.679 1.680 @@ -3836,17 +3973,16 @@ 1.681 const TypeKlassPtr *TypeKlassPtr::OBJECT; 1.682 const TypeKlassPtr *TypeKlassPtr::OBJECT_OR_NULL; 1.683 1.684 -//------------------------------TypeKlasPtr------------------------------------ 1.685 +//------------------------------TypeKlassPtr----------------------------------- 1.686 TypeKlassPtr::TypeKlassPtr( PTR ptr, ciKlass* klass, int offset ) 1.687 - : TypeOopPtr(KlassPtr, ptr, klass, (ptr==Constant), (ptr==Constant ? klass : NULL), offset, 0) { 1.688 + : TypePtr(KlassPtr, ptr, offset), _klass(klass), _klass_is_exact(ptr == Constant) { 1.689 } 1.690 1.691 //------------------------------make------------------------------------------- 1.692 // ptr to klass 'k', if Constant, or possibly to a sub-klass if not a Constant 1.693 const TypeKlassPtr *TypeKlassPtr::make( PTR ptr, ciKlass* k, int offset ) { 1.694 assert( k != NULL, "Expect a non-NULL klass"); 1.695 - assert(k->is_instance_klass() || k->is_array_klass() || 1.696 - k->is_method_klass(), "Incorrect type of klass oop"); 1.697 + assert(k->is_instance_klass() || k->is_array_klass(), "Incorrect type of klass oop"); 1.698 TypeKlassPtr *r = 1.699 (TypeKlassPtr*)(new TypeKlassPtr(ptr, k, offset))->hashcons(); 1.700 1.701 @@ -3859,15 +3995,23 @@ 1.702 const TypeKlassPtr *p = t->is_klassptr(); 1.703 return 1.704 klass()->equals(p->klass()) && 1.705 - TypeOopPtr::eq(p); 1.706 + TypePtr::eq(p); 1.707 } 1.708 1.709 //------------------------------hash------------------------------------------- 1.710 // Type-specific hashing function. 1.711 int TypeKlassPtr::hash(void) const { 1.712 - return klass()->hash() + TypeOopPtr::hash(); 1.713 -} 1.714 - 1.715 + return klass()->hash() + TypePtr::hash(); 1.716 +} 1.717 + 1.718 +//------------------------------singleton-------------------------------------- 1.719 +// TRUE if Type is a singleton type, FALSE otherwise. Singletons are simple 1.720 +// constants 1.721 +bool TypeKlassPtr::singleton(void) const { 1.722 + // detune optimizer to not generate constant klass + constant offset as a constant! 1.723 + // TopPTR, Null, AnyNull, Constant are all singletons 1.724 + return (_offset == 0) && !below_centerline(_ptr); 1.725 +} 1.726 1.727 //----------------------compute_klass------------------------------------------ 1.728 // Compute the defining klass for this class 1.729 @@ -4018,24 +4162,6 @@ 1.730 default: // All else is a mistake 1.731 typerr(t); 1.732 1.733 - case RawPtr: return TypePtr::BOTTOM; 1.734 - 1.735 - case OopPtr: { // Meeting to OopPtrs 1.736 - // Found a OopPtr type vs self-KlassPtr type 1.737 - const TypePtr *tp = t->is_oopptr(); 1.738 - int offset = meet_offset(tp->offset()); 1.739 - PTR ptr = meet_ptr(tp->ptr()); 1.740 - switch (tp->ptr()) { 1.741 - case TopPTR: 1.742 - case AnyNull: 1.743 - return make(ptr, klass(), offset); 1.744 - case BotPTR: 1.745 - case NotNull: 1.746 - return TypePtr::make(AnyPtr, ptr, offset); 1.747 - default: typerr(t); 1.748 - } 1.749 - } 1.750 - 1.751 case AnyPtr: { // Meeting to AnyPtrs 1.752 // Found an AnyPtr type vs self-KlassPtr type 1.753 const TypePtr *tp = t->is_ptr(); 1.754 @@ -4055,9 +4181,12 @@ 1.755 } 1.756 } 1.757 1.758 + case RawPtr: 1.759 + case MetadataPtr: 1.760 + case OopPtr: 1.761 case AryPtr: // Meet with AryPtr 1.762 case InstPtr: // Meet with InstPtr 1.763 - return TypeInstPtr::BOTTOM; 1.764 + return TypePtr::BOTTOM; 1.765 1.766 // 1.767 // A-top } 1.768 @@ -4112,17 +4241,11 @@ 1.769 // If the klasses are equal, the constants may still differ. Fall to 1.770 // NotNull if they do (neither constant is NULL; that is a special case 1.771 // handled elsewhere). 1.772 - ciObject* o = NULL; // Assume not constant when done 1.773 - ciObject* this_oop = const_oop(); 1.774 - ciObject* tkls_oop = tkls->const_oop(); 1.775 if( ptr == Constant ) { 1.776 - if (this_oop != NULL && tkls_oop != NULL && 1.777 - this_oop->equals(tkls_oop) ) 1.778 - o = this_oop; 1.779 - else if (above_centerline(this->ptr())) 1.780 - o = tkls_oop; 1.781 - else if (above_centerline(tkls->ptr())) 1.782 - o = this_oop; 1.783 + if (this->_ptr == Constant && tkls->_ptr == Constant && 1.784 + this->klass()->equals(tkls->klass())); 1.785 + else if (above_centerline(this->ptr())); 1.786 + else if (above_centerline(tkls->ptr())); 1.787 else 1.788 ptr = NotNull; 1.789 } 1.790 @@ -4148,6 +4271,25 @@ 1.791 return new TypeKlassPtr( dual_ptr(), klass(), dual_offset() ); 1.792 } 1.793 1.794 +//------------------------------get_con---------------------------------------- 1.795 +intptr_t TypeKlassPtr::get_con() const { 1.796 + assert( _ptr == Null || _ptr == Constant, "" ); 1.797 + assert( _offset >= 0, "" ); 1.798 + 1.799 + if (_offset != 0) { 1.800 + // After being ported to the compiler interface, the compiler no longer 1.801 + // directly manipulates the addresses of oops. Rather, it only has a pointer 1.802 + // to a handle at compile time. This handle is embedded in the generated 1.803 + // code and dereferenced at the time the nmethod is made. Until that time, 1.804 + // it is not reasonable to do arithmetic with the addresses of oops (we don't 1.805 + // have access to the addresses!). This does not seem to currently happen, 1.806 + // but this assertion here is to help prevent its occurence. 1.807 + tty->print_cr("Found oop constant with non-zero offset"); 1.808 + ShouldNotReachHere(); 1.809 + } 1.810 + 1.811 + return (intptr_t)klass()->constant_encoding(); 1.812 +} 1.813 //------------------------------dump2------------------------------------------ 1.814 // Dump Klass Type 1.815 #ifndef PRODUCT 1.816 @@ -4280,35 +4422,6 @@ 1.817 } 1.818 st->print(" )"); 1.819 } 1.820 - 1.821 -//------------------------------print_flattened-------------------------------- 1.822 -// Print a 'flattened' signature 1.823 -static const char * const flat_type_msg[Type::lastype] = { 1.824 - "bad","control","top","int","long","_", "narrowoop", 1.825 - "tuple:", "array:", "vectors:", "vectord:", "vectorx:", "vectory:", 1.826 - "ptr", "rawptr", "ptr", "ptr", "ptr", "ptr", 1.827 - "func", "abIO", "return_address", "mem", 1.828 - "float_top", "ftcon:", "flt", 1.829 - "double_top", "dblcon:", "dbl", 1.830 - "bottom" 1.831 -}; 1.832 - 1.833 -void TypeFunc::print_flattened() const { 1.834 - if( _range->_cnt <= Parms ) 1.835 - tty->print("void"); 1.836 - else { 1.837 - uint i; 1.838 - for (i = Parms; i < _range->_cnt-1; i++) 1.839 - tty->print("%s/",flat_type_msg[_range->field_at(i)->base()]); 1.840 - tty->print("%s",flat_type_msg[_range->field_at(i)->base()]); 1.841 - } 1.842 - tty->print(" ( "); 1.843 - if (Parms < _domain->_cnt) 1.844 - tty->print("%s",flat_type_msg[_domain->field_at(Parms)->base()]); 1.845 - for (uint i = Parms+1; i < _domain->_cnt; i++) 1.846 - tty->print(", %s",flat_type_msg[_domain->field_at(i)->base()]); 1.847 - tty->print(" )"); 1.848 -} 1.849 #endif 1.850 1.851 //------------------------------singleton--------------------------------------