hotspot/src/share/vm/opto/type.hpp
changeset 360 21d113ecbf6a
parent 237 fba97e902303
child 392 0b3167e2f2de
equal deleted inserted replaced
357:f4edb0d9f109 360:21d113ecbf6a
    39 class Type;
    39 class Type;
    40 class   TypeD;
    40 class   TypeD;
    41 class   TypeF;
    41 class   TypeF;
    42 class   TypeInt;
    42 class   TypeInt;
    43 class   TypeLong;
    43 class   TypeLong;
       
    44 class   TypeNarrowOop;
    44 class   TypeAry;
    45 class   TypeAry;
    45 class   TypeTuple;
    46 class   TypeTuple;
    46 class   TypePtr;
    47 class   TypePtr;
    47 class     TypeRawPtr;
    48 class     TypeRawPtr;
    48 class     TypeOopPtr;
    49 class     TypeOopPtr;
    62     Control,                    // Control of code (not in lattice)
    63     Control,                    // Control of code (not in lattice)
    63     Top,                        // Top of the lattice
    64     Top,                        // Top of the lattice
    64     Int,                        // Integer range (lo-hi)
    65     Int,                        // Integer range (lo-hi)
    65     Long,                       // Long integer range (lo-hi)
    66     Long,                       // Long integer range (lo-hi)
    66     Half,                       // Placeholder half of doubleword
    67     Half,                       // Placeholder half of doubleword
       
    68     NarrowOop,                  // Compressed oop pointer
    67 
    69 
    68     Tuple,                      // Method signature or object layout
    70     Tuple,                      // Method signature or object layout
    69     Array,                      // Array types
    71     Array,                      // Array types
    70 
    72 
    71     AnyPtr,                     // Any old raw, klass, inst, or array pointer
    73     AnyPtr,                     // Any old raw, klass, inst, or array pointer
   186   // Modified version of JOIN adapted to the needs Node::Value.
   188   // Modified version of JOIN adapted to the needs Node::Value.
   187   // Normalizes all empty values to TOP.  Does not kill _widen bits.
   189   // Normalizes all empty values to TOP.  Does not kill _widen bits.
   188   // Currently, it also works around limitations involving interface types.
   190   // Currently, it also works around limitations involving interface types.
   189   virtual const Type *filter( const Type *kills ) const;
   191   virtual const Type *filter( const Type *kills ) const;
   190 
   192 
       
   193   // Returns true if this pointer points at memory which contains a
       
   194   // compressed oop references.  In 32-bit builds it's non-virtual
       
   195   // since we don't support compressed oops at all in the mode.
       
   196   LP64_ONLY(virtual) bool is_narrow() const { return false; }
       
   197 
   191   // Convenience access
   198   // Convenience access
   192   float getf() const;
   199   float getf() const;
   193   double getd() const;
   200   double getd() const;
   194 
   201 
   195   const TypeInt    *is_int() const;
   202   const TypeInt    *is_int() const;
   202   const TypeF      *isa_float_constant() const;  // Returns NULL if not a FloatCon
   209   const TypeF      *isa_float_constant() const;  // Returns NULL if not a FloatCon
   203   const TypeTuple  *is_tuple() const;            // Collection of fields, NOT a pointer
   210   const TypeTuple  *is_tuple() const;            // Collection of fields, NOT a pointer
   204   const TypeAry    *is_ary() const;              // Array, NOT array pointer
   211   const TypeAry    *is_ary() const;              // Array, NOT array pointer
   205   const TypePtr    *is_ptr() const;              // Asserts it is a ptr type
   212   const TypePtr    *is_ptr() const;              // Asserts it is a ptr type
   206   const TypePtr    *isa_ptr() const;             // Returns NULL if not ptr type
   213   const TypePtr    *isa_ptr() const;             // Returns NULL if not ptr type
   207   const TypeRawPtr *is_rawptr() const;           // NOT Java oop
   214   const TypeRawPtr *isa_rawptr() const;          // NOT Java oop
   208   const TypeOopPtr *isa_oopptr() const;          // Returns NULL if not ptr type
   215   const TypeRawPtr *is_rawptr() const;           // Asserts is rawptr
   209   const TypeKlassPtr *isa_klassptr() const; // Returns NULL if not KlassPtr
   216   const TypeNarrowOop  *is_narrowoop() const;        // Java-style GC'd pointer
   210   const TypeKlassPtr *is_klassptr() const; // assert if not KlassPtr
   217   const TypeNarrowOop  *isa_narrowoop() const;       // Returns NULL if not oop ptr type
   211   const TypeOopPtr  *is_oopptr() const;          // Java-style GC'd pointer
   218   const TypeOopPtr   *isa_oopptr() const;        // Returns NULL if not oop ptr type
   212   const TypeInstPtr *isa_instptr() const;        // Returns NULL if not InstPtr
   219   const TypeOopPtr   *is_oopptr() const;         // Java-style GC'd pointer
   213   const TypeInstPtr *is_instptr() const;         // Instance
   220   const TypeKlassPtr *isa_klassptr() const;      // Returns NULL if not KlassPtr
   214   const TypeAryPtr *isa_aryptr() const;          // Returns NULL if not AryPtr
   221   const TypeKlassPtr *is_klassptr() const;       // assert if not KlassPtr
   215   const TypeAryPtr *is_aryptr() const;           // Array oop
   222   const TypeInstPtr  *isa_instptr() const;       // Returns NULL if not InstPtr
       
   223   const TypeInstPtr  *is_instptr() const;        // Instance
       
   224   const TypeAryPtr   *isa_aryptr() const;        // Returns NULL if not AryPtr
       
   225   const TypeAryPtr   *is_aryptr() const;         // Array oop
   216   virtual bool      is_finite() const;           // Has a finite value
   226   virtual bool      is_finite() const;           // Has a finite value
   217   virtual bool      is_nan()    const;           // Is not a number (NaN)
   227   virtual bool      is_nan()    const;           // Is not a number (NaN)
   218 
   228 
   219   // Special test for register pressure heuristic
   229   // Special test for register pressure heuristic
   220   bool is_floatingpoint() const;        // True if Float or Double base type
   230   bool is_floatingpoint() const;        // True if Float or Double base type
   538 // Class of machine Pointer Types: raw data, instances or arrays.
   548 // Class of machine Pointer Types: raw data, instances or arrays.
   539 // If the _base enum is AnyPtr, then this refers to all of the above.
   549 // If the _base enum is AnyPtr, then this refers to all of the above.
   540 // Otherwise the _base will indicate which subset of pointers is affected,
   550 // Otherwise the _base will indicate which subset of pointers is affected,
   541 // and the class will be inherited from.
   551 // and the class will be inherited from.
   542 class TypePtr : public Type {
   552 class TypePtr : public Type {
       
   553   friend class TypeNarrowOop;
   543 public:
   554 public:
   544   enum PTR { TopPTR, AnyNull, Constant, Null, NotNull, BotPTR, lastPTR };
   555   enum PTR { TopPTR, AnyNull, Constant, Null, NotNull, BotPTR, lastPTR };
   545 protected:
   556 protected:
   546   TypePtr( TYPES t, PTR ptr, int offset ) : Type(t), _ptr(ptr), _offset(offset) {}
   557   TypePtr( TYPES t, PTR ptr, int offset ) : Type(t), _ptr(ptr), _offset(offset) {}
   547   virtual bool eq( const Type *t ) const;
   558   virtual bool eq( const Type *t ) const;
   699   // corresponding pointer to klass, for a given instance
   710   // corresponding pointer to klass, for a given instance
   700   const TypeKlassPtr* as_klass_type() const;
   711   const TypeKlassPtr* as_klass_type() const;
   701 
   712 
   702   virtual const TypePtr *add_offset( int offset ) const;
   713   virtual const TypePtr *add_offset( int offset ) const;
   703 
   714 
       
   715   // returns the equivalent compressed version of this pointer type
       
   716   virtual const TypeNarrowOop* make_narrowoop() const;
       
   717 
       
   718 #ifdef _LP64
       
   719   virtual bool is_narrow() const {
       
   720     return (UseCompressedOops && _offset != 0);
       
   721   }
       
   722 #endif
       
   723 
   704   virtual const Type *xmeet( const Type *t ) const;
   724   virtual const Type *xmeet( const Type *t ) const;
   705   virtual const Type *xdual() const;    // Compute dual right now.
   725   virtual const Type *xdual() const;    // Compute dual right now.
   706 
   726 
   707   // Do not allow interface-vs.-noninterface joins to collapse to top.
   727   // Do not allow interface-vs.-noninterface joins to collapse to top.
   708   virtual const Type *filter( const Type *kills ) const;
   728   virtual const Type *filter( const Type *kills ) const;
   819   virtual bool empty(void) const;        // TRUE if type is vacuous
   839   virtual bool empty(void) const;        // TRUE if type is vacuous
   820   virtual const TypePtr *add_offset( int offset ) const;
   840   virtual const TypePtr *add_offset( int offset ) const;
   821 
   841 
   822   virtual const Type *xmeet( const Type *t ) const;
   842   virtual const Type *xmeet( const Type *t ) const;
   823   virtual const Type *xdual() const;    // Compute dual right now.
   843   virtual const Type *xdual() const;    // Compute dual right now.
       
   844 
       
   845 #ifdef _LP64
       
   846   virtual bool is_narrow() const {
       
   847     return (UseCompressedOops && klass() != NULL && _offset != 0);
       
   848   }
       
   849 #endif
   824 
   850 
   825   // Convenience common pre-built types.
   851   // Convenience common pre-built types.
   826   static const TypeAryPtr *RANGE;
   852   static const TypeAryPtr *RANGE;
   827   static const TypeAryPtr *OOPS;
   853   static const TypeAryPtr *OOPS;
   828   static const TypeAryPtr *BYTES;
   854   static const TypeAryPtr *BYTES;
   872 
   898 
   873   virtual const TypePtr *add_offset( int offset ) const;
   899   virtual const TypePtr *add_offset( int offset ) const;
   874   virtual const Type    *xmeet( const Type *t ) const;
   900   virtual const Type    *xmeet( const Type *t ) const;
   875   virtual const Type    *xdual() const;      // Compute dual right now.
   901   virtual const Type    *xdual() const;      // Compute dual right now.
   876 
   902 
       
   903 #ifdef _LP64
       
   904   // Perm objects don't use compressed references, except for static fields
       
   905   // which are currently compressed
       
   906   virtual bool is_narrow() const {
       
   907     if (UseCompressedOops && _offset != 0 && _klass->is_instance_klass()) {
       
   908       ciInstanceKlass* ik = _klass->as_instance_klass();
       
   909       return ik != NULL && ik->get_field_by_offset(_offset, true) != NULL;
       
   910     }
       
   911     return false;
       
   912   }
       
   913 #endif
       
   914 
   877   // Convenience common pre-built types.
   915   // Convenience common pre-built types.
   878   static const TypeKlassPtr* OBJECT; // Not-null object klass or below
   916   static const TypeKlassPtr* OBJECT; // Not-null object klass or below
   879   static const TypeKlassPtr* OBJECT_OR_NULL; // Maybe-null version of same
   917   static const TypeKlassPtr* OBJECT_OR_NULL; // Maybe-null version of same
   880 #ifndef PRODUCT
   918 #ifndef PRODUCT
   881   virtual void dump2( Dict &d, uint depth, outputStream *st ) const; // Specialized per-Type dumping
   919   virtual void dump2( Dict &d, uint depth, outputStream *st ) const; // Specialized per-Type dumping
       
   920 #endif
       
   921 };
       
   922 
       
   923 //------------------------------TypeNarrowOop----------------------------------------
       
   924 // A compressed reference to some kind of Oop.  This type wraps around
       
   925 // a preexisting TypeOopPtr and forwards most of it's operations to
       
   926 // the underlying type.  It's only real purpose is to track the
       
   927 // oopness of the compressed oop value when we expose the conversion
       
   928 // between the normal and the compressed form.
       
   929 class TypeNarrowOop : public Type {
       
   930 protected:
       
   931   const TypePtr* _ooptype;
       
   932 
       
   933   TypeNarrowOop( const TypePtr* ooptype): Type(NarrowOop),
       
   934     _ooptype(ooptype) {
       
   935     assert(ooptype->offset() == 0 ||
       
   936            ooptype->offset() == OffsetBot ||
       
   937            ooptype->offset() == OffsetTop, "no real offsets");
       
   938   }
       
   939 public:
       
   940   virtual bool eq( const Type *t ) const;
       
   941   virtual int  hash() const;             // Type specific hashing
       
   942   virtual bool singleton(void) const;    // TRUE if type is a singleton
       
   943 
       
   944   virtual const Type *xmeet( const Type *t ) const;
       
   945   virtual const Type *xdual() const;    // Compute dual right now.
       
   946 
       
   947   virtual intptr_t get_con() const;
       
   948 
       
   949   // Do not allow interface-vs.-noninterface joins to collapse to top.
       
   950   virtual const Type *filter( const Type *kills ) const;
       
   951 
       
   952   virtual bool empty(void) const;        // TRUE if type is vacuous
       
   953 
       
   954   static const TypeNarrowOop *make( const TypePtr* type);
       
   955 
       
   956   static const TypeNarrowOop* make_from_constant(ciObject* con) {
       
   957     return make(TypeOopPtr::make_from_constant(con));
       
   958   }
       
   959 
       
   960   // returns the equivalent oopptr type for this compressed pointer
       
   961   virtual const TypePtr *make_oopptr() const {
       
   962     return _ooptype;
       
   963   }
       
   964 
       
   965   static const TypeNarrowOop *BOTTOM;
       
   966   static const TypeNarrowOop *NULL_PTR;
       
   967 
       
   968 #ifndef PRODUCT
       
   969   virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
   882 #endif
   970 #endif
   883 };
   971 };
   884 
   972 
   885 //------------------------------TypeFunc---------------------------------------
   973 //------------------------------TypeFunc---------------------------------------
   886 // Class of Array Types
   974 // Class of Array Types
  1000 inline const TypeOopPtr *Type::isa_oopptr() const {
  1088 inline const TypeOopPtr *Type::isa_oopptr() const {
  1001   // OopPtr is the first and KlassPtr the last, with no non-oops between.
  1089   // OopPtr is the first and KlassPtr the last, with no non-oops between.
  1002   return (_base >= OopPtr && _base <= KlassPtr) ? (TypeOopPtr*)this : NULL;
  1090   return (_base >= OopPtr && _base <= KlassPtr) ? (TypeOopPtr*)this : NULL;
  1003 }
  1091 }
  1004 
  1092 
       
  1093 inline const TypeRawPtr *Type::isa_rawptr() const {
       
  1094   return (_base == RawPtr) ? (TypeRawPtr*)this : NULL;
       
  1095 }
       
  1096 
  1005 inline const TypeRawPtr *Type::is_rawptr() const {
  1097 inline const TypeRawPtr *Type::is_rawptr() const {
  1006   assert( _base == RawPtr, "Not a raw pointer" );
  1098   assert( _base == RawPtr, "Not a raw pointer" );
  1007   return (TypeRawPtr*)this;
  1099   return (TypeRawPtr*)this;
  1008 }
  1100 }
  1009 
  1101 
  1021 }
  1113 }
  1022 
  1114 
  1023 inline const TypeAryPtr *Type::is_aryptr() const {
  1115 inline const TypeAryPtr *Type::is_aryptr() const {
  1024   assert( _base == AryPtr, "Not an array pointer" );
  1116   assert( _base == AryPtr, "Not an array pointer" );
  1025   return (TypeAryPtr*)this;
  1117   return (TypeAryPtr*)this;
       
  1118 }
       
  1119 
       
  1120 inline const TypeNarrowOop *Type::is_narrowoop() const {
       
  1121   // OopPtr is the first and KlassPtr the last, with no non-oops between.
       
  1122   assert(_base == NarrowOop, "Not a narrow oop" ) ;
       
  1123   return (TypeNarrowOop*)this;
       
  1124 }
       
  1125 
       
  1126 inline const TypeNarrowOop *Type::isa_narrowoop() const {
       
  1127   // OopPtr is the first and KlassPtr the last, with no non-oops between.
       
  1128   return (_base == NarrowOop) ? (TypeNarrowOop*)this : NULL;
  1026 }
  1129 }
  1027 
  1130 
  1028 inline const TypeKlassPtr *Type::isa_klassptr() const {
  1131 inline const TypeKlassPtr *Type::isa_klassptr() const {
  1029   return (_base == KlassPtr) ? (TypeKlassPtr*)this : NULL;
  1132   return (_base == KlassPtr) ? (TypeKlassPtr*)this : NULL;
  1030 }
  1133 }