398 static const Type *MEMORY;
399 static const Type *MULTI;
400 static const Type *RETURN_ADDRESS;
401 static const Type *TOP;
402
403 // Mapping from compiler type to VM BasicType
404 BasicType basic_type() const { return _type_info[_base].basic_type; }
405 int ideal_reg() const { return _type_info[_base].ideal_reg; }
406 const char* msg() const { return _type_info[_base].msg; }
407 bool isa_oop_ptr() const { return _type_info[_base].isa_oop; }
408 relocInfo::relocType reloc() const { return _type_info[_base].reloc; }
409
410 // Mapping from CI type system to compiler type:
411 static const Type* get_typeflow_type(ciType* type);
412
413 static const Type* make_from_constant(ciConstant constant,
414 bool require_constant = false,
415 bool is_autobox_cache = false);
416
417 // Speculative type. See TypeInstPtr
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; }
421
422 private:
423 // support arrays
424 static const BasicType _basic_type[];
425 static const Type* _zero_type[T_CONFLICT+1];
426 static const Type* _const_basic_type[T_CONFLICT+1];
427 };
428
429 //------------------------------TypeF------------------------------------------
430 // Class of Float-Constant Types.
431 class TypeF : public Type {
432 TypeF( float f ) : Type(FloatCon), _f(f) {};
433 public:
434 virtual bool eq( const Type *t ) const;
435 virtual int hash() const; // Type specific hashing
436 virtual bool singleton(void) const; // TRUE if type is a singleton
437 virtual bool empty(void) const; // TRUE if type is vacuous
776 // meet, dual and join over pointer equivalence sets
777 PTR meet_ptr( const PTR in_ptr ) const { return ptr_meet[in_ptr][ptr()]; }
778 PTR dual_ptr() const { return ptr_dual[ptr()]; }
779
780 // This is textually confusing unless one recalls that
781 // join(t) == dual()->meet(t->dual())->dual().
782 PTR join_ptr( const PTR in_ptr ) const {
783 return ptr_dual[ ptr_meet[ ptr_dual[in_ptr] ] [ dual_ptr() ] ];
784 }
785
786 // Tests for relation to centerline of type lattice:
787 static bool above_centerline(PTR ptr) { return (ptr <= AnyNull); }
788 static bool below_centerline(PTR ptr) { return (ptr >= NotNull); }
789 // Convenience common pre-built types.
790 static const TypePtr *NULL_PTR;
791 static const TypePtr *NOTNULL;
792 static const TypePtr *BOTTOM;
793 #ifndef PRODUCT
794 virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
795 #endif
796 };
797
798 //------------------------------TypeRawPtr-------------------------------------
799 // Class of raw pointers, pointers to things other than Oops. Examples
800 // include the stack pointer, top of heap, card-marking area, handles, etc.
801 class TypeRawPtr : public TypePtr {
802 protected:
803 TypeRawPtr( PTR ptr, address bits ) : TypePtr(RawPtr,ptr,0), _bits(bits){}
804 public:
805 virtual bool eq( const Type *t ) const;
806 virtual int hash() const; // Type specific hashing
807
808 const address _bits; // Constant value, if applicable
809
810 static const TypeRawPtr *make( PTR ptr );
811 static const TypeRawPtr *make( address bits );
812
813 // Return a 'ptr' version of this type
814 virtual const Type *cast_to_ptr_type(PTR ptr) const;
815
816 virtual intptr_t get_con() const;
817
818 virtual const TypePtr *add_offset( intptr_t offset ) const;
819
820 virtual const Type *xmeet( const Type *t ) const;
821 virtual const Type *xdual() const; // Compute dual right now.
822 // Convenience common pre-built types.
823 static const TypeRawPtr *BOTTOM;
824 static const TypeRawPtr *NOTNULL;
825 #ifndef PRODUCT
826 virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
827 #endif
828 };
829
830 //------------------------------TypeOopPtr-------------------------------------
831 // Some kind of oop (Java pointer), either klass or instance or array.
832 class TypeOopPtr : public TypePtr {
833 protected:
834 TypeOopPtr(TYPES t, PTR ptr, ciKlass* k, bool xk, ciObject* o, int offset, int instance_id, const TypeOopPtr* speculative);
835 public:
836 virtual bool eq( const Type *t ) const;
837 virtual int hash() const; // Type specific hashing
838 virtual bool singleton(void) const; // TRUE if type is a singleton
839 enum {
840 InstanceTop = -1, // undefined instance
841 InstanceBot = 0 // any possible instance
842 };
843 protected:
844
845 // Oop is NULL, unless this is a constant oop.
846 ciObject* _const_oop; // Constant oop
847 // If _klass is NULL, then so is _sig. This is an unloaded klass.
848 ciKlass* _klass; // Klass object
849 // Does the type exclude subclasses of the klass? (Inexact == polymorphic.)
850 bool _klass_is_exact;
851 bool _is_ptr_to_narrowoop;
852 bool _is_ptr_to_narrowklass;
853 bool _is_ptr_to_boxed_value;
854
855 // If not InstanceTop or InstanceBot, indicates that this is
856 // a particular instance of this type which is distinct.
857 // This is the the node index of the allocation node creating this instance.
858 int _instance_id;
859
860 // Extra type information profiling gave us. We propagate it the
861 // same way the rest of the type info is propagated. If we want to
862 // use it, then we have to emit a guard: this part of the type is
863 // not something we know but something we speculate about the type.
864 const TypeOopPtr* _speculative;
865
866 static const TypeOopPtr* make_from_klass_common(ciKlass* klass, bool klass_change, bool try_for_exact);
867
868 int dual_instance_id() const;
869 int meet_instance_id(int uid) const;
870
871 // utility methods to work on the speculative part of the type
872 const TypeOopPtr* dual_speculative() const;
873 const TypeOopPtr* xmeet_speculative(const TypeOopPtr* other) const;
874 bool eq_speculative(const TypeOopPtr* other) const;
875 int hash_speculative() const;
876 const TypeOopPtr* add_offset_speculative(intptr_t offset) const;
877 #ifndef PRODUCT
878 void dump_speculative(outputStream *st) const;
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;
883
884 public:
885 // Creates a type given a klass. Correctly handles multi-dimensional arrays
886 // Respects UseUniqueSubclasses.
887 // If the klass is final, the resulting type will be exact.
888 static const TypeOopPtr* make_from_klass(ciKlass* klass) {
889 return make_from_klass_common(klass, true, false);
890 }
891 // Same as before, but will produce an exact type, even if
892 // the klass is not final, as long as it has exactly one implementation.
893 static const TypeOopPtr* make_from_klass_unique(ciKlass* klass) {
894 return make_from_klass_common(klass, true, true);
895 }
896 // Same as before, but does not respects UseUniqueSubclasses.
897 // Use this only for creating array element types.
898 static const TypeOopPtr* make_from_klass_raw(ciKlass* klass) {
899 return make_from_klass_common(klass, false, false);
900 }
901 // Creates a singleton type given an object.
902 // If the object cannot be rendered as a constant,
903 // may return a non-singleton type.
904 // If require_constant, produce a NULL if a singleton is not possible.
905 static const TypeOopPtr* make_from_constant(ciObject* o,
906 bool require_constant = false,
907 bool not_null_elements = false);
908
909 // Make a generic (unclassed) pointer to an oop.
910 static const TypeOopPtr* make(PTR ptr, int offset, int instance_id, const TypeOopPtr* speculative);
911
912 ciObject* const_oop() const { return _const_oop; }
913 virtual ciKlass* klass() const { return _klass; }
914 bool klass_is_exact() const { return _klass_is_exact; }
915
916 // Returns true if this pointer points at memory which contains a
917 // compressed oop references.
918 bool is_ptr_to_narrowoop_nv() const { return _is_ptr_to_narrowoop; }
919 bool is_ptr_to_narrowklass_nv() const { return _is_ptr_to_narrowklass; }
920 bool is_ptr_to_boxed_value() const { return _is_ptr_to_boxed_value; }
921 bool is_known_instance() const { return _instance_id > 0; }
922 int instance_id() const { return _instance_id; }
923 bool is_known_instance_field() const { return is_known_instance() && _offset >= 0; }
924 const TypeOopPtr* speculative() const { return _speculative; }
925
926 virtual intptr_t get_con() const;
927
928 virtual const Type *cast_to_ptr_type(PTR ptr) const;
929
930 virtual const Type *cast_to_exactness(bool klass_is_exact) const;
931
932 virtual const TypeOopPtr *cast_to_instance_id(int instance_id) const;
933
934 // corresponding pointer to klass, for a given instance
935 const TypeKlassPtr* as_klass_type() const;
936
937 virtual const TypePtr *add_offset( intptr_t offset ) const;
938 // Return same type without a speculative part
939 virtual const Type* remove_speculative() const;
940
941 virtual const Type *xmeet(const Type *t) const;
942 virtual const Type *xdual() const; // Compute dual right now.
943 // the core of the computation of the meet for TypeOopPtr and for its subclasses
944 virtual const Type *xmeet_helper(const Type *t) const;
945
946 // Convenience common pre-built type.
947 static const TypeOopPtr *BOTTOM;
948 #ifndef PRODUCT
949 virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
950 #endif
951
952 // Return the speculative type if any
953 ciKlass* speculative_type() const {
954 if (_speculative != NULL) {
955 const TypeOopPtr* speculative = _speculative->join(this)->is_oopptr();
956 if (speculative->klass_is_exact()) {
957 return speculative->klass();
958 }
959 }
960 return NULL;
961 }
962 };
963
964 //------------------------------TypeInstPtr------------------------------------
965 // Class of Java object pointers, pointing either to non-array Java instances
966 // or to a Klass* (including array klasses).
967 class TypeInstPtr : public TypeOopPtr {
968 TypeInstPtr(PTR ptr, ciKlass* k, bool xk, ciObject* o, int offset, int instance_id, const TypeOopPtr* speculative);
969 virtual bool eq( const Type *t ) const;
970 virtual int hash() const; // Type specific hashing
971
972 ciSymbol* _name; // class name
973
974 public:
975 ciSymbol* name() const { return _name; }
976
977 bool is_loaded() const { return _klass->is_loaded(); }
978
979 // Make a pointer to a constant oop.
980 static const TypeInstPtr *make(ciObject* o) {
981 return make(TypePtr::Constant, o->klass(), true, o, 0, InstanceBot);
982 }
983 // Make a pointer to a constant oop with offset.
984 static const TypeInstPtr *make(ciObject* o, int offset) {
985 return make(TypePtr::Constant, o->klass(), true, o, offset, InstanceBot);
986 }
987
988 // Make a pointer to some value of type klass.
989 static const TypeInstPtr *make(PTR ptr, ciKlass* klass) {
990 return make(ptr, klass, false, NULL, 0, InstanceBot);
991 }
992
993 // Make a pointer to some non-polymorphic value of exactly type klass.
994 static const TypeInstPtr *make_exact(PTR ptr, ciKlass* klass) {
995 return make(ptr, klass, true, NULL, 0, InstanceBot);
996 }
997
998 // Make a pointer to some value of type klass with offset.
999 static const TypeInstPtr *make(PTR ptr, ciKlass* klass, int offset) {
1000 return make(ptr, klass, false, NULL, offset, InstanceBot);
1001 }
1002
1003 // Make a pointer to an oop.
1004 static const TypeInstPtr *make(PTR ptr, ciKlass* k, bool xk, ciObject* o, int offset, int instance_id = InstanceBot, const TypeOopPtr* speculative = NULL);
1005
1006 /** Create constant type for a constant boxed value */
1007 const Type* get_const_boxed_value() const;
1008
1009 // If this is a java.lang.Class constant, return the type for it or NULL.
1010 // Pass to Type::get_const_type to turn it to a type, which will usually
1011 // be a TypeInstPtr, but may also be a TypeInt::INT for int.class, etc.
1012 ciType* java_mirror_type() const;
1013
1014 virtual const Type *cast_to_ptr_type(PTR ptr) const;
1015
1016 virtual const Type *cast_to_exactness(bool klass_is_exact) const;
1017
1018 virtual const TypeOopPtr *cast_to_instance_id(int instance_id) const;
1019
1020 virtual const TypePtr *add_offset( intptr_t offset ) const;
1021 // Return same type without a speculative part
1022 virtual const Type* remove_speculative() const;
1023
1024 // the core of the computation of the meet of 2 types
1025 virtual const Type *xmeet_helper(const Type *t) const;
1026 virtual const TypeInstPtr *xmeet_unloaded( const TypeInstPtr *t ) const;
1027 virtual const Type *xdual() const; // Compute dual right now.
1028
1029 // Convenience common pre-built types.
1030 static const TypeInstPtr *NOTNULL;
1031 static const TypeInstPtr *BOTTOM;
1032 static const TypeInstPtr *MIRROR;
1033 static const TypeInstPtr *MARK;
1034 static const TypeInstPtr *KLASS;
1035 #ifndef PRODUCT
1036 virtual void dump2( Dict &d, uint depth, outputStream *st ) const; // Specialized per-Type dumping
1037 #endif
1038 };
1039
1040 //------------------------------TypeAryPtr-------------------------------------
1041 // Class of Java array pointers
1042 class TypeAryPtr : public TypeOopPtr {
1043 TypeAryPtr( PTR ptr, ciObject* o, const TypeAry *ary, ciKlass* k, bool xk,
1044 int offset, int instance_id, bool is_autobox_cache, const TypeOopPtr* speculative)
1045 : TypeOopPtr(AryPtr,ptr,k,xk,o,offset, instance_id, speculative),
1046 _ary(ary),
1047 _is_autobox_cache(is_autobox_cache)
1048 {
1049 #ifdef ASSERT
1050 if (k != NULL) {
1051 // Verify that specified klass and TypeAryPtr::klass() follow the same rules.
1052 ciKlass* ck = compute_klass(true);
1053 if (k != ck) {
1054 this->dump(); tty->cr();
1055 tty->print(" k: ");
1056 k->print(); tty->cr();
1057 tty->print("ck: ");
1058 if (ck != NULL) ck->print();
1059 else tty->print("<NULL>");
1060 tty->cr();
1061 assert(false, "unexpected TypeAryPtr::_klass");
1062 }
1063 }
1064 #endif
1065 }
1066 virtual bool eq( const Type *t ) const;
1067 virtual int hash() const; // Type specific hashing
1068 const TypeAry *_ary; // Array we point into
1069 const bool _is_autobox_cache;
1070
1071 ciKlass* compute_klass(DEBUG_ONLY(bool verify = false)) const;
1072
1073 public:
1074 // Accessors
1075 ciKlass* klass() const;
1076 const TypeAry* ary() const { return _ary; }
1077 const Type* elem() const { return _ary->_elem; }
1078 const TypeInt* size() const { return _ary->_size; }
1079 bool is_stable() const { return _ary->_stable; }
1080
1081 bool is_autobox_cache() const { return _is_autobox_cache; }
1082
1083 static const TypeAryPtr *make( PTR ptr, const TypeAry *ary, ciKlass* k, bool xk, int offset, int instance_id = InstanceBot, const TypeOopPtr* speculative = NULL);
1084 // Constant pointer to array
1085 static const TypeAryPtr *make( PTR ptr, ciObject* o, const TypeAry *ary, ciKlass* k, bool xk, int offset, int instance_id = InstanceBot, const TypeOopPtr* speculative = NULL, bool is_autobox_cache = false);
1086
1087 // Return a 'ptr' version of this type
1088 virtual const Type *cast_to_ptr_type(PTR ptr) const;
1089
1090 virtual const Type *cast_to_exactness(bool klass_is_exact) const;
1091
1092 virtual const TypeOopPtr *cast_to_instance_id(int instance_id) const;
1093
1094 virtual const TypeAryPtr* cast_to_size(const TypeInt* size) const;
1095 virtual const TypeInt* narrow_size_type(const TypeInt* size) const;
1096
1097 virtual bool empty(void) const; // TRUE if type is vacuous
1098 virtual const TypePtr *add_offset( intptr_t offset ) const;
1099 // Return same type without a speculative part
1100 virtual const Type* remove_speculative() const;
1101
1102 // the core of the computation of the meet of 2 types
1103 virtual const Type *xmeet_helper(const Type *t) const;
1104 virtual const Type *xdual() const; // Compute dual right now.
1105
1106 const TypeAryPtr* cast_to_stable(bool stable, int stable_dimension = 1) const;
1107 int stable_dimension() const;
1108
1109 // Convenience common pre-built types.
1110 static const TypeAryPtr *RANGE;
1111 static const TypeAryPtr *OOPS;
1112 static const TypeAryPtr *NARROWOOPS;
1113 static const TypeAryPtr *BYTES;
1114 static const TypeAryPtr *SHORTS;
1115 static const TypeAryPtr *CHARS;
1116 static const TypeAryPtr *INTS;
1117 static const TypeAryPtr *LONGS;
1118 static const TypeAryPtr *FLOATS;
1119 static const TypeAryPtr *DOUBLES;
1120 // selects one of the above:
|
398 static const Type *MEMORY;
399 static const Type *MULTI;
400 static const Type *RETURN_ADDRESS;
401 static const Type *TOP;
402
403 // Mapping from compiler type to VM BasicType
404 BasicType basic_type() const { return _type_info[_base].basic_type; }
405 int ideal_reg() const { return _type_info[_base].ideal_reg; }
406 const char* msg() const { return _type_info[_base].msg; }
407 bool isa_oop_ptr() const { return _type_info[_base].isa_oop; }
408 relocInfo::relocType reloc() const { return _type_info[_base].reloc; }
409
410 // Mapping from CI type system to compiler type:
411 static const Type* get_typeflow_type(ciType* type);
412
413 static const Type* make_from_constant(ciConstant constant,
414 bool require_constant = false,
415 bool is_autobox_cache = false);
416
417 // Speculative type. See TypeInstPtr
418 virtual const TypeOopPtr* speculative() const { return NULL; }
419 virtual ciKlass* speculative_type() const { return NULL; }
420 const Type* maybe_remove_speculative(bool include_speculative) const;
421 virtual const Type* remove_speculative() const { return this; }
422
423 private:
424 // support arrays
425 static const BasicType _basic_type[];
426 static const Type* _zero_type[T_CONFLICT+1];
427 static const Type* _const_basic_type[T_CONFLICT+1];
428 };
429
430 //------------------------------TypeF------------------------------------------
431 // Class of Float-Constant Types.
432 class TypeF : public Type {
433 TypeF( float f ) : Type(FloatCon), _f(f) {};
434 public:
435 virtual bool eq( const Type *t ) const;
436 virtual int hash() const; // Type specific hashing
437 virtual bool singleton(void) const; // TRUE if type is a singleton
438 virtual bool empty(void) const; // TRUE if type is vacuous
777 // meet, dual and join over pointer equivalence sets
778 PTR meet_ptr( const PTR in_ptr ) const { return ptr_meet[in_ptr][ptr()]; }
779 PTR dual_ptr() const { return ptr_dual[ptr()]; }
780
781 // This is textually confusing unless one recalls that
782 // join(t) == dual()->meet(t->dual())->dual().
783 PTR join_ptr( const PTR in_ptr ) const {
784 return ptr_dual[ ptr_meet[ ptr_dual[in_ptr] ] [ dual_ptr() ] ];
785 }
786
787 // Tests for relation to centerline of type lattice:
788 static bool above_centerline(PTR ptr) { return (ptr <= AnyNull); }
789 static bool below_centerline(PTR ptr) { return (ptr >= NotNull); }
790 // Convenience common pre-built types.
791 static const TypePtr *NULL_PTR;
792 static const TypePtr *NOTNULL;
793 static const TypePtr *BOTTOM;
794 #ifndef PRODUCT
795 virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
796 #endif
797
798 virtual int inline_depth() const {
799 fatal("should not be used");
800 return 0;
801 }
802 };
803
804 //------------------------------TypeRawPtr-------------------------------------
805 // Class of raw pointers, pointers to things other than Oops. Examples
806 // include the stack pointer, top of heap, card-marking area, handles, etc.
807 class TypeRawPtr : public TypePtr {
808 protected:
809 TypeRawPtr( PTR ptr, address bits ) : TypePtr(RawPtr,ptr,0), _bits(bits){}
810 public:
811 virtual bool eq( const Type *t ) const;
812 virtual int hash() const; // Type specific hashing
813
814 const address _bits; // Constant value, if applicable
815
816 static const TypeRawPtr *make( PTR ptr );
817 static const TypeRawPtr *make( address bits );
818
819 // Return a 'ptr' version of this type
820 virtual const Type *cast_to_ptr_type(PTR ptr) const;
821
822 virtual intptr_t get_con() const;
823
824 virtual const TypePtr *add_offset( intptr_t offset ) const;
825
826 virtual const Type *xmeet( const Type *t ) const;
827 virtual const Type *xdual() const; // Compute dual right now.
828 // Convenience common pre-built types.
829 static const TypeRawPtr *BOTTOM;
830 static const TypeRawPtr *NOTNULL;
831 #ifndef PRODUCT
832 virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
833 #endif
834 };
835
836 //------------------------------TypeOopPtr-------------------------------------
837 // Some kind of oop (Java pointer), either klass or instance or array.
838 class TypeOopPtr : public TypePtr {
839 protected:
840 TypeOopPtr(TYPES t, PTR ptr, ciKlass* k, bool xk, ciObject* o, int offset, int instance_id, const TypeOopPtr* speculative, int inline_depth);
841 public:
842 virtual bool eq( const Type *t ) const;
843 virtual int hash() const; // Type specific hashing
844 virtual bool singleton(void) const; // TRUE if type is a singleton
845 enum {
846 InstanceTop = -1, // undefined instance
847 InstanceBot = 0 // any possible instance
848 };
849 enum {
850 InlineDepthTop = INT_MAX,
851 InlineDepthBottom = -InlineDepthTop
852 };
853 protected:
854
855 // Oop is NULL, unless this is a constant oop.
856 ciObject* _const_oop; // Constant oop
857 // If _klass is NULL, then so is _sig. This is an unloaded klass.
858 ciKlass* _klass; // Klass object
859 // Does the type exclude subclasses of the klass? (Inexact == polymorphic.)
860 bool _klass_is_exact;
861 bool _is_ptr_to_narrowoop;
862 bool _is_ptr_to_narrowklass;
863 bool _is_ptr_to_boxed_value;
864
865 // If not InstanceTop or InstanceBot, indicates that this is
866 // a particular instance of this type which is distinct.
867 // This is the the node index of the allocation node creating this instance.
868 int _instance_id;
869
870 // Extra type information profiling gave us. We propagate it the
871 // same way the rest of the type info is propagated. If we want to
872 // use it, then we have to emit a guard: this part of the type is
873 // not something we know but something we speculate about the type.
874 const TypeOopPtr* _speculative;
875 // For speculative types, we record at what inlining depth the
876 // profiling point that provided the data is. We want to favor
877 // profile data coming from outer scopes which are likely better for
878 // the current compilation.
879 int _inline_depth;
880
881 static const TypeOopPtr* make_from_klass_common(ciKlass* klass, bool klass_change, bool try_for_exact);
882
883 int dual_instance_id() const;
884 int meet_instance_id(int uid) const;
885
886 // utility methods to work on the speculative part of the type
887 const TypeOopPtr* dual_speculative() const;
888 const TypeOopPtr* xmeet_speculative(const TypeOopPtr* other) const;
889 bool eq_speculative(const TypeOopPtr* other) const;
890 int hash_speculative() const;
891 const TypeOopPtr* add_offset_speculative(intptr_t offset) const;
892 #ifndef PRODUCT
893 void dump_speculative(outputStream *st) const;
894 #endif
895 // utility methods to work on the inline depth of the type
896 int dual_inline_depth() const;
897 int meet_inline_depth(int depth) const;
898 #ifndef PRODUCT
899 void dump_inline_depth(outputStream *st) const;
900 #endif
901
902 // Do not allow interface-vs.-noninterface joins to collapse to top.
903 virtual const Type *filter_helper(const Type *kills, bool include_speculative) const;
904
905 public:
906 // Creates a type given a klass. Correctly handles multi-dimensional arrays
907 // Respects UseUniqueSubclasses.
908 // If the klass is final, the resulting type will be exact.
909 static const TypeOopPtr* make_from_klass(ciKlass* klass) {
910 return make_from_klass_common(klass, true, false);
911 }
912 // Same as before, but will produce an exact type, even if
913 // the klass is not final, as long as it has exactly one implementation.
914 static const TypeOopPtr* make_from_klass_unique(ciKlass* klass) {
915 return make_from_klass_common(klass, true, true);
916 }
917 // Same as before, but does not respects UseUniqueSubclasses.
918 // Use this only for creating array element types.
919 static const TypeOopPtr* make_from_klass_raw(ciKlass* klass) {
920 return make_from_klass_common(klass, false, false);
921 }
922 // Creates a singleton type given an object.
923 // If the object cannot be rendered as a constant,
924 // may return a non-singleton type.
925 // If require_constant, produce a NULL if a singleton is not possible.
926 static const TypeOopPtr* make_from_constant(ciObject* o,
927 bool require_constant = false,
928 bool not_null_elements = false);
929
930 // Make a generic (unclassed) pointer to an oop.
931 static const TypeOopPtr* make(PTR ptr, int offset, int instance_id, const TypeOopPtr* speculative = NULL, int inline_depth = InlineDepthBottom);
932
933 ciObject* const_oop() const { return _const_oop; }
934 virtual ciKlass* klass() const { return _klass; }
935 bool klass_is_exact() const { return _klass_is_exact; }
936
937 // Returns true if this pointer points at memory which contains a
938 // compressed oop references.
939 bool is_ptr_to_narrowoop_nv() const { return _is_ptr_to_narrowoop; }
940 bool is_ptr_to_narrowklass_nv() const { return _is_ptr_to_narrowklass; }
941 bool is_ptr_to_boxed_value() const { return _is_ptr_to_boxed_value; }
942 bool is_known_instance() const { return _instance_id > 0; }
943 int instance_id() const { return _instance_id; }
944 bool is_known_instance_field() const { return is_known_instance() && _offset >= 0; }
945 virtual const TypeOopPtr* speculative() const { return _speculative; }
946
947 virtual intptr_t get_con() const;
948
949 virtual const Type *cast_to_ptr_type(PTR ptr) const;
950
951 virtual const Type *cast_to_exactness(bool klass_is_exact) const;
952
953 virtual const TypeOopPtr *cast_to_instance_id(int instance_id) const;
954
955 // corresponding pointer to klass, for a given instance
956 const TypeKlassPtr* as_klass_type() const;
957
958 virtual const TypePtr *add_offset( intptr_t offset ) const;
959 // Return same type without a speculative part
960 virtual const Type* remove_speculative() const;
961
962 virtual const Type *xmeet(const Type *t) const;
963 virtual const Type *xdual() const; // Compute dual right now.
964 // the core of the computation of the meet for TypeOopPtr and for its subclasses
965 virtual const Type *xmeet_helper(const Type *t) const;
966
967 // Convenience common pre-built type.
968 static const TypeOopPtr *BOTTOM;
969 #ifndef PRODUCT
970 virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
971 #endif
972
973 // Return the speculative type if any
974 ciKlass* speculative_type() const {
975 if (_speculative != NULL) {
976 const TypeOopPtr* speculative = _speculative->join(this)->is_oopptr();
977 if (speculative->klass_is_exact()) {
978 return speculative->klass();
979 }
980 }
981 return NULL;
982 }
983 virtual const TypeOopPtr* with_inline_depth(int depth) const;
984 virtual int inline_depth() const {
985 return _inline_depth;
986 }
987 };
988
989 //------------------------------TypeInstPtr------------------------------------
990 // Class of Java object pointers, pointing either to non-array Java instances
991 // or to a Klass* (including array klasses).
992 class TypeInstPtr : public TypeOopPtr {
993 TypeInstPtr(PTR ptr, ciKlass* k, bool xk, ciObject* o, int offset, int instance_id, const TypeOopPtr* speculative, int inline_depth);
994 virtual bool eq( const Type *t ) const;
995 virtual int hash() const; // Type specific hashing
996
997 ciSymbol* _name; // class name
998
999 public:
1000 ciSymbol* name() const { return _name; }
1001
1002 bool is_loaded() const { return _klass->is_loaded(); }
1003
1004 // Make a pointer to a constant oop.
1005 static const TypeInstPtr *make(ciObject* o) {
1006 return make(TypePtr::Constant, o->klass(), true, o, 0, InstanceBot);
1007 }
1008 // Make a pointer to a constant oop with offset.
1009 static const TypeInstPtr *make(ciObject* o, int offset) {
1010 return make(TypePtr::Constant, o->klass(), true, o, offset, InstanceBot);
1011 }
1012
1013 // Make a pointer to some value of type klass.
1014 static const TypeInstPtr *make(PTR ptr, ciKlass* klass) {
1015 return make(ptr, klass, false, NULL, 0, InstanceBot);
1016 }
1017
1018 // Make a pointer to some non-polymorphic value of exactly type klass.
1019 static const TypeInstPtr *make_exact(PTR ptr, ciKlass* klass) {
1020 return make(ptr, klass, true, NULL, 0, InstanceBot);
1021 }
1022
1023 // Make a pointer to some value of type klass with offset.
1024 static const TypeInstPtr *make(PTR ptr, ciKlass* klass, int offset) {
1025 return make(ptr, klass, false, NULL, offset, InstanceBot);
1026 }
1027
1028 // Make a pointer to an oop.
1029 static const TypeInstPtr *make(PTR ptr, ciKlass* k, bool xk, ciObject* o, int offset, int instance_id = InstanceBot, const TypeOopPtr* speculative = NULL, int inline_depth = InlineDepthBottom);
1030
1031 /** Create constant type for a constant boxed value */
1032 const Type* get_const_boxed_value() const;
1033
1034 // If this is a java.lang.Class constant, return the type for it or NULL.
1035 // Pass to Type::get_const_type to turn it to a type, which will usually
1036 // be a TypeInstPtr, but may also be a TypeInt::INT for int.class, etc.
1037 ciType* java_mirror_type() const;
1038
1039 virtual const Type *cast_to_ptr_type(PTR ptr) const;
1040
1041 virtual const Type *cast_to_exactness(bool klass_is_exact) const;
1042
1043 virtual const TypeOopPtr *cast_to_instance_id(int instance_id) const;
1044
1045 virtual const TypePtr *add_offset( intptr_t offset ) const;
1046 // Return same type without a speculative part
1047 virtual const Type* remove_speculative() const;
1048 virtual const TypeOopPtr* with_inline_depth(int depth) const;
1049
1050 // the core of the computation of the meet of 2 types
1051 virtual const Type *xmeet_helper(const Type *t) const;
1052 virtual const TypeInstPtr *xmeet_unloaded( const TypeInstPtr *t ) const;
1053 virtual const Type *xdual() const; // Compute dual right now.
1054
1055 // Convenience common pre-built types.
1056 static const TypeInstPtr *NOTNULL;
1057 static const TypeInstPtr *BOTTOM;
1058 static const TypeInstPtr *MIRROR;
1059 static const TypeInstPtr *MARK;
1060 static const TypeInstPtr *KLASS;
1061 #ifndef PRODUCT
1062 virtual void dump2( Dict &d, uint depth, outputStream *st ) const; // Specialized per-Type dumping
1063 #endif
1064 };
1065
1066 //------------------------------TypeAryPtr-------------------------------------
1067 // Class of Java array pointers
1068 class TypeAryPtr : public TypeOopPtr {
1069 TypeAryPtr( PTR ptr, ciObject* o, const TypeAry *ary, ciKlass* k, bool xk,
1070 int offset, int instance_id, bool is_autobox_cache, const TypeOopPtr* speculative, int inline_depth)
1071 : TypeOopPtr(AryPtr,ptr,k,xk,o,offset, instance_id, speculative, inline_depth),
1072 _ary(ary),
1073 _is_autobox_cache(is_autobox_cache)
1074 {
1075 #ifdef ASSERT
1076 if (k != NULL) {
1077 // Verify that specified klass and TypeAryPtr::klass() follow the same rules.
1078 ciKlass* ck = compute_klass(true);
1079 if (k != ck) {
1080 this->dump(); tty->cr();
1081 tty->print(" k: ");
1082 k->print(); tty->cr();
1083 tty->print("ck: ");
1084 if (ck != NULL) ck->print();
1085 else tty->print("<NULL>");
1086 tty->cr();
1087 assert(false, "unexpected TypeAryPtr::_klass");
1088 }
1089 }
1090 #endif
1091 }
1092 virtual bool eq( const Type *t ) const;
1093 virtual int hash() const; // Type specific hashing
1094 const TypeAry *_ary; // Array we point into
1095 const bool _is_autobox_cache;
1096
1097 ciKlass* compute_klass(DEBUG_ONLY(bool verify = false)) const;
1098
1099 public:
1100 // Accessors
1101 ciKlass* klass() const;
1102 const TypeAry* ary() const { return _ary; }
1103 const Type* elem() const { return _ary->_elem; }
1104 const TypeInt* size() const { return _ary->_size; }
1105 bool is_stable() const { return _ary->_stable; }
1106
1107 bool is_autobox_cache() const { return _is_autobox_cache; }
1108
1109 static const TypeAryPtr *make( PTR ptr, const TypeAry *ary, ciKlass* k, bool xk, int offset, int instance_id = InstanceBot, const TypeOopPtr* speculative = NULL, int inline_depth = InlineDepthBottom);
1110 // Constant pointer to array
1111 static const TypeAryPtr *make( PTR ptr, ciObject* o, const TypeAry *ary, ciKlass* k, bool xk, int offset, int instance_id = InstanceBot, const TypeOopPtr* speculative = NULL, int inline_depth = InlineDepthBottom, bool is_autobox_cache= false);
1112
1113 // Return a 'ptr' version of this type
1114 virtual const Type *cast_to_ptr_type(PTR ptr) const;
1115
1116 virtual const Type *cast_to_exactness(bool klass_is_exact) const;
1117
1118 virtual const TypeOopPtr *cast_to_instance_id(int instance_id) const;
1119
1120 virtual const TypeAryPtr* cast_to_size(const TypeInt* size) const;
1121 virtual const TypeInt* narrow_size_type(const TypeInt* size) const;
1122
1123 virtual bool empty(void) const; // TRUE if type is vacuous
1124 virtual const TypePtr *add_offset( intptr_t offset ) const;
1125 // Return same type without a speculative part
1126 virtual const Type* remove_speculative() const;
1127 virtual const TypeOopPtr* with_inline_depth(int depth) const;
1128
1129 // the core of the computation of the meet of 2 types
1130 virtual const Type *xmeet_helper(const Type *t) const;
1131 virtual const Type *xdual() const; // Compute dual right now.
1132
1133 const TypeAryPtr* cast_to_stable(bool stable, int stable_dimension = 1) const;
1134 int stable_dimension() const;
1135
1136 // Convenience common pre-built types.
1137 static const TypeAryPtr *RANGE;
1138 static const TypeAryPtr *OOPS;
1139 static const TypeAryPtr *NARROWOOPS;
1140 static const TypeAryPtr *BYTES;
1141 static const TypeAryPtr *SHORTS;
1142 static const TypeAryPtr *CHARS;
1143 static const TypeAryPtr *INTS;
1144 static const TypeAryPtr *LONGS;
1145 static const TypeAryPtr *FLOATS;
1146 static const TypeAryPtr *DOUBLES;
1147 // selects one of the above:
|