395 static const Type *CONTROL;
396 static const Type *DOUBLE;
397 static const Type *FLOAT;
398 static const Type *HALF;
399 static const Type *MEMORY;
400 static const Type *MULTI;
401 static const Type *RETURN_ADDRESS;
402 static const Type *TOP;
403
404 // Mapping from compiler type to VM BasicType
405 BasicType basic_type() const { return _type_info[_base].basic_type; }
406 int ideal_reg() const { return _type_info[_base].ideal_reg; }
407 const char* msg() const { return _type_info[_base].msg; }
408 bool isa_oop_ptr() const { return _type_info[_base].isa_oop; }
409 relocInfo::relocType reloc() const { return _type_info[_base].reloc; }
410
411 // Mapping from CI type system to compiler type:
412 static const Type* get_typeflow_type(ciType* type);
413
414 static const Type* make_from_constant(ciConstant constant,
415 bool require_constant = false,
416 bool is_autobox_cache = false);
417
418 // Speculative type helper methods. See TypePtr.
419 virtual const TypePtr* speculative() const { return NULL; }
420 virtual ciKlass* speculative_type() const { return NULL; }
421 virtual ciKlass* speculative_type_not_null() const { return NULL; }
422 virtual bool speculative_maybe_null() const { return true; }
423 virtual const Type* remove_speculative() const { return this; }
424 virtual const Type* cleanup_speculative() const { return this; }
425 virtual bool would_improve_type(ciKlass* exact_kls, int inline_depth) const { return exact_kls != NULL; }
426 virtual bool would_improve_ptr(bool maybe_null) const { return !maybe_null; }
427 const Type* maybe_remove_speculative(bool include_speculative) const;
428
429 virtual bool maybe_null() const { return true; }
430
431 private:
432 // support arrays
433 static const BasicType _basic_type[];
434 static const Type* _zero_type[T_CONFLICT+1];
435 static const Type* _const_basic_type[T_CONFLICT+1];
436 };
956 // Respects UseUniqueSubclasses.
957 // If the klass is final, the resulting type will be exact.
958 static const TypeOopPtr* make_from_klass(ciKlass* klass) {
959 return make_from_klass_common(klass, true, false);
960 }
961 // Same as before, but will produce an exact type, even if
962 // the klass is not final, as long as it has exactly one implementation.
963 static const TypeOopPtr* make_from_klass_unique(ciKlass* klass) {
964 return make_from_klass_common(klass, true, true);
965 }
966 // Same as before, but does not respects UseUniqueSubclasses.
967 // Use this only for creating array element types.
968 static const TypeOopPtr* make_from_klass_raw(ciKlass* klass) {
969 return make_from_klass_common(klass, false, false);
970 }
971 // Creates a singleton type given an object.
972 // If the object cannot be rendered as a constant,
973 // may return a non-singleton type.
974 // If require_constant, produce a NULL if a singleton is not possible.
975 static const TypeOopPtr* make_from_constant(ciObject* o,
976 bool require_constant = false,
977 bool not_null_elements = false);
978
979 // Make a generic (unclassed) pointer to an oop.
980 static const TypeOopPtr* make(PTR ptr, int offset, int instance_id,
981 const TypePtr* speculative = NULL,
982 int inline_depth = InlineDepthBottom);
983
984 ciObject* const_oop() const { return _const_oop; }
985 virtual ciKlass* klass() const { return _klass; }
986 bool klass_is_exact() const { return _klass_is_exact; }
987
988 // Returns true if this pointer points at memory which contains a
989 // compressed oop references.
990 bool is_ptr_to_narrowoop_nv() const { return _is_ptr_to_narrowoop; }
991 bool is_ptr_to_narrowklass_nv() const { return _is_ptr_to_narrowklass; }
992 bool is_ptr_to_boxed_value() const { return _is_ptr_to_boxed_value; }
993 bool is_known_instance() const { return _instance_id > 0; }
994 int instance_id() const { return _instance_id; }
995 bool is_known_instance_field() const { return is_known_instance() && _offset >= 0; }
996
997 virtual intptr_t get_con() const;
1167
1168 virtual const TypeOopPtr *cast_to_instance_id(int instance_id) const;
1169
1170 virtual const TypeAryPtr* cast_to_size(const TypeInt* size) const;
1171 virtual const TypeInt* narrow_size_type(const TypeInt* size) const;
1172
1173 virtual bool empty(void) const; // TRUE if type is vacuous
1174 virtual const TypePtr *add_offset( intptr_t offset ) const;
1175
1176 // Speculative type helper methods.
1177 virtual const Type* remove_speculative() const;
1178 virtual const TypePtr* with_inline_depth(int depth) const;
1179
1180 // the core of the computation of the meet of 2 types
1181 virtual const Type *xmeet_helper(const Type *t) const;
1182 virtual const Type *xdual() const; // Compute dual right now.
1183
1184 const TypeAryPtr* cast_to_stable(bool stable, int stable_dimension = 1) const;
1185 int stable_dimension() const;
1186
1187 // Convenience common pre-built types.
1188 static const TypeAryPtr *RANGE;
1189 static const TypeAryPtr *OOPS;
1190 static const TypeAryPtr *NARROWOOPS;
1191 static const TypeAryPtr *BYTES;
1192 static const TypeAryPtr *SHORTS;
1193 static const TypeAryPtr *CHARS;
1194 static const TypeAryPtr *INTS;
1195 static const TypeAryPtr *LONGS;
1196 static const TypeAryPtr *FLOATS;
1197 static const TypeAryPtr *DOUBLES;
1198 // selects one of the above:
1199 static const TypeAryPtr *get_array_body_type(BasicType elem) {
1200 assert((uint)elem <= T_CONFLICT && _array_body_type[elem] != NULL, "bad elem type");
1201 return _array_body_type[elem];
1202 }
1203 static const TypeAryPtr *_array_body_type[T_CONFLICT+1];
1204 // sharpen the type of an int which is used as an array size
1205 #ifdef ASSERT
1206 // One type is interface, the other is oop
1658 assert(_base == MetadataPtr, "Not a metadata pointer" ) ;
1659 return (TypeMetadataPtr*)this;
1660 }
1661
1662 inline const TypeMetadataPtr *Type::isa_metadataptr() const {
1663 return (_base == MetadataPtr) ? (TypeMetadataPtr*)this : NULL;
1664 }
1665
1666 inline const TypeKlassPtr *Type::isa_klassptr() const {
1667 return (_base == KlassPtr) ? (TypeKlassPtr*)this : NULL;
1668 }
1669
1670 inline const TypeKlassPtr *Type::is_klassptr() const {
1671 assert( _base == KlassPtr, "Not a klass pointer" );
1672 return (TypeKlassPtr*)this;
1673 }
1674
1675 inline const TypePtr* Type::make_ptr() const {
1676 return (_base == NarrowOop) ? is_narrowoop()->get_ptrtype() :
1677 ((_base == NarrowKlass) ? is_narrowklass()->get_ptrtype() :
1678 (isa_ptr() ? is_ptr() : NULL));
1679 }
1680
1681 inline const TypeOopPtr* Type::make_oopptr() const {
1682 return (_base == NarrowOop) ? is_narrowoop()->get_ptrtype()->is_oopptr() : is_oopptr();
1683 }
1684
1685 inline const TypeNarrowOop* Type::make_narrowoop() const {
1686 return (_base == NarrowOop) ? is_narrowoop() :
1687 (isa_ptr() ? TypeNarrowOop::make(is_ptr()) : NULL);
1688 }
1689
1690 inline const TypeNarrowKlass* Type::make_narrowklass() const {
1691 return (_base == NarrowKlass) ? is_narrowklass() :
1692 (isa_ptr() ? TypeNarrowKlass::make(is_ptr()) : NULL);
1693 }
1694
1695 inline bool Type::is_floatingpoint() const {
1696 if( (_base == FloatCon) || (_base == FloatBot) ||
1697 (_base == DoubleCon) || (_base == DoubleBot) )
1698 return true;
1699 return false;
1700 }
1701
1702 inline bool Type::is_ptr_to_boxing_obj() const {
|
395 static const Type *CONTROL;
396 static const Type *DOUBLE;
397 static const Type *FLOAT;
398 static const Type *HALF;
399 static const Type *MEMORY;
400 static const Type *MULTI;
401 static const Type *RETURN_ADDRESS;
402 static const Type *TOP;
403
404 // Mapping from compiler type to VM BasicType
405 BasicType basic_type() const { return _type_info[_base].basic_type; }
406 int ideal_reg() const { return _type_info[_base].ideal_reg; }
407 const char* msg() const { return _type_info[_base].msg; }
408 bool isa_oop_ptr() const { return _type_info[_base].isa_oop; }
409 relocInfo::relocType reloc() const { return _type_info[_base].reloc; }
410
411 // Mapping from CI type system to compiler type:
412 static const Type* get_typeflow_type(ciType* type);
413
414 static const Type* make_from_constant(ciConstant constant,
415 bool require_constant = false);
416
417 static const Type* make_constant(ciField* field, Node* obj);
418
419 // Speculative type helper methods. See TypePtr.
420 virtual const TypePtr* speculative() const { return NULL; }
421 virtual ciKlass* speculative_type() const { return NULL; }
422 virtual ciKlass* speculative_type_not_null() const { return NULL; }
423 virtual bool speculative_maybe_null() const { return true; }
424 virtual const Type* remove_speculative() const { return this; }
425 virtual const Type* cleanup_speculative() const { return this; }
426 virtual bool would_improve_type(ciKlass* exact_kls, int inline_depth) const { return exact_kls != NULL; }
427 virtual bool would_improve_ptr(bool maybe_null) const { return !maybe_null; }
428 const Type* maybe_remove_speculative(bool include_speculative) const;
429
430 virtual bool maybe_null() const { return true; }
431
432 private:
433 // support arrays
434 static const BasicType _basic_type[];
435 static const Type* _zero_type[T_CONFLICT+1];
436 static const Type* _const_basic_type[T_CONFLICT+1];
437 };
957 // Respects UseUniqueSubclasses.
958 // If the klass is final, the resulting type will be exact.
959 static const TypeOopPtr* make_from_klass(ciKlass* klass) {
960 return make_from_klass_common(klass, true, false);
961 }
962 // Same as before, but will produce an exact type, even if
963 // the klass is not final, as long as it has exactly one implementation.
964 static const TypeOopPtr* make_from_klass_unique(ciKlass* klass) {
965 return make_from_klass_common(klass, true, true);
966 }
967 // Same as before, but does not respects UseUniqueSubclasses.
968 // Use this only for creating array element types.
969 static const TypeOopPtr* make_from_klass_raw(ciKlass* klass) {
970 return make_from_klass_common(klass, false, false);
971 }
972 // Creates a singleton type given an object.
973 // If the object cannot be rendered as a constant,
974 // may return a non-singleton type.
975 // If require_constant, produce a NULL if a singleton is not possible.
976 static const TypeOopPtr* make_from_constant(ciObject* o,
977 bool require_constant = false);
978
979 // Make a generic (unclassed) pointer to an oop.
980 static const TypeOopPtr* make(PTR ptr, int offset, int instance_id,
981 const TypePtr* speculative = NULL,
982 int inline_depth = InlineDepthBottom);
983
984 ciObject* const_oop() const { return _const_oop; }
985 virtual ciKlass* klass() const { return _klass; }
986 bool klass_is_exact() const { return _klass_is_exact; }
987
988 // Returns true if this pointer points at memory which contains a
989 // compressed oop references.
990 bool is_ptr_to_narrowoop_nv() const { return _is_ptr_to_narrowoop; }
991 bool is_ptr_to_narrowklass_nv() const { return _is_ptr_to_narrowklass; }
992 bool is_ptr_to_boxed_value() const { return _is_ptr_to_boxed_value; }
993 bool is_known_instance() const { return _instance_id > 0; }
994 int instance_id() const { return _instance_id; }
995 bool is_known_instance_field() const { return is_known_instance() && _offset >= 0; }
996
997 virtual intptr_t get_con() const;
1167
1168 virtual const TypeOopPtr *cast_to_instance_id(int instance_id) const;
1169
1170 virtual const TypeAryPtr* cast_to_size(const TypeInt* size) const;
1171 virtual const TypeInt* narrow_size_type(const TypeInt* size) const;
1172
1173 virtual bool empty(void) const; // TRUE if type is vacuous
1174 virtual const TypePtr *add_offset( intptr_t offset ) const;
1175
1176 // Speculative type helper methods.
1177 virtual const Type* remove_speculative() const;
1178 virtual const TypePtr* with_inline_depth(int depth) const;
1179
1180 // the core of the computation of the meet of 2 types
1181 virtual const Type *xmeet_helper(const Type *t) const;
1182 virtual const Type *xdual() const; // Compute dual right now.
1183
1184 const TypeAryPtr* cast_to_stable(bool stable, int stable_dimension = 1) const;
1185 int stable_dimension() const;
1186
1187 const TypeAryPtr* cast_to_autobox_cache(bool cache) const;
1188
1189 // Convenience common pre-built types.
1190 static const TypeAryPtr *RANGE;
1191 static const TypeAryPtr *OOPS;
1192 static const TypeAryPtr *NARROWOOPS;
1193 static const TypeAryPtr *BYTES;
1194 static const TypeAryPtr *SHORTS;
1195 static const TypeAryPtr *CHARS;
1196 static const TypeAryPtr *INTS;
1197 static const TypeAryPtr *LONGS;
1198 static const TypeAryPtr *FLOATS;
1199 static const TypeAryPtr *DOUBLES;
1200 // selects one of the above:
1201 static const TypeAryPtr *get_array_body_type(BasicType elem) {
1202 assert((uint)elem <= T_CONFLICT && _array_body_type[elem] != NULL, "bad elem type");
1203 return _array_body_type[elem];
1204 }
1205 static const TypeAryPtr *_array_body_type[T_CONFLICT+1];
1206 // sharpen the type of an int which is used as an array size
1207 #ifdef ASSERT
1208 // One type is interface, the other is oop
1660 assert(_base == MetadataPtr, "Not a metadata pointer" ) ;
1661 return (TypeMetadataPtr*)this;
1662 }
1663
1664 inline const TypeMetadataPtr *Type::isa_metadataptr() const {
1665 return (_base == MetadataPtr) ? (TypeMetadataPtr*)this : NULL;
1666 }
1667
1668 inline const TypeKlassPtr *Type::isa_klassptr() const {
1669 return (_base == KlassPtr) ? (TypeKlassPtr*)this : NULL;
1670 }
1671
1672 inline const TypeKlassPtr *Type::is_klassptr() const {
1673 assert( _base == KlassPtr, "Not a klass pointer" );
1674 return (TypeKlassPtr*)this;
1675 }
1676
1677 inline const TypePtr* Type::make_ptr() const {
1678 return (_base == NarrowOop) ? is_narrowoop()->get_ptrtype() :
1679 ((_base == NarrowKlass) ? is_narrowklass()->get_ptrtype() :
1680 isa_ptr());
1681 }
1682
1683 inline const TypeOopPtr* Type::make_oopptr() const {
1684 return (_base == NarrowOop) ? is_narrowoop()->get_ptrtype()->isa_oopptr() : isa_oopptr();
1685 }
1686
1687 inline const TypeNarrowOop* Type::make_narrowoop() const {
1688 return (_base == NarrowOop) ? is_narrowoop() :
1689 (isa_ptr() ? TypeNarrowOop::make(is_ptr()) : NULL);
1690 }
1691
1692 inline const TypeNarrowKlass* Type::make_narrowklass() const {
1693 return (_base == NarrowKlass) ? is_narrowklass() :
1694 (isa_ptr() ? TypeNarrowKlass::make(is_ptr()) : NULL);
1695 }
1696
1697 inline bool Type::is_floatingpoint() const {
1698 if( (_base == FloatCon) || (_base == FloatBot) ||
1699 (_base == DoubleCon) || (_base == DoubleBot) )
1700 return true;
1701 return false;
1702 }
1703
1704 inline bool Type::is_ptr_to_boxing_obj() const {
|