< prev index next >

src/hotspot/share/opto/type.hpp

Print this page

   1 /*
   2  * Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *

  36 // This class defines a Type lattice.  The lattice is used in the constant
  37 // propagation algorithms, and for some type-checking of the iloc code.
  38 // Basic types include RSD's (lower bound, upper bound, stride for integers),
  39 // float & double precision constants, sets of data-labels and code-labels.
  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

 740   uint length() const { return _length; }
 741   uint length_in_bytes() const {
 742    return _length * type2aelembytes(element_basic_type());
 743   }
 744 
 745   virtual bool eq(const Type *t) const;
 746   virtual int  hash() const;             // Type specific hashing
 747   virtual bool singleton(void) const;    // TRUE if type is a singleton
 748   virtual bool empty(void) const;        // TRUE if type is vacuous
 749 
 750   static const TypeVect *make(const BasicType elem_bt, uint length) {
 751     // Use bottom primitive type.
 752     return make(get_const_basic_type(elem_bt), length);
 753   }
 754   // Used directly by Replicate nodes to construct singleton vector.
 755   static const TypeVect *make(const Type* elem, uint length);
 756 
 757   virtual const Type *xmeet( const Type *t) const;
 758   virtual const Type *xdual() const;     // Compute dual right now.
 759 

 760   static const TypeVect *VECTS;
 761   static const TypeVect *VECTD;
 762   static const TypeVect *VECTX;
 763   static const TypeVect *VECTY;
 764   static const TypeVect *VECTZ;
 765 
 766 #ifndef PRODUCT
 767   virtual void dump2(Dict &d, uint, outputStream *st) const; // Specialized per-Type dumping
 768 #endif
 769 };
 770 





 771 class TypeVectS : public TypeVect {
 772   friend class TypeVect;
 773   TypeVectS(const Type* elem, uint length) : TypeVect(VectorS, elem, length) {}
 774 };
 775 
 776 class TypeVectD : public TypeVect {
 777   friend class TypeVect;
 778   TypeVectD(const Type* elem, uint length) : TypeVect(VectorD, elem, length) {}
 779 };
 780 
 781 class TypeVectX : public TypeVect {
 782   friend class TypeVect;
 783   TypeVectX(const Type* elem, uint length) : TypeVect(VectorX, elem, length) {}
 784 };
 785 
 786 class TypeVectY : public TypeVect {
 787   friend class TypeVect;
 788   TypeVectY(const Type* elem, uint length) : TypeVect(VectorY, elem, length) {}
 789 };
 790 

1605 
1606 inline const TypeD *Type::isa_double_constant() const {
1607   return ( _base == DoubleCon ? (TypeD*)this : NULL);
1608 }
1609 
1610 inline const TypeTuple *Type::is_tuple() const {
1611   assert( _base == Tuple, "Not a Tuple" );
1612   return (TypeTuple*)this;
1613 }
1614 
1615 inline const TypeAry *Type::is_ary() const {
1616   assert( _base == Array , "Not an Array" );
1617   return (TypeAry*)this;
1618 }
1619 
1620 inline const TypeAry *Type::isa_ary() const {
1621   return ((_base == Array) ? (TypeAry*)this : NULL);
1622 }
1623 
1624 inline const TypeVect *Type::is_vect() const {
1625   assert( _base >= VectorS && _base <= VectorZ, "Not a Vector" );
1626   return (TypeVect*)this;
1627 }
1628 
1629 inline const TypeVect *Type::isa_vect() const {
1630   return (_base >= VectorS && _base <= VectorZ) ? (TypeVect*)this : NULL;
1631 }
1632 
1633 inline const TypePtr *Type::is_ptr() const {
1634   // AnyPtr is the first Ptr and KlassPtr the last, with no non-ptrs between.
1635   assert(_base >= AnyPtr && _base <= KlassPtr, "Not a pointer");
1636   return (TypePtr*)this;
1637 }
1638 
1639 inline const TypePtr *Type::isa_ptr() const {
1640   // AnyPtr is the first Ptr and KlassPtr the last, with no non-ptrs between.
1641   return (_base >= AnyPtr && _base <= KlassPtr) ? (TypePtr*)this : NULL;
1642 }
1643 
1644 inline const TypeOopPtr *Type::is_oopptr() const {
1645   // OopPtr is the first and KlassPtr the last, with no non-oops between.
1646   assert(_base >= OopPtr && _base <= AryPtr, "Not a Java pointer" ) ;
1647   return (TypeOopPtr*)this;
1648 }
1649 
1650 inline const TypeOopPtr *Type::isa_oopptr() const {

   1 /*
   2  * Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *

  36 // This class defines a Type lattice.  The lattice is used in the constant
  37 // propagation algorithms, and for some type-checking of the iloc code.
  38 // Basic types include RSD's (lower bound, upper bound, stride for integers),
  39 // float & double precision constants, sets of data-labels and code-labels.
  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     TypeVectA;
  57 class     TypeVectS;
  58 class     TypeVectD;
  59 class     TypeVectX;
  60 class     TypeVectY;
  61 class     TypeVectZ;
  62 class   TypePtr;
  63 class     TypeRawPtr;
  64 class     TypeOopPtr;
  65 class       TypeInstPtr;
  66 class       TypeAryPtr;
  67 class     TypeKlassPtr;
  68 class     TypeMetadataPtr;
  69 
  70 //------------------------------Type-------------------------------------------
  71 // Basic Type object, represents a set of primitive Values.
  72 // Types are hash-cons'd into a private class dictionary, so only one of each
  73 // different kind of Type exists.  Types are never modified after creation, so
  74 // all their interesting fields are constant.
  75 class Type {
  76   friend class VMStructs;
  77 
  78 public:
  79   enum TYPES {
  80     Bad=0,                      // Type check
  81     Control,                    // Control of code (not in lattice)
  82     Top,                        // Top of the lattice
  83     Int,                        // Integer range (lo-hi)
  84     Long,                       // Long integer range (lo-hi)
  85     Half,                       // Placeholder half of doubleword
  86     NarrowOop,                  // Compressed oop pointer
  87     NarrowKlass,                // Compressed klass pointer
  88 
  89     Tuple,                      // Method signature or object layout
  90     Array,                      // Array types
  91     VectorA,                    // (Scalable) Vector types for vector length agnostic
  92     VectorS,                    //  32bit Vector types
  93     VectorD,                    //  64bit Vector types
  94     VectorX,                    // 128bit Vector types
  95     VectorY,                    // 256bit Vector types
  96     VectorZ,                    // 512bit Vector types
  97 
  98     AnyPtr,                     // Any old raw, klass, inst, or array pointer
  99     RawPtr,                     // Raw (non-oop) pointers
 100     OopPtr,                     // Any and all Java heap entities
 101     InstPtr,                    // Instance pointers (non-array objects)
 102     AryPtr,                     // Array pointers
 103     // (Ptr order matters:  See is_ptr, isa_ptr, is_oopptr, isa_oopptr.)
 104 
 105     MetadataPtr,                // Generic metadata
 106     KlassPtr,                   // Klass pointers
 107 
 108     Function,                   // Function signature
 109     Abio,                       // Abstract I/O
 110     Return_Address,             // Subroutine return address
 111     Memory,                     // Abstract store

 742   uint length() const { return _length; }
 743   uint length_in_bytes() const {
 744    return _length * type2aelembytes(element_basic_type());
 745   }
 746 
 747   virtual bool eq(const Type *t) const;
 748   virtual int  hash() const;             // Type specific hashing
 749   virtual bool singleton(void) const;    // TRUE if type is a singleton
 750   virtual bool empty(void) const;        // TRUE if type is vacuous
 751 
 752   static const TypeVect *make(const BasicType elem_bt, uint length) {
 753     // Use bottom primitive type.
 754     return make(get_const_basic_type(elem_bt), length);
 755   }
 756   // Used directly by Replicate nodes to construct singleton vector.
 757   static const TypeVect *make(const Type* elem, uint length);
 758 
 759   virtual const Type *xmeet( const Type *t) const;
 760   virtual const Type *xdual() const;     // Compute dual right now.
 761 
 762   static const TypeVect *VECTA;
 763   static const TypeVect *VECTS;
 764   static const TypeVect *VECTD;
 765   static const TypeVect *VECTX;
 766   static const TypeVect *VECTY;
 767   static const TypeVect *VECTZ;
 768 
 769 #ifndef PRODUCT
 770   virtual void dump2(Dict &d, uint, outputStream *st) const; // Specialized per-Type dumping
 771 #endif
 772 };
 773 
 774 class TypeVectA : public TypeVect {
 775   friend class TypeVect;
 776   TypeVectA(const Type* elem, uint length) : TypeVect(VectorA, elem, length) {}
 777 };
 778 
 779 class TypeVectS : public TypeVect {
 780   friend class TypeVect;
 781   TypeVectS(const Type* elem, uint length) : TypeVect(VectorS, elem, length) {}
 782 };
 783 
 784 class TypeVectD : public TypeVect {
 785   friend class TypeVect;
 786   TypeVectD(const Type* elem, uint length) : TypeVect(VectorD, elem, length) {}
 787 };
 788 
 789 class TypeVectX : public TypeVect {
 790   friend class TypeVect;
 791   TypeVectX(const Type* elem, uint length) : TypeVect(VectorX, elem, length) {}
 792 };
 793 
 794 class TypeVectY : public TypeVect {
 795   friend class TypeVect;
 796   TypeVectY(const Type* elem, uint length) : TypeVect(VectorY, elem, length) {}
 797 };
 798 

1613 
1614 inline const TypeD *Type::isa_double_constant() const {
1615   return ( _base == DoubleCon ? (TypeD*)this : NULL);
1616 }
1617 
1618 inline const TypeTuple *Type::is_tuple() const {
1619   assert( _base == Tuple, "Not a Tuple" );
1620   return (TypeTuple*)this;
1621 }
1622 
1623 inline const TypeAry *Type::is_ary() const {
1624   assert( _base == Array , "Not an Array" );
1625   return (TypeAry*)this;
1626 }
1627 
1628 inline const TypeAry *Type::isa_ary() const {
1629   return ((_base == Array) ? (TypeAry*)this : NULL);
1630 }
1631 
1632 inline const TypeVect *Type::is_vect() const {
1633   assert( _base >= VectorA && _base <= VectorZ, "Not a Vector" );
1634   return (TypeVect*)this;
1635 }
1636 
1637 inline const TypeVect *Type::isa_vect() const {
1638   return (_base >= VectorA && _base <= VectorZ) ? (TypeVect*)this : NULL;
1639 }
1640 
1641 inline const TypePtr *Type::is_ptr() const {
1642   // AnyPtr is the first Ptr and KlassPtr the last, with no non-ptrs between.
1643   assert(_base >= AnyPtr && _base <= KlassPtr, "Not a pointer");
1644   return (TypePtr*)this;
1645 }
1646 
1647 inline const TypePtr *Type::isa_ptr() const {
1648   // AnyPtr is the first Ptr and KlassPtr the last, with no non-ptrs between.
1649   return (_base >= AnyPtr && _base <= KlassPtr) ? (TypePtr*)this : NULL;
1650 }
1651 
1652 inline const TypeOopPtr *Type::is_oopptr() const {
1653   // OopPtr is the first and KlassPtr the last, with no non-oops between.
1654   assert(_base >= OopPtr && _base <= AryPtr, "Not a Java pointer" ) ;
1655   return (TypeOopPtr*)this;
1656 }
1657 
1658 inline const TypeOopPtr *Type::isa_oopptr() const {
< prev index next >