40 // The complete lattice is described below. Subtypes have no relationship to 41 // up or down in the lattice; that is entirely determined by the behavior of 42 // the MEET/JOIN functions. 43 44 class Dict; 45 class Type; 46 class TypeD; 47 class TypeF; 48 class TypeInt; 49 class TypeLong; 50 class TypeNarrowPtr; 51 class TypeNarrowOop; 52 class TypeNarrowKlass; 53 class TypeAry; 54 class TypeTuple; 55 class TypeVect; 56 class TypeVectS; 57 class TypeVectD; 58 class TypeVectX; 59 class TypeVectY; 60 class TypePtr; 61 class TypeRawPtr; 62 class TypeOopPtr; 63 class TypeInstPtr; 64 class TypeAryPtr; 65 class TypeKlassPtr; 66 class TypeMetadataPtr; 67 68 //------------------------------Type------------------------------------------- 69 // Basic Type object, represents a set of primitive Values. 70 // Types are hash-cons'd into a private class dictionary, so only one of each 71 // different kind of Type exists. Types are never modified after creation, so 72 // all their interesting fields are constant. 73 class Type { 74 friend class VMStructs; 75 76 public: 77 enum TYPES { 78 Bad=0, // Type check 79 Control, // Control of code (not in lattice) 80 Top, // Top of the lattice 81 Int, // Integer range (lo-hi) 82 Long, // Long integer range (lo-hi) 83 Half, // Placeholder half of doubleword 84 NarrowOop, // Compressed oop pointer 85 NarrowKlass, // Compressed klass pointer 86 87 Tuple, // Method signature or object layout 88 Array, // Array types 89 VectorS, // 32bit Vector types 90 VectorD, // 64bit Vector types 91 VectorX, // 128bit Vector types 92 VectorY, // 256bit Vector types 93 94 AnyPtr, // Any old raw, klass, inst, or array pointer 95 RawPtr, // Raw (non-oop) pointers 96 OopPtr, // Any and all Java heap entities 97 InstPtr, // Instance pointers (non-array objects) 98 AryPtr, // Array pointers 99 // (Ptr order matters: See is_ptr, isa_ptr, is_oopptr, isa_oopptr.) 100 101 MetadataPtr, // Generic metadata 102 KlassPtr, // Klass pointers 103 104 Function, // Function signature 105 Abio, // Abstract I/O 106 Return_Address, // Subroutine return address 107 Memory, // Abstract store 108 FloatTop, // No float value 109 FloatCon, // Floating point constant 110 FloatBot, // Any float value 111 DoubleTop, // No double value 112 DoubleCon, // Double precision constant 712 713 virtual bool eq(const Type *t) const; 714 virtual int hash() const; // Type specific hashing 715 virtual bool singleton(void) const; // TRUE if type is a singleton 716 virtual bool empty(void) const; // TRUE if type is vacuous 717 718 static const TypeVect *make(const BasicType elem_bt, uint length) { 719 // Use bottom primitive type. 720 return make(get_const_basic_type(elem_bt), length); 721 } 722 // Used directly by Replicate nodes to construct singleton vector. 723 static const TypeVect *make(const Type* elem, uint length); 724 725 virtual const Type *xmeet( const Type *t) const; 726 virtual const Type *xdual() const; // Compute dual right now. 727 728 static const TypeVect *VECTS; 729 static const TypeVect *VECTD; 730 static const TypeVect *VECTX; 731 static const TypeVect *VECTY; 732 733 #ifndef PRODUCT 734 virtual void dump2(Dict &d, uint, outputStream *st) const; // Specialized per-Type dumping 735 #endif 736 }; 737 738 class TypeVectS : public TypeVect { 739 friend class TypeVect; 740 TypeVectS(const Type* elem, uint length) : TypeVect(VectorS, elem, length) {} 741 }; 742 743 class TypeVectD : public TypeVect { 744 friend class TypeVect; 745 TypeVectD(const Type* elem, uint length) : TypeVect(VectorD, elem, length) {} 746 }; 747 748 class TypeVectX : public TypeVect { 749 friend class TypeVect; 750 TypeVectX(const Type* elem, uint length) : TypeVect(VectorX, elem, length) {} 751 }; 752 753 class TypeVectY : public TypeVect { 754 friend class TypeVect; 755 TypeVectY(const Type* elem, uint length) : TypeVect(VectorY, elem, length) {} 756 }; 757 758 //------------------------------TypePtr---------------------------------------- 759 // Class of machine Pointer Types: raw data, instances or arrays. 760 // If the _base enum is AnyPtr, then this refers to all of the above. 761 // Otherwise the _base will indicate which subset of pointers is affected, 762 // and the class will be inherited from. 763 class TypePtr : public Type { 764 friend class TypeNarrowPtr; 765 public: 766 enum PTR { TopPTR, AnyNull, Constant, Null, NotNull, BotPTR, lastPTR }; 767 protected: 768 TypePtr(TYPES t, PTR ptr, int offset, 769 const TypePtr* speculative = NULL, 770 int inline_depth = InlineDepthBottom) : 771 Type(t), _ptr(ptr), _offset(offset), _speculative(speculative), 772 _inline_depth(inline_depth) {} 773 static const PTR ptr_meet[lastPTR][lastPTR]; 774 static const PTR ptr_dual[lastPTR]; 775 static const char * const ptr_msg[lastPTR]; 776 777 enum { 1551 inline const TypeD *Type::is_double_constant() const { 1552 assert( _base == DoubleCon, "Not a Double" ); 1553 return (TypeD*)this; 1554 } 1555 1556 inline const TypeD *Type::isa_double_constant() const { 1557 return ( _base == DoubleCon ? (TypeD*)this : NULL); 1558 } 1559 1560 inline const TypeTuple *Type::is_tuple() const { 1561 assert( _base == Tuple, "Not a Tuple" ); 1562 return (TypeTuple*)this; 1563 } 1564 1565 inline const TypeAry *Type::is_ary() const { 1566 assert( _base == Array , "Not an Array" ); 1567 return (TypeAry*)this; 1568 } 1569 1570 inline const TypeVect *Type::is_vect() const { 1571 assert( _base >= VectorS && _base <= VectorY, "Not a Vector" ); 1572 return (TypeVect*)this; 1573 } 1574 1575 inline const TypeVect *Type::isa_vect() const { 1576 return (_base >= VectorS && _base <= VectorY) ? (TypeVect*)this : NULL; 1577 } 1578 1579 inline const TypePtr *Type::is_ptr() const { 1580 // AnyPtr is the first Ptr and KlassPtr the last, with no non-ptrs between. 1581 assert(_base >= AnyPtr && _base <= KlassPtr, "Not a pointer"); 1582 return (TypePtr*)this; 1583 } 1584 1585 inline const TypePtr *Type::isa_ptr() const { 1586 // AnyPtr is the first Ptr and KlassPtr the last, with no non-ptrs between. 1587 return (_base >= AnyPtr && _base <= KlassPtr) ? (TypePtr*)this : NULL; 1588 } 1589 1590 inline const TypeOopPtr *Type::is_oopptr() const { 1591 // OopPtr is the first and KlassPtr the last, with no non-oops between. 1592 assert(_base >= OopPtr && _base <= AryPtr, "Not a Java pointer" ) ; 1593 return (TypeOopPtr*)this; 1594 } 1595 1596 inline const TypeOopPtr *Type::isa_oopptr() const { | 40 // The complete lattice is described below. Subtypes have no relationship to 41 // up or down in the lattice; that is entirely determined by the behavior of 42 // the MEET/JOIN functions. 43 44 class Dict; 45 class Type; 46 class TypeD; 47 class TypeF; 48 class TypeInt; 49 class TypeLong; 50 class TypeNarrowPtr; 51 class TypeNarrowOop; 52 class TypeNarrowKlass; 53 class TypeAry; 54 class TypeTuple; 55 class TypeVect; 56 class TypeVectS; 57 class TypeVectD; 58 class TypeVectX; 59 class TypeVectY; 60 class TypeVectZ; 61 class TypePtr; 62 class TypeRawPtr; 63 class TypeOopPtr; 64 class TypeInstPtr; 65 class TypeAryPtr; 66 class TypeKlassPtr; 67 class TypeMetadataPtr; 68 69 //------------------------------Type------------------------------------------- 70 // Basic Type object, represents a set of primitive Values. 71 // Types are hash-cons'd into a private class dictionary, so only one of each 72 // different kind of Type exists. Types are never modified after creation, so 73 // all their interesting fields are constant. 74 class Type { 75 friend class VMStructs; 76 77 public: 78 enum TYPES { 79 Bad=0, // Type check 80 Control, // Control of code (not in lattice) 81 Top, // Top of the lattice 82 Int, // Integer range (lo-hi) 83 Long, // Long integer range (lo-hi) 84 Half, // Placeholder half of doubleword 85 NarrowOop, // Compressed oop pointer 86 NarrowKlass, // Compressed klass pointer 87 88 Tuple, // Method signature or object layout 89 Array, // Array types 90 VectorS, // 32bit Vector types 91 VectorD, // 64bit Vector types 92 VectorX, // 128bit Vector types 93 VectorY, // 256bit Vector types 94 VectorZ, // 512bit Vector types 95 96 AnyPtr, // Any old raw, klass, inst, or array pointer 97 RawPtr, // Raw (non-oop) pointers 98 OopPtr, // Any and all Java heap entities 99 InstPtr, // Instance pointers (non-array objects) 100 AryPtr, // Array pointers 101 // (Ptr order matters: See is_ptr, isa_ptr, is_oopptr, isa_oopptr.) 102 103 MetadataPtr, // Generic metadata 104 KlassPtr, // Klass pointers 105 106 Function, // Function signature 107 Abio, // Abstract I/O 108 Return_Address, // Subroutine return address 109 Memory, // Abstract store 110 FloatTop, // No float value 111 FloatCon, // Floating point constant 112 FloatBot, // Any float value 113 DoubleTop, // No double value 114 DoubleCon, // Double precision constant 714 715 virtual bool eq(const Type *t) const; 716 virtual int hash() const; // Type specific hashing 717 virtual bool singleton(void) const; // TRUE if type is a singleton 718 virtual bool empty(void) const; // TRUE if type is vacuous 719 720 static const TypeVect *make(const BasicType elem_bt, uint length) { 721 // Use bottom primitive type. 722 return make(get_const_basic_type(elem_bt), length); 723 } 724 // Used directly by Replicate nodes to construct singleton vector. 725 static const TypeVect *make(const Type* elem, uint length); 726 727 virtual const Type *xmeet( const Type *t) const; 728 virtual const Type *xdual() const; // Compute dual right now. 729 730 static const TypeVect *VECTS; 731 static const TypeVect *VECTD; 732 static const TypeVect *VECTX; 733 static const TypeVect *VECTY; 734 static const TypeVect *VECTZ; 735 736 #ifndef PRODUCT 737 virtual void dump2(Dict &d, uint, outputStream *st) const; // Specialized per-Type dumping 738 #endif 739 }; 740 741 class TypeVectS : public TypeVect { 742 friend class TypeVect; 743 TypeVectS(const Type* elem, uint length) : TypeVect(VectorS, elem, length) {} 744 }; 745 746 class TypeVectD : public TypeVect { 747 friend class TypeVect; 748 TypeVectD(const Type* elem, uint length) : TypeVect(VectorD, elem, length) {} 749 }; 750 751 class TypeVectX : public TypeVect { 752 friend class TypeVect; 753 TypeVectX(const Type* elem, uint length) : TypeVect(VectorX, elem, length) {} 754 }; 755 756 class TypeVectY : public TypeVect { 757 friend class TypeVect; 758 TypeVectY(const Type* elem, uint length) : TypeVect(VectorY, elem, length) {} 759 }; 760 761 class TypeVectZ : public TypeVect { 762 friend class TypeVect; 763 TypeVectZ(const Type* elem, uint length) : TypeVect(VectorZ, elem, length) {} 764 }; 765 766 //------------------------------TypePtr---------------------------------------- 767 // Class of machine Pointer Types: raw data, instances or arrays. 768 // If the _base enum is AnyPtr, then this refers to all of the above. 769 // Otherwise the _base will indicate which subset of pointers is affected, 770 // and the class will be inherited from. 771 class TypePtr : public Type { 772 friend class TypeNarrowPtr; 773 public: 774 enum PTR { TopPTR, AnyNull, Constant, Null, NotNull, BotPTR, lastPTR }; 775 protected: 776 TypePtr(TYPES t, PTR ptr, int offset, 777 const TypePtr* speculative = NULL, 778 int inline_depth = InlineDepthBottom) : 779 Type(t), _ptr(ptr), _offset(offset), _speculative(speculative), 780 _inline_depth(inline_depth) {} 781 static const PTR ptr_meet[lastPTR][lastPTR]; 782 static const PTR ptr_dual[lastPTR]; 783 static const char * const ptr_msg[lastPTR]; 784 785 enum { 1559 inline const TypeD *Type::is_double_constant() const { 1560 assert( _base == DoubleCon, "Not a Double" ); 1561 return (TypeD*)this; 1562 } 1563 1564 inline const TypeD *Type::isa_double_constant() const { 1565 return ( _base == DoubleCon ? (TypeD*)this : NULL); 1566 } 1567 1568 inline const TypeTuple *Type::is_tuple() const { 1569 assert( _base == Tuple, "Not a Tuple" ); 1570 return (TypeTuple*)this; 1571 } 1572 1573 inline const TypeAry *Type::is_ary() const { 1574 assert( _base == Array , "Not an Array" ); 1575 return (TypeAry*)this; 1576 } 1577 1578 inline const TypeVect *Type::is_vect() const { 1579 assert( _base >= VectorS && _base <= VectorZ, "Not a Vector" ); 1580 return (TypeVect*)this; 1581 } 1582 1583 inline const TypeVect *Type::isa_vect() const { 1584 return (_base >= VectorS && _base <= VectorZ) ? (TypeVect*)this : NULL; 1585 } 1586 1587 inline const TypePtr *Type::is_ptr() const { 1588 // AnyPtr is the first Ptr and KlassPtr the last, with no non-ptrs between. 1589 assert(_base >= AnyPtr && _base <= KlassPtr, "Not a pointer"); 1590 return (TypePtr*)this; 1591 } 1592 1593 inline const TypePtr *Type::isa_ptr() const { 1594 // AnyPtr is the first Ptr and KlassPtr the last, with no non-ptrs between. 1595 return (_base >= AnyPtr && _base <= KlassPtr) ? (TypePtr*)this : NULL; 1596 } 1597 1598 inline const TypeOopPtr *Type::is_oopptr() const { 1599 // OopPtr is the first and KlassPtr the last, with no non-oops between. 1600 assert(_base >= OopPtr && _base <= AryPtr, "Not a Java pointer" ) ; 1601 return (TypeOopPtr*)this; 1602 } 1603 1604 inline const TypeOopPtr *Type::isa_oopptr() const { |