652 public: |
652 public: |
653 virtual bool eq( const Type *t ) const; |
653 virtual bool eq( const Type *t ) const; |
654 virtual int hash() const; // Type specific hashing |
654 virtual int hash() const; // Type specific hashing |
655 virtual bool singleton(void) const; // TRUE if type is a singleton |
655 virtual bool singleton(void) const; // TRUE if type is a singleton |
656 enum { |
656 enum { |
657 UNKNOWN_INSTANCE = 0 |
657 InstanceTop = -1, // undefined instance |
|
658 InstanceBot = 0 // any possible instance |
658 }; |
659 }; |
659 protected: |
660 protected: |
660 |
661 |
661 int xadd_offset( int offset ) const; |
662 int xadd_offset( int offset ) const; |
662 // Oop is NULL, unless this is a constant oop. |
663 // Oop is NULL, unless this is a constant oop. |
665 ciKlass* _klass; // Klass object |
666 ciKlass* _klass; // Klass object |
666 // Does the type exclude subclasses of the klass? (Inexact == polymorphic.) |
667 // Does the type exclude subclasses of the klass? (Inexact == polymorphic.) |
667 bool _klass_is_exact; |
668 bool _klass_is_exact; |
668 bool _is_ptr_to_narrowoop; |
669 bool _is_ptr_to_narrowoop; |
669 |
670 |
670 int _instance_id; // if not UNKNOWN_INSTANCE, indicates that this is a particular instance |
671 // If not InstanceTop or InstanceBot, indicates that this is |
671 // of this type which is distinct. This is the the node index of the |
672 // a particular instance of this type which is distinct. |
672 // node creating this instance |
673 // This is the the node index of the allocation node creating this instance. |
|
674 int _instance_id; |
673 |
675 |
674 static const TypeOopPtr* make_from_klass_common(ciKlass* klass, bool klass_change, bool try_for_exact); |
676 static const TypeOopPtr* make_from_klass_common(ciKlass* klass, bool klass_change, bool try_for_exact); |
675 |
677 |
676 int dual_instance() const { return -_instance_id; } |
678 int dual_instance_id() const; |
677 int meet_instance(int uid) const; |
679 int meet_instance_id(int uid) const; |
678 |
680 |
679 public: |
681 public: |
680 // Creates a type given a klass. Correctly handles multi-dimensional arrays |
682 // Creates a type given a klass. Correctly handles multi-dimensional arrays |
681 // Respects UseUniqueSubclasses. |
683 // Respects UseUniqueSubclasses. |
682 // If the klass is final, the resulting type will be exact. |
684 // If the klass is final, the resulting type will be exact. |
705 |
707 |
706 // Returns true if this pointer points at memory which contains a |
708 // Returns true if this pointer points at memory which contains a |
707 // compressed oop references. |
709 // compressed oop references. |
708 bool is_ptr_to_narrowoop_nv() const { return _is_ptr_to_narrowoop; } |
710 bool is_ptr_to_narrowoop_nv() const { return _is_ptr_to_narrowoop; } |
709 |
711 |
710 bool is_instance() const { return _instance_id != UNKNOWN_INSTANCE; } |
712 bool is_known_instance() const { return _instance_id > 0; } |
711 uint instance_id() const { return _instance_id; } |
713 int instance_id() const { return _instance_id; } |
712 bool is_instance_field() const { return _instance_id != UNKNOWN_INSTANCE && _offset >= 0; } |
714 bool is_known_instance_field() const { return is_known_instance() && _offset >= 0; } |
713 |
715 |
714 virtual intptr_t get_con() const; |
716 virtual intptr_t get_con() const; |
715 |
717 |
716 virtual const Type *cast_to_ptr_type(PTR ptr) const; |
718 virtual const Type *cast_to_ptr_type(PTR ptr) const; |
717 |
719 |
718 virtual const Type *cast_to_exactness(bool klass_is_exact) const; |
720 virtual const Type *cast_to_exactness(bool klass_is_exact) const; |
719 |
721 |
720 virtual const TypeOopPtr *cast_to_instance(int instance_id) const; |
722 virtual const TypeOopPtr *cast_to_instance_id(int instance_id) const; |
721 |
723 |
722 // corresponding pointer to klass, for a given instance |
724 // corresponding pointer to klass, for a given instance |
723 const TypeKlassPtr* as_klass_type() const; |
725 const TypeKlassPtr* as_klass_type() const; |
724 |
726 |
725 virtual const TypePtr *add_offset( int offset ) const; |
727 virtual const TypePtr *add_offset( int offset ) const; |
776 static const TypeInstPtr *make(PTR ptr, ciKlass* klass, int offset) { |
778 static const TypeInstPtr *make(PTR ptr, ciKlass* klass, int offset) { |
777 return make(ptr, klass, false, NULL, offset); |
779 return make(ptr, klass, false, NULL, offset); |
778 } |
780 } |
779 |
781 |
780 // Make a pointer to an oop. |
782 // Make a pointer to an oop. |
781 static const TypeInstPtr *make(PTR ptr, ciKlass* k, bool xk, ciObject* o, int offset, int instance_id = 0 ); |
783 static const TypeInstPtr *make(PTR ptr, ciKlass* k, bool xk, ciObject* o, int offset, int instance_id = InstanceBot ); |
782 |
784 |
783 // If this is a java.lang.Class constant, return the type for it or NULL. |
785 // If this is a java.lang.Class constant, return the type for it or NULL. |
784 // Pass to Type::get_const_type to turn it to a type, which will usually |
786 // Pass to Type::get_const_type to turn it to a type, which will usually |
785 // be a TypeInstPtr, but may also be a TypeInt::INT for int.class, etc. |
787 // be a TypeInstPtr, but may also be a TypeInt::INT for int.class, etc. |
786 ciType* java_mirror_type() const; |
788 ciType* java_mirror_type() const; |
787 |
789 |
788 virtual const Type *cast_to_ptr_type(PTR ptr) const; |
790 virtual const Type *cast_to_ptr_type(PTR ptr) const; |
789 |
791 |
790 virtual const Type *cast_to_exactness(bool klass_is_exact) const; |
792 virtual const Type *cast_to_exactness(bool klass_is_exact) const; |
791 |
793 |
792 virtual const TypeOopPtr *cast_to_instance(int instance_id) const; |
794 virtual const TypeOopPtr *cast_to_instance_id(int instance_id) const; |
793 |
795 |
794 virtual const TypePtr *add_offset( int offset ) const; |
796 virtual const TypePtr *add_offset( int offset ) const; |
795 |
797 |
796 virtual const Type *xmeet( const Type *t ) const; |
798 virtual const Type *xmeet( const Type *t ) const; |
797 virtual const TypeInstPtr *xmeet_unloaded( const TypeInstPtr *t ) const; |
799 virtual const TypeInstPtr *xmeet_unloaded( const TypeInstPtr *t ) const; |
821 ciKlass* klass() const; |
823 ciKlass* klass() const; |
822 const TypeAry* ary() const { return _ary; } |
824 const TypeAry* ary() const { return _ary; } |
823 const Type* elem() const { return _ary->_elem; } |
825 const Type* elem() const { return _ary->_elem; } |
824 const TypeInt* size() const { return _ary->_size; } |
826 const TypeInt* size() const { return _ary->_size; } |
825 |
827 |
826 static const TypeAryPtr *make( PTR ptr, const TypeAry *ary, ciKlass* k, bool xk, int offset, int instance_id = 0); |
828 static const TypeAryPtr *make( PTR ptr, const TypeAry *ary, ciKlass* k, bool xk, int offset, int instance_id = InstanceBot); |
827 // Constant pointer to array |
829 // Constant pointer to array |
828 static const TypeAryPtr *make( PTR ptr, ciObject* o, const TypeAry *ary, ciKlass* k, bool xk, int offset, int instance_id = 0); |
830 static const TypeAryPtr *make( PTR ptr, ciObject* o, const TypeAry *ary, ciKlass* k, bool xk, int offset, int instance_id = InstanceBot); |
829 |
831 |
830 // Convenience |
832 // Convenience |
831 static const TypeAryPtr *make(ciObject* o); |
833 static const TypeAryPtr *make(ciObject* o); |
832 |
834 |
833 // Return a 'ptr' version of this type |
835 // Return a 'ptr' version of this type |
834 virtual const Type *cast_to_ptr_type(PTR ptr) const; |
836 virtual const Type *cast_to_ptr_type(PTR ptr) const; |
835 |
837 |
836 virtual const Type *cast_to_exactness(bool klass_is_exact) const; |
838 virtual const Type *cast_to_exactness(bool klass_is_exact) const; |
837 |
839 |
838 virtual const TypeOopPtr *cast_to_instance(int instance_id) const; |
840 virtual const TypeOopPtr *cast_to_instance_id(int instance_id) const; |
839 |
841 |
840 virtual const TypeAryPtr* cast_to_size(const TypeInt* size) const; |
842 virtual const TypeAryPtr* cast_to_size(const TypeInt* size) const; |
841 |
843 |
842 virtual bool empty(void) const; // TRUE if type is vacuous |
844 virtual bool empty(void) const; // TRUE if type is vacuous |
843 virtual const TypePtr *add_offset( int offset ) const; |
845 virtual const TypePtr *add_offset( int offset ) const; |