1.1 --- a/src/share/vm/opto/type.cpp Tue Jan 14 17:46:48 2014 -0800 1.2 +++ b/src/share/vm/opto/type.cpp Fri Jan 24 09:31:53 2014 +0100 1.3 @@ -236,6 +236,13 @@ 1.4 return !t1->eq(t2); // Return ZERO if equal 1.5 } 1.6 1.7 +const Type* Type::maybe_remove_speculative(bool include_speculative) const { 1.8 + if (!include_speculative) { 1.9 + return remove_speculative(); 1.10 + } 1.11 + return this; 1.12 +} 1.13 + 1.14 //------------------------------hash------------------------------------------- 1.15 int Type::uhash( const Type *const t ) { 1.16 return t->hash(); 1.17 @@ -628,41 +635,44 @@ 1.18 //------------------------------meet------------------------------------------- 1.19 // Compute the MEET of two types. NOT virtual. It enforces that meet is 1.20 // commutative and the lattice is symmetric. 1.21 -const Type *Type::meet( const Type *t ) const { 1.22 +const Type *Type::meet_helper(const Type *t, bool include_speculative) const { 1.23 if (isa_narrowoop() && t->isa_narrowoop()) { 1.24 - const Type* result = make_ptr()->meet(t->make_ptr()); 1.25 + const Type* result = make_ptr()->meet_helper(t->make_ptr(), include_speculative); 1.26 return result->make_narrowoop(); 1.27 } 1.28 if (isa_narrowklass() && t->isa_narrowklass()) { 1.29 - const Type* result = make_ptr()->meet(t->make_ptr()); 1.30 + const Type* result = make_ptr()->meet_helper(t->make_ptr(), include_speculative); 1.31 return result->make_narrowklass(); 1.32 } 1.33 1.34 - const Type *mt = xmeet(t); 1.35 + const Type *this_t = maybe_remove_speculative(include_speculative); 1.36 + t = t->maybe_remove_speculative(include_speculative); 1.37 + 1.38 + const Type *mt = this_t->xmeet(t); 1.39 if (isa_narrowoop() || t->isa_narrowoop()) return mt; 1.40 if (isa_narrowklass() || t->isa_narrowklass()) return mt; 1.41 #ifdef ASSERT 1.42 - assert( mt == t->xmeet(this), "meet not commutative" ); 1.43 + assert(mt == t->xmeet(this_t), "meet not commutative"); 1.44 const Type* dual_join = mt->_dual; 1.45 const Type *t2t = dual_join->xmeet(t->_dual); 1.46 - const Type *t2this = dual_join->xmeet( _dual); 1.47 + const Type *t2this = dual_join->xmeet(this_t->_dual); 1.48 1.49 // Interface meet Oop is Not Symmetric: 1.50 // Interface:AnyNull meet Oop:AnyNull == Interface:AnyNull 1.51 // Interface:NotNull meet Oop:NotNull == java/lang/Object:NotNull 1.52 1.53 - if( !interface_vs_oop(t) && (t2t != t->_dual || t2this != _dual) ) { 1.54 + if( !interface_vs_oop(t) && (t2t != t->_dual || t2this != this_t->_dual) ) { 1.55 tty->print_cr("=== Meet Not Symmetric ==="); 1.56 - tty->print("t = "); t->dump(); tty->cr(); 1.57 - tty->print("this= "); dump(); tty->cr(); 1.58 - tty->print("mt=(t meet this)= "); mt->dump(); tty->cr(); 1.59 - 1.60 - tty->print("t_dual= "); t->_dual->dump(); tty->cr(); 1.61 - tty->print("this_dual= "); _dual->dump(); tty->cr(); 1.62 - tty->print("mt_dual= "); mt->_dual->dump(); tty->cr(); 1.63 - 1.64 - tty->print("mt_dual meet t_dual= "); t2t ->dump(); tty->cr(); 1.65 - tty->print("mt_dual meet this_dual= "); t2this ->dump(); tty->cr(); 1.66 + tty->print("t = "); t->dump(); tty->cr(); 1.67 + tty->print("this= "); this_t->dump(); tty->cr(); 1.68 + tty->print("mt=(t meet this)= "); mt->dump(); tty->cr(); 1.69 + 1.70 + tty->print("t_dual= "); t->_dual->dump(); tty->cr(); 1.71 + tty->print("this_dual= "); this_t->_dual->dump(); tty->cr(); 1.72 + tty->print("mt_dual= "); mt->_dual->dump(); tty->cr(); 1.73 + 1.74 + tty->print("mt_dual meet t_dual= "); t2t ->dump(); tty->cr(); 1.75 + tty->print("mt_dual meet this_dual= "); t2this ->dump(); tty->cr(); 1.76 1.77 fatal("meet not symmetric" ); 1.78 } 1.79 @@ -754,8 +764,8 @@ 1.80 } 1.81 1.82 //-----------------------------filter------------------------------------------ 1.83 -const Type *Type::filter( const Type *kills ) const { 1.84 - const Type* ft = join(kills); 1.85 +const Type *Type::filter_helper(const Type *kills, bool include_speculative) const { 1.86 + const Type* ft = join_helper(kills, include_speculative); 1.87 if (ft->empty()) 1.88 return Type::TOP; // Canonical empty value 1.89 return ft; 1.90 @@ -1309,8 +1319,8 @@ 1.91 } 1.92 1.93 //-----------------------------filter------------------------------------------ 1.94 -const Type *TypeInt::filter( const Type *kills ) const { 1.95 - const TypeInt* ft = join(kills)->isa_int(); 1.96 +const Type *TypeInt::filter_helper(const Type *kills, bool include_speculative) const { 1.97 + const TypeInt* ft = join_helper(kills, include_speculative)->isa_int(); 1.98 if (ft == NULL || ft->empty()) 1.99 return Type::TOP; // Canonical empty value 1.100 if (ft->_widen < this->_widen) { 1.101 @@ -1570,8 +1580,8 @@ 1.102 } 1.103 1.104 //-----------------------------filter------------------------------------------ 1.105 -const Type *TypeLong::filter( const Type *kills ) const { 1.106 - const TypeLong* ft = join(kills)->isa_long(); 1.107 +const Type *TypeLong::filter_helper(const Type *kills, bool include_speculative) const { 1.108 + const TypeLong* ft = join_helper(kills, include_speculative)->isa_long(); 1.109 if (ft == NULL || ft->empty()) 1.110 return Type::TOP; // Canonical empty value 1.111 if (ft->_widen < this->_widen) { 1.112 @@ -1726,7 +1736,7 @@ 1.113 total_fields++; 1.114 field_array = fields(total_fields); 1.115 // Use get_const_type here because it respects UseUniqueSubclasses: 1.116 - field_array[pos++] = get_const_type(recv)->join(TypePtr::NOTNULL); 1.117 + field_array[pos++] = get_const_type(recv)->join_speculative(TypePtr::NOTNULL); 1.118 } else { 1.119 field_array = fields(total_fields); 1.120 } 1.121 @@ -1916,7 +1926,7 @@ 1.122 1.123 case Array: { // Meeting 2 arrays? 1.124 const TypeAry *a = t->is_ary(); 1.125 - return TypeAry::make(_elem->meet(a->_elem), 1.126 + return TypeAry::make(_elem->meet_speculative(a->_elem), 1.127 _size->xmeet(a->_size)->is_int(), 1.128 _stable & a->_stable); 1.129 } 1.130 @@ -1949,6 +1959,13 @@ 1.131 return (intptr_t)_elem + (intptr_t)_size + (_stable ? 43 : 0); 1.132 } 1.133 1.134 +/** 1.135 + * Return same type without a speculative part in the element 1.136 + */ 1.137 +const Type* TypeAry::remove_speculative() const { 1.138 + return make(_elem->remove_speculative(), _size, _stable); 1.139 +} 1.140 + 1.141 //----------------------interface_vs_oop--------------------------------------- 1.142 #ifdef ASSERT 1.143 bool TypeAry::interface_vs_oop(const Type *t) const { 1.144 @@ -2560,14 +2577,14 @@ 1.145 return res; 1.146 } 1.147 1.148 - if (res->isa_oopptr() != NULL) { 1.149 + const TypeOopPtr* res_oopptr = res->is_oopptr(); 1.150 + if (res_oopptr->speculative() != NULL) { 1.151 // type->speculative() == NULL means that speculation is no better 1.152 // than type, i.e. type->speculative() == type. So there are 2 1.153 // ways to represent the fact that we have no useful speculative 1.154 // data and we should use a single one to be able to test for 1.155 // equality between types. Check whether type->speculative() == 1.156 // type and set speculative to NULL if it is the case. 1.157 - const TypeOopPtr* res_oopptr = res->is_oopptr(); 1.158 if (res_oopptr->remove_speculative() == res_oopptr->speculative()) { 1.159 return res_oopptr->remove_speculative(); 1.160 } 1.161 @@ -2633,7 +2650,7 @@ 1.162 case OopPtr: { // Meeting to other OopPtrs 1.163 const TypeOopPtr *tp = t->is_oopptr(); 1.164 int instance_id = meet_instance_id(tp->instance_id()); 1.165 - const TypeOopPtr* speculative = meet_speculative(tp); 1.166 + const TypeOopPtr* speculative = xmeet_speculative(tp); 1.167 return make(meet_ptr(tp->ptr()), meet_offset(tp->offset()), instance_id, speculative); 1.168 } 1.169 1.170 @@ -2787,9 +2804,9 @@ 1.171 1.172 //-----------------------------filter------------------------------------------ 1.173 // Do not allow interface-vs.-noninterface joins to collapse to top. 1.174 -const Type *TypeOopPtr::filter(const Type *kills) const { 1.175 - 1.176 - const Type* ft = join(kills); 1.177 +const Type *TypeOopPtr::filter_helper(const Type *kills, bool include_speculative) const { 1.178 + 1.179 + const Type* ft = join_helper(kills, include_speculative); 1.180 const TypeInstPtr* ftip = ft->isa_instptr(); 1.181 const TypeInstPtr* ktip = kills->isa_instptr(); 1.182 1.183 @@ -2901,7 +2918,10 @@ 1.184 /** 1.185 * Return same type without a speculative part 1.186 */ 1.187 -const TypeOopPtr* TypeOopPtr::remove_speculative() const { 1.188 +const Type* TypeOopPtr::remove_speculative() const { 1.189 + if (_speculative == NULL) { 1.190 + return this; 1.191 + } 1.192 return make(_ptr, _offset, _instance_id, NULL); 1.193 } 1.194 1.195 @@ -2927,7 +2947,7 @@ 1.196 * 1.197 * @param other type to meet with 1.198 */ 1.199 -const TypeOopPtr* TypeOopPtr::meet_speculative(const TypeOopPtr* other) const { 1.200 +const TypeOopPtr* TypeOopPtr::xmeet_speculative(const TypeOopPtr* other) const { 1.201 bool this_has_spec = (_speculative != NULL); 1.202 bool other_has_spec = (other->speculative() != NULL); 1.203 1.204 @@ -2952,7 +2972,7 @@ 1.205 other_spec = other; 1.206 } 1.207 1.208 - return this_spec->meet(other_spec)->is_oopptr(); 1.209 + return this_spec->meet_speculative(other_spec)->is_oopptr(); 1.210 } 1.211 1.212 /** 1.213 @@ -3111,7 +3131,7 @@ 1.214 int off = meet_offset(tinst->offset()); 1.215 PTR ptr = meet_ptr(tinst->ptr()); 1.216 int instance_id = meet_instance_id(tinst->instance_id()); 1.217 - const TypeOopPtr* speculative = meet_speculative(tinst); 1.218 + const TypeOopPtr* speculative = xmeet_speculative(tinst); 1.219 1.220 const TypeInstPtr *loaded = is_loaded() ? this : tinst; 1.221 const TypeInstPtr *unloaded = is_loaded() ? tinst : this; 1.222 @@ -3188,7 +3208,7 @@ 1.223 int offset = meet_offset(tp->offset()); 1.224 PTR ptr = meet_ptr(tp->ptr()); 1.225 int instance_id = meet_instance_id(tp->instance_id()); 1.226 - const TypeOopPtr* speculative = meet_speculative(tp); 1.227 + const TypeOopPtr* speculative = xmeet_speculative(tp); 1.228 switch (ptr) { 1.229 case TopPTR: 1.230 case AnyNull: // Fall 'down' to dual of object klass 1.231 @@ -3238,14 +3258,14 @@ 1.232 case TopPTR: 1.233 case AnyNull: { 1.234 int instance_id = meet_instance_id(InstanceTop); 1.235 - const TypeOopPtr* speculative = meet_speculative(tp); 1.236 + const TypeOopPtr* speculative = xmeet_speculative(tp); 1.237 return make(ptr, klass(), klass_is_exact(), 1.238 (ptr == Constant ? const_oop() : NULL), offset, instance_id, speculative); 1.239 } 1.240 case NotNull: 1.241 case BotPTR: { 1.242 int instance_id = meet_instance_id(tp->instance_id()); 1.243 - const TypeOopPtr* speculative = meet_speculative(tp); 1.244 + const TypeOopPtr* speculative = xmeet_speculative(tp); 1.245 return TypeOopPtr::make(ptr, offset, instance_id, speculative); 1.246 } 1.247 default: typerr(t); 1.248 @@ -3297,7 +3317,7 @@ 1.249 int off = meet_offset( tinst->offset() ); 1.250 PTR ptr = meet_ptr( tinst->ptr() ); 1.251 int instance_id = meet_instance_id(tinst->instance_id()); 1.252 - const TypeOopPtr* speculative = meet_speculative(tinst); 1.253 + const TypeOopPtr* speculative = xmeet_speculative(tinst); 1.254 1.255 // Check for easy case; klasses are equal (and perhaps not loaded!) 1.256 // If we have constants, then we created oops so classes are loaded 1.257 @@ -3546,7 +3566,10 @@ 1.258 return make(_ptr, klass(), klass_is_exact(), const_oop(), xadd_offset(offset), _instance_id, add_offset_speculative(offset)); 1.259 } 1.260 1.261 -const TypeOopPtr *TypeInstPtr::remove_speculative() const { 1.262 +const Type *TypeInstPtr::remove_speculative() const { 1.263 + if (_speculative == NULL) { 1.264 + return this; 1.265 + } 1.266 return make(_ptr, klass(), klass_is_exact(), const_oop(), _offset, _instance_id, NULL); 1.267 } 1.268 1.269 @@ -3748,14 +3771,14 @@ 1.270 case TopPTR: 1.271 case AnyNull: { 1.272 int instance_id = meet_instance_id(InstanceTop); 1.273 - const TypeOopPtr* speculative = meet_speculative(tp); 1.274 + const TypeOopPtr* speculative = xmeet_speculative(tp); 1.275 return make(ptr, (ptr == Constant ? const_oop() : NULL), 1.276 _ary, _klass, _klass_is_exact, offset, instance_id, speculative); 1.277 } 1.278 case BotPTR: 1.279 case NotNull: { 1.280 int instance_id = meet_instance_id(tp->instance_id()); 1.281 - const TypeOopPtr* speculative = meet_speculative(tp); 1.282 + const TypeOopPtr* speculative = xmeet_speculative(tp); 1.283 return TypeOopPtr::make(ptr, offset, instance_id, speculative); 1.284 } 1.285 default: ShouldNotReachHere(); 1.286 @@ -3793,10 +3816,10 @@ 1.287 case AryPtr: { // Meeting 2 references? 1.288 const TypeAryPtr *tap = t->is_aryptr(); 1.289 int off = meet_offset(tap->offset()); 1.290 - const TypeAry *tary = _ary->meet(tap->_ary)->is_ary(); 1.291 + const TypeAry *tary = _ary->meet_speculative(tap->_ary)->is_ary(); 1.292 PTR ptr = meet_ptr(tap->ptr()); 1.293 int instance_id = meet_instance_id(tap->instance_id()); 1.294 - const TypeOopPtr* speculative = meet_speculative(tap); 1.295 + const TypeOopPtr* speculative = xmeet_speculative(tap); 1.296 ciKlass* lazy_klass = NULL; 1.297 if (tary->_elem->isa_int()) { 1.298 // Integral array element types have irrelevant lattice relations. 1.299 @@ -3876,7 +3899,7 @@ 1.300 int offset = meet_offset(tp->offset()); 1.301 PTR ptr = meet_ptr(tp->ptr()); 1.302 int instance_id = meet_instance_id(tp->instance_id()); 1.303 - const TypeOopPtr* speculative = meet_speculative(tp); 1.304 + const TypeOopPtr* speculative = xmeet_speculative(tp); 1.305 switch (ptr) { 1.306 case TopPTR: 1.307 case AnyNull: // Fall 'down' to dual of object klass 1.308 @@ -3990,8 +4013,8 @@ 1.309 return make(_ptr, _const_oop, _ary, _klass, _klass_is_exact, xadd_offset(offset), _instance_id, add_offset_speculative(offset)); 1.310 } 1.311 1.312 -const TypeOopPtr *TypeAryPtr::remove_speculative() const { 1.313 - return make(_ptr, _const_oop, _ary, _klass, _klass_is_exact, _offset, _instance_id, NULL); 1.314 +const Type *TypeAryPtr::remove_speculative() const { 1.315 + return make(_ptr, _const_oop, _ary->remove_speculative()->is_ary(), _klass, _klass_is_exact, _offset, _instance_id, NULL); 1.316 } 1.317 1.318 //============================================================================= 1.319 @@ -4031,9 +4054,9 @@ 1.320 } 1.321 1.322 1.323 -const Type *TypeNarrowPtr::filter( const Type *kills ) const { 1.324 +const Type *TypeNarrowPtr::filter_helper(const Type *kills, bool include_speculative) const { 1.325 if (isa_same_narrowptr(kills)) { 1.326 - const Type* ft =_ptrtype->filter(is_same_narrowptr(kills)->_ptrtype); 1.327 + const Type* ft =_ptrtype->filter_helper(is_same_narrowptr(kills)->_ptrtype, include_speculative); 1.328 if (ft->empty()) 1.329 return Type::TOP; // Canonical empty value 1.330 if (ft->isa_ptr()) { 1.331 @@ -4041,7 +4064,7 @@ 1.332 } 1.333 return ft; 1.334 } else if (kills->isa_ptr()) { 1.335 - const Type* ft = _ptrtype->join(kills); 1.336 + const Type* ft = _ptrtype->join_helper(kills, include_speculative); 1.337 if (ft->empty()) 1.338 return Type::TOP; // Canonical empty value 1.339 return ft; 1.340 @@ -4171,8 +4194,8 @@ 1.341 1.342 //-----------------------------filter------------------------------------------ 1.343 // Do not allow interface-vs.-noninterface joins to collapse to top. 1.344 -const Type *TypeMetadataPtr::filter( const Type *kills ) const { 1.345 - const TypeMetadataPtr* ft = join(kills)->isa_metadataptr(); 1.346 +const Type *TypeMetadataPtr::filter_helper(const Type *kills, bool include_speculative) const { 1.347 + const TypeMetadataPtr* ft = join_helper(kills, include_speculative)->isa_metadataptr(); 1.348 if (ft == NULL || ft->empty()) 1.349 return Type::TOP; // Canonical empty value 1.350 return ft; 1.351 @@ -4374,10 +4397,10 @@ 1.352 } 1.353 1.354 // Do not allow interface-vs.-noninterface joins to collapse to top. 1.355 -const Type *TypeKlassPtr::filter(const Type *kills) const { 1.356 +const Type *TypeKlassPtr::filter_helper(const Type *kills, bool include_speculative) const { 1.357 // logic here mirrors the one from TypeOopPtr::filter. See comments 1.358 // there. 1.359 - const Type* ft = join(kills); 1.360 + const Type* ft = join_helper(kills, include_speculative); 1.361 const TypeKlassPtr* ftkp = ft->isa_klassptr(); 1.362 const TypeKlassPtr* ktkp = kills->isa_klassptr(); 1.363