src/share/vm/opto/type.hpp

changeset 670
9c2ecc2ffb12
parent 631
d1605aabd0a1
parent 658
1dd146f17531
child 741
af945ba2e739
equal deleted inserted replaced
632:de141433919f 670:9c2ecc2ffb12
223 const TypeAryPtr *isa_aryptr() const; // Returns NULL if not AryPtr 223 const TypeAryPtr *isa_aryptr() const; // Returns NULL if not AryPtr
224 const TypeAryPtr *is_aryptr() const; // Array oop 224 const TypeAryPtr *is_aryptr() const; // Array oop
225 virtual bool is_finite() const; // Has a finite value 225 virtual bool is_finite() const; // Has a finite value
226 virtual bool is_nan() const; // Is not a number (NaN) 226 virtual bool is_nan() const; // Is not a number (NaN)
227 227
228 // Returns this ptr type or the equivalent ptr type for this compressed pointer.
229 const TypePtr* make_ptr() const;
230 // Returns this compressed pointer or the equivalent compressed version
231 // of this pointer type.
232 const TypeNarrowOop* make_narrowoop() const;
233
228 // Special test for register pressure heuristic 234 // Special test for register pressure heuristic
229 bool is_floatingpoint() const; // True if Float or Double base type 235 bool is_floatingpoint() const; // True if Float or Double base type
230 236
231 // Do you have memory, directly or through a tuple? 237 // Do you have memory, directly or through a tuple?
232 bool has_memory( ) const; 238 bool has_memory( ) const;
646 public: 652 public:
647 virtual bool eq( const Type *t ) const; 653 virtual bool eq( const Type *t ) const;
648 virtual int hash() const; // Type specific hashing 654 virtual int hash() const; // Type specific hashing
649 virtual bool singleton(void) const; // TRUE if type is a singleton 655 virtual bool singleton(void) const; // TRUE if type is a singleton
650 enum { 656 enum {
651 UNKNOWN_INSTANCE = 0 657 InstanceTop = -1, // undefined instance
658 InstanceBot = 0 // any possible instance
652 }; 659 };
653 protected: 660 protected:
654 661
655 int xadd_offset( int offset ) const; 662 int xadd_offset( int offset ) const;
656 // Oop is NULL, unless this is a constant oop. 663 // Oop is NULL, unless this is a constant oop.
659 ciKlass* _klass; // Klass object 666 ciKlass* _klass; // Klass object
660 // Does the type exclude subclasses of the klass? (Inexact == polymorphic.) 667 // Does the type exclude subclasses of the klass? (Inexact == polymorphic.)
661 bool _klass_is_exact; 668 bool _klass_is_exact;
662 bool _is_ptr_to_narrowoop; 669 bool _is_ptr_to_narrowoop;
663 670
664 int _instance_id; // if not UNKNOWN_INSTANCE, indicates that this is a particular instance 671 // If not InstanceTop or InstanceBot, indicates that this is
665 // of this type which is distinct. This is the the node index of the 672 // a particular instance of this type which is distinct.
666 // node creating this instance 673 // This is the the node index of the allocation node creating this instance.
674 int _instance_id;
667 675
668 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);
669 677
670 int dual_instance() const { return -_instance_id; } 678 int dual_instance_id() const;
671 int meet_instance(int uid) const; 679 int meet_instance_id(int uid) const;
672 680
673 public: 681 public:
674 // Creates a type given a klass. Correctly handles multi-dimensional arrays 682 // Creates a type given a klass. Correctly handles multi-dimensional arrays
675 // Respects UseUniqueSubclasses. 683 // Respects UseUniqueSubclasses.
676 // If the klass is final, the resulting type will be exact. 684 // If the klass is final, the resulting type will be exact.
699 707
700 // Returns true if this pointer points at memory which contains a 708 // Returns true if this pointer points at memory which contains a
701 // compressed oop references. 709 // compressed oop references.
702 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; }
703 711
704 bool is_instance() const { return _instance_id != UNKNOWN_INSTANCE; } 712 bool is_known_instance() const { return _instance_id > 0; }
705 uint instance_id() const { return _instance_id; } 713 int instance_id() const { return _instance_id; }
706 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; }
707 715
708 virtual intptr_t get_con() const; 716 virtual intptr_t get_con() const;
709 717
710 virtual const Type *cast_to_ptr_type(PTR ptr) const; 718 virtual const Type *cast_to_ptr_type(PTR ptr) const;
711 719
712 virtual const Type *cast_to_exactness(bool klass_is_exact) const; 720 virtual const Type *cast_to_exactness(bool klass_is_exact) const;
713 721
714 virtual const TypeOopPtr *cast_to_instance(int instance_id) const; 722 virtual const TypeOopPtr *cast_to_instance_id(int instance_id) const;
715 723
716 // corresponding pointer to klass, for a given instance 724 // corresponding pointer to klass, for a given instance
717 const TypeKlassPtr* as_klass_type() const; 725 const TypeKlassPtr* as_klass_type() const;
718 726
719 virtual const TypePtr *add_offset( int offset ) const; 727 virtual const TypePtr *add_offset( int offset ) const;
720
721 // returns the equivalent compressed version of this pointer type
722 virtual const TypeNarrowOop* make_narrowoop() const;
723 728
724 virtual const Type *xmeet( const Type *t ) const; 729 virtual const Type *xmeet( const Type *t ) const;
725 virtual const Type *xdual() const; // Compute dual right now. 730 virtual const Type *xdual() const; // Compute dual right now.
726 731
727 // Do not allow interface-vs.-noninterface joins to collapse to top. 732 // Do not allow interface-vs.-noninterface joins to collapse to top.
773 static const TypeInstPtr *make(PTR ptr, ciKlass* klass, int offset) { 778 static const TypeInstPtr *make(PTR ptr, ciKlass* klass, int offset) {
774 return make(ptr, klass, false, NULL, offset); 779 return make(ptr, klass, false, NULL, offset);
775 } 780 }
776 781
777 // Make a pointer to an oop. 782 // Make a pointer to an oop.
778 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 );
779 784
780 // 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.
781 // 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
782 // 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.
783 ciType* java_mirror_type() const; 788 ciType* java_mirror_type() const;
784 789
785 virtual const Type *cast_to_ptr_type(PTR ptr) const; 790 virtual const Type *cast_to_ptr_type(PTR ptr) const;
786 791
787 virtual const Type *cast_to_exactness(bool klass_is_exact) const; 792 virtual const Type *cast_to_exactness(bool klass_is_exact) const;
788 793
789 virtual const TypeOopPtr *cast_to_instance(int instance_id) const; 794 virtual const TypeOopPtr *cast_to_instance_id(int instance_id) const;
790 795
791 virtual const TypePtr *add_offset( int offset ) const; 796 virtual const TypePtr *add_offset( int offset ) const;
792 797
793 virtual const Type *xmeet( const Type *t ) const; 798 virtual const Type *xmeet( const Type *t ) const;
794 virtual const TypeInstPtr *xmeet_unloaded( const TypeInstPtr *t ) const; 799 virtual const TypeInstPtr *xmeet_unloaded( const TypeInstPtr *t ) const;
818 ciKlass* klass() const; 823 ciKlass* klass() const;
819 const TypeAry* ary() const { return _ary; } 824 const TypeAry* ary() const { return _ary; }
820 const Type* elem() const { return _ary->_elem; } 825 const Type* elem() const { return _ary->_elem; }
821 const TypeInt* size() const { return _ary->_size; } 826 const TypeInt* size() const { return _ary->_size; }
822 827
823 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);
824 // Constant pointer to array 829 // Constant pointer to array
825 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);
826 831
827 // Convenience 832 // Convenience
828 static const TypeAryPtr *make(ciObject* o); 833 static const TypeAryPtr *make(ciObject* o);
829 834
830 // Return a 'ptr' version of this type 835 // Return a 'ptr' version of this type
831 virtual const Type *cast_to_ptr_type(PTR ptr) const; 836 virtual const Type *cast_to_ptr_type(PTR ptr) const;
832 837
833 virtual const Type *cast_to_exactness(bool klass_is_exact) const; 838 virtual const Type *cast_to_exactness(bool klass_is_exact) const;
834 839
835 virtual const TypeOopPtr *cast_to_instance(int instance_id) const; 840 virtual const TypeOopPtr *cast_to_instance_id(int instance_id) const;
836 841
837 virtual const TypeAryPtr* cast_to_size(const TypeInt* size) const; 842 virtual const TypeAryPtr* cast_to_size(const TypeInt* size) const;
838 843
839 virtual bool empty(void) const; // TRUE if type is vacuous 844 virtual bool empty(void) const; // TRUE if type is vacuous
840 virtual const TypePtr *add_offset( int offset ) const; 845 virtual const TypePtr *add_offset( int offset ) const;
909 // the underlying type. It's only real purpose is to track the 914 // the underlying type. It's only real purpose is to track the
910 // oopness of the compressed oop value when we expose the conversion 915 // oopness of the compressed oop value when we expose the conversion
911 // between the normal and the compressed form. 916 // between the normal and the compressed form.
912 class TypeNarrowOop : public Type { 917 class TypeNarrowOop : public Type {
913 protected: 918 protected:
914 const TypePtr* _ooptype; 919 const TypePtr* _ooptype; // Could be TypePtr::NULL_PTR
915 920
916 TypeNarrowOop( const TypePtr* ooptype): Type(NarrowOop), 921 TypeNarrowOop( const TypePtr* ooptype): Type(NarrowOop),
917 _ooptype(ooptype) { 922 _ooptype(ooptype) {
918 assert(ooptype->offset() == 0 || 923 assert(ooptype->offset() == 0 ||
919 ooptype->offset() == OffsetBot || 924 ooptype->offset() == OffsetBot ||
938 943
939 static const TypeNarrowOop* make_from_constant(ciObject* con) { 944 static const TypeNarrowOop* make_from_constant(ciObject* con) {
940 return make(TypeOopPtr::make_from_constant(con)); 945 return make(TypeOopPtr::make_from_constant(con));
941 } 946 }
942 947
943 // returns the equivalent oopptr type for this compressed pointer 948 // returns the equivalent ptr type for this compressed pointer
944 virtual const TypePtr *make_oopptr() const { 949 const TypePtr *make_oopptr() const {
945 return _ooptype; 950 return _ooptype;
946 } 951 }
947 952
948 static const TypeNarrowOop *BOTTOM; 953 static const TypeNarrowOop *BOTTOM;
949 static const TypeNarrowOop *NULL_PTR; 954 static const TypeNarrowOop *NULL_PTR;
1124 } 1129 }
1125 1130
1126 inline const TypeKlassPtr *Type::is_klassptr() const { 1131 inline const TypeKlassPtr *Type::is_klassptr() const {
1127 assert( _base == KlassPtr, "Not a klass pointer" ); 1132 assert( _base == KlassPtr, "Not a klass pointer" );
1128 return (TypeKlassPtr*)this; 1133 return (TypeKlassPtr*)this;
1134 }
1135
1136 inline const TypePtr* Type::make_ptr() const {
1137 return (_base == NarrowOop) ? is_narrowoop()->make_oopptr() :
1138 (isa_ptr() ? is_ptr() : NULL);
1139 }
1140
1141 inline const TypeNarrowOop* Type::make_narrowoop() const {
1142 return (_base == NarrowOop) ? is_narrowoop() :
1143 (isa_ptr() ? TypeNarrowOop::make(is_ptr()) : NULL);
1129 } 1144 }
1130 1145
1131 inline bool Type::is_floatingpoint() const { 1146 inline bool Type::is_floatingpoint() const {
1132 if( (_base == FloatCon) || (_base == FloatBot) || 1147 if( (_base == FloatCon) || (_base == FloatBot) ||
1133 (_base == DoubleCon) || (_base == DoubleBot) ) 1148 (_base == DoubleCon) || (_base == DoubleBot) )

mercurial