1.1 --- a/src/share/vm/opto/type.cpp Tue Feb 25 18:16:24 2014 +0100 1.2 +++ b/src/share/vm/opto/type.cpp Fri Mar 14 17:15:32 2014 +0100 1.3 @@ -2457,7 +2457,7 @@ 1.4 const TypeOopPtr *TypeOopPtr::BOTTOM; 1.5 1.6 //------------------------------TypeOopPtr------------------------------------- 1.7 -TypeOopPtr::TypeOopPtr(TYPES t, PTR ptr, ciKlass* k, bool xk, ciObject* o, int offset, int instance_id, const TypeOopPtr* speculative) 1.8 +TypeOopPtr::TypeOopPtr(TYPES t, PTR ptr, ciKlass* k, bool xk, ciObject* o, int offset, int instance_id, const TypeOopPtr* speculative, int inline_depth) 1.9 : TypePtr(t, ptr, offset), 1.10 _const_oop(o), _klass(k), 1.11 _klass_is_exact(xk), 1.12 @@ -2465,7 +2465,8 @@ 1.13 _is_ptr_to_narrowklass(false), 1.14 _is_ptr_to_boxed_value(false), 1.15 _instance_id(instance_id), 1.16 - _speculative(speculative) { 1.17 + _speculative(speculative), 1.18 + _inline_depth(inline_depth){ 1.19 if (Compile::current()->eliminate_boxing() && (t == InstPtr) && 1.20 (offset > 0) && xk && (k != 0) && k->is_instance_klass()) { 1.21 _is_ptr_to_boxed_value = k->as_instance_klass()->is_boxed_value_offset(offset); 1.22 @@ -2532,12 +2533,12 @@ 1.23 1.24 //------------------------------make------------------------------------------- 1.25 const TypeOopPtr *TypeOopPtr::make(PTR ptr, 1.26 - int offset, int instance_id, const TypeOopPtr* speculative) { 1.27 + int offset, int instance_id, const TypeOopPtr* speculative, int inline_depth) { 1.28 assert(ptr != Constant, "no constant generic pointers"); 1.29 ciKlass* k = Compile::current()->env()->Object_klass(); 1.30 bool xk = false; 1.31 ciObject* o = NULL; 1.32 - return (TypeOopPtr*)(new TypeOopPtr(OopPtr, ptr, k, xk, o, offset, instance_id, speculative))->hashcons(); 1.33 + return (TypeOopPtr*)(new TypeOopPtr(OopPtr, ptr, k, xk, o, offset, instance_id, speculative, inline_depth))->hashcons(); 1.34 } 1.35 1.36 1.37 @@ -2545,7 +2546,7 @@ 1.38 const Type *TypeOopPtr::cast_to_ptr_type(PTR ptr) const { 1.39 assert(_base == OopPtr, "subclass must override cast_to_ptr_type"); 1.40 if( ptr == _ptr ) return this; 1.41 - return make(ptr, _offset, _instance_id, _speculative); 1.42 + return make(ptr, _offset, _instance_id, _speculative, _inline_depth); 1.43 } 1.44 1.45 //-----------------------------cast_to_instance_id---------------------------- 1.46 @@ -2642,7 +2643,7 @@ 1.47 case AnyNull: { 1.48 int instance_id = meet_instance_id(InstanceTop); 1.49 const TypeOopPtr* speculative = _speculative; 1.50 - return make(ptr, offset, instance_id, speculative); 1.51 + return make(ptr, offset, instance_id, speculative, _inline_depth); 1.52 } 1.53 case BotPTR: 1.54 case NotNull: 1.55 @@ -2655,7 +2656,8 @@ 1.56 const TypeOopPtr *tp = t->is_oopptr(); 1.57 int instance_id = meet_instance_id(tp->instance_id()); 1.58 const TypeOopPtr* speculative = xmeet_speculative(tp); 1.59 - return make(meet_ptr(tp->ptr()), meet_offset(tp->offset()), instance_id, speculative); 1.60 + int depth = meet_inline_depth(tp->inline_depth()); 1.61 + return make(meet_ptr(tp->ptr()), meet_offset(tp->offset()), instance_id, speculative, depth); 1.62 } 1.63 1.64 case InstPtr: // For these, flip the call around to cut down 1.65 @@ -2672,7 +2674,7 @@ 1.66 const Type *TypeOopPtr::xdual() const { 1.67 assert(klass() == Compile::current()->env()->Object_klass(), "no klasses here"); 1.68 assert(const_oop() == NULL, "no constants here"); 1.69 - return new TypeOopPtr(_base, dual_ptr(), klass(), klass_is_exact(), const_oop(), dual_offset(), dual_instance_id(), dual_speculative()); 1.70 + return new TypeOopPtr(_base, dual_ptr(), klass(), klass_is_exact(), const_oop(), dual_offset(), dual_instance_id(), dual_speculative(), dual_inline_depth()); 1.71 } 1.72 1.73 //--------------------------make_from_klass_common----------------------------- 1.74 @@ -2763,7 +2765,7 @@ 1.75 } else if (!o->should_be_constant()) { 1.76 return TypeAryPtr::make(TypePtr::NotNull, arr0, klass, true, 0); 1.77 } 1.78 - const TypeAryPtr* arr = TypeAryPtr::make(TypePtr::Constant, o, arr0, klass, true, 0, InstanceBot, NULL, is_autobox_cache); 1.79 + const TypeAryPtr* arr = TypeAryPtr::make(TypePtr::Constant, o, arr0, klass, true, 0, InstanceBot, NULL, InlineDepthBottom, is_autobox_cache); 1.80 return arr; 1.81 } else if (klass->is_type_array_klass()) { 1.82 // Element is an typeArray 1.83 @@ -2852,7 +2854,8 @@ 1.84 const TypeOopPtr *a = (const TypeOopPtr*)t; 1.85 if (_klass_is_exact != a->_klass_is_exact || 1.86 _instance_id != a->_instance_id || 1.87 - !eq_speculative(a)) return false; 1.88 + !eq_speculative(a) || 1.89 + _inline_depth != a->_inline_depth) return false; 1.90 ciObject* one = const_oop(); 1.91 ciObject* two = a->const_oop(); 1.92 if (one == NULL || two == NULL) { 1.93 @@ -2870,6 +2873,7 @@ 1.94 _klass_is_exact + 1.95 _instance_id + 1.96 hash_speculative() + 1.97 + _inline_depth + 1.98 TypePtr::hash(); 1.99 } 1.100 1.101 @@ -2890,6 +2894,7 @@ 1.102 else if (_instance_id != InstanceBot) 1.103 st->print(",iid=%d",_instance_id); 1.104 1.105 + dump_inline_depth(st); 1.106 dump_speculative(st); 1.107 } 1.108 1.109 @@ -2903,6 +2908,16 @@ 1.110 st->print(")"); 1.111 } 1.112 } 1.113 + 1.114 +void TypeOopPtr::dump_inline_depth(outputStream *st) const { 1.115 + if (_inline_depth != InlineDepthBottom) { 1.116 + if (_inline_depth == InlineDepthTop) { 1.117 + st->print(" (inline_depth=InlineDepthTop)"); 1.118 + } else { 1.119 + st->print(" (inline_depth=%d)", _inline_depth); 1.120 + } 1.121 + } 1.122 +} 1.123 #endif 1.124 1.125 //------------------------------singleton-------------------------------------- 1.126 @@ -2916,7 +2931,7 @@ 1.127 1.128 //------------------------------add_offset------------------------------------- 1.129 const TypePtr *TypeOopPtr::add_offset(intptr_t offset) const { 1.130 - return make(_ptr, xadd_offset(offset), _instance_id, add_offset_speculative(offset)); 1.131 + return make(_ptr, xadd_offset(offset), _instance_id, add_offset_speculative(offset), _inline_depth); 1.132 } 1.133 1.134 /** 1.135 @@ -2926,7 +2941,52 @@ 1.136 if (_speculative == NULL) { 1.137 return this; 1.138 } 1.139 - return make(_ptr, _offset, _instance_id, NULL); 1.140 + assert(_inline_depth == InlineDepthTop || _inline_depth == InlineDepthBottom, "non speculative type shouldn't have inline depth"); 1.141 + return make(_ptr, _offset, _instance_id, NULL, _inline_depth); 1.142 +} 1.143 + 1.144 +/** 1.145 + * Return same type but with a different inline depth (used for speculation) 1.146 + * 1.147 + * @param depth depth to meet with 1.148 + */ 1.149 +const TypeOopPtr* TypeOopPtr::with_inline_depth(int depth) const { 1.150 + if (!UseInlineDepthForSpeculativeTypes) { 1.151 + return this; 1.152 + } 1.153 + return make(_ptr, _offset, _instance_id, _speculative, depth); 1.154 +} 1.155 + 1.156 +/** 1.157 + * Check whether new profiling would improve speculative type 1.158 + * 1.159 + * @param exact_kls class from profiling 1.160 + * @param inline_depth inlining depth of profile point 1.161 + * 1.162 + * @return true if type profile is valuable 1.163 + */ 1.164 +bool TypeOopPtr::would_improve_type(ciKlass* exact_kls, int inline_depth) const { 1.165 + // no way to improve an already exact type 1.166 + if (klass_is_exact()) { 1.167 + return false; 1.168 + } 1.169 + // no profiling? 1.170 + if (exact_kls == NULL) { 1.171 + return false; 1.172 + } 1.173 + // no speculative type or non exact speculative type? 1.174 + if (speculative_type() == NULL) { 1.175 + return true; 1.176 + } 1.177 + // If the node already has an exact speculative type keep it, 1.178 + // unless it was provided by profiling that is at a deeper 1.179 + // inlining level. Profiling at a higher inlining depth is 1.180 + // expected to be less accurate. 1.181 + if (_speculative->inline_depth() == InlineDepthBottom) { 1.182 + return false; 1.183 + } 1.184 + assert(_speculative->inline_depth() != InlineDepthTop, "can't do the comparison"); 1.185 + return inline_depth < _speculative->inline_depth(); 1.186 } 1.187 1.188 //------------------------------meet_instance_id-------------------------------- 1.189 @@ -3029,6 +3089,21 @@ 1.190 return _speculative->hash(); 1.191 } 1.192 1.193 +/** 1.194 + * dual of the inline depth for this type (used for speculation) 1.195 + */ 1.196 +int TypeOopPtr::dual_inline_depth() const { 1.197 + return -inline_depth(); 1.198 +} 1.199 + 1.200 +/** 1.201 + * meet of 2 inline depth (used for speculation) 1.202 + * 1.203 + * @param depth depth to meet with 1.204 + */ 1.205 +int TypeOopPtr::meet_inline_depth(int depth) const { 1.206 + return MAX2(inline_depth(), depth); 1.207 +} 1.208 1.209 //============================================================================= 1.210 // Convenience common pre-built types. 1.211 @@ -3039,8 +3114,8 @@ 1.212 const TypeInstPtr *TypeInstPtr::KLASS; 1.213 1.214 //------------------------------TypeInstPtr------------------------------------- 1.215 -TypeInstPtr::TypeInstPtr(PTR ptr, ciKlass* k, bool xk, ciObject* o, int off, int instance_id, const TypeOopPtr* speculative) 1.216 - : TypeOopPtr(InstPtr, ptr, k, xk, o, off, instance_id, speculative), _name(k->name()) { 1.217 +TypeInstPtr::TypeInstPtr(PTR ptr, ciKlass* k, bool xk, ciObject* o, int off, int instance_id, const TypeOopPtr* speculative, int inline_depth) 1.218 + : TypeOopPtr(InstPtr, ptr, k, xk, o, off, instance_id, speculative, inline_depth), _name(k->name()) { 1.219 assert(k != NULL && 1.220 (k->is_loaded() || o == NULL), 1.221 "cannot have constants with non-loaded klass"); 1.222 @@ -3053,7 +3128,8 @@ 1.223 ciObject* o, 1.224 int offset, 1.225 int instance_id, 1.226 - const TypeOopPtr* speculative) { 1.227 + const TypeOopPtr* speculative, 1.228 + int inline_depth) { 1.229 assert( !k->is_loaded() || k->is_instance_klass(), "Must be for instance"); 1.230 // Either const_oop() is NULL or else ptr is Constant 1.231 assert( (!o && ptr != Constant) || (o && ptr == Constant), 1.232 @@ -3074,7 +3150,7 @@ 1.233 1.234 // Now hash this baby 1.235 TypeInstPtr *result = 1.236 - (TypeInstPtr*)(new TypeInstPtr(ptr, k, xk, o ,offset, instance_id, speculative))->hashcons(); 1.237 + (TypeInstPtr*)(new TypeInstPtr(ptr, k, xk, o ,offset, instance_id, speculative, inline_depth))->hashcons(); 1.238 1.239 return result; 1.240 } 1.241 @@ -3107,7 +3183,7 @@ 1.242 if( ptr == _ptr ) return this; 1.243 // Reconstruct _sig info here since not a problem with later lazy 1.244 // construction, _sig will show up on demand. 1.245 - return make(ptr, klass(), klass_is_exact(), const_oop(), _offset, _instance_id, _speculative); 1.246 + return make(ptr, klass(), klass_is_exact(), const_oop(), _offset, _instance_id, _speculative, _inline_depth); 1.247 } 1.248 1.249 1.250 @@ -3119,13 +3195,13 @@ 1.251 ciInstanceKlass* ik = _klass->as_instance_klass(); 1.252 if( (ik->is_final() || _const_oop) ) return this; // cannot clear xk 1.253 if( ik->is_interface() ) return this; // cannot set xk 1.254 - return make(ptr(), klass(), klass_is_exact, const_oop(), _offset, _instance_id, _speculative); 1.255 + return make(ptr(), klass(), klass_is_exact, const_oop(), _offset, _instance_id, _speculative, _inline_depth); 1.256 } 1.257 1.258 //-----------------------------cast_to_instance_id---------------------------- 1.259 const TypeOopPtr *TypeInstPtr::cast_to_instance_id(int instance_id) const { 1.260 if( instance_id == _instance_id ) return this; 1.261 - return make(_ptr, klass(), _klass_is_exact, const_oop(), _offset, instance_id, _speculative); 1.262 + return make(_ptr, klass(), _klass_is_exact, const_oop(), _offset, instance_id, _speculative, _inline_depth); 1.263 } 1.264 1.265 //------------------------------xmeet_unloaded--------------------------------- 1.266 @@ -3136,6 +3212,7 @@ 1.267 PTR ptr = meet_ptr(tinst->ptr()); 1.268 int instance_id = meet_instance_id(tinst->instance_id()); 1.269 const TypeOopPtr* speculative = xmeet_speculative(tinst); 1.270 + int depth = meet_inline_depth(tinst->inline_depth()); 1.271 1.272 const TypeInstPtr *loaded = is_loaded() ? this : tinst; 1.273 const TypeInstPtr *unloaded = is_loaded() ? tinst : this; 1.274 @@ -3156,7 +3233,7 @@ 1.275 assert(loaded->ptr() != TypePtr::Null, "insanity check"); 1.276 // 1.277 if( loaded->ptr() == TypePtr::TopPTR ) { return unloaded; } 1.278 - else if (loaded->ptr() == TypePtr::AnyNull) { return TypeInstPtr::make(ptr, unloaded->klass(), false, NULL, off, instance_id, speculative); } 1.279 + else if (loaded->ptr() == TypePtr::AnyNull) { return TypeInstPtr::make(ptr, unloaded->klass(), false, NULL, off, instance_id, speculative, depth); } 1.280 else if (loaded->ptr() == TypePtr::BotPTR ) { return TypeInstPtr::BOTTOM; } 1.281 else if (loaded->ptr() == TypePtr::Constant || loaded->ptr() == TypePtr::NotNull) { 1.282 if (unloaded->ptr() == TypePtr::BotPTR ) { return TypeInstPtr::BOTTOM; } 1.283 @@ -3213,6 +3290,7 @@ 1.284 PTR ptr = meet_ptr(tp->ptr()); 1.285 int instance_id = meet_instance_id(tp->instance_id()); 1.286 const TypeOopPtr* speculative = xmeet_speculative(tp); 1.287 + int depth = meet_inline_depth(tp->inline_depth()); 1.288 switch (ptr) { 1.289 case TopPTR: 1.290 case AnyNull: // Fall 'down' to dual of object klass 1.291 @@ -3220,12 +3298,12 @@ 1.292 // below the centerline when the superclass is exact. We need to 1.293 // do the same here. 1.294 if (klass()->equals(ciEnv::current()->Object_klass()) && !klass_is_exact()) { 1.295 - return TypeAryPtr::make(ptr, tp->ary(), tp->klass(), tp->klass_is_exact(), offset, instance_id, speculative); 1.296 + return TypeAryPtr::make(ptr, tp->ary(), tp->klass(), tp->klass_is_exact(), offset, instance_id, speculative, depth); 1.297 } else { 1.298 // cannot subclass, so the meet has to fall badly below the centerline 1.299 ptr = NotNull; 1.300 instance_id = InstanceBot; 1.301 - return TypeInstPtr::make( ptr, ciEnv::current()->Object_klass(), false, NULL, offset, instance_id, speculative); 1.302 + return TypeInstPtr::make( ptr, ciEnv::current()->Object_klass(), false, NULL, offset, instance_id, speculative, depth); 1.303 } 1.304 case Constant: 1.305 case NotNull: 1.306 @@ -3240,7 +3318,7 @@ 1.307 if (klass()->equals(ciEnv::current()->Object_klass()) && !klass_is_exact()) { 1.308 // that is, tp's array type is a subtype of my klass 1.309 return TypeAryPtr::make(ptr, (ptr == Constant ? tp->const_oop() : NULL), 1.310 - tp->ary(), tp->klass(), tp->klass_is_exact(), offset, instance_id, speculative); 1.311 + tp->ary(), tp->klass(), tp->klass_is_exact(), offset, instance_id, speculative, depth); 1.312 } 1.313 } 1.314 // The other case cannot happen, since I cannot be a subtype of an array. 1.315 @@ -3248,7 +3326,7 @@ 1.316 if( ptr == Constant ) 1.317 ptr = NotNull; 1.318 instance_id = InstanceBot; 1.319 - return make(ptr, ciEnv::current()->Object_klass(), false, NULL, offset, instance_id, speculative); 1.320 + return make(ptr, ciEnv::current()->Object_klass(), false, NULL, offset, instance_id, speculative, depth); 1.321 default: typerr(t); 1.322 } 1.323 } 1.324 @@ -3263,14 +3341,16 @@ 1.325 case AnyNull: { 1.326 int instance_id = meet_instance_id(InstanceTop); 1.327 const TypeOopPtr* speculative = xmeet_speculative(tp); 1.328 + int depth = meet_inline_depth(tp->inline_depth()); 1.329 return make(ptr, klass(), klass_is_exact(), 1.330 - (ptr == Constant ? const_oop() : NULL), offset, instance_id, speculative); 1.331 + (ptr == Constant ? const_oop() : NULL), offset, instance_id, speculative, depth); 1.332 } 1.333 case NotNull: 1.334 case BotPTR: { 1.335 int instance_id = meet_instance_id(tp->instance_id()); 1.336 const TypeOopPtr* speculative = xmeet_speculative(tp); 1.337 - return TypeOopPtr::make(ptr, offset, instance_id, speculative); 1.338 + int depth = meet_inline_depth(tp->inline_depth()); 1.339 + return TypeOopPtr::make(ptr, offset, instance_id, speculative, depth); 1.340 } 1.341 default: typerr(t); 1.342 } 1.343 @@ -3290,7 +3370,7 @@ 1.344 int instance_id = meet_instance_id(InstanceTop); 1.345 const TypeOopPtr* speculative = _speculative; 1.346 return make(ptr, klass(), klass_is_exact(), 1.347 - (ptr == Constant ? const_oop() : NULL), offset, instance_id, speculative); 1.348 + (ptr == Constant ? const_oop() : NULL), offset, instance_id, speculative, _inline_depth); 1.349 } 1.350 case NotNull: 1.351 case BotPTR: 1.352 @@ -3322,13 +3402,14 @@ 1.353 PTR ptr = meet_ptr( tinst->ptr() ); 1.354 int instance_id = meet_instance_id(tinst->instance_id()); 1.355 const TypeOopPtr* speculative = xmeet_speculative(tinst); 1.356 + int depth = meet_inline_depth(tinst->inline_depth()); 1.357 1.358 // Check for easy case; klasses are equal (and perhaps not loaded!) 1.359 // If we have constants, then we created oops so classes are loaded 1.360 // and we can handle the constants further down. This case handles 1.361 // both-not-loaded or both-loaded classes 1.362 if (ptr != Constant && klass()->equals(tinst->klass()) && klass_is_exact() == tinst->klass_is_exact()) { 1.363 - return make(ptr, klass(), klass_is_exact(), NULL, off, instance_id, speculative); 1.364 + return make(ptr, klass(), klass_is_exact(), NULL, off, instance_id, speculative, depth); 1.365 } 1.366 1.367 // Classes require inspection in the Java klass hierarchy. Must be loaded. 1.368 @@ -3392,7 +3473,7 @@ 1.369 // Find out which constant. 1.370 o = (this_klass == klass()) ? const_oop() : tinst->const_oop(); 1.371 } 1.372 - return make(ptr, k, xk, o, off, instance_id, speculative); 1.373 + return make(ptr, k, xk, o, off, instance_id, speculative, depth); 1.374 } 1.375 1.376 // Either oop vs oop or interface vs interface or interface vs Object 1.377 @@ -3469,7 +3550,7 @@ 1.378 else 1.379 ptr = NotNull; 1.380 } 1.381 - return make(ptr, this_klass, this_xk, o, off, instance_id, speculative); 1.382 + return make(ptr, this_klass, this_xk, o, off, instance_id, speculative, depth); 1.383 } // Else classes are not equal 1.384 1.385 // Since klasses are different, we require a LCA in the Java 1.386 @@ -3480,7 +3561,7 @@ 1.387 1.388 // Now we find the LCA of Java classes 1.389 ciKlass* k = this_klass->least_common_ancestor(tinst_klass); 1.390 - return make(ptr, k, false, NULL, off, instance_id, speculative); 1.391 + return make(ptr, k, false, NULL, off, instance_id, speculative, depth); 1.392 } // End of case InstPtr 1.393 1.394 } // End of switch 1.395 @@ -3504,7 +3585,7 @@ 1.396 // Dual: do NOT dual on klasses. This means I do NOT understand the Java 1.397 // inheritance mechanism. 1.398 const Type *TypeInstPtr::xdual() const { 1.399 - return new TypeInstPtr(dual_ptr(), klass(), klass_is_exact(), const_oop(), dual_offset(), dual_instance_id(), dual_speculative()); 1.400 + return new TypeInstPtr(dual_ptr(), klass(), klass_is_exact(), const_oop(), dual_offset(), dual_instance_id(), dual_speculative(), dual_inline_depth()); 1.401 } 1.402 1.403 //------------------------------eq--------------------------------------------- 1.404 @@ -3561,6 +3642,7 @@ 1.405 else if (_instance_id != InstanceBot) 1.406 st->print(",iid=%d",_instance_id); 1.407 1.408 + dump_inline_depth(st); 1.409 dump_speculative(st); 1.410 } 1.411 #endif 1.412 @@ -3574,7 +3656,15 @@ 1.413 if (_speculative == NULL) { 1.414 return this; 1.415 } 1.416 - return make(_ptr, klass(), klass_is_exact(), const_oop(), _offset, _instance_id, NULL); 1.417 + assert(_inline_depth == InlineDepthTop || _inline_depth == InlineDepthBottom, "non speculative type shouldn't have inline depth"); 1.418 + return make(_ptr, klass(), klass_is_exact(), const_oop(), _offset, _instance_id, NULL, _inline_depth); 1.419 +} 1.420 + 1.421 +const TypeOopPtr *TypeInstPtr::with_inline_depth(int depth) const { 1.422 + if (!UseInlineDepthForSpeculativeTypes) { 1.423 + return this; 1.424 + } 1.425 + return make(_ptr, klass(), klass_is_exact(), const_oop(), _offset, _instance_id, _speculative, depth); 1.426 } 1.427 1.428 //============================================================================= 1.429 @@ -3591,30 +3681,30 @@ 1.430 const TypeAryPtr *TypeAryPtr::DOUBLES; 1.431 1.432 //------------------------------make------------------------------------------- 1.433 -const TypeAryPtr *TypeAryPtr::make(PTR ptr, const TypeAry *ary, ciKlass* k, bool xk, int offset, int instance_id, const TypeOopPtr* speculative) { 1.434 +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.435 assert(!(k == NULL && ary->_elem->isa_int()), 1.436 "integral arrays must be pre-equipped with a class"); 1.437 if (!xk) xk = ary->ary_must_be_exact(); 1.438 assert(instance_id <= 0 || xk || !UseExactTypes, "instances are always exactly typed"); 1.439 if (!UseExactTypes) xk = (ptr == Constant); 1.440 - return (TypeAryPtr*)(new TypeAryPtr(ptr, NULL, ary, k, xk, offset, instance_id, false, speculative))->hashcons(); 1.441 + return (TypeAryPtr*)(new TypeAryPtr(ptr, NULL, ary, k, xk, offset, instance_id, false, speculative, inline_depth))->hashcons(); 1.442 } 1.443 1.444 //------------------------------make------------------------------------------- 1.445 -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.446 +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.447 assert(!(k == NULL && ary->_elem->isa_int()), 1.448 "integral arrays must be pre-equipped with a class"); 1.449 assert( (ptr==Constant && o) || (ptr!=Constant && !o), "" ); 1.450 if (!xk) xk = (o != NULL) || ary->ary_must_be_exact(); 1.451 assert(instance_id <= 0 || xk || !UseExactTypes, "instances are always exactly typed"); 1.452 if (!UseExactTypes) xk = (ptr == Constant); 1.453 - return (TypeAryPtr*)(new TypeAryPtr(ptr, o, ary, k, xk, offset, instance_id, is_autobox_cache, speculative))->hashcons(); 1.454 + return (TypeAryPtr*)(new TypeAryPtr(ptr, o, ary, k, xk, offset, instance_id, is_autobox_cache, speculative, inline_depth))->hashcons(); 1.455 } 1.456 1.457 //------------------------------cast_to_ptr_type------------------------------- 1.458 const Type *TypeAryPtr::cast_to_ptr_type(PTR ptr) const { 1.459 if( ptr == _ptr ) return this; 1.460 - return make(ptr, const_oop(), _ary, klass(), klass_is_exact(), _offset, _instance_id, _speculative); 1.461 + return make(ptr, const_oop(), _ary, klass(), klass_is_exact(), _offset, _instance_id, _speculative, _inline_depth); 1.462 } 1.463 1.464 1.465 @@ -3623,13 +3713,13 @@ 1.466 if( klass_is_exact == _klass_is_exact ) return this; 1.467 if (!UseExactTypes) return this; 1.468 if (_ary->ary_must_be_exact()) return this; // cannot clear xk 1.469 - return make(ptr(), const_oop(), _ary, klass(), klass_is_exact, _offset, _instance_id, _speculative); 1.470 + return make(ptr(), const_oop(), _ary, klass(), klass_is_exact, _offset, _instance_id, _speculative, _inline_depth); 1.471 } 1.472 1.473 //-----------------------------cast_to_instance_id---------------------------- 1.474 const TypeOopPtr *TypeAryPtr::cast_to_instance_id(int instance_id) const { 1.475 if( instance_id == _instance_id ) return this; 1.476 - return make(_ptr, const_oop(), _ary, klass(), _klass_is_exact, _offset, instance_id, _speculative); 1.477 + return make(_ptr, const_oop(), _ary, klass(), _klass_is_exact, _offset, instance_id, _speculative, _inline_depth); 1.478 } 1.479 1.480 //-----------------------------narrow_size_type------------------------------- 1.481 @@ -3692,7 +3782,7 @@ 1.482 new_size = narrow_size_type(new_size); 1.483 if (new_size == size()) return this; 1.484 const TypeAry* new_ary = TypeAry::make(elem(), new_size, is_stable()); 1.485 - return make(ptr(), const_oop(), new_ary, klass(), klass_is_exact(), _offset, _instance_id, _speculative); 1.486 + return make(ptr(), const_oop(), new_ary, klass(), klass_is_exact(), _offset, _instance_id, _speculative, _inline_depth); 1.487 } 1.488 1.489 1.490 @@ -3771,19 +3861,20 @@ 1.491 const TypeOopPtr *tp = t->is_oopptr(); 1.492 int offset = meet_offset(tp->offset()); 1.493 PTR ptr = meet_ptr(tp->ptr()); 1.494 + int depth = meet_inline_depth(tp->inline_depth()); 1.495 switch (tp->ptr()) { 1.496 case TopPTR: 1.497 case AnyNull: { 1.498 int instance_id = meet_instance_id(InstanceTop); 1.499 const TypeOopPtr* speculative = xmeet_speculative(tp); 1.500 return make(ptr, (ptr == Constant ? const_oop() : NULL), 1.501 - _ary, _klass, _klass_is_exact, offset, instance_id, speculative); 1.502 + _ary, _klass, _klass_is_exact, offset, instance_id, speculative, depth); 1.503 } 1.504 case BotPTR: 1.505 case NotNull: { 1.506 int instance_id = meet_instance_id(tp->instance_id()); 1.507 const TypeOopPtr* speculative = xmeet_speculative(tp); 1.508 - return TypeOopPtr::make(ptr, offset, instance_id, speculative); 1.509 + return TypeOopPtr::make(ptr, offset, instance_id, speculative, depth); 1.510 } 1.511 default: ShouldNotReachHere(); 1.512 } 1.513 @@ -3807,7 +3898,7 @@ 1.514 int instance_id = meet_instance_id(InstanceTop); 1.515 const TypeOopPtr* speculative = _speculative; 1.516 return make(ptr, (ptr == Constant ? const_oop() : NULL), 1.517 - _ary, _klass, _klass_is_exact, offset, instance_id, speculative); 1.518 + _ary, _klass, _klass_is_exact, offset, instance_id, speculative, _inline_depth); 1.519 } 1.520 default: ShouldNotReachHere(); 1.521 } 1.522 @@ -3824,6 +3915,7 @@ 1.523 PTR ptr = meet_ptr(tap->ptr()); 1.524 int instance_id = meet_instance_id(tap->instance_id()); 1.525 const TypeOopPtr* speculative = xmeet_speculative(tap); 1.526 + int depth = meet_inline_depth(tap->inline_depth()); 1.527 ciKlass* lazy_klass = NULL; 1.528 if (tary->_elem->isa_int()) { 1.529 // Integral array element types have irrelevant lattice relations. 1.530 @@ -3864,7 +3956,7 @@ 1.531 } else { 1.532 xk = (tap->_klass_is_exact | this->_klass_is_exact); 1.533 } 1.534 - return make(ptr, const_oop(), tary, lazy_klass, xk, off, instance_id, speculative); 1.535 + return make(ptr, const_oop(), tary, lazy_klass, xk, off, instance_id, speculative, depth); 1.536 case Constant: { 1.537 ciObject* o = const_oop(); 1.538 if( _ptr == Constant ) { 1.539 @@ -3883,7 +3975,7 @@ 1.540 // Only precise for identical arrays 1.541 xk = this->_klass_is_exact && (klass() == tap->klass()); 1.542 } 1.543 - return TypeAryPtr::make(ptr, o, tary, lazy_klass, xk, off, instance_id, speculative); 1.544 + return TypeAryPtr::make(ptr, o, tary, lazy_klass, xk, off, instance_id, speculative, depth); 1.545 } 1.546 case NotNull: 1.547 case BotPTR: 1.548 @@ -3892,7 +3984,7 @@ 1.549 xk = tap->_klass_is_exact; 1.550 else xk = (tap->_klass_is_exact & this->_klass_is_exact) && 1.551 (klass() == tap->klass()); // Only precise for identical arrays 1.552 - return TypeAryPtr::make(ptr, NULL, tary, lazy_klass, xk, off, instance_id, speculative); 1.553 + return TypeAryPtr::make(ptr, NULL, tary, lazy_klass, xk, off, instance_id, speculative, depth); 1.554 default: ShouldNotReachHere(); 1.555 } 1.556 } 1.557 @@ -3904,6 +3996,7 @@ 1.558 PTR ptr = meet_ptr(tp->ptr()); 1.559 int instance_id = meet_instance_id(tp->instance_id()); 1.560 const TypeOopPtr* speculative = xmeet_speculative(tp); 1.561 + int depth = meet_inline_depth(tp->inline_depth()); 1.562 switch (ptr) { 1.563 case TopPTR: 1.564 case AnyNull: // Fall 'down' to dual of object klass 1.565 @@ -3911,12 +4004,12 @@ 1.566 // below the centerline when the superclass is exact. We need to 1.567 // do the same here. 1.568 if (tp->klass()->equals(ciEnv::current()->Object_klass()) && !tp->klass_is_exact()) { 1.569 - return TypeAryPtr::make(ptr, _ary, _klass, _klass_is_exact, offset, instance_id, speculative); 1.570 + return TypeAryPtr::make(ptr, _ary, _klass, _klass_is_exact, offset, instance_id, speculative, depth); 1.571 } else { 1.572 // cannot subclass, so the meet has to fall badly below the centerline 1.573 ptr = NotNull; 1.574 instance_id = InstanceBot; 1.575 - return TypeInstPtr::make(ptr, ciEnv::current()->Object_klass(), false, NULL,offset, instance_id, speculative); 1.576 + return TypeInstPtr::make(ptr, ciEnv::current()->Object_klass(), false, NULL,offset, instance_id, speculative, depth); 1.577 } 1.578 case Constant: 1.579 case NotNull: 1.580 @@ -3931,7 +4024,7 @@ 1.581 if (tp->klass()->equals(ciEnv::current()->Object_klass()) && !tp->klass_is_exact()) { 1.582 // that is, my array type is a subtype of 'tp' klass 1.583 return make(ptr, (ptr == Constant ? const_oop() : NULL), 1.584 - _ary, _klass, _klass_is_exact, offset, instance_id, speculative); 1.585 + _ary, _klass, _klass_is_exact, offset, instance_id, speculative, depth); 1.586 } 1.587 } 1.588 // The other case cannot happen, since t cannot be a subtype of an array. 1.589 @@ -3939,7 +4032,7 @@ 1.590 if( ptr == Constant ) 1.591 ptr = NotNull; 1.592 instance_id = InstanceBot; 1.593 - return TypeInstPtr::make(ptr, ciEnv::current()->Object_klass(), false, NULL,offset, instance_id, speculative); 1.594 + return TypeInstPtr::make(ptr, ciEnv::current()->Object_klass(), false, NULL,offset, instance_id, speculative, depth); 1.595 default: typerr(t); 1.596 } 1.597 } 1.598 @@ -3950,7 +4043,7 @@ 1.599 //------------------------------xdual------------------------------------------ 1.600 // Dual: compute field-by-field dual 1.601 const Type *TypeAryPtr::xdual() const { 1.602 - 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.603 + 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.604 } 1.605 1.606 //----------------------interface_vs_oop--------------------------------------- 1.607 @@ -4003,6 +4096,7 @@ 1.608 else if (_instance_id != InstanceBot) 1.609 st->print(",iid=%d",_instance_id); 1.610 1.611 + dump_inline_depth(st); 1.612 dump_speculative(st); 1.613 } 1.614 #endif 1.615 @@ -4014,11 +4108,22 @@ 1.616 1.617 //------------------------------add_offset------------------------------------- 1.618 const TypePtr *TypeAryPtr::add_offset(intptr_t offset) const { 1.619 - return make(_ptr, _const_oop, _ary, _klass, _klass_is_exact, xadd_offset(offset), _instance_id, add_offset_speculative(offset)); 1.620 + return make(_ptr, _const_oop, _ary, _klass, _klass_is_exact, xadd_offset(offset), _instance_id, add_offset_speculative(offset), _inline_depth); 1.621 } 1.622 1.623 const Type *TypeAryPtr::remove_speculative() const { 1.624 - return make(_ptr, _const_oop, _ary->remove_speculative()->is_ary(), _klass, _klass_is_exact, _offset, _instance_id, NULL); 1.625 + if (_speculative == NULL) { 1.626 + return this; 1.627 + } 1.628 + assert(_inline_depth == InlineDepthTop || _inline_depth == InlineDepthBottom, "non speculative type shouldn't have inline depth"); 1.629 + return make(_ptr, _const_oop, _ary->remove_speculative()->is_ary(), _klass, _klass_is_exact, _offset, _instance_id, NULL, _inline_depth); 1.630 +} 1.631 + 1.632 +const TypeOopPtr *TypeAryPtr::with_inline_depth(int depth) const { 1.633 + if (!UseInlineDepthForSpeculativeTypes) { 1.634 + return this; 1.635 + } 1.636 + return make(_ptr, _const_oop, _ary->remove_speculative()->is_ary(), _klass, _klass_is_exact, _offset, _instance_id, _speculative, depth); 1.637 } 1.638 1.639 //=============================================================================