comparison src/share/vm/opto/type.hpp @ 14383:5ec7dace41a6

8027422: assert(_gvn.type(obj)->higher_equal(tjp)) failed: cast_up is no longer needed Summary: type methods shouldn't always operate on speculative part Reviewed-by: kvn, twisti
author roland
date Fri, 24 Jan 2014 09:31:53 +0100
parents 6c2f07d1495f
children 45467c53f178 085b304a1cc5
comparison
equal deleted inserted replaced
14272:757ec609d8d5 14383:5ec7dace41a6
162 #ifdef ASSERT 162 #ifdef ASSERT
163 // One type is interface, the other is oop 163 // One type is interface, the other is oop
164 virtual bool interface_vs_oop_helper(const Type *t) const; 164 virtual bool interface_vs_oop_helper(const Type *t) const;
165 #endif 165 #endif
166 166
167 const Type *meet_helper(const Type *t, bool include_speculative) const;
168
167 protected: 169 protected:
168 // Each class of type is also identified by its base. 170 // Each class of type is also identified by its base.
169 const TYPES _base; // Enum of Types type 171 const TYPES _base; // Enum of Types type
170 172
171 Type( TYPES t ) : _dual(NULL), _base(t) {} // Simple types 173 Type( TYPES t ) : _dual(NULL), _base(t) {} // Simple types
172 // ~Type(); // Use fast deallocation 174 // ~Type(); // Use fast deallocation
173 const Type *hashcons(); // Hash-cons the type 175 const Type *hashcons(); // Hash-cons the type
176 virtual const Type *filter_helper(const Type *kills, bool include_speculative) const;
177 const Type *join_helper(const Type *t, bool include_speculative) const {
178 return dual()->meet_helper(t->dual(), include_speculative)->dual();
179 }
174 180
175 public: 181 public:
176 182
177 inline void* operator new( size_t x ) throw() { 183 inline void* operator new( size_t x ) throw() {
178 Compile* compile = Compile::current(); 184 Compile* compile = Compile::current();
200 // Create a new hash-consd type 206 // Create a new hash-consd type
201 static const Type *make(enum TYPES); 207 static const Type *make(enum TYPES);
202 // Test for equivalence of types 208 // Test for equivalence of types
203 static int cmp( const Type *const t1, const Type *const t2 ); 209 static int cmp( const Type *const t1, const Type *const t2 );
204 // Test for higher or equal in lattice 210 // Test for higher or equal in lattice
205 int higher_equal( const Type *t ) const { return !cmp(meet(t),t); } 211 // Variant that drops the speculative part of the types
212 int higher_equal(const Type *t) const {
213 return !cmp(meet(t),t->remove_speculative());
214 }
215 // Variant that keeps the speculative part of the types
216 int higher_equal_speculative(const Type *t) const {
217 return !cmp(meet_speculative(t),t);
218 }
206 219
207 // MEET operation; lower in lattice. 220 // MEET operation; lower in lattice.
208 const Type *meet( const Type *t ) const; 221 // Variant that drops the speculative part of the types
222 const Type *meet(const Type *t) const {
223 return meet_helper(t, false);
224 }
225 // Variant that keeps the speculative part of the types
226 const Type *meet_speculative(const Type *t) const {
227 return meet_helper(t, true);
228 }
209 // WIDEN: 'widens' for Ints and other range types 229 // WIDEN: 'widens' for Ints and other range types
210 virtual const Type *widen( const Type *old, const Type* limit ) const { return this; } 230 virtual const Type *widen( const Type *old, const Type* limit ) const { return this; }
211 // NARROW: complement for widen, used by pessimistic phases 231 // NARROW: complement for widen, used by pessimistic phases
212 virtual const Type *narrow( const Type *old ) const { return this; } 232 virtual const Type *narrow( const Type *old ) const { return this; }
213 233
219 virtual const Type *xmeet( const Type *t ) const; 239 virtual const Type *xmeet( const Type *t ) const;
220 virtual const Type *xdual() const; // Compute dual right now. 240 virtual const Type *xdual() const; // Compute dual right now.
221 241
222 // JOIN operation; higher in lattice. Done by finding the dual of the 242 // JOIN operation; higher in lattice. Done by finding the dual of the
223 // meet of the dual of the 2 inputs. 243 // meet of the dual of the 2 inputs.
224 const Type *join( const Type *t ) const { 244 // Variant that drops the speculative part of the types
225 return dual()->meet(t->dual())->dual(); } 245 const Type *join(const Type *t) const {
246 return join_helper(t, false);
247 }
248 // Variant that keeps the speculative part of the types
249 const Type *join_speculative(const Type *t) const {
250 return join_helper(t, true);
251 }
226 252
227 // Modified version of JOIN adapted to the needs Node::Value. 253 // Modified version of JOIN adapted to the needs Node::Value.
228 // Normalizes all empty values to TOP. Does not kill _widen bits. 254 // Normalizes all empty values to TOP. Does not kill _widen bits.
229 // Currently, it also works around limitations involving interface types. 255 // Currently, it also works around limitations involving interface types.
230 virtual const Type *filter( const Type *kills ) const; 256 // Variant that drops the speculative part of the types
257 const Type *filter(const Type *kills) const {
258 return filter_helper(kills, false);
259 }
260 // Variant that keeps the speculative part of the types
261 const Type *filter_speculative(const Type *kills) const {
262 return filter_helper(kills, true);
263 }
231 264
232 #ifdef ASSERT 265 #ifdef ASSERT
233 // One type is interface, the other is oop 266 // One type is interface, the other is oop
234 virtual bool interface_vs_oop(const Type *t) const; 267 virtual bool interface_vs_oop(const Type *t) const;
235 #endif 268 #endif
381 bool require_constant = false, 414 bool require_constant = false,
382 bool is_autobox_cache = false); 415 bool is_autobox_cache = false);
383 416
384 // Speculative type. See TypeInstPtr 417 // Speculative type. See TypeInstPtr
385 virtual ciKlass* speculative_type() const { return NULL; } 418 virtual ciKlass* speculative_type() const { return NULL; }
419 const Type* maybe_remove_speculative(bool include_speculative) const;
420 virtual const Type* remove_speculative() const { return this; }
386 421
387 private: 422 private:
388 // support arrays 423 // support arrays
389 static const BasicType _basic_type[]; 424 static const BasicType _basic_type[];
390 static const Type* _zero_type[T_CONFLICT+1]; 425 static const Type* _zero_type[T_CONFLICT+1];
448 //------------------------------TypeInt---------------------------------------- 483 //------------------------------TypeInt----------------------------------------
449 // Class of integer ranges, the set of integers between a lower bound and an 484 // Class of integer ranges, the set of integers between a lower bound and an
450 // upper bound, inclusive. 485 // upper bound, inclusive.
451 class TypeInt : public Type { 486 class TypeInt : public Type {
452 TypeInt( jint lo, jint hi, int w ); 487 TypeInt( jint lo, jint hi, int w );
488 protected:
489 virtual const Type *filter_helper(const Type *kills, bool include_speculative) const;
490
453 public: 491 public:
454 virtual bool eq( const Type *t ) const; 492 virtual bool eq( const Type *t ) const;
455 virtual int hash() const; // Type specific hashing 493 virtual int hash() const; // Type specific hashing
456 virtual bool singleton(void) const; // TRUE if type is a singleton 494 virtual bool singleton(void) const; // TRUE if type is a singleton
457 virtual bool empty(void) const; // TRUE if type is vacuous 495 virtual bool empty(void) const; // TRUE if type is vacuous
458 public:
459 const jint _lo, _hi; // Lower bound, upper bound 496 const jint _lo, _hi; // Lower bound, upper bound
460 const short _widen; // Limit on times we widen this sucker 497 const short _widen; // Limit on times we widen this sucker
461 498
462 static const TypeInt *make(jint lo); 499 static const TypeInt *make(jint lo);
463 // must always specify w 500 // must always specify w
473 virtual const Type *xmeet( const Type *t ) const; 510 virtual const Type *xmeet( const Type *t ) const;
474 virtual const Type *xdual() const; // Compute dual right now. 511 virtual const Type *xdual() const; // Compute dual right now.
475 virtual const Type *widen( const Type *t, const Type* limit_type ) const; 512 virtual const Type *widen( const Type *t, const Type* limit_type ) const;
476 virtual const Type *narrow( const Type *t ) const; 513 virtual const Type *narrow( const Type *t ) const;
477 // Do not kill _widen bits. 514 // Do not kill _widen bits.
478 virtual const Type *filter( const Type *kills ) const;
479 // Convenience common pre-built types. 515 // Convenience common pre-built types.
480 static const TypeInt *MINUS_1; 516 static const TypeInt *MINUS_1;
481 static const TypeInt *ZERO; 517 static const TypeInt *ZERO;
482 static const TypeInt *ONE; 518 static const TypeInt *ONE;
483 static const TypeInt *BOOL; 519 static const TypeInt *BOOL;
504 //------------------------------TypeLong--------------------------------------- 540 //------------------------------TypeLong---------------------------------------
505 // Class of long integer ranges, the set of integers between a lower bound and 541 // Class of long integer ranges, the set of integers between a lower bound and
506 // an upper bound, inclusive. 542 // an upper bound, inclusive.
507 class TypeLong : public Type { 543 class TypeLong : public Type {
508 TypeLong( jlong lo, jlong hi, int w ); 544 TypeLong( jlong lo, jlong hi, int w );
545 protected:
546 // Do not kill _widen bits.
547 virtual const Type *filter_helper(const Type *kills, bool include_speculative) const;
509 public: 548 public:
510 virtual bool eq( const Type *t ) const; 549 virtual bool eq( const Type *t ) const;
511 virtual int hash() const; // Type specific hashing 550 virtual int hash() const; // Type specific hashing
512 virtual bool singleton(void) const; // TRUE if type is a singleton 551 virtual bool singleton(void) const; // TRUE if type is a singleton
513 virtual bool empty(void) const; // TRUE if type is vacuous 552 virtual bool empty(void) const; // TRUE if type is vacuous
528 567
529 virtual const Type *xmeet( const Type *t ) const; 568 virtual const Type *xmeet( const Type *t ) const;
530 virtual const Type *xdual() const; // Compute dual right now. 569 virtual const Type *xdual() const; // Compute dual right now.
531 virtual const Type *widen( const Type *t, const Type* limit_type ) const; 570 virtual const Type *widen( const Type *t, const Type* limit_type ) const;
532 virtual const Type *narrow( const Type *t ) const; 571 virtual const Type *narrow( const Type *t ) const;
533 // Do not kill _widen bits.
534 virtual const Type *filter( const Type *kills ) const;
535 // Convenience common pre-built types. 572 // Convenience common pre-built types.
536 static const TypeLong *MINUS_1; 573 static const TypeLong *MINUS_1;
537 static const TypeLong *ZERO; 574 static const TypeLong *ZERO;
538 static const TypeLong *ONE; 575 static const TypeLong *ONE;
539 static const TypeLong *POS; 576 static const TypeLong *POS;
620 static const TypeAry* make(const Type* elem, const TypeInt* size, bool stable = false); 657 static const TypeAry* make(const Type* elem, const TypeInt* size, bool stable = false);
621 658
622 virtual const Type *xmeet( const Type *t ) const; 659 virtual const Type *xmeet( const Type *t ) const;
623 virtual const Type *xdual() const; // Compute dual right now. 660 virtual const Type *xdual() const; // Compute dual right now.
624 bool ary_must_be_exact() const; // true if arrays of such are never generic 661 bool ary_must_be_exact() const; // true if arrays of such are never generic
662 virtual const Type* remove_speculative() const;
625 #ifdef ASSERT 663 #ifdef ASSERT
626 // One type is interface, the other is oop 664 // One type is interface, the other is oop
627 virtual bool interface_vs_oop(const Type *t) const; 665 virtual bool interface_vs_oop(const Type *t) const;
628 #endif 666 #endif
629 #ifndef PRODUCT 667 #ifndef PRODUCT
830 int dual_instance_id() const; 868 int dual_instance_id() const;
831 int meet_instance_id(int uid) const; 869 int meet_instance_id(int uid) const;
832 870
833 // utility methods to work on the speculative part of the type 871 // utility methods to work on the speculative part of the type
834 const TypeOopPtr* dual_speculative() const; 872 const TypeOopPtr* dual_speculative() const;
835 const TypeOopPtr* meet_speculative(const TypeOopPtr* other) const; 873 const TypeOopPtr* xmeet_speculative(const TypeOopPtr* other) const;
836 bool eq_speculative(const TypeOopPtr* other) const; 874 bool eq_speculative(const TypeOopPtr* other) const;
837 int hash_speculative() const; 875 int hash_speculative() const;
838 const TypeOopPtr* add_offset_speculative(intptr_t offset) const; 876 const TypeOopPtr* add_offset_speculative(intptr_t offset) const;
839 #ifndef PRODUCT 877 #ifndef PRODUCT
840 void dump_speculative(outputStream *st) const; 878 void dump_speculative(outputStream *st) const;
841 #endif 879 #endif
880
881 // Do not allow interface-vs.-noninterface joins to collapse to top.
882 virtual const Type *filter_helper(const Type *kills, bool include_speculative) const;
842 883
843 public: 884 public:
844 // Creates a type given a klass. Correctly handles multi-dimensional arrays 885 // Creates a type given a klass. Correctly handles multi-dimensional arrays
845 // Respects UseUniqueSubclasses. 886 // Respects UseUniqueSubclasses.
846 // If the klass is final, the resulting type will be exact. 887 // If the klass is final, the resulting type will be exact.
893 // corresponding pointer to klass, for a given instance 934 // corresponding pointer to klass, for a given instance
894 const TypeKlassPtr* as_klass_type() const; 935 const TypeKlassPtr* as_klass_type() const;
895 936
896 virtual const TypePtr *add_offset( intptr_t offset ) const; 937 virtual const TypePtr *add_offset( intptr_t offset ) const;
897 // Return same type without a speculative part 938 // Return same type without a speculative part
898 virtual const TypeOopPtr* remove_speculative() const; 939 virtual const Type* remove_speculative() const;
899 940
900 virtual const Type *xmeet(const Type *t) const; 941 virtual const Type *xmeet(const Type *t) const;
901 virtual const Type *xdual() const; // Compute dual right now. 942 virtual const Type *xdual() const; // Compute dual right now.
902 // the core of the computation of the meet for TypeOopPtr and for its subclasses 943 // the core of the computation of the meet for TypeOopPtr and for its subclasses
903 virtual const Type *xmeet_helper(const Type *t) const; 944 virtual const Type *xmeet_helper(const Type *t) const;
904
905 // Do not allow interface-vs.-noninterface joins to collapse to top.
906 virtual const Type *filter( const Type *kills ) const;
907 945
908 // Convenience common pre-built type. 946 // Convenience common pre-built type.
909 static const TypeOopPtr *BOTTOM; 947 static const TypeOopPtr *BOTTOM;
910 #ifndef PRODUCT 948 #ifndef PRODUCT
911 virtual void dump2( Dict &d, uint depth, outputStream *st ) const; 949 virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
979 1017
980 virtual const TypeOopPtr *cast_to_instance_id(int instance_id) const; 1018 virtual const TypeOopPtr *cast_to_instance_id(int instance_id) const;
981 1019
982 virtual const TypePtr *add_offset( intptr_t offset ) const; 1020 virtual const TypePtr *add_offset( intptr_t offset ) const;
983 // Return same type without a speculative part 1021 // Return same type without a speculative part
984 virtual const TypeOopPtr* remove_speculative() const; 1022 virtual const Type* remove_speculative() const;
985 1023
986 // the core of the computation of the meet of 2 types 1024 // the core of the computation of the meet of 2 types
987 virtual const Type *xmeet_helper(const Type *t) const; 1025 virtual const Type *xmeet_helper(const Type *t) const;
988 virtual const TypeInstPtr *xmeet_unloaded( const TypeInstPtr *t ) const; 1026 virtual const TypeInstPtr *xmeet_unloaded( const TypeInstPtr *t ) const;
989 virtual const Type *xdual() const; // Compute dual right now. 1027 virtual const Type *xdual() const; // Compute dual right now.
1057 virtual const TypeInt* narrow_size_type(const TypeInt* size) const; 1095 virtual const TypeInt* narrow_size_type(const TypeInt* size) const;
1058 1096
1059 virtual bool empty(void) const; // TRUE if type is vacuous 1097 virtual bool empty(void) const; // TRUE if type is vacuous
1060 virtual const TypePtr *add_offset( intptr_t offset ) const; 1098 virtual const TypePtr *add_offset( intptr_t offset ) const;
1061 // Return same type without a speculative part 1099 // Return same type without a speculative part
1062 virtual const TypeOopPtr* remove_speculative() const; 1100 virtual const Type* remove_speculative() const;
1063 1101
1064 // the core of the computation of the meet of 2 types 1102 // the core of the computation of the meet of 2 types
1065 virtual const Type *xmeet_helper(const Type *t) const; 1103 virtual const Type *xmeet_helper(const Type *t) const;
1066 virtual const Type *xdual() const; // Compute dual right now. 1104 virtual const Type *xdual() const; // Compute dual right now.
1067 1105
1098 //------------------------------TypeMetadataPtr------------------------------------- 1136 //------------------------------TypeMetadataPtr-------------------------------------
1099 // Some kind of metadata, either Method*, MethodData* or CPCacheOop 1137 // Some kind of metadata, either Method*, MethodData* or CPCacheOop
1100 class TypeMetadataPtr : public TypePtr { 1138 class TypeMetadataPtr : public TypePtr {
1101 protected: 1139 protected:
1102 TypeMetadataPtr(PTR ptr, ciMetadata* metadata, int offset); 1140 TypeMetadataPtr(PTR ptr, ciMetadata* metadata, int offset);
1141 // Do not allow interface-vs.-noninterface joins to collapse to top.
1142 virtual const Type *filter_helper(const Type *kills, bool include_speculative) const;
1103 public: 1143 public:
1104 virtual bool eq( const Type *t ) const; 1144 virtual bool eq( const Type *t ) const;
1105 virtual int hash() const; // Type specific hashing 1145 virtual int hash() const; // Type specific hashing
1106 virtual bool singleton(void) const; // TRUE if type is a singleton 1146 virtual bool singleton(void) const; // TRUE if type is a singleton
1107 1147
1122 1162
1123 virtual const Type *xmeet( const Type *t ) const; 1163 virtual const Type *xmeet( const Type *t ) const;
1124 virtual const Type *xdual() const; // Compute dual right now. 1164 virtual const Type *xdual() const; // Compute dual right now.
1125 1165
1126 virtual intptr_t get_con() const; 1166 virtual intptr_t get_con() const;
1127
1128 // Do not allow interface-vs.-noninterface joins to collapse to top.
1129 virtual const Type *filter( const Type *kills ) const;
1130 1167
1131 // Convenience common pre-built types. 1168 // Convenience common pre-built types.
1132 static const TypeMetadataPtr *BOTTOM; 1169 static const TypeMetadataPtr *BOTTOM;
1133 1170
1134 #ifndef PRODUCT 1171 #ifndef PRODUCT
1139 //------------------------------TypeKlassPtr----------------------------------- 1176 //------------------------------TypeKlassPtr-----------------------------------
1140 // Class of Java Klass pointers 1177 // Class of Java Klass pointers
1141 class TypeKlassPtr : public TypePtr { 1178 class TypeKlassPtr : public TypePtr {
1142 TypeKlassPtr( PTR ptr, ciKlass* klass, int offset ); 1179 TypeKlassPtr( PTR ptr, ciKlass* klass, int offset );
1143 1180
1181 protected:
1182 virtual const Type *filter_helper(const Type *kills, bool include_speculative) const;
1144 public: 1183 public:
1145 virtual bool eq( const Type *t ) const; 1184 virtual bool eq( const Type *t ) const;
1146 virtual int hash() const; // Type specific hashing 1185 virtual int hash() const; // Type specific hashing
1147 virtual bool singleton(void) const; // TRUE if type is a singleton 1186 virtual bool singleton(void) const; // TRUE if type is a singleton
1148 private: 1187 private:
1200 virtual const Type *xmeet( const Type *t ) const; 1239 virtual const Type *xmeet( const Type *t ) const;
1201 virtual const Type *xdual() const; // Compute dual right now. 1240 virtual const Type *xdual() const; // Compute dual right now.
1202 1241
1203 virtual intptr_t get_con() const; 1242 virtual intptr_t get_con() const;
1204 1243
1205 // Do not allow interface-vs.-noninterface joins to collapse to top.
1206 virtual const Type *filter( const Type *kills ) const;
1207
1208 // Convenience common pre-built types. 1244 // Convenience common pre-built types.
1209 static const TypeKlassPtr* OBJECT; // Not-null object klass or below 1245 static const TypeKlassPtr* OBJECT; // Not-null object klass or below
1210 static const TypeKlassPtr* OBJECT_OR_NULL; // Maybe-null version of same 1246 static const TypeKlassPtr* OBJECT_OR_NULL; // Maybe-null version of same
1211 #ifndef PRODUCT 1247 #ifndef PRODUCT
1212 virtual void dump2( Dict &d, uint depth, outputStream *st ) const; // Specialized per-Type dumping 1248 virtual void dump2( Dict &d, uint depth, outputStream *st ) const; // Specialized per-Type dumping
1226 1262
1227 virtual const TypeNarrowPtr *isa_same_narrowptr(const Type *t) const = 0; 1263 virtual const TypeNarrowPtr *isa_same_narrowptr(const Type *t) const = 0;
1228 virtual const TypeNarrowPtr *is_same_narrowptr(const Type *t) const = 0; 1264 virtual const TypeNarrowPtr *is_same_narrowptr(const Type *t) const = 0;
1229 virtual const TypeNarrowPtr *make_same_narrowptr(const TypePtr *t) const = 0; 1265 virtual const TypeNarrowPtr *make_same_narrowptr(const TypePtr *t) const = 0;
1230 virtual const TypeNarrowPtr *make_hash_same_narrowptr(const TypePtr *t) const = 0; 1266 virtual const TypeNarrowPtr *make_hash_same_narrowptr(const TypePtr *t) const = 0;
1267 // Do not allow interface-vs.-noninterface joins to collapse to top.
1268 virtual const Type *filter_helper(const Type *kills, bool include_speculative) const;
1231 public: 1269 public:
1232 virtual bool eq( const Type *t ) const; 1270 virtual bool eq( const Type *t ) const;
1233 virtual int hash() const; // Type specific hashing 1271 virtual int hash() const; // Type specific hashing
1234 virtual bool singleton(void) const; // TRUE if type is a singleton 1272 virtual bool singleton(void) const; // TRUE if type is a singleton
1235 1273
1236 virtual const Type *xmeet( const Type *t ) const; 1274 virtual const Type *xmeet( const Type *t ) const;
1237 virtual const Type *xdual() const; // Compute dual right now. 1275 virtual const Type *xdual() const; // Compute dual right now.
1238 1276
1239 virtual intptr_t get_con() const; 1277 virtual intptr_t get_con() const;
1240
1241 // Do not allow interface-vs.-noninterface joins to collapse to top.
1242 virtual const Type *filter( const Type *kills ) const;
1243 1278
1244 virtual bool empty(void) const; // TRUE if type is vacuous 1279 virtual bool empty(void) const; // TRUE if type is vacuous
1245 1280
1246 // returns the equivalent ptr type for this compressed pointer 1281 // returns the equivalent ptr type for this compressed pointer
1247 const TypePtr *get_ptrtype() const { 1282 const TypePtr *get_ptrtype() const {
1288 return make(TypeOopPtr::make_from_constant(con, require_constant)); 1323 return make(TypeOopPtr::make_from_constant(con, require_constant));
1289 } 1324 }
1290 1325
1291 static const TypeNarrowOop *BOTTOM; 1326 static const TypeNarrowOop *BOTTOM;
1292 static const TypeNarrowOop *NULL_PTR; 1327 static const TypeNarrowOop *NULL_PTR;
1328
1329 virtual const Type* remove_speculative() const {
1330 return make(_ptrtype->remove_speculative()->is_ptr());
1331 }
1293 1332
1294 #ifndef PRODUCT 1333 #ifndef PRODUCT
1295 virtual void dump2( Dict &d, uint depth, outputStream *st ) const; 1334 virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
1296 #endif 1335 #endif
1297 }; 1336 };