comparison src/share/vm/opto/type.hpp @ 14457:45467c53f178

Merge
author kvn
date Tue, 28 Jan 2014 12:28:17 -0800
parents 15120a36272d 5ec7dace41a6
children cd5d10655495 62c54fcc0a35
comparison
equal deleted inserted replaced
14456:abec000618bf 14457:45467c53f178
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
531 570
532 virtual const Type *xmeet( const Type *t ) const; 571 virtual const Type *xmeet( const Type *t ) const;
533 virtual const Type *xdual() const; // Compute dual right now. 572 virtual const Type *xdual() const; // Compute dual right now.
534 virtual const Type *widen( const Type *t, const Type* limit_type ) const; 573 virtual const Type *widen( const Type *t, const Type* limit_type ) const;
535 virtual const Type *narrow( const Type *t ) const; 574 virtual const Type *narrow( const Type *t ) const;
536 // Do not kill _widen bits.
537 virtual const Type *filter( const Type *kills ) const;
538 // Convenience common pre-built types. 575 // Convenience common pre-built types.
539 static const TypeLong *MINUS_1; 576 static const TypeLong *MINUS_1;
540 static const TypeLong *ZERO; 577 static const TypeLong *ZERO;
541 static const TypeLong *ONE; 578 static const TypeLong *ONE;
542 static const TypeLong *POS; 579 static const TypeLong *POS;
623 static const TypeAry* make(const Type* elem, const TypeInt* size, bool stable = false); 660 static const TypeAry* make(const Type* elem, const TypeInt* size, bool stable = false);
624 661
625 virtual const Type *xmeet( const Type *t ) const; 662 virtual const Type *xmeet( const Type *t ) const;
626 virtual const Type *xdual() const; // Compute dual right now. 663 virtual const Type *xdual() const; // Compute dual right now.
627 bool ary_must_be_exact() const; // true if arrays of such are never generic 664 bool ary_must_be_exact() const; // true if arrays of such are never generic
665 virtual const Type* remove_speculative() const;
628 #ifdef ASSERT 666 #ifdef ASSERT
629 // One type is interface, the other is oop 667 // One type is interface, the other is oop
630 virtual bool interface_vs_oop(const Type *t) const; 668 virtual bool interface_vs_oop(const Type *t) const;
631 #endif 669 #endif
632 #ifndef PRODUCT 670 #ifndef PRODUCT
833 int dual_instance_id() const; 871 int dual_instance_id() const;
834 int meet_instance_id(int uid) const; 872 int meet_instance_id(int uid) const;
835 873
836 // utility methods to work on the speculative part of the type 874 // utility methods to work on the speculative part of the type
837 const TypeOopPtr* dual_speculative() const; 875 const TypeOopPtr* dual_speculative() const;
838 const TypeOopPtr* meet_speculative(const TypeOopPtr* other) const; 876 const TypeOopPtr* xmeet_speculative(const TypeOopPtr* other) const;
839 bool eq_speculative(const TypeOopPtr* other) const; 877 bool eq_speculative(const TypeOopPtr* other) const;
840 int hash_speculative() const; 878 int hash_speculative() const;
841 const TypeOopPtr* add_offset_speculative(intptr_t offset) const; 879 const TypeOopPtr* add_offset_speculative(intptr_t offset) const;
842 #ifndef PRODUCT 880 #ifndef PRODUCT
843 void dump_speculative(outputStream *st) const; 881 void dump_speculative(outputStream *st) const;
844 #endif 882 #endif
883
884 // Do not allow interface-vs.-noninterface joins to collapse to top.
885 virtual const Type *filter_helper(const Type *kills, bool include_speculative) const;
845 886
846 public: 887 public:
847 // Creates a type given a klass. Correctly handles multi-dimensional arrays 888 // Creates a type given a klass. Correctly handles multi-dimensional arrays
848 // Respects UseUniqueSubclasses. 889 // Respects UseUniqueSubclasses.
849 // If the klass is final, the resulting type will be exact. 890 // If the klass is final, the resulting type will be exact.
896 // corresponding pointer to klass, for a given instance 937 // corresponding pointer to klass, for a given instance
897 const TypeKlassPtr* as_klass_type() const; 938 const TypeKlassPtr* as_klass_type() const;
898 939
899 virtual const TypePtr *add_offset( intptr_t offset ) const; 940 virtual const TypePtr *add_offset( intptr_t offset ) const;
900 // Return same type without a speculative part 941 // Return same type without a speculative part
901 virtual const TypeOopPtr* remove_speculative() const; 942 virtual const Type* remove_speculative() const;
902 943
903 virtual const Type *xmeet(const Type *t) const; 944 virtual const Type *xmeet(const Type *t) const;
904 virtual const Type *xdual() const; // Compute dual right now. 945 virtual const Type *xdual() const; // Compute dual right now.
905 // the core of the computation of the meet for TypeOopPtr and for its subclasses 946 // the core of the computation of the meet for TypeOopPtr and for its subclasses
906 virtual const Type *xmeet_helper(const Type *t) const; 947 virtual const Type *xmeet_helper(const Type *t) const;
907
908 // Do not allow interface-vs.-noninterface joins to collapse to top.
909 virtual const Type *filter( const Type *kills ) const;
910 948
911 // Convenience common pre-built type. 949 // Convenience common pre-built type.
912 static const TypeOopPtr *BOTTOM; 950 static const TypeOopPtr *BOTTOM;
913 #ifndef PRODUCT 951 #ifndef PRODUCT
914 virtual void dump2( Dict &d, uint depth, outputStream *st ) const; 952 virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
982 1020
983 virtual const TypeOopPtr *cast_to_instance_id(int instance_id) const; 1021 virtual const TypeOopPtr *cast_to_instance_id(int instance_id) const;
984 1022
985 virtual const TypePtr *add_offset( intptr_t offset ) const; 1023 virtual const TypePtr *add_offset( intptr_t offset ) const;
986 // Return same type without a speculative part 1024 // Return same type without a speculative part
987 virtual const TypeOopPtr* remove_speculative() const; 1025 virtual const Type* remove_speculative() const;
988 1026
989 // the core of the computation of the meet of 2 types 1027 // the core of the computation of the meet of 2 types
990 virtual const Type *xmeet_helper(const Type *t) const; 1028 virtual const Type *xmeet_helper(const Type *t) const;
991 virtual const TypeInstPtr *xmeet_unloaded( const TypeInstPtr *t ) const; 1029 virtual const TypeInstPtr *xmeet_unloaded( const TypeInstPtr *t ) const;
992 virtual const Type *xdual() const; // Compute dual right now. 1030 virtual const Type *xdual() const; // Compute dual right now.
1060 virtual const TypeInt* narrow_size_type(const TypeInt* size) const; 1098 virtual const TypeInt* narrow_size_type(const TypeInt* size) const;
1061 1099
1062 virtual bool empty(void) const; // TRUE if type is vacuous 1100 virtual bool empty(void) const; // TRUE if type is vacuous
1063 virtual const TypePtr *add_offset( intptr_t offset ) const; 1101 virtual const TypePtr *add_offset( intptr_t offset ) const;
1064 // Return same type without a speculative part 1102 // Return same type without a speculative part
1065 virtual const TypeOopPtr* remove_speculative() const; 1103 virtual const Type* remove_speculative() const;
1066 1104
1067 // the core of the computation of the meet of 2 types 1105 // the core of the computation of the meet of 2 types
1068 virtual const Type *xmeet_helper(const Type *t) const; 1106 virtual const Type *xmeet_helper(const Type *t) const;
1069 virtual const Type *xdual() const; // Compute dual right now. 1107 virtual const Type *xdual() const; // Compute dual right now.
1070 1108
1101 //------------------------------TypeMetadataPtr------------------------------------- 1139 //------------------------------TypeMetadataPtr-------------------------------------
1102 // Some kind of metadata, either Method*, MethodData* or CPCacheOop 1140 // Some kind of metadata, either Method*, MethodData* or CPCacheOop
1103 class TypeMetadataPtr : public TypePtr { 1141 class TypeMetadataPtr : public TypePtr {
1104 protected: 1142 protected:
1105 TypeMetadataPtr(PTR ptr, ciMetadata* metadata, int offset); 1143 TypeMetadataPtr(PTR ptr, ciMetadata* metadata, int offset);
1144 // Do not allow interface-vs.-noninterface joins to collapse to top.
1145 virtual const Type *filter_helper(const Type *kills, bool include_speculative) const;
1106 public: 1146 public:
1107 virtual bool eq( const Type *t ) const; 1147 virtual bool eq( const Type *t ) const;
1108 virtual int hash() const; // Type specific hashing 1148 virtual int hash() const; // Type specific hashing
1109 virtual bool singleton(void) const; // TRUE if type is a singleton 1149 virtual bool singleton(void) const; // TRUE if type is a singleton
1110 1150
1125 1165
1126 virtual const Type *xmeet( const Type *t ) const; 1166 virtual const Type *xmeet( const Type *t ) const;
1127 virtual const Type *xdual() const; // Compute dual right now. 1167 virtual const Type *xdual() const; // Compute dual right now.
1128 1168
1129 virtual intptr_t get_con() const; 1169 virtual intptr_t get_con() const;
1130
1131 // Do not allow interface-vs.-noninterface joins to collapse to top.
1132 virtual const Type *filter( const Type *kills ) const;
1133 1170
1134 // Convenience common pre-built types. 1171 // Convenience common pre-built types.
1135 static const TypeMetadataPtr *BOTTOM; 1172 static const TypeMetadataPtr *BOTTOM;
1136 1173
1137 #ifndef PRODUCT 1174 #ifndef PRODUCT
1142 //------------------------------TypeKlassPtr----------------------------------- 1179 //------------------------------TypeKlassPtr-----------------------------------
1143 // Class of Java Klass pointers 1180 // Class of Java Klass pointers
1144 class TypeKlassPtr : public TypePtr { 1181 class TypeKlassPtr : public TypePtr {
1145 TypeKlassPtr( PTR ptr, ciKlass* klass, int offset ); 1182 TypeKlassPtr( PTR ptr, ciKlass* klass, int offset );
1146 1183
1184 protected:
1185 virtual const Type *filter_helper(const Type *kills, bool include_speculative) const;
1147 public: 1186 public:
1148 virtual bool eq( const Type *t ) const; 1187 virtual bool eq( const Type *t ) const;
1149 virtual int hash() const; // Type specific hashing 1188 virtual int hash() const; // Type specific hashing
1150 virtual bool singleton(void) const; // TRUE if type is a singleton 1189 virtual bool singleton(void) const; // TRUE if type is a singleton
1151 private: 1190 private:
1203 virtual const Type *xmeet( const Type *t ) const; 1242 virtual const Type *xmeet( const Type *t ) const;
1204 virtual const Type *xdual() const; // Compute dual right now. 1243 virtual const Type *xdual() const; // Compute dual right now.
1205 1244
1206 virtual intptr_t get_con() const; 1245 virtual intptr_t get_con() const;
1207 1246
1208 // Do not allow interface-vs.-noninterface joins to collapse to top.
1209 virtual const Type *filter( const Type *kills ) const;
1210
1211 // Convenience common pre-built types. 1247 // Convenience common pre-built types.
1212 static const TypeKlassPtr* OBJECT; // Not-null object klass or below 1248 static const TypeKlassPtr* OBJECT; // Not-null object klass or below
1213 static const TypeKlassPtr* OBJECT_OR_NULL; // Maybe-null version of same 1249 static const TypeKlassPtr* OBJECT_OR_NULL; // Maybe-null version of same
1214 #ifndef PRODUCT 1250 #ifndef PRODUCT
1215 virtual void dump2( Dict &d, uint depth, outputStream *st ) const; // Specialized per-Type dumping 1251 virtual void dump2( Dict &d, uint depth, outputStream *st ) const; // Specialized per-Type dumping
1229 1265
1230 virtual const TypeNarrowPtr *isa_same_narrowptr(const Type *t) const = 0; 1266 virtual const TypeNarrowPtr *isa_same_narrowptr(const Type *t) const = 0;
1231 virtual const TypeNarrowPtr *is_same_narrowptr(const Type *t) const = 0; 1267 virtual const TypeNarrowPtr *is_same_narrowptr(const Type *t) const = 0;
1232 virtual const TypeNarrowPtr *make_same_narrowptr(const TypePtr *t) const = 0; 1268 virtual const TypeNarrowPtr *make_same_narrowptr(const TypePtr *t) const = 0;
1233 virtual const TypeNarrowPtr *make_hash_same_narrowptr(const TypePtr *t) const = 0; 1269 virtual const TypeNarrowPtr *make_hash_same_narrowptr(const TypePtr *t) const = 0;
1270 // Do not allow interface-vs.-noninterface joins to collapse to top.
1271 virtual const Type *filter_helper(const Type *kills, bool include_speculative) const;
1234 public: 1272 public:
1235 virtual bool eq( const Type *t ) const; 1273 virtual bool eq( const Type *t ) const;
1236 virtual int hash() const; // Type specific hashing 1274 virtual int hash() const; // Type specific hashing
1237 virtual bool singleton(void) const; // TRUE if type is a singleton 1275 virtual bool singleton(void) const; // TRUE if type is a singleton
1238 1276
1239 virtual const Type *xmeet( const Type *t ) const; 1277 virtual const Type *xmeet( const Type *t ) const;
1240 virtual const Type *xdual() const; // Compute dual right now. 1278 virtual const Type *xdual() const; // Compute dual right now.
1241 1279
1242 virtual intptr_t get_con() const; 1280 virtual intptr_t get_con() const;
1243
1244 // Do not allow interface-vs.-noninterface joins to collapse to top.
1245 virtual const Type *filter( const Type *kills ) const;
1246 1281
1247 virtual bool empty(void) const; // TRUE if type is vacuous 1282 virtual bool empty(void) const; // TRUE if type is vacuous
1248 1283
1249 // returns the equivalent ptr type for this compressed pointer 1284 // returns the equivalent ptr type for this compressed pointer
1250 const TypePtr *get_ptrtype() const { 1285 const TypePtr *get_ptrtype() const {
1291 return make(TypeOopPtr::make_from_constant(con, require_constant)); 1326 return make(TypeOopPtr::make_from_constant(con, require_constant));
1292 } 1327 }
1293 1328
1294 static const TypeNarrowOop *BOTTOM; 1329 static const TypeNarrowOop *BOTTOM;
1295 static const TypeNarrowOop *NULL_PTR; 1330 static const TypeNarrowOop *NULL_PTR;
1331
1332 virtual const Type* remove_speculative() const {
1333 return make(_ptrtype->remove_speculative()->is_ptr());
1334 }
1296 1335
1297 #ifndef PRODUCT 1336 #ifndef PRODUCT
1298 virtual void dump2( Dict &d, uint depth, outputStream *st ) const; 1337 virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
1299 #endif 1338 #endif
1300 }; 1339 };