1.1 --- a/src/share/vm/opto/type.cpp Tue Mar 25 12:54:21 2014 -0700 1.2 +++ b/src/share/vm/opto/type.cpp Tue Mar 25 17:07:36 2014 -0700 1.3 @@ -306,6 +306,7 @@ 1.4 TypeInt::POS1 = TypeInt::make(1,max_jint, WidenMin); // Positive values 1.5 TypeInt::INT = TypeInt::make(min_jint,max_jint, WidenMax); // 32-bit integers 1.6 TypeInt::SYMINT = TypeInt::make(-max_jint,max_jint,WidenMin); // symmetric range 1.7 + TypeInt::TYPE_DOMAIN = TypeInt::INT; 1.8 // CmpL is overloaded both as the bytecode computation returning 1.9 // a trinary (-1,0,+1) integer result AND as an efficient long 1.10 // compare returning optimizer ideal-type flags. 1.11 @@ -322,6 +323,7 @@ 1.12 TypeLong::LONG = TypeLong::make(min_jlong,max_jlong,WidenMax); // 64-bit integers 1.13 TypeLong::INT = TypeLong::make((jlong)min_jint,(jlong)max_jint,WidenMin); 1.14 TypeLong::UINT = TypeLong::make(0,(jlong)max_juint,WidenMin); 1.15 + TypeLong::TYPE_DOMAIN = TypeLong::LONG; 1.16 1.17 const Type **fboth =(const Type**)shared_type_arena->Amalloc_4(2*sizeof(Type*)); 1.18 fboth[0] = Type::CONTROL; 1.19 @@ -1161,6 +1163,7 @@ 1.20 const TypeInt *TypeInt::POS1; // Positive 32-bit integers 1.21 const TypeInt *TypeInt::INT; // 32-bit integers 1.22 const TypeInt *TypeInt::SYMINT; // symmetric range [-max_jint..max_jint] 1.23 +const TypeInt *TypeInt::TYPE_DOMAIN; // alias for TypeInt::INT 1.24 1.25 //------------------------------TypeInt---------------------------------------- 1.26 TypeInt::TypeInt( jint lo, jint hi, int w ) : Type(Int), _lo(lo), _hi(hi), _widen(w) { 1.27 @@ -1418,6 +1421,7 @@ 1.28 const TypeLong *TypeLong::LONG; // 64-bit integers 1.29 const TypeLong *TypeLong::INT; // 32-bit subrange 1.30 const TypeLong *TypeLong::UINT; // 32-bit unsigned subrange 1.31 +const TypeLong *TypeLong::TYPE_DOMAIN; // alias for TypeLong::LONG 1.32 1.33 //------------------------------TypeLong--------------------------------------- 1.34 TypeLong::TypeLong( jlong lo, jlong hi, int w ) : Type(Long), _lo(lo), _hi(hi), _widen(w) { 1.35 @@ -2459,7 +2463,7 @@ 1.36 const TypeOopPtr *TypeOopPtr::BOTTOM; 1.37 1.38 //------------------------------TypeOopPtr------------------------------------- 1.39 -TypeOopPtr::TypeOopPtr(TYPES t, PTR ptr, ciKlass* k, bool xk, ciObject* o, int offset, int instance_id, const TypeOopPtr* speculative) 1.40 +TypeOopPtr::TypeOopPtr(TYPES t, PTR ptr, ciKlass* k, bool xk, ciObject* o, int offset, int instance_id, const TypeOopPtr* speculative, int inline_depth) 1.41 : TypePtr(t, ptr, offset), 1.42 _const_oop(o), _klass(k), 1.43 _klass_is_exact(xk), 1.44 @@ -2467,7 +2471,8 @@ 1.45 _is_ptr_to_narrowklass(false), 1.46 _is_ptr_to_boxed_value(false), 1.47 _instance_id(instance_id), 1.48 - _speculative(speculative) { 1.49 + _speculative(speculative), 1.50 + _inline_depth(inline_depth){ 1.51 if (Compile::current()->eliminate_boxing() && (t == InstPtr) && 1.52 (offset > 0) && xk && (k != 0) && k->is_instance_klass()) { 1.53 _is_ptr_to_boxed_value = k->as_instance_klass()->is_boxed_value_offset(offset); 1.54 @@ -2534,12 +2539,12 @@ 1.55 1.56 //------------------------------make------------------------------------------- 1.57 const TypeOopPtr *TypeOopPtr::make(PTR ptr, 1.58 - int offset, int instance_id, const TypeOopPtr* speculative) { 1.59 + int offset, int instance_id, const TypeOopPtr* speculative, int inline_depth) { 1.60 assert(ptr != Constant, "no constant generic pointers"); 1.61 ciKlass* k = Compile::current()->env()->Object_klass(); 1.62 bool xk = false; 1.63 ciObject* o = NULL; 1.64 - return (TypeOopPtr*)(new TypeOopPtr(OopPtr, ptr, k, xk, o, offset, instance_id, speculative))->hashcons(); 1.65 + return (TypeOopPtr*)(new TypeOopPtr(OopPtr, ptr, k, xk, o, offset, instance_id, speculative, inline_depth))->hashcons(); 1.66 } 1.67 1.68 1.69 @@ -2547,7 +2552,7 @@ 1.70 const Type *TypeOopPtr::cast_to_ptr_type(PTR ptr) const { 1.71 assert(_base == OopPtr, "subclass must override cast_to_ptr_type"); 1.72 if( ptr == _ptr ) return this; 1.73 - return make(ptr, _offset, _instance_id, _speculative); 1.74 + return make(ptr, _offset, _instance_id, _speculative, _inline_depth); 1.75 } 1.76 1.77 //-----------------------------cast_to_instance_id---------------------------- 1.78 @@ -2644,7 +2649,7 @@ 1.79 case AnyNull: { 1.80 int instance_id = meet_instance_id(InstanceTop); 1.81 const TypeOopPtr* speculative = _speculative; 1.82 - return make(ptr, offset, instance_id, speculative); 1.83 + return make(ptr, offset, instance_id, speculative, _inline_depth); 1.84 } 1.85 case BotPTR: 1.86 case NotNull: 1.87 @@ -2657,7 +2662,8 @@ 1.88 const TypeOopPtr *tp = t->is_oopptr(); 1.89 int instance_id = meet_instance_id(tp->instance_id()); 1.90 const TypeOopPtr* speculative = xmeet_speculative(tp); 1.91 - return make(meet_ptr(tp->ptr()), meet_offset(tp->offset()), instance_id, speculative); 1.92 + int depth = meet_inline_depth(tp->inline_depth()); 1.93 + return make(meet_ptr(tp->ptr()), meet_offset(tp->offset()), instance_id, speculative, depth); 1.94 } 1.95 1.96 case InstPtr: // For these, flip the call around to cut down 1.97 @@ -2674,7 +2680,7 @@ 1.98 const Type *TypeOopPtr::xdual() const { 1.99 assert(klass() == Compile::current()->env()->Object_klass(), "no klasses here"); 1.100 assert(const_oop() == NULL, "no constants here"); 1.101 - return new TypeOopPtr(_base, dual_ptr(), klass(), klass_is_exact(), const_oop(), dual_offset(), dual_instance_id(), dual_speculative()); 1.102 + return new TypeOopPtr(_base, dual_ptr(), klass(), klass_is_exact(), const_oop(), dual_offset(), dual_instance_id(), dual_speculative(), dual_inline_depth()); 1.103 } 1.104 1.105 //--------------------------make_from_klass_common----------------------------- 1.106 @@ -2765,7 +2771,7 @@ 1.107 } else if (!o->should_be_constant()) { 1.108 return TypeAryPtr::make(TypePtr::NotNull, arr0, klass, true, 0); 1.109 } 1.110 - const TypeAryPtr* arr = TypeAryPtr::make(TypePtr::Constant, o, arr0, klass, true, 0, InstanceBot, NULL, is_autobox_cache); 1.111 + const TypeAryPtr* arr = TypeAryPtr::make(TypePtr::Constant, o, arr0, klass, true, 0, InstanceBot, NULL, InlineDepthBottom, is_autobox_cache); 1.112 return arr; 1.113 } else if (klass->is_type_array_klass()) { 1.114 // Element is an typeArray 1.115 @@ -2854,7 +2860,8 @@ 1.116 const TypeOopPtr *a = (const TypeOopPtr*)t; 1.117 if (_klass_is_exact != a->_klass_is_exact || 1.118 _instance_id != a->_instance_id || 1.119 - !eq_speculative(a)) return false; 1.120 + !eq_speculative(a) || 1.121 + _inline_depth != a->_inline_depth) return false; 1.122 ciObject* one = const_oop(); 1.123 ciObject* two = a->const_oop(); 1.124 if (one == NULL || two == NULL) { 1.125 @@ -2872,6 +2879,7 @@ 1.126 _klass_is_exact + 1.127 _instance_id + 1.128 hash_speculative() + 1.129 + _inline_depth + 1.130 TypePtr::hash(); 1.131 } 1.132 1.133 @@ -2892,6 +2900,7 @@ 1.134 else if (_instance_id != InstanceBot) 1.135 st->print(",iid=%d",_instance_id); 1.136 1.137 + dump_inline_depth(st); 1.138 dump_speculative(st); 1.139 } 1.140 1.141 @@ -2905,6 +2914,16 @@ 1.142 st->print(")"); 1.143 } 1.144 } 1.145 + 1.146 +void TypeOopPtr::dump_inline_depth(outputStream *st) const { 1.147 + if (_inline_depth != InlineDepthBottom) { 1.148 + if (_inline_depth == InlineDepthTop) { 1.149 + st->print(" (inline_depth=InlineDepthTop)"); 1.150 + } else { 1.151 + st->print(" (inline_depth=%d)", _inline_depth); 1.152 + } 1.153 + } 1.154 +} 1.155 #endif 1.156 1.157 //------------------------------singleton-------------------------------------- 1.158 @@ -2918,7 +2937,7 @@ 1.159 1.160 //------------------------------add_offset------------------------------------- 1.161 const TypePtr *TypeOopPtr::add_offset(intptr_t offset) const { 1.162 - return make(_ptr, xadd_offset(offset), _instance_id, add_offset_speculative(offset)); 1.163 + return make(_ptr, xadd_offset(offset), _instance_id, add_offset_speculative(offset), _inline_depth); 1.164 } 1.165 1.166 /** 1.167 @@ -2928,7 +2947,52 @@ 1.168 if (_speculative == NULL) { 1.169 return this; 1.170 } 1.171 - return make(_ptr, _offset, _instance_id, NULL); 1.172 + assert(_inline_depth == InlineDepthTop || _inline_depth == InlineDepthBottom, "non speculative type shouldn't have inline depth"); 1.173 + return make(_ptr, _offset, _instance_id, NULL, _inline_depth); 1.174 +} 1.175 + 1.176 +/** 1.177 + * Return same type but with a different inline depth (used for speculation) 1.178 + * 1.179 + * @param depth depth to meet with 1.180 + */ 1.181 +const TypeOopPtr* TypeOopPtr::with_inline_depth(int depth) const { 1.182 + if (!UseInlineDepthForSpeculativeTypes) { 1.183 + return this; 1.184 + } 1.185 + return make(_ptr, _offset, _instance_id, _speculative, depth); 1.186 +} 1.187 + 1.188 +/** 1.189 + * Check whether new profiling would improve speculative type 1.190 + * 1.191 + * @param exact_kls class from profiling 1.192 + * @param inline_depth inlining depth of profile point 1.193 + * 1.194 + * @return true if type profile is valuable 1.195 + */ 1.196 +bool TypeOopPtr::would_improve_type(ciKlass* exact_kls, int inline_depth) const { 1.197 + // no way to improve an already exact type 1.198 + if (klass_is_exact()) { 1.199 + return false; 1.200 + } 1.201 + // no profiling? 1.202 + if (exact_kls == NULL) { 1.203 + return false; 1.204 + } 1.205 + // no speculative type or non exact speculative type? 1.206 + if (speculative_type() == NULL) { 1.207 + return true; 1.208 + } 1.209 + // If the node already has an exact speculative type keep it, 1.210 + // unless it was provided by profiling that is at a deeper 1.211 + // inlining level. Profiling at a higher inlining depth is 1.212 + // expected to be less accurate. 1.213 + if (_speculative->inline_depth() == InlineDepthBottom) { 1.214 + return false; 1.215 + } 1.216 + assert(_speculative->inline_depth() != InlineDepthTop, "can't do the comparison"); 1.217 + return inline_depth < _speculative->inline_depth(); 1.218 } 1.219 1.220 //------------------------------meet_instance_id-------------------------------- 1.221 @@ -3031,6 +3095,21 @@ 1.222 return _speculative->hash(); 1.223 } 1.224 1.225 +/** 1.226 + * dual of the inline depth for this type (used for speculation) 1.227 + */ 1.228 +int TypeOopPtr::dual_inline_depth() const { 1.229 + return -inline_depth(); 1.230 +} 1.231 + 1.232 +/** 1.233 + * meet of 2 inline depth (used for speculation) 1.234 + * 1.235 + * @param depth depth to meet with 1.236 + */ 1.237 +int TypeOopPtr::meet_inline_depth(int depth) const { 1.238 + return MAX2(inline_depth(), depth); 1.239 +} 1.240 1.241 //============================================================================= 1.242 // Convenience common pre-built types. 1.243 @@ -3041,8 +3120,8 @@ 1.244 const TypeInstPtr *TypeInstPtr::KLASS; 1.245 1.246 //------------------------------TypeInstPtr------------------------------------- 1.247 -TypeInstPtr::TypeInstPtr(PTR ptr, ciKlass* k, bool xk, ciObject* o, int off, int instance_id, const TypeOopPtr* speculative) 1.248 - : TypeOopPtr(InstPtr, ptr, k, xk, o, off, instance_id, speculative), _name(k->name()) { 1.249 +TypeInstPtr::TypeInstPtr(PTR ptr, ciKlass* k, bool xk, ciObject* o, int off, int instance_id, const TypeOopPtr* speculative, int inline_depth) 1.250 + : TypeOopPtr(InstPtr, ptr, k, xk, o, off, instance_id, speculative, inline_depth), _name(k->name()) { 1.251 assert(k != NULL && 1.252 (k->is_loaded() || o == NULL), 1.253 "cannot have constants with non-loaded klass"); 1.254 @@ -3055,7 +3134,8 @@ 1.255 ciObject* o, 1.256 int offset, 1.257 int instance_id, 1.258 - const TypeOopPtr* speculative) { 1.259 + const TypeOopPtr* speculative, 1.260 + int inline_depth) { 1.261 assert( !k->is_loaded() || k->is_instance_klass(), "Must be for instance"); 1.262 // Either const_oop() is NULL or else ptr is Constant 1.263 assert( (!o && ptr != Constant) || (o && ptr == Constant), 1.264 @@ -3076,7 +3156,7 @@ 1.265 1.266 // Now hash this baby 1.267 TypeInstPtr *result = 1.268 - (TypeInstPtr*)(new TypeInstPtr(ptr, k, xk, o ,offset, instance_id, speculative))->hashcons(); 1.269 + (TypeInstPtr*)(new TypeInstPtr(ptr, k, xk, o ,offset, instance_id, speculative, inline_depth))->hashcons(); 1.270 1.271 return result; 1.272 } 1.273 @@ -3109,7 +3189,7 @@ 1.274 if( ptr == _ptr ) return this; 1.275 // Reconstruct _sig info here since not a problem with later lazy 1.276 // construction, _sig will show up on demand. 1.277 - return make(ptr, klass(), klass_is_exact(), const_oop(), _offset, _instance_id, _speculative); 1.278 + return make(ptr, klass(), klass_is_exact(), const_oop(), _offset, _instance_id, _speculative, _inline_depth); 1.279 } 1.280 1.281 1.282 @@ -3121,13 +3201,13 @@ 1.283 ciInstanceKlass* ik = _klass->as_instance_klass(); 1.284 if( (ik->is_final() || _const_oop) ) return this; // cannot clear xk 1.285 if( ik->is_interface() ) return this; // cannot set xk 1.286 - return make(ptr(), klass(), klass_is_exact, const_oop(), _offset, _instance_id, _speculative); 1.287 + return make(ptr(), klass(), klass_is_exact, const_oop(), _offset, _instance_id, _speculative, _inline_depth); 1.288 } 1.289 1.290 //-----------------------------cast_to_instance_id---------------------------- 1.291 const TypeOopPtr *TypeInstPtr::cast_to_instance_id(int instance_id) const { 1.292 if( instance_id == _instance_id ) return this; 1.293 - return make(_ptr, klass(), _klass_is_exact, const_oop(), _offset, instance_id, _speculative); 1.294 + return make(_ptr, klass(), _klass_is_exact, const_oop(), _offset, instance_id, _speculative, _inline_depth); 1.295 } 1.296 1.297 //------------------------------xmeet_unloaded--------------------------------- 1.298 @@ -3138,6 +3218,7 @@ 1.299 PTR ptr = meet_ptr(tinst->ptr()); 1.300 int instance_id = meet_instance_id(tinst->instance_id()); 1.301 const TypeOopPtr* speculative = xmeet_speculative(tinst); 1.302 + int depth = meet_inline_depth(tinst->inline_depth()); 1.303 1.304 const TypeInstPtr *loaded = is_loaded() ? this : tinst; 1.305 const TypeInstPtr *unloaded = is_loaded() ? tinst : this; 1.306 @@ -3158,7 +3239,7 @@ 1.307 assert(loaded->ptr() != TypePtr::Null, "insanity check"); 1.308 // 1.309 if( loaded->ptr() == TypePtr::TopPTR ) { return unloaded; } 1.310 - else if (loaded->ptr() == TypePtr::AnyNull) { return TypeInstPtr::make(ptr, unloaded->klass(), false, NULL, off, instance_id, speculative); } 1.311 + else if (loaded->ptr() == TypePtr::AnyNull) { return TypeInstPtr::make(ptr, unloaded->klass(), false, NULL, off, instance_id, speculative, depth); } 1.312 else if (loaded->ptr() == TypePtr::BotPTR ) { return TypeInstPtr::BOTTOM; } 1.313 else if (loaded->ptr() == TypePtr::Constant || loaded->ptr() == TypePtr::NotNull) { 1.314 if (unloaded->ptr() == TypePtr::BotPTR ) { return TypeInstPtr::BOTTOM; } 1.315 @@ -3215,6 +3296,7 @@ 1.316 PTR ptr = meet_ptr(tp->ptr()); 1.317 int instance_id = meet_instance_id(tp->instance_id()); 1.318 const TypeOopPtr* speculative = xmeet_speculative(tp); 1.319 + int depth = meet_inline_depth(tp->inline_depth()); 1.320 switch (ptr) { 1.321 case TopPTR: 1.322 case AnyNull: // Fall 'down' to dual of object klass 1.323 @@ -3222,12 +3304,12 @@ 1.324 // below the centerline when the superclass is exact. We need to 1.325 // do the same here. 1.326 if (klass()->equals(ciEnv::current()->Object_klass()) && !klass_is_exact()) { 1.327 - return TypeAryPtr::make(ptr, tp->ary(), tp->klass(), tp->klass_is_exact(), offset, instance_id, speculative); 1.328 + return TypeAryPtr::make(ptr, tp->ary(), tp->klass(), tp->klass_is_exact(), offset, instance_id, speculative, depth); 1.329 } else { 1.330 // cannot subclass, so the meet has to fall badly below the centerline 1.331 ptr = NotNull; 1.332 instance_id = InstanceBot; 1.333 - return TypeInstPtr::make( ptr, ciEnv::current()->Object_klass(), false, NULL, offset, instance_id, speculative); 1.334 + return TypeInstPtr::make( ptr, ciEnv::current()->Object_klass(), false, NULL, offset, instance_id, speculative, depth); 1.335 } 1.336 case Constant: 1.337 case NotNull: 1.338 @@ -3242,7 +3324,7 @@ 1.339 if (klass()->equals(ciEnv::current()->Object_klass()) && !klass_is_exact()) { 1.340 // that is, tp's array type is a subtype of my klass 1.341 return TypeAryPtr::make(ptr, (ptr == Constant ? tp->const_oop() : NULL), 1.342 - tp->ary(), tp->klass(), tp->klass_is_exact(), offset, instance_id, speculative); 1.343 + tp->ary(), tp->klass(), tp->klass_is_exact(), offset, instance_id, speculative, depth); 1.344 } 1.345 } 1.346 // The other case cannot happen, since I cannot be a subtype of an array. 1.347 @@ -3250,7 +3332,7 @@ 1.348 if( ptr == Constant ) 1.349 ptr = NotNull; 1.350 instance_id = InstanceBot; 1.351 - return make(ptr, ciEnv::current()->Object_klass(), false, NULL, offset, instance_id, speculative); 1.352 + return make(ptr, ciEnv::current()->Object_klass(), false, NULL, offset, instance_id, speculative, depth); 1.353 default: typerr(t); 1.354 } 1.355 } 1.356 @@ -3265,14 +3347,16 @@ 1.357 case AnyNull: { 1.358 int instance_id = meet_instance_id(InstanceTop); 1.359 const TypeOopPtr* speculative = xmeet_speculative(tp); 1.360 + int depth = meet_inline_depth(tp->inline_depth()); 1.361 return make(ptr, klass(), klass_is_exact(), 1.362 - (ptr == Constant ? const_oop() : NULL), offset, instance_id, speculative); 1.363 + (ptr == Constant ? const_oop() : NULL), offset, instance_id, speculative, depth); 1.364 } 1.365 case NotNull: 1.366 case BotPTR: { 1.367 int instance_id = meet_instance_id(tp->instance_id()); 1.368 const TypeOopPtr* speculative = xmeet_speculative(tp); 1.369 - return TypeOopPtr::make(ptr, offset, instance_id, speculative); 1.370 + int depth = meet_inline_depth(tp->inline_depth()); 1.371 + return TypeOopPtr::make(ptr, offset, instance_id, speculative, depth); 1.372 } 1.373 default: typerr(t); 1.374 } 1.375 @@ -3292,7 +3376,7 @@ 1.376 int instance_id = meet_instance_id(InstanceTop); 1.377 const TypeOopPtr* speculative = _speculative; 1.378 return make(ptr, klass(), klass_is_exact(), 1.379 - (ptr == Constant ? const_oop() : NULL), offset, instance_id, speculative); 1.380 + (ptr == Constant ? const_oop() : NULL), offset, instance_id, speculative, _inline_depth); 1.381 } 1.382 case NotNull: 1.383 case BotPTR: 1.384 @@ -3324,13 +3408,14 @@ 1.385 PTR ptr = meet_ptr( tinst->ptr() ); 1.386 int instance_id = meet_instance_id(tinst->instance_id()); 1.387 const TypeOopPtr* speculative = xmeet_speculative(tinst); 1.388 + int depth = meet_inline_depth(tinst->inline_depth()); 1.389 1.390 // Check for easy case; klasses are equal (and perhaps not loaded!) 1.391 // If we have constants, then we created oops so classes are loaded 1.392 // and we can handle the constants further down. This case handles 1.393 // both-not-loaded or both-loaded classes 1.394 if (ptr != Constant && klass()->equals(tinst->klass()) && klass_is_exact() == tinst->klass_is_exact()) { 1.395 - return make(ptr, klass(), klass_is_exact(), NULL, off, instance_id, speculative); 1.396 + return make(ptr, klass(), klass_is_exact(), NULL, off, instance_id, speculative, depth); 1.397 } 1.398 1.399 // Classes require inspection in the Java klass hierarchy. Must be loaded. 1.400 @@ -3394,7 +3479,7 @@ 1.401 // Find out which constant. 1.402 o = (this_klass == klass()) ? const_oop() : tinst->const_oop(); 1.403 } 1.404 - return make(ptr, k, xk, o, off, instance_id, speculative); 1.405 + return make(ptr, k, xk, o, off, instance_id, speculative, depth); 1.406 } 1.407 1.408 // Either oop vs oop or interface vs interface or interface vs Object 1.409 @@ -3471,7 +3556,7 @@ 1.410 else 1.411 ptr = NotNull; 1.412 } 1.413 - return make(ptr, this_klass, this_xk, o, off, instance_id, speculative); 1.414 + return make(ptr, this_klass, this_xk, o, off, instance_id, speculative, depth); 1.415 } // Else classes are not equal 1.416 1.417 // Since klasses are different, we require a LCA in the Java 1.418 @@ -3482,7 +3567,7 @@ 1.419 1.420 // Now we find the LCA of Java classes 1.421 ciKlass* k = this_klass->least_common_ancestor(tinst_klass); 1.422 - return make(ptr, k, false, NULL, off, instance_id, speculative); 1.423 + return make(ptr, k, false, NULL, off, instance_id, speculative, depth); 1.424 } // End of case InstPtr 1.425 1.426 } // End of switch 1.427 @@ -3506,7 +3591,7 @@ 1.428 // Dual: do NOT dual on klasses. This means I do NOT understand the Java 1.429 // inheritance mechanism. 1.430 const Type *TypeInstPtr::xdual() const { 1.431 - return new TypeInstPtr(dual_ptr(), klass(), klass_is_exact(), const_oop(), dual_offset(), dual_instance_id(), dual_speculative()); 1.432 + return new TypeInstPtr(dual_ptr(), klass(), klass_is_exact(), const_oop(), dual_offset(), dual_instance_id(), dual_speculative(), dual_inline_depth()); 1.433 } 1.434 1.435 //------------------------------eq--------------------------------------------- 1.436 @@ -3563,6 +3648,7 @@ 1.437 else if (_instance_id != InstanceBot) 1.438 st->print(",iid=%d",_instance_id); 1.439 1.440 + dump_inline_depth(st); 1.441 dump_speculative(st); 1.442 } 1.443 #endif 1.444 @@ -3576,7 +3662,15 @@ 1.445 if (_speculative == NULL) { 1.446 return this; 1.447 } 1.448 - return make(_ptr, klass(), klass_is_exact(), const_oop(), _offset, _instance_id, NULL); 1.449 + assert(_inline_depth == InlineDepthTop || _inline_depth == InlineDepthBottom, "non speculative type shouldn't have inline depth"); 1.450 + return make(_ptr, klass(), klass_is_exact(), const_oop(), _offset, _instance_id, NULL, _inline_depth); 1.451 +} 1.452 + 1.453 +const TypeOopPtr *TypeInstPtr::with_inline_depth(int depth) const { 1.454 + if (!UseInlineDepthForSpeculativeTypes) { 1.455 + return this; 1.456 + } 1.457 + return make(_ptr, klass(), klass_is_exact(), const_oop(), _offset, _instance_id, _speculative, depth); 1.458 } 1.459 1.460 //============================================================================= 1.461 @@ -3593,30 +3687,30 @@ 1.462 const TypeAryPtr *TypeAryPtr::DOUBLES; 1.463 1.464 //------------------------------make------------------------------------------- 1.465 -const TypeAryPtr *TypeAryPtr::make(PTR ptr, const TypeAry *ary, ciKlass* k, bool xk, int offset, int instance_id, const TypeOopPtr* speculative) { 1.466 +const TypeAryPtr *TypeAryPtr::make(PTR ptr, const TypeAry *ary, ciKlass* k, bool xk, int offset, int instance_id, const TypeOopPtr* speculative, int inline_depth) { 1.467 assert(!(k == NULL && ary->_elem->isa_int()), 1.468 "integral arrays must be pre-equipped with a class"); 1.469 if (!xk) xk = ary->ary_must_be_exact(); 1.470 assert(instance_id <= 0 || xk || !UseExactTypes, "instances are always exactly typed"); 1.471 if (!UseExactTypes) xk = (ptr == Constant); 1.472 - return (TypeAryPtr*)(new TypeAryPtr(ptr, NULL, ary, k, xk, offset, instance_id, false, speculative))->hashcons(); 1.473 + return (TypeAryPtr*)(new TypeAryPtr(ptr, NULL, ary, k, xk, offset, instance_id, false, speculative, inline_depth))->hashcons(); 1.474 } 1.475 1.476 //------------------------------make------------------------------------------- 1.477 -const TypeAryPtr *TypeAryPtr::make(PTR ptr, ciObject* o, const TypeAry *ary, ciKlass* k, bool xk, int offset, int instance_id, const TypeOopPtr* speculative, bool is_autobox_cache) { 1.478 +const TypeAryPtr *TypeAryPtr::make(PTR ptr, ciObject* o, const TypeAry *ary, ciKlass* k, bool xk, int offset, int instance_id, const TypeOopPtr* speculative, int inline_depth, bool is_autobox_cache) { 1.479 assert(!(k == NULL && ary->_elem->isa_int()), 1.480 "integral arrays must be pre-equipped with a class"); 1.481 assert( (ptr==Constant && o) || (ptr!=Constant && !o), "" ); 1.482 if (!xk) xk = (o != NULL) || ary->ary_must_be_exact(); 1.483 assert(instance_id <= 0 || xk || !UseExactTypes, "instances are always exactly typed"); 1.484 if (!UseExactTypes) xk = (ptr == Constant); 1.485 - return (TypeAryPtr*)(new TypeAryPtr(ptr, o, ary, k, xk, offset, instance_id, is_autobox_cache, speculative))->hashcons(); 1.486 + return (TypeAryPtr*)(new TypeAryPtr(ptr, o, ary, k, xk, offset, instance_id, is_autobox_cache, speculative, inline_depth))->hashcons(); 1.487 } 1.488 1.489 //------------------------------cast_to_ptr_type------------------------------- 1.490 const Type *TypeAryPtr::cast_to_ptr_type(PTR ptr) const { 1.491 if( ptr == _ptr ) return this; 1.492 - return make(ptr, const_oop(), _ary, klass(), klass_is_exact(), _offset, _instance_id, _speculative); 1.493 + return make(ptr, const_oop(), _ary, klass(), klass_is_exact(), _offset, _instance_id, _speculative, _inline_depth); 1.494 } 1.495 1.496 1.497 @@ -3625,13 +3719,13 @@ 1.498 if( klass_is_exact == _klass_is_exact ) return this; 1.499 if (!UseExactTypes) return this; 1.500 if (_ary->ary_must_be_exact()) return this; // cannot clear xk 1.501 - return make(ptr(), const_oop(), _ary, klass(), klass_is_exact, _offset, _instance_id, _speculative); 1.502 + return make(ptr(), const_oop(), _ary, klass(), klass_is_exact, _offset, _instance_id, _speculative, _inline_depth); 1.503 } 1.504 1.505 //-----------------------------cast_to_instance_id---------------------------- 1.506 const TypeOopPtr *TypeAryPtr::cast_to_instance_id(int instance_id) const { 1.507 if( instance_id == _instance_id ) return this; 1.508 - return make(_ptr, const_oop(), _ary, klass(), _klass_is_exact, _offset, instance_id, _speculative); 1.509 + return make(_ptr, const_oop(), _ary, klass(), _klass_is_exact, _offset, instance_id, _speculative, _inline_depth); 1.510 } 1.511 1.512 //-----------------------------narrow_size_type------------------------------- 1.513 @@ -3694,7 +3788,7 @@ 1.514 new_size = narrow_size_type(new_size); 1.515 if (new_size == size()) return this; 1.516 const TypeAry* new_ary = TypeAry::make(elem(), new_size, is_stable()); 1.517 - return make(ptr(), const_oop(), new_ary, klass(), klass_is_exact(), _offset, _instance_id, _speculative); 1.518 + return make(ptr(), const_oop(), new_ary, klass(), klass_is_exact(), _offset, _instance_id, _speculative, _inline_depth); 1.519 } 1.520 1.521 1.522 @@ -3773,19 +3867,20 @@ 1.523 const TypeOopPtr *tp = t->is_oopptr(); 1.524 int offset = meet_offset(tp->offset()); 1.525 PTR ptr = meet_ptr(tp->ptr()); 1.526 + int depth = meet_inline_depth(tp->inline_depth()); 1.527 switch (tp->ptr()) { 1.528 case TopPTR: 1.529 case AnyNull: { 1.530 int instance_id = meet_instance_id(InstanceTop); 1.531 const TypeOopPtr* speculative = xmeet_speculative(tp); 1.532 return make(ptr, (ptr == Constant ? const_oop() : NULL), 1.533 - _ary, _klass, _klass_is_exact, offset, instance_id, speculative); 1.534 + _ary, _klass, _klass_is_exact, offset, instance_id, speculative, depth); 1.535 } 1.536 case BotPTR: 1.537 case NotNull: { 1.538 int instance_id = meet_instance_id(tp->instance_id()); 1.539 const TypeOopPtr* speculative = xmeet_speculative(tp); 1.540 - return TypeOopPtr::make(ptr, offset, instance_id, speculative); 1.541 + return TypeOopPtr::make(ptr, offset, instance_id, speculative, depth); 1.542 } 1.543 default: ShouldNotReachHere(); 1.544 } 1.545 @@ -3809,7 +3904,7 @@ 1.546 int instance_id = meet_instance_id(InstanceTop); 1.547 const TypeOopPtr* speculative = _speculative; 1.548 return make(ptr, (ptr == Constant ? const_oop() : NULL), 1.549 - _ary, _klass, _klass_is_exact, offset, instance_id, speculative); 1.550 + _ary, _klass, _klass_is_exact, offset, instance_id, speculative, _inline_depth); 1.551 } 1.552 default: ShouldNotReachHere(); 1.553 } 1.554 @@ -3826,6 +3921,7 @@ 1.555 PTR ptr = meet_ptr(tap->ptr()); 1.556 int instance_id = meet_instance_id(tap->instance_id()); 1.557 const TypeOopPtr* speculative = xmeet_speculative(tap); 1.558 + int depth = meet_inline_depth(tap->inline_depth()); 1.559 ciKlass* lazy_klass = NULL; 1.560 if (tary->_elem->isa_int()) { 1.561 // Integral array element types have irrelevant lattice relations. 1.562 @@ -3866,7 +3962,7 @@ 1.563 } else { 1.564 xk = (tap->_klass_is_exact | this->_klass_is_exact); 1.565 } 1.566 - return make(ptr, const_oop(), tary, lazy_klass, xk, off, instance_id, speculative); 1.567 + return make(ptr, const_oop(), tary, lazy_klass, xk, off, instance_id, speculative, depth); 1.568 case Constant: { 1.569 ciObject* o = const_oop(); 1.570 if( _ptr == Constant ) { 1.571 @@ -3885,7 +3981,7 @@ 1.572 // Only precise for identical arrays 1.573 xk = this->_klass_is_exact && (klass() == tap->klass()); 1.574 } 1.575 - return TypeAryPtr::make(ptr, o, tary, lazy_klass, xk, off, instance_id, speculative); 1.576 + return TypeAryPtr::make(ptr, o, tary, lazy_klass, xk, off, instance_id, speculative, depth); 1.577 } 1.578 case NotNull: 1.579 case BotPTR: 1.580 @@ -3894,7 +3990,7 @@ 1.581 xk = tap->_klass_is_exact; 1.582 else xk = (tap->_klass_is_exact & this->_klass_is_exact) && 1.583 (klass() == tap->klass()); // Only precise for identical arrays 1.584 - return TypeAryPtr::make(ptr, NULL, tary, lazy_klass, xk, off, instance_id, speculative); 1.585 + return TypeAryPtr::make(ptr, NULL, tary, lazy_klass, xk, off, instance_id, speculative, depth); 1.586 default: ShouldNotReachHere(); 1.587 } 1.588 } 1.589 @@ -3906,6 +4002,7 @@ 1.590 PTR ptr = meet_ptr(tp->ptr()); 1.591 int instance_id = meet_instance_id(tp->instance_id()); 1.592 const TypeOopPtr* speculative = xmeet_speculative(tp); 1.593 + int depth = meet_inline_depth(tp->inline_depth()); 1.594 switch (ptr) { 1.595 case TopPTR: 1.596 case AnyNull: // Fall 'down' to dual of object klass 1.597 @@ -3913,12 +4010,12 @@ 1.598 // below the centerline when the superclass is exact. We need to 1.599 // do the same here. 1.600 if (tp->klass()->equals(ciEnv::current()->Object_klass()) && !tp->klass_is_exact()) { 1.601 - return TypeAryPtr::make(ptr, _ary, _klass, _klass_is_exact, offset, instance_id, speculative); 1.602 + return TypeAryPtr::make(ptr, _ary, _klass, _klass_is_exact, offset, instance_id, speculative, depth); 1.603 } else { 1.604 // cannot subclass, so the meet has to fall badly below the centerline 1.605 ptr = NotNull; 1.606 instance_id = InstanceBot; 1.607 - return TypeInstPtr::make(ptr, ciEnv::current()->Object_klass(), false, NULL,offset, instance_id, speculative); 1.608 + return TypeInstPtr::make(ptr, ciEnv::current()->Object_klass(), false, NULL,offset, instance_id, speculative, depth); 1.609 } 1.610 case Constant: 1.611 case NotNull: 1.612 @@ -3933,7 +4030,7 @@ 1.613 if (tp->klass()->equals(ciEnv::current()->Object_klass()) && !tp->klass_is_exact()) { 1.614 // that is, my array type is a subtype of 'tp' klass 1.615 return make(ptr, (ptr == Constant ? const_oop() : NULL), 1.616 - _ary, _klass, _klass_is_exact, offset, instance_id, speculative); 1.617 + _ary, _klass, _klass_is_exact, offset, instance_id, speculative, depth); 1.618 } 1.619 } 1.620 // The other case cannot happen, since t cannot be a subtype of an array. 1.621 @@ -3941,7 +4038,7 @@ 1.622 if( ptr == Constant ) 1.623 ptr = NotNull; 1.624 instance_id = InstanceBot; 1.625 - return TypeInstPtr::make(ptr, ciEnv::current()->Object_klass(), false, NULL,offset, instance_id, speculative); 1.626 + return TypeInstPtr::make(ptr, ciEnv::current()->Object_klass(), false, NULL,offset, instance_id, speculative, depth); 1.627 default: typerr(t); 1.628 } 1.629 } 1.630 @@ -3952,7 +4049,7 @@ 1.631 //------------------------------xdual------------------------------------------ 1.632 // Dual: compute field-by-field dual 1.633 const Type *TypeAryPtr::xdual() const { 1.634 - return new TypeAryPtr(dual_ptr(), _const_oop, _ary->dual()->is_ary(),_klass, _klass_is_exact, dual_offset(), dual_instance_id(), is_autobox_cache(), dual_speculative()); 1.635 + return new TypeAryPtr(dual_ptr(), _const_oop, _ary->dual()->is_ary(),_klass, _klass_is_exact, dual_offset(), dual_instance_id(), is_autobox_cache(), dual_speculative(), dual_inline_depth()); 1.636 } 1.637 1.638 //----------------------interface_vs_oop--------------------------------------- 1.639 @@ -4005,6 +4102,7 @@ 1.640 else if (_instance_id != InstanceBot) 1.641 st->print(",iid=%d",_instance_id); 1.642 1.643 + dump_inline_depth(st); 1.644 dump_speculative(st); 1.645 } 1.646 #endif 1.647 @@ -4016,11 +4114,22 @@ 1.648 1.649 //------------------------------add_offset------------------------------------- 1.650 const TypePtr *TypeAryPtr::add_offset(intptr_t offset) const { 1.651 - return make(_ptr, _const_oop, _ary, _klass, _klass_is_exact, xadd_offset(offset), _instance_id, add_offset_speculative(offset)); 1.652 + return make(_ptr, _const_oop, _ary, _klass, _klass_is_exact, xadd_offset(offset), _instance_id, add_offset_speculative(offset), _inline_depth); 1.653 } 1.654 1.655 const Type *TypeAryPtr::remove_speculative() const { 1.656 - return make(_ptr, _const_oop, _ary->remove_speculative()->is_ary(), _klass, _klass_is_exact, _offset, _instance_id, NULL); 1.657 + if (_speculative == NULL) { 1.658 + return this; 1.659 + } 1.660 + assert(_inline_depth == InlineDepthTop || _inline_depth == InlineDepthBottom, "non speculative type shouldn't have inline depth"); 1.661 + return make(_ptr, _const_oop, _ary->remove_speculative()->is_ary(), _klass, _klass_is_exact, _offset, _instance_id, NULL, _inline_depth); 1.662 +} 1.663 + 1.664 +const TypeOopPtr *TypeAryPtr::with_inline_depth(int depth) const { 1.665 + if (!UseInlineDepthForSpeculativeTypes) { 1.666 + return this; 1.667 + } 1.668 + return make(_ptr, _const_oop, _ary->remove_speculative()->is_ary(), _klass, _klass_is_exact, _offset, _instance_id, _speculative, depth); 1.669 } 1.670 1.671 //============================================================================= 1.672 @@ -4271,7 +4380,7 @@ 1.673 // else fall through: 1.674 case TopPTR: 1.675 case AnyNull: { 1.676 - return make(ptr, NULL, offset); 1.677 + return make(ptr, _metadata, offset); 1.678 } 1.679 case BotPTR: 1.680 case NotNull: