src/share/vm/opto/type.hpp

Mon, 28 Oct 2013 09:58:59 +0100

author
roland
date
Mon, 28 Oct 2013 09:58:59 +0100
changeset 6043
6c2f07d1495f
parent 5997
59e8ad757e19
child 6313
de95063c0e34
child 6487
15120a36272d
permissions
-rw-r--r--

8027140: Assertion in compiler when running bigapps/Kitchensink/stability
Summary: filter() code for TypeKlassPtr not moved when permgen removal was introduced
Reviewed-by: twisti, iveresov

     1 /*
     2  * Copyright (c) 1997, 2013, 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  *
    23  */
    25 #ifndef SHARE_VM_OPTO_TYPE_HPP
    26 #define SHARE_VM_OPTO_TYPE_HPP
    28 #include "libadt/port.hpp"
    29 #include "opto/adlcVMDeps.hpp"
    30 #include "runtime/handles.hpp"
    32 // Portions of code courtesy of Clifford Click
    34 // Optimization - Graph Style
    37 // This class defines a Type lattice.  The lattice is used in the constant
    38 // propagation algorithms, and for some type-checking of the iloc code.
    39 // Basic types include RSD's (lower bound, upper bound, stride for integers),
    40 // float & double precision constants, sets of data-labels and code-labels.
    41 // The complete lattice is described below.  Subtypes have no relationship to
    42 // up or down in the lattice; that is entirely determined by the behavior of
    43 // the MEET/JOIN functions.
    45 class Dict;
    46 class Type;
    47 class   TypeD;
    48 class   TypeF;
    49 class   TypeInt;
    50 class   TypeLong;
    51 class   TypeNarrowPtr;
    52 class     TypeNarrowOop;
    53 class     TypeNarrowKlass;
    54 class   TypeAry;
    55 class   TypeTuple;
    56 class   TypeVect;
    57 class     TypeVectS;
    58 class     TypeVectD;
    59 class     TypeVectX;
    60 class     TypeVectY;
    61 class   TypePtr;
    62 class     TypeRawPtr;
    63 class     TypeOopPtr;
    64 class       TypeInstPtr;
    65 class       TypeAryPtr;
    66 class     TypeKlassPtr;
    67 class     TypeMetadataPtr;
    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;
    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
    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
    95     AnyPtr,                     // Any old raw, klass, inst, or array pointer
    96     RawPtr,                     // Raw (non-oop) pointers
    97     OopPtr,                     // Any and all Java heap entities
    98     InstPtr,                    // Instance pointers (non-array objects)
    99     AryPtr,                     // Array pointers
   100     // (Ptr order matters:  See is_ptr, isa_ptr, is_oopptr, isa_oopptr.)
   102     MetadataPtr,                // Generic metadata
   103     KlassPtr,                   // Klass pointers
   105     Function,                   // Function signature
   106     Abio,                       // Abstract I/O
   107     Return_Address,             // Subroutine return address
   108     Memory,                     // Abstract store
   109     FloatTop,                   // No float value
   110     FloatCon,                   // Floating point constant
   111     FloatBot,                   // Any float value
   112     DoubleTop,                  // No double value
   113     DoubleCon,                  // Double precision constant
   114     DoubleBot,                  // Any double value
   115     Bottom,                     // Bottom of lattice
   116     lastype                     // Bogus ending type (not in lattice)
   117   };
   119   // Signal values for offsets from a base pointer
   120   enum OFFSET_SIGNALS {
   121     OffsetTop = -2000000000,    // undefined offset
   122     OffsetBot = -2000000001     // any possible offset
   123   };
   125   // Min and max WIDEN values.
   126   enum WIDEN {
   127     WidenMin = 0,
   128     WidenMax = 3
   129   };
   131 private:
   132   typedef struct {
   133     const TYPES                dual_type;
   134     const BasicType            basic_type;
   135     const char*                msg;
   136     const bool                 isa_oop;
   137     const int                  ideal_reg;
   138     const relocInfo::relocType reloc;
   139   } TypeInfo;
   141   // Dictionary of types shared among compilations.
   142   static Dict* _shared_type_dict;
   143   static TypeInfo _type_info[];
   145   static int uhash( const Type *const t );
   146   // Structural equality check.  Assumes that cmp() has already compared
   147   // the _base types and thus knows it can cast 't' appropriately.
   148   virtual bool eq( const Type *t ) const;
   150   // Top-level hash-table of types
   151   static Dict *type_dict() {
   152     return Compile::current()->type_dict();
   153   }
   155   // DUAL operation: reflect around lattice centerline.  Used instead of
   156   // join to ensure my lattice is symmetric up and down.  Dual is computed
   157   // lazily, on demand, and cached in _dual.
   158   const Type *_dual;            // Cached dual value
   159   // Table for efficient dualing of base types
   160   static const TYPES dual_type[lastype];
   162 #ifdef ASSERT
   163   // One type is interface, the other is oop
   164   virtual bool interface_vs_oop_helper(const Type *t) const;
   165 #endif
   167 protected:
   168   // Each class of type is also identified by its base.
   169   const TYPES _base;            // Enum of Types type
   171   Type( TYPES t ) : _dual(NULL),  _base(t) {} // Simple types
   172   // ~Type();                   // Use fast deallocation
   173   const Type *hashcons();       // Hash-cons the type
   175 public:
   177   inline void* operator new( size_t x ) throw() {
   178     Compile* compile = Compile::current();
   179     compile->set_type_last_size(x);
   180     void *temp = compile->type_arena()->Amalloc_D(x);
   181     compile->set_type_hwm(temp);
   182     return temp;
   183   }
   184   inline void operator delete( void* ptr ) {
   185     Compile* compile = Compile::current();
   186     compile->type_arena()->Afree(ptr,compile->type_last_size());
   187   }
   189   // Initialize the type system for a particular compilation.
   190   static void Initialize(Compile* compile);
   192   // Initialize the types shared by all compilations.
   193   static void Initialize_shared(Compile* compile);
   195   TYPES base() const {
   196     assert(_base > Bad && _base < lastype, "sanity");
   197     return _base;
   198   }
   200   // Create a new hash-consd type
   201   static const Type *make(enum TYPES);
   202   // Test for equivalence of types
   203   static int cmp( const Type *const t1, const Type *const t2 );
   204   // Test for higher or equal in lattice
   205   int higher_equal( const Type *t ) const { return !cmp(meet(t),t); }
   207   // MEET operation; lower in lattice.
   208   const Type *meet( const Type *t ) const;
   209   // WIDEN: 'widens' for Ints and other range types
   210   virtual const Type *widen( const Type *old, const Type* limit ) const { return this; }
   211   // NARROW: complement for widen, used by pessimistic phases
   212   virtual const Type *narrow( const Type *old ) const { return this; }
   214   // DUAL operation: reflect around lattice centerline.  Used instead of
   215   // join to ensure my lattice is symmetric up and down.
   216   const Type *dual() const { return _dual; }
   218   // Compute meet dependent on base type
   219   virtual const Type *xmeet( const Type *t ) const;
   220   virtual const Type *xdual() const;    // Compute dual right now.
   222   // JOIN operation; higher in lattice.  Done by finding the dual of the
   223   // meet of the dual of the 2 inputs.
   224   const Type *join( const Type *t ) const {
   225     return dual()->meet(t->dual())->dual(); }
   227   // Modified version of JOIN adapted to the needs Node::Value.
   228   // Normalizes all empty values to TOP.  Does not kill _widen bits.
   229   // Currently, it also works around limitations involving interface types.
   230   virtual const Type *filter( const Type *kills ) const;
   232 #ifdef ASSERT
   233   // One type is interface, the other is oop
   234   virtual bool interface_vs_oop(const Type *t) const;
   235 #endif
   237   // Returns true if this pointer points at memory which contains a
   238   // compressed oop references.
   239   bool is_ptr_to_narrowoop() const;
   240   bool is_ptr_to_narrowklass() const;
   242   bool is_ptr_to_boxing_obj() const;
   245   // Convenience access
   246   float getf() const;
   247   double getd() const;
   249   const TypeInt    *is_int() const;
   250   const TypeInt    *isa_int() const;             // Returns NULL if not an Int
   251   const TypeLong   *is_long() const;
   252   const TypeLong   *isa_long() const;            // Returns NULL if not a Long
   253   const TypeD      *isa_double() const;          // Returns NULL if not a Double{Top,Con,Bot}
   254   const TypeD      *is_double_constant() const;  // Asserts it is a DoubleCon
   255   const TypeD      *isa_double_constant() const; // Returns NULL if not a DoubleCon
   256   const TypeF      *isa_float() const;           // Returns NULL if not a Float{Top,Con,Bot}
   257   const TypeF      *is_float_constant() const;   // Asserts it is a FloatCon
   258   const TypeF      *isa_float_constant() const;  // Returns NULL if not a FloatCon
   259   const TypeTuple  *is_tuple() const;            // Collection of fields, NOT a pointer
   260   const TypeAry    *is_ary() const;              // Array, NOT array pointer
   261   const TypeVect   *is_vect() const;             // Vector
   262   const TypeVect   *isa_vect() const;            // Returns NULL if not a Vector
   263   const TypePtr    *is_ptr() const;              // Asserts it is a ptr type
   264   const TypePtr    *isa_ptr() const;             // Returns NULL if not ptr type
   265   const TypeRawPtr *isa_rawptr() const;          // NOT Java oop
   266   const TypeRawPtr *is_rawptr() const;           // Asserts is rawptr
   267   const TypeNarrowOop  *is_narrowoop() const;    // Java-style GC'd pointer
   268   const TypeNarrowOop  *isa_narrowoop() const;   // Returns NULL if not oop ptr type
   269   const TypeNarrowKlass *is_narrowklass() const; // compressed klass pointer
   270   const TypeNarrowKlass *isa_narrowklass() const;// Returns NULL if not oop ptr type
   271   const TypeOopPtr   *isa_oopptr() const;        // Returns NULL if not oop ptr type
   272   const TypeOopPtr   *is_oopptr() const;         // Java-style GC'd pointer
   273   const TypeInstPtr  *isa_instptr() const;       // Returns NULL if not InstPtr
   274   const TypeInstPtr  *is_instptr() const;        // Instance
   275   const TypeAryPtr   *isa_aryptr() const;        // Returns NULL if not AryPtr
   276   const TypeAryPtr   *is_aryptr() const;         // Array oop
   278   const TypeMetadataPtr   *isa_metadataptr() const;   // Returns NULL if not oop ptr type
   279   const TypeMetadataPtr   *is_metadataptr() const;    // Java-style GC'd pointer
   280   const TypeKlassPtr      *isa_klassptr() const;      // Returns NULL if not KlassPtr
   281   const TypeKlassPtr      *is_klassptr() const;       // assert if not KlassPtr
   283   virtual bool      is_finite() const;           // Has a finite value
   284   virtual bool      is_nan()    const;           // Is not a number (NaN)
   286   // Returns this ptr type or the equivalent ptr type for this compressed pointer.
   287   const TypePtr* make_ptr() const;
   289   // Returns this oopptr type or the equivalent oopptr type for this compressed pointer.
   290   // Asserts if the underlying type is not an oopptr or narrowoop.
   291   const TypeOopPtr* make_oopptr() const;
   293   // Returns this compressed pointer or the equivalent compressed version
   294   // of this pointer type.
   295   const TypeNarrowOop* make_narrowoop() const;
   297   // Returns this compressed klass pointer or the equivalent
   298   // compressed version of this pointer type.
   299   const TypeNarrowKlass* make_narrowklass() const;
   301   // Special test for register pressure heuristic
   302   bool is_floatingpoint() const;        // True if Float or Double base type
   304   // Do you have memory, directly or through a tuple?
   305   bool has_memory( ) const;
   307   // TRUE if type is a singleton
   308   virtual bool singleton(void) const;
   310   // TRUE if type is above the lattice centerline, and is therefore vacuous
   311   virtual bool empty(void) const;
   313   // Return a hash for this type.  The hash function is public so ConNode
   314   // (constants) can hash on their constant, which is represented by a Type.
   315   virtual int hash() const;
   317   // Map ideal registers (machine types) to ideal types
   318   static const Type *mreg2type[];
   320   // Printing, statistics
   321 #ifndef PRODUCT
   322   void         dump_on(outputStream *st) const;
   323   void         dump() const {
   324     dump_on(tty);
   325   }
   326   virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
   327   static  void dump_stats();
   328 #endif
   329   void typerr(const Type *t) const; // Mixing types error
   331   // Create basic type
   332   static const Type* get_const_basic_type(BasicType type) {
   333     assert((uint)type <= T_CONFLICT && _const_basic_type[type] != NULL, "bad type");
   334     return _const_basic_type[type];
   335   }
   337   // Mapping to the array element's basic type.
   338   BasicType array_element_basic_type() const;
   340   // Create standard type for a ciType:
   341   static const Type* get_const_type(ciType* type);
   343   // Create standard zero value:
   344   static const Type* get_zero_type(BasicType type) {
   345     assert((uint)type <= T_CONFLICT && _zero_type[type] != NULL, "bad type");
   346     return _zero_type[type];
   347   }
   349   // Report if this is a zero value (not top).
   350   bool is_zero_type() const {
   351     BasicType type = basic_type();
   352     if (type == T_VOID || type >= T_CONFLICT)
   353       return false;
   354     else
   355       return (this == _zero_type[type]);
   356   }
   358   // Convenience common pre-built types.
   359   static const Type *ABIO;
   360   static const Type *BOTTOM;
   361   static const Type *CONTROL;
   362   static const Type *DOUBLE;
   363   static const Type *FLOAT;
   364   static const Type *HALF;
   365   static const Type *MEMORY;
   366   static const Type *MULTI;
   367   static const Type *RETURN_ADDRESS;
   368   static const Type *TOP;
   370   // Mapping from compiler type to VM BasicType
   371   BasicType basic_type() const       { return _type_info[_base].basic_type; }
   372   int ideal_reg() const              { return _type_info[_base].ideal_reg; }
   373   const char* msg() const            { return _type_info[_base].msg; }
   374   bool isa_oop_ptr() const           { return _type_info[_base].isa_oop; }
   375   relocInfo::relocType reloc() const { return _type_info[_base].reloc; }
   377   // Mapping from CI type system to compiler type:
   378   static const Type* get_typeflow_type(ciType* type);
   380   static const Type* make_from_constant(ciConstant constant,
   381                                         bool require_constant = false,
   382                                         bool is_autobox_cache = false);
   384   // Speculative type. See TypeInstPtr
   385   virtual ciKlass* speculative_type() const { return NULL; }
   387 private:
   388   // support arrays
   389   static const BasicType _basic_type[];
   390   static const Type*        _zero_type[T_CONFLICT+1];
   391   static const Type* _const_basic_type[T_CONFLICT+1];
   392 };
   394 //------------------------------TypeF------------------------------------------
   395 // Class of Float-Constant Types.
   396 class TypeF : public Type {
   397   TypeF( float f ) : Type(FloatCon), _f(f) {};
   398 public:
   399   virtual bool eq( const Type *t ) const;
   400   virtual int  hash() const;             // Type specific hashing
   401   virtual bool singleton(void) const;    // TRUE if type is a singleton
   402   virtual bool empty(void) const;        // TRUE if type is vacuous
   403 public:
   404   const float _f;               // Float constant
   406   static const TypeF *make(float f);
   408   virtual bool        is_finite() const;  // Has a finite value
   409   virtual bool        is_nan()    const;  // Is not a number (NaN)
   411   virtual const Type *xmeet( const Type *t ) const;
   412   virtual const Type *xdual() const;    // Compute dual right now.
   413   // Convenience common pre-built types.
   414   static const TypeF *ZERO; // positive zero only
   415   static const TypeF *ONE;
   416 #ifndef PRODUCT
   417   virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
   418 #endif
   419 };
   421 //------------------------------TypeD------------------------------------------
   422 // Class of Double-Constant Types.
   423 class TypeD : public Type {
   424   TypeD( double d ) : Type(DoubleCon), _d(d) {};
   425 public:
   426   virtual bool eq( const Type *t ) const;
   427   virtual int  hash() const;             // Type specific hashing
   428   virtual bool singleton(void) const;    // TRUE if type is a singleton
   429   virtual bool empty(void) const;        // TRUE if type is vacuous
   430 public:
   431   const double _d;              // Double constant
   433   static const TypeD *make(double d);
   435   virtual bool        is_finite() const;  // Has a finite value
   436   virtual bool        is_nan()    const;  // Is not a number (NaN)
   438   virtual const Type *xmeet( const Type *t ) const;
   439   virtual const Type *xdual() const;    // Compute dual right now.
   440   // Convenience common pre-built types.
   441   static const TypeD *ZERO; // positive zero only
   442   static const TypeD *ONE;
   443 #ifndef PRODUCT
   444   virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
   445 #endif
   446 };
   448 //------------------------------TypeInt----------------------------------------
   449 // Class of integer ranges, the set of integers between a lower bound and an
   450 // upper bound, inclusive.
   451 class TypeInt : public Type {
   452   TypeInt( jint lo, jint hi, int w );
   453 public:
   454   virtual bool eq( const Type *t ) const;
   455   virtual int  hash() const;             // Type specific hashing
   456   virtual bool singleton(void) const;    // TRUE if type is a singleton
   457   virtual bool empty(void) const;        // TRUE if type is vacuous
   458 public:
   459   const jint _lo, _hi;          // Lower bound, upper bound
   460   const short _widen;           // Limit on times we widen this sucker
   462   static const TypeInt *make(jint lo);
   463   // must always specify w
   464   static const TypeInt *make(jint lo, jint hi, int w);
   466   // Check for single integer
   467   int is_con() const { return _lo==_hi; }
   468   bool is_con(int i) const { return is_con() && _lo == i; }
   469   jint get_con() const { assert( is_con(), "" );  return _lo; }
   471   virtual bool        is_finite() const;  // Has a finite value
   473   virtual const Type *xmeet( const Type *t ) const;
   474   virtual const Type *xdual() const;    // Compute dual right now.
   475   virtual const Type *widen( const Type *t, const Type* limit_type ) const;
   476   virtual const Type *narrow( const Type *t ) const;
   477   // Do not kill _widen bits.
   478   virtual const Type *filter( const Type *kills ) const;
   479   // Convenience common pre-built types.
   480   static const TypeInt *MINUS_1;
   481   static const TypeInt *ZERO;
   482   static const TypeInt *ONE;
   483   static const TypeInt *BOOL;
   484   static const TypeInt *CC;
   485   static const TypeInt *CC_LT;  // [-1]  == MINUS_1
   486   static const TypeInt *CC_GT;  // [1]   == ONE
   487   static const TypeInt *CC_EQ;  // [0]   == ZERO
   488   static const TypeInt *CC_LE;  // [-1,0]
   489   static const TypeInt *CC_GE;  // [0,1] == BOOL (!)
   490   static const TypeInt *BYTE;
   491   static const TypeInt *UBYTE;
   492   static const TypeInt *CHAR;
   493   static const TypeInt *SHORT;
   494   static const TypeInt *POS;
   495   static const TypeInt *POS1;
   496   static const TypeInt *INT;
   497   static const TypeInt *SYMINT; // symmetric range [-max_jint..max_jint]
   498 #ifndef PRODUCT
   499   virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
   500 #endif
   501 };
   504 //------------------------------TypeLong---------------------------------------
   505 // Class of long integer ranges, the set of integers between a lower bound and
   506 // an upper bound, inclusive.
   507 class TypeLong : public Type {
   508   TypeLong( jlong lo, jlong hi, int w );
   509 public:
   510   virtual bool eq( const Type *t ) const;
   511   virtual int  hash() const;             // Type specific hashing
   512   virtual bool singleton(void) const;    // TRUE if type is a singleton
   513   virtual bool empty(void) const;        // TRUE if type is vacuous
   514 public:
   515   const jlong _lo, _hi;         // Lower bound, upper bound
   516   const short _widen;           // Limit on times we widen this sucker
   518   static const TypeLong *make(jlong lo);
   519   // must always specify w
   520   static const TypeLong *make(jlong lo, jlong hi, int w);
   522   // Check for single integer
   523   int is_con() const { return _lo==_hi; }
   524   bool is_con(int i) const { return is_con() && _lo == i; }
   525   jlong get_con() const { assert( is_con(), "" ); return _lo; }
   527   virtual bool        is_finite() const;  // Has a finite value
   529   virtual const Type *xmeet( const Type *t ) const;
   530   virtual const Type *xdual() const;    // Compute dual right now.
   531   virtual const Type *widen( const Type *t, const Type* limit_type ) const;
   532   virtual const Type *narrow( const Type *t ) const;
   533   // Do not kill _widen bits.
   534   virtual const Type *filter( const Type *kills ) const;
   535   // Convenience common pre-built types.
   536   static const TypeLong *MINUS_1;
   537   static const TypeLong *ZERO;
   538   static const TypeLong *ONE;
   539   static const TypeLong *POS;
   540   static const TypeLong *LONG;
   541   static const TypeLong *INT;    // 32-bit subrange [min_jint..max_jint]
   542   static const TypeLong *UINT;   // 32-bit unsigned [0..max_juint]
   543 #ifndef PRODUCT
   544   virtual void dump2( Dict &d, uint, outputStream *st  ) const;// Specialized per-Type dumping
   545 #endif
   546 };
   548 //------------------------------TypeTuple--------------------------------------
   549 // Class of Tuple Types, essentially type collections for function signatures
   550 // and class layouts.  It happens to also be a fast cache for the HotSpot
   551 // signature types.
   552 class TypeTuple : public Type {
   553   TypeTuple( uint cnt, const Type **fields ) : Type(Tuple), _cnt(cnt), _fields(fields) { }
   554 public:
   555   virtual bool eq( const Type *t ) const;
   556   virtual int  hash() const;             // Type specific hashing
   557   virtual bool singleton(void) const;    // TRUE if type is a singleton
   558   virtual bool empty(void) const;        // TRUE if type is vacuous
   560 public:
   561   const uint          _cnt;              // Count of fields
   562   const Type ** const _fields;           // Array of field types
   564   // Accessors:
   565   uint cnt() const { return _cnt; }
   566   const Type* field_at(uint i) const {
   567     assert(i < _cnt, "oob");
   568     return _fields[i];
   569   }
   570   void set_field_at(uint i, const Type* t) {
   571     assert(i < _cnt, "oob");
   572     _fields[i] = t;
   573   }
   575   static const TypeTuple *make( uint cnt, const Type **fields );
   576   static const TypeTuple *make_range(ciSignature *sig);
   577   static const TypeTuple *make_domain(ciInstanceKlass* recv, ciSignature *sig);
   579   // Subroutine call type with space allocated for argument types
   580   static const Type **fields( uint arg_cnt );
   582   virtual const Type *xmeet( const Type *t ) const;
   583   virtual const Type *xdual() const;    // Compute dual right now.
   584   // Convenience common pre-built types.
   585   static const TypeTuple *IFBOTH;
   586   static const TypeTuple *IFFALSE;
   587   static const TypeTuple *IFTRUE;
   588   static const TypeTuple *IFNEITHER;
   589   static const TypeTuple *LOOPBODY;
   590   static const TypeTuple *MEMBAR;
   591   static const TypeTuple *STORECONDITIONAL;
   592   static const TypeTuple *START_I2C;
   593   static const TypeTuple *INT_PAIR;
   594   static const TypeTuple *LONG_PAIR;
   595   static const TypeTuple *INT_CC_PAIR;
   596   static const TypeTuple *LONG_CC_PAIR;
   597 #ifndef PRODUCT
   598   virtual void dump2( Dict &d, uint, outputStream *st  ) const; // Specialized per-Type dumping
   599 #endif
   600 };
   602 //------------------------------TypeAry----------------------------------------
   603 // Class of Array Types
   604 class TypeAry : public Type {
   605   TypeAry(const Type* elem, const TypeInt* size, bool stable) : Type(Array),
   606       _elem(elem), _size(size), _stable(stable) {}
   607 public:
   608   virtual bool eq( const Type *t ) const;
   609   virtual int  hash() const;             // Type specific hashing
   610   virtual bool singleton(void) const;    // TRUE if type is a singleton
   611   virtual bool empty(void) const;        // TRUE if type is vacuous
   613 private:
   614   const Type *_elem;            // Element type of array
   615   const TypeInt *_size;         // Elements in array
   616   const bool _stable;           // Are elements @Stable?
   617   friend class TypeAryPtr;
   619 public:
   620   static const TypeAry* make(const Type* elem, const TypeInt* size, bool stable = false);
   622   virtual const Type *xmeet( const Type *t ) const;
   623   virtual const Type *xdual() const;    // Compute dual right now.
   624   bool ary_must_be_exact() const;  // true if arrays of such are never generic
   625 #ifdef ASSERT
   626   // One type is interface, the other is oop
   627   virtual bool interface_vs_oop(const Type *t) const;
   628 #endif
   629 #ifndef PRODUCT
   630   virtual void dump2( Dict &d, uint, outputStream *st  ) const; // Specialized per-Type dumping
   631 #endif
   632 };
   634 //------------------------------TypeVect---------------------------------------
   635 // Class of Vector Types
   636 class TypeVect : public Type {
   637   const Type*   _elem;  // Vector's element type
   638   const uint  _length;  // Elements in vector (power of 2)
   640 protected:
   641   TypeVect(TYPES t, const Type* elem, uint length) : Type(t),
   642     _elem(elem), _length(length) {}
   644 public:
   645   const Type* element_type() const { return _elem; }
   646   BasicType element_basic_type() const { return _elem->array_element_basic_type(); }
   647   uint length() const { return _length; }
   648   uint length_in_bytes() const {
   649    return _length * type2aelembytes(element_basic_type());
   650   }
   652   virtual bool eq(const Type *t) const;
   653   virtual int  hash() const;             // Type specific hashing
   654   virtual bool singleton(void) const;    // TRUE if type is a singleton
   655   virtual bool empty(void) const;        // TRUE if type is vacuous
   657   static const TypeVect *make(const BasicType elem_bt, uint length) {
   658     // Use bottom primitive type.
   659     return make(get_const_basic_type(elem_bt), length);
   660   }
   661   // Used directly by Replicate nodes to construct singleton vector.
   662   static const TypeVect *make(const Type* elem, uint length);
   664   virtual const Type *xmeet( const Type *t) const;
   665   virtual const Type *xdual() const;     // Compute dual right now.
   667   static const TypeVect *VECTS;
   668   static const TypeVect *VECTD;
   669   static const TypeVect *VECTX;
   670   static const TypeVect *VECTY;
   672 #ifndef PRODUCT
   673   virtual void dump2(Dict &d, uint, outputStream *st) const; // Specialized per-Type dumping
   674 #endif
   675 };
   677 class TypeVectS : public TypeVect {
   678   friend class TypeVect;
   679   TypeVectS(const Type* elem, uint length) : TypeVect(VectorS, elem, length) {}
   680 };
   682 class TypeVectD : public TypeVect {
   683   friend class TypeVect;
   684   TypeVectD(const Type* elem, uint length) : TypeVect(VectorD, elem, length) {}
   685 };
   687 class TypeVectX : public TypeVect {
   688   friend class TypeVect;
   689   TypeVectX(const Type* elem, uint length) : TypeVect(VectorX, elem, length) {}
   690 };
   692 class TypeVectY : public TypeVect {
   693   friend class TypeVect;
   694   TypeVectY(const Type* elem, uint length) : TypeVect(VectorY, elem, length) {}
   695 };
   697 //------------------------------TypePtr----------------------------------------
   698 // Class of machine Pointer Types: raw data, instances or arrays.
   699 // If the _base enum is AnyPtr, then this refers to all of the above.
   700 // Otherwise the _base will indicate which subset of pointers is affected,
   701 // and the class will be inherited from.
   702 class TypePtr : public Type {
   703   friend class TypeNarrowPtr;
   704 public:
   705   enum PTR { TopPTR, AnyNull, Constant, Null, NotNull, BotPTR, lastPTR };
   706 protected:
   707   TypePtr( TYPES t, PTR ptr, int offset ) : Type(t), _ptr(ptr), _offset(offset) {}
   708   virtual bool eq( const Type *t ) const;
   709   virtual int  hash() const;             // Type specific hashing
   710   static const PTR ptr_meet[lastPTR][lastPTR];
   711   static const PTR ptr_dual[lastPTR];
   712   static const char * const ptr_msg[lastPTR];
   714 public:
   715   const int _offset;            // Offset into oop, with TOP & BOT
   716   const PTR _ptr;               // Pointer equivalence class
   718   const int offset() const { return _offset; }
   719   const PTR ptr()    const { return _ptr; }
   721   static const TypePtr *make( TYPES t, PTR ptr, int offset );
   723   // Return a 'ptr' version of this type
   724   virtual const Type *cast_to_ptr_type(PTR ptr) const;
   726   virtual intptr_t get_con() const;
   728   int xadd_offset( intptr_t offset ) const;
   729   virtual const TypePtr *add_offset( intptr_t offset ) const;
   731   virtual bool singleton(void) const;    // TRUE if type is a singleton
   732   virtual bool empty(void) const;        // TRUE if type is vacuous
   733   virtual const Type *xmeet( const Type *t ) const;
   734   int meet_offset( int offset ) const;
   735   int dual_offset( ) const;
   736   virtual const Type *xdual() const;    // Compute dual right now.
   738   // meet, dual and join over pointer equivalence sets
   739   PTR meet_ptr( const PTR in_ptr ) const { return ptr_meet[in_ptr][ptr()]; }
   740   PTR dual_ptr()                   const { return ptr_dual[ptr()];      }
   742   // This is textually confusing unless one recalls that
   743   // join(t) == dual()->meet(t->dual())->dual().
   744   PTR join_ptr( const PTR in_ptr ) const {
   745     return ptr_dual[ ptr_meet[ ptr_dual[in_ptr] ] [ dual_ptr() ] ];
   746   }
   748   // Tests for relation to centerline of type lattice:
   749   static bool above_centerline(PTR ptr) { return (ptr <= AnyNull); }
   750   static bool below_centerline(PTR ptr) { return (ptr >= NotNull); }
   751   // Convenience common pre-built types.
   752   static const TypePtr *NULL_PTR;
   753   static const TypePtr *NOTNULL;
   754   static const TypePtr *BOTTOM;
   755 #ifndef PRODUCT
   756   virtual void dump2( Dict &d, uint depth, outputStream *st  ) const;
   757 #endif
   758 };
   760 //------------------------------TypeRawPtr-------------------------------------
   761 // Class of raw pointers, pointers to things other than Oops.  Examples
   762 // include the stack pointer, top of heap, card-marking area, handles, etc.
   763 class TypeRawPtr : public TypePtr {
   764 protected:
   765   TypeRawPtr( PTR ptr, address bits ) : TypePtr(RawPtr,ptr,0), _bits(bits){}
   766 public:
   767   virtual bool eq( const Type *t ) const;
   768   virtual int  hash() const;     // Type specific hashing
   770   const address _bits;          // Constant value, if applicable
   772   static const TypeRawPtr *make( PTR ptr );
   773   static const TypeRawPtr *make( address bits );
   775   // Return a 'ptr' version of this type
   776   virtual const Type *cast_to_ptr_type(PTR ptr) const;
   778   virtual intptr_t get_con() const;
   780   virtual const TypePtr *add_offset( intptr_t offset ) const;
   782   virtual const Type *xmeet( const Type *t ) const;
   783   virtual const Type *xdual() const;    // Compute dual right now.
   784   // Convenience common pre-built types.
   785   static const TypeRawPtr *BOTTOM;
   786   static const TypeRawPtr *NOTNULL;
   787 #ifndef PRODUCT
   788   virtual void dump2( Dict &d, uint depth, outputStream *st  ) const;
   789 #endif
   790 };
   792 //------------------------------TypeOopPtr-------------------------------------
   793 // Some kind of oop (Java pointer), either klass or instance or array.
   794 class TypeOopPtr : public TypePtr {
   795 protected:
   796   TypeOopPtr(TYPES t, PTR ptr, ciKlass* k, bool xk, ciObject* o, int offset, int instance_id, const TypeOopPtr* speculative);
   797 public:
   798   virtual bool eq( const Type *t ) const;
   799   virtual int  hash() const;             // Type specific hashing
   800   virtual bool singleton(void) const;    // TRUE if type is a singleton
   801   enum {
   802    InstanceTop = -1,   // undefined instance
   803    InstanceBot = 0     // any possible instance
   804   };
   805 protected:
   807   // Oop is NULL, unless this is a constant oop.
   808   ciObject*     _const_oop;   // Constant oop
   809   // If _klass is NULL, then so is _sig.  This is an unloaded klass.
   810   ciKlass*      _klass;       // Klass object
   811   // Does the type exclude subclasses of the klass?  (Inexact == polymorphic.)
   812   bool          _klass_is_exact;
   813   bool          _is_ptr_to_narrowoop;
   814   bool          _is_ptr_to_narrowklass;
   815   bool          _is_ptr_to_boxed_value;
   817   // If not InstanceTop or InstanceBot, indicates that this is
   818   // a particular instance of this type which is distinct.
   819   // This is the the node index of the allocation node creating this instance.
   820   int           _instance_id;
   822   // Extra type information profiling gave us. We propagate it the
   823   // same way the rest of the type info is propagated. If we want to
   824   // use it, then we have to emit a guard: this part of the type is
   825   // not something we know but something we speculate about the type.
   826   const TypeOopPtr*   _speculative;
   828   static const TypeOopPtr* make_from_klass_common(ciKlass* klass, bool klass_change, bool try_for_exact);
   830   int dual_instance_id() const;
   831   int meet_instance_id(int uid) const;
   833   // utility methods to work on the speculative part of the type
   834   const TypeOopPtr* dual_speculative() const;
   835   const TypeOopPtr* meet_speculative(const TypeOopPtr* other) const;
   836   bool eq_speculative(const TypeOopPtr* other) const;
   837   int hash_speculative() const;
   838   const TypeOopPtr* add_offset_speculative(intptr_t offset) const;
   839 #ifndef PRODUCT
   840   void dump_speculative(outputStream *st) const;
   841 #endif
   843 public:
   844   // Creates a type given a klass. Correctly handles multi-dimensional arrays
   845   // Respects UseUniqueSubclasses.
   846   // If the klass is final, the resulting type will be exact.
   847   static const TypeOopPtr* make_from_klass(ciKlass* klass) {
   848     return make_from_klass_common(klass, true, false);
   849   }
   850   // Same as before, but will produce an exact type, even if
   851   // the klass is not final, as long as it has exactly one implementation.
   852   static const TypeOopPtr* make_from_klass_unique(ciKlass* klass) {
   853     return make_from_klass_common(klass, true, true);
   854   }
   855   // Same as before, but does not respects UseUniqueSubclasses.
   856   // Use this only for creating array element types.
   857   static const TypeOopPtr* make_from_klass_raw(ciKlass* klass) {
   858     return make_from_klass_common(klass, false, false);
   859   }
   860   // Creates a singleton type given an object.
   861   // If the object cannot be rendered as a constant,
   862   // may return a non-singleton type.
   863   // If require_constant, produce a NULL if a singleton is not possible.
   864   static const TypeOopPtr* make_from_constant(ciObject* o,
   865                                               bool require_constant = false,
   866                                               bool not_null_elements = false);
   868   // Make a generic (unclassed) pointer to an oop.
   869   static const TypeOopPtr* make(PTR ptr, int offset, int instance_id, const TypeOopPtr* speculative);
   871   ciObject* const_oop()    const { return _const_oop; }
   872   virtual ciKlass* klass() const { return _klass;     }
   873   bool klass_is_exact()    const { return _klass_is_exact; }
   875   // Returns true if this pointer points at memory which contains a
   876   // compressed oop references.
   877   bool is_ptr_to_narrowoop_nv() const { return _is_ptr_to_narrowoop; }
   878   bool is_ptr_to_narrowklass_nv() const { return _is_ptr_to_narrowklass; }
   879   bool is_ptr_to_boxed_value()   const { return _is_ptr_to_boxed_value; }
   880   bool is_known_instance()       const { return _instance_id > 0; }
   881   int  instance_id()             const { return _instance_id; }
   882   bool is_known_instance_field() const { return is_known_instance() && _offset >= 0; }
   883   const TypeOopPtr* speculative() const { return _speculative; }
   885   virtual intptr_t get_con() const;
   887   virtual const Type *cast_to_ptr_type(PTR ptr) const;
   889   virtual const Type *cast_to_exactness(bool klass_is_exact) const;
   891   virtual const TypeOopPtr *cast_to_instance_id(int instance_id) const;
   893   // corresponding pointer to klass, for a given instance
   894   const TypeKlassPtr* as_klass_type() const;
   896   virtual const TypePtr *add_offset( intptr_t offset ) const;
   897   // Return same type without a speculative part
   898   virtual const TypeOopPtr* remove_speculative() const;
   900   virtual const Type *xmeet(const Type *t) const;
   901   virtual const Type *xdual() const;    // Compute dual right now.
   902   // the core of the computation of the meet for TypeOopPtr and for its subclasses
   903   virtual const Type *xmeet_helper(const Type *t) const;
   905   // Do not allow interface-vs.-noninterface joins to collapse to top.
   906   virtual const Type *filter( const Type *kills ) const;
   908   // Convenience common pre-built type.
   909   static const TypeOopPtr *BOTTOM;
   910 #ifndef PRODUCT
   911   virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
   912 #endif
   914   // Return the speculative type if any
   915   ciKlass* speculative_type() const {
   916     if (_speculative != NULL) {
   917       const TypeOopPtr* speculative = _speculative->join(this)->is_oopptr();
   918       if (speculative->klass_is_exact()) {
   919        return speculative->klass();
   920       }
   921     }
   922     return NULL;
   923   }
   924 };
   926 //------------------------------TypeInstPtr------------------------------------
   927 // Class of Java object pointers, pointing either to non-array Java instances
   928 // or to a Klass* (including array klasses).
   929 class TypeInstPtr : public TypeOopPtr {
   930   TypeInstPtr(PTR ptr, ciKlass* k, bool xk, ciObject* o, int offset, int instance_id, const TypeOopPtr* speculative);
   931   virtual bool eq( const Type *t ) const;
   932   virtual int  hash() const;             // Type specific hashing
   934   ciSymbol*  _name;        // class name
   936  public:
   937   ciSymbol* name()         const { return _name; }
   939   bool  is_loaded() const { return _klass->is_loaded(); }
   941   // Make a pointer to a constant oop.
   942   static const TypeInstPtr *make(ciObject* o) {
   943     return make(TypePtr::Constant, o->klass(), true, o, 0, InstanceBot);
   944   }
   945   // Make a pointer to a constant oop with offset.
   946   static const TypeInstPtr *make(ciObject* o, int offset) {
   947     return make(TypePtr::Constant, o->klass(), true, o, offset, InstanceBot);
   948   }
   950   // Make a pointer to some value of type klass.
   951   static const TypeInstPtr *make(PTR ptr, ciKlass* klass) {
   952     return make(ptr, klass, false, NULL, 0, InstanceBot);
   953   }
   955   // Make a pointer to some non-polymorphic value of exactly type klass.
   956   static const TypeInstPtr *make_exact(PTR ptr, ciKlass* klass) {
   957     return make(ptr, klass, true, NULL, 0, InstanceBot);
   958   }
   960   // Make a pointer to some value of type klass with offset.
   961   static const TypeInstPtr *make(PTR ptr, ciKlass* klass, int offset) {
   962     return make(ptr, klass, false, NULL, offset, InstanceBot);
   963   }
   965   // Make a pointer to an oop.
   966   static const TypeInstPtr *make(PTR ptr, ciKlass* k, bool xk, ciObject* o, int offset, int instance_id = InstanceBot, const TypeOopPtr* speculative = NULL);
   968   /** Create constant type for a constant boxed value */
   969   const Type* get_const_boxed_value() const;
   971   // If this is a java.lang.Class constant, return the type for it or NULL.
   972   // Pass to Type::get_const_type to turn it to a type, which will usually
   973   // be a TypeInstPtr, but may also be a TypeInt::INT for int.class, etc.
   974   ciType* java_mirror_type() const;
   976   virtual const Type *cast_to_ptr_type(PTR ptr) const;
   978   virtual const Type *cast_to_exactness(bool klass_is_exact) const;
   980   virtual const TypeOopPtr *cast_to_instance_id(int instance_id) const;
   982   virtual const TypePtr *add_offset( intptr_t offset ) const;
   983   // Return same type without a speculative part
   984   virtual const TypeOopPtr* remove_speculative() const;
   986   // the core of the computation of the meet of 2 types
   987   virtual const Type *xmeet_helper(const Type *t) const;
   988   virtual const TypeInstPtr *xmeet_unloaded( const TypeInstPtr *t ) const;
   989   virtual const Type *xdual() const;    // Compute dual right now.
   991   // Convenience common pre-built types.
   992   static const TypeInstPtr *NOTNULL;
   993   static const TypeInstPtr *BOTTOM;
   994   static const TypeInstPtr *MIRROR;
   995   static const TypeInstPtr *MARK;
   996   static const TypeInstPtr *KLASS;
   997 #ifndef PRODUCT
   998   virtual void dump2( Dict &d, uint depth, outputStream *st ) const; // Specialized per-Type dumping
   999 #endif
  1000 };
  1002 //------------------------------TypeAryPtr-------------------------------------
  1003 // Class of Java array pointers
  1004 class TypeAryPtr : public TypeOopPtr {
  1005   TypeAryPtr( PTR ptr, ciObject* o, const TypeAry *ary, ciKlass* k, bool xk,
  1006               int offset, int instance_id, bool is_autobox_cache, const TypeOopPtr* speculative)
  1007     : TypeOopPtr(AryPtr,ptr,k,xk,o,offset, instance_id, speculative),
  1008     _ary(ary),
  1009     _is_autobox_cache(is_autobox_cache)
  1011 #ifdef ASSERT
  1012     if (k != NULL) {
  1013       // Verify that specified klass and TypeAryPtr::klass() follow the same rules.
  1014       ciKlass* ck = compute_klass(true);
  1015       if (k != ck) {
  1016         this->dump(); tty->cr();
  1017         tty->print(" k: ");
  1018         k->print(); tty->cr();
  1019         tty->print("ck: ");
  1020         if (ck != NULL) ck->print();
  1021         else tty->print("<NULL>");
  1022         tty->cr();
  1023         assert(false, "unexpected TypeAryPtr::_klass");
  1026 #endif
  1028   virtual bool eq( const Type *t ) const;
  1029   virtual int hash() const;     // Type specific hashing
  1030   const TypeAry *_ary;          // Array we point into
  1031   const bool     _is_autobox_cache;
  1033   ciKlass* compute_klass(DEBUG_ONLY(bool verify = false)) const;
  1035 public:
  1036   // Accessors
  1037   ciKlass* klass() const;
  1038   const TypeAry* ary() const  { return _ary; }
  1039   const Type*    elem() const { return _ary->_elem; }
  1040   const TypeInt* size() const { return _ary->_size; }
  1041   bool      is_stable() const { return _ary->_stable; }
  1043   bool is_autobox_cache() const { return _is_autobox_cache; }
  1045   static const TypeAryPtr *make( PTR ptr, const TypeAry *ary, ciKlass* k, bool xk, int offset, int instance_id = InstanceBot, const TypeOopPtr* speculative = NULL);
  1046   // Constant pointer to array
  1047   static const TypeAryPtr *make( PTR ptr, ciObject* o, const TypeAry *ary, ciKlass* k, bool xk, int offset, int instance_id = InstanceBot, const TypeOopPtr* speculative = NULL, bool is_autobox_cache = false);
  1049   // Return a 'ptr' version of this type
  1050   virtual const Type *cast_to_ptr_type(PTR ptr) const;
  1052   virtual const Type *cast_to_exactness(bool klass_is_exact) const;
  1054   virtual const TypeOopPtr *cast_to_instance_id(int instance_id) const;
  1056   virtual const TypeAryPtr* cast_to_size(const TypeInt* size) const;
  1057   virtual const TypeInt* narrow_size_type(const TypeInt* size) const;
  1059   virtual bool empty(void) const;        // TRUE if type is vacuous
  1060   virtual const TypePtr *add_offset( intptr_t offset ) const;
  1061   // Return same type without a speculative part
  1062   virtual const TypeOopPtr* remove_speculative() const;
  1064   // the core of the computation of the meet of 2 types
  1065   virtual const Type *xmeet_helper(const Type *t) const;
  1066   virtual const Type *xdual() const;    // Compute dual right now.
  1068   const TypeAryPtr* cast_to_stable(bool stable, int stable_dimension = 1) const;
  1069   int stable_dimension() const;
  1071   // Convenience common pre-built types.
  1072   static const TypeAryPtr *RANGE;
  1073   static const TypeAryPtr *OOPS;
  1074   static const TypeAryPtr *NARROWOOPS;
  1075   static const TypeAryPtr *BYTES;
  1076   static const TypeAryPtr *SHORTS;
  1077   static const TypeAryPtr *CHARS;
  1078   static const TypeAryPtr *INTS;
  1079   static const TypeAryPtr *LONGS;
  1080   static const TypeAryPtr *FLOATS;
  1081   static const TypeAryPtr *DOUBLES;
  1082   // selects one of the above:
  1083   static const TypeAryPtr *get_array_body_type(BasicType elem) {
  1084     assert((uint)elem <= T_CONFLICT && _array_body_type[elem] != NULL, "bad elem type");
  1085     return _array_body_type[elem];
  1087   static const TypeAryPtr *_array_body_type[T_CONFLICT+1];
  1088   // sharpen the type of an int which is used as an array size
  1089 #ifdef ASSERT
  1090   // One type is interface, the other is oop
  1091   virtual bool interface_vs_oop(const Type *t) const;
  1092 #endif
  1093 #ifndef PRODUCT
  1094   virtual void dump2( Dict &d, uint depth, outputStream *st ) const; // Specialized per-Type dumping
  1095 #endif
  1096 };
  1098 //------------------------------TypeMetadataPtr-------------------------------------
  1099 // Some kind of metadata, either Method*, MethodData* or CPCacheOop
  1100 class TypeMetadataPtr : public TypePtr {
  1101 protected:
  1102   TypeMetadataPtr(PTR ptr, ciMetadata* metadata, int offset);
  1103 public:
  1104   virtual bool eq( const Type *t ) const;
  1105   virtual int  hash() const;             // Type specific hashing
  1106   virtual bool singleton(void) const;    // TRUE if type is a singleton
  1108 private:
  1109   ciMetadata*   _metadata;
  1111 public:
  1112   static const TypeMetadataPtr* make(PTR ptr, ciMetadata* m, int offset);
  1114   static const TypeMetadataPtr* make(ciMethod* m);
  1115   static const TypeMetadataPtr* make(ciMethodData* m);
  1117   ciMetadata* metadata() const { return _metadata; }
  1119   virtual const Type *cast_to_ptr_type(PTR ptr) const;
  1121   virtual const TypePtr *add_offset( intptr_t offset ) const;
  1123   virtual const Type *xmeet( const Type *t ) const;
  1124   virtual const Type *xdual() const;    // Compute dual right now.
  1126   virtual intptr_t get_con() const;
  1128   // Do not allow interface-vs.-noninterface joins to collapse to top.
  1129   virtual const Type *filter( const Type *kills ) const;
  1131   // Convenience common pre-built types.
  1132   static const TypeMetadataPtr *BOTTOM;
  1134 #ifndef PRODUCT
  1135   virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
  1136 #endif
  1137 };
  1139 //------------------------------TypeKlassPtr-----------------------------------
  1140 // Class of Java Klass pointers
  1141 class TypeKlassPtr : public TypePtr {
  1142   TypeKlassPtr( PTR ptr, ciKlass* klass, int offset );
  1144  public:
  1145   virtual bool eq( const Type *t ) const;
  1146   virtual int hash() const;             // Type specific hashing
  1147   virtual bool singleton(void) const;    // TRUE if type is a singleton
  1148  private:
  1150   static const TypeKlassPtr* make_from_klass_common(ciKlass* klass, bool klass_change, bool try_for_exact);
  1152   ciKlass* _klass;
  1154   // Does the type exclude subclasses of the klass?  (Inexact == polymorphic.)
  1155   bool          _klass_is_exact;
  1157 public:
  1158   ciSymbol* name()  const { return klass()->name(); }
  1160   ciKlass* klass() const { return  _klass; }
  1161   bool klass_is_exact()    const { return _klass_is_exact; }
  1163   bool  is_loaded() const { return klass()->is_loaded(); }
  1165   // Creates a type given a klass. Correctly handles multi-dimensional arrays
  1166   // Respects UseUniqueSubclasses.
  1167   // If the klass is final, the resulting type will be exact.
  1168   static const TypeKlassPtr* make_from_klass(ciKlass* klass) {
  1169     return make_from_klass_common(klass, true, false);
  1171   // Same as before, but will produce an exact type, even if
  1172   // the klass is not final, as long as it has exactly one implementation.
  1173   static const TypeKlassPtr* make_from_klass_unique(ciKlass* klass) {
  1174     return make_from_klass_common(klass, true, true);
  1176   // Same as before, but does not respects UseUniqueSubclasses.
  1177   // Use this only for creating array element types.
  1178   static const TypeKlassPtr* make_from_klass_raw(ciKlass* klass) {
  1179     return make_from_klass_common(klass, false, false);
  1182   // Make a generic (unclassed) pointer to metadata.
  1183   static const TypeKlassPtr* make(PTR ptr, int offset);
  1185   // ptr to klass 'k'
  1186   static const TypeKlassPtr *make( ciKlass* k ) { return make( TypePtr::Constant, k, 0); }
  1187   // ptr to klass 'k' with offset
  1188   static const TypeKlassPtr *make( ciKlass* k, int offset ) { return make( TypePtr::Constant, k, offset); }
  1189   // ptr to klass 'k' or sub-klass
  1190   static const TypeKlassPtr *make( PTR ptr, ciKlass* k, int offset);
  1192   virtual const Type *cast_to_ptr_type(PTR ptr) const;
  1194   virtual const Type *cast_to_exactness(bool klass_is_exact) const;
  1196   // corresponding pointer to instance, for a given class
  1197   const TypeOopPtr* as_instance_type() const;
  1199   virtual const TypePtr *add_offset( intptr_t offset ) const;
  1200   virtual const Type    *xmeet( const Type *t ) const;
  1201   virtual const Type    *xdual() const;      // Compute dual right now.
  1203   virtual intptr_t get_con() const;
  1205   // Do not allow interface-vs.-noninterface joins to collapse to top.
  1206   virtual const Type *filter( const Type *kills ) const;
  1208   // Convenience common pre-built types.
  1209   static const TypeKlassPtr* OBJECT; // Not-null object klass or below
  1210   static const TypeKlassPtr* OBJECT_OR_NULL; // Maybe-null version of same
  1211 #ifndef PRODUCT
  1212   virtual void dump2( Dict &d, uint depth, outputStream *st ) const; // Specialized per-Type dumping
  1213 #endif
  1214 };
  1216 class TypeNarrowPtr : public Type {
  1217 protected:
  1218   const TypePtr* _ptrtype; // Could be TypePtr::NULL_PTR
  1220   TypeNarrowPtr(TYPES t, const TypePtr* ptrtype): _ptrtype(ptrtype),
  1221                                                   Type(t) {
  1222     assert(ptrtype->offset() == 0 ||
  1223            ptrtype->offset() == OffsetBot ||
  1224            ptrtype->offset() == OffsetTop, "no real offsets");
  1227   virtual const TypeNarrowPtr *isa_same_narrowptr(const Type *t) const = 0;
  1228   virtual const TypeNarrowPtr *is_same_narrowptr(const Type *t) const = 0;
  1229   virtual const TypeNarrowPtr *make_same_narrowptr(const TypePtr *t) const = 0;
  1230   virtual const TypeNarrowPtr *make_hash_same_narrowptr(const TypePtr *t) const = 0;
  1231 public:
  1232   virtual bool eq( const Type *t ) const;
  1233   virtual int  hash() const;             // Type specific hashing
  1234   virtual bool singleton(void) const;    // TRUE if type is a singleton
  1236   virtual const Type *xmeet( const Type *t ) const;
  1237   virtual const Type *xdual() const;    // Compute dual right now.
  1239   virtual intptr_t get_con() const;
  1241   // Do not allow interface-vs.-noninterface joins to collapse to top.
  1242   virtual const Type *filter( const Type *kills ) const;
  1244   virtual bool empty(void) const;        // TRUE if type is vacuous
  1246   // returns the equivalent ptr type for this compressed pointer
  1247   const TypePtr *get_ptrtype() const {
  1248     return _ptrtype;
  1251 #ifndef PRODUCT
  1252   virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
  1253 #endif
  1254 };
  1256 //------------------------------TypeNarrowOop----------------------------------
  1257 // A compressed reference to some kind of Oop.  This type wraps around
  1258 // a preexisting TypeOopPtr and forwards most of it's operations to
  1259 // the underlying type.  It's only real purpose is to track the
  1260 // oopness of the compressed oop value when we expose the conversion
  1261 // between the normal and the compressed form.
  1262 class TypeNarrowOop : public TypeNarrowPtr {
  1263 protected:
  1264   TypeNarrowOop( const TypePtr* ptrtype): TypeNarrowPtr(NarrowOop, ptrtype) {
  1267   virtual const TypeNarrowPtr *isa_same_narrowptr(const Type *t) const {
  1268     return t->isa_narrowoop();
  1271   virtual const TypeNarrowPtr *is_same_narrowptr(const Type *t) const {
  1272     return t->is_narrowoop();
  1275   virtual const TypeNarrowPtr *make_same_narrowptr(const TypePtr *t) const {
  1276     return new TypeNarrowOop(t);
  1279   virtual const TypeNarrowPtr *make_hash_same_narrowptr(const TypePtr *t) const {
  1280     return (const TypeNarrowPtr*)((new TypeNarrowOop(t))->hashcons());
  1283 public:
  1285   static const TypeNarrowOop *make( const TypePtr* type);
  1287   static const TypeNarrowOop* make_from_constant(ciObject* con, bool require_constant = false) {
  1288     return make(TypeOopPtr::make_from_constant(con, require_constant));
  1291   static const TypeNarrowOop *BOTTOM;
  1292   static const TypeNarrowOop *NULL_PTR;
  1294 #ifndef PRODUCT
  1295   virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
  1296 #endif
  1297 };
  1299 //------------------------------TypeNarrowKlass----------------------------------
  1300 // A compressed reference to klass pointer.  This type wraps around a
  1301 // preexisting TypeKlassPtr and forwards most of it's operations to
  1302 // the underlying type.
  1303 class TypeNarrowKlass : public TypeNarrowPtr {
  1304 protected:
  1305   TypeNarrowKlass( const TypePtr* ptrtype): TypeNarrowPtr(NarrowKlass, ptrtype) {
  1308   virtual const TypeNarrowPtr *isa_same_narrowptr(const Type *t) const {
  1309     return t->isa_narrowklass();
  1312   virtual const TypeNarrowPtr *is_same_narrowptr(const Type *t) const {
  1313     return t->is_narrowklass();
  1316   virtual const TypeNarrowPtr *make_same_narrowptr(const TypePtr *t) const {
  1317     return new TypeNarrowKlass(t);
  1320   virtual const TypeNarrowPtr *make_hash_same_narrowptr(const TypePtr *t) const {
  1321     return (const TypeNarrowPtr*)((new TypeNarrowKlass(t))->hashcons());
  1324 public:
  1325   static const TypeNarrowKlass *make( const TypePtr* type);
  1327   // static const TypeNarrowKlass *BOTTOM;
  1328   static const TypeNarrowKlass *NULL_PTR;
  1330 #ifndef PRODUCT
  1331   virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
  1332 #endif
  1333 };
  1335 //------------------------------TypeFunc---------------------------------------
  1336 // Class of Array Types
  1337 class TypeFunc : public Type {
  1338   TypeFunc( const TypeTuple *domain, const TypeTuple *range ) : Type(Function),  _domain(domain), _range(range) {}
  1339   virtual bool eq( const Type *t ) const;
  1340   virtual int  hash() const;             // Type specific hashing
  1341   virtual bool singleton(void) const;    // TRUE if type is a singleton
  1342   virtual bool empty(void) const;        // TRUE if type is vacuous
  1343 public:
  1344   // Constants are shared among ADLC and VM
  1345   enum { Control    = AdlcVMDeps::Control,
  1346          I_O        = AdlcVMDeps::I_O,
  1347          Memory     = AdlcVMDeps::Memory,
  1348          FramePtr   = AdlcVMDeps::FramePtr,
  1349          ReturnAdr  = AdlcVMDeps::ReturnAdr,
  1350          Parms      = AdlcVMDeps::Parms
  1351   };
  1353   const TypeTuple* const _domain;     // Domain of inputs
  1354   const TypeTuple* const _range;      // Range of results
  1356   // Accessors:
  1357   const TypeTuple* domain() const { return _domain; }
  1358   const TypeTuple* range()  const { return _range; }
  1360   static const TypeFunc *make(ciMethod* method);
  1361   static const TypeFunc *make(ciSignature signature, const Type* extra);
  1362   static const TypeFunc *make(const TypeTuple* domain, const TypeTuple* range);
  1364   virtual const Type *xmeet( const Type *t ) const;
  1365   virtual const Type *xdual() const;    // Compute dual right now.
  1367   BasicType return_type() const;
  1369 #ifndef PRODUCT
  1370   virtual void dump2( Dict &d, uint depth, outputStream *st ) const; // Specialized per-Type dumping
  1371 #endif
  1372   // Convenience common pre-built types.
  1373 };
  1375 //------------------------------accessors--------------------------------------
  1376 inline bool Type::is_ptr_to_narrowoop() const {
  1377 #ifdef _LP64
  1378   return (isa_oopptr() != NULL && is_oopptr()->is_ptr_to_narrowoop_nv());
  1379 #else
  1380   return false;
  1381 #endif
  1384 inline bool Type::is_ptr_to_narrowklass() const {
  1385 #ifdef _LP64
  1386   return (isa_oopptr() != NULL && is_oopptr()->is_ptr_to_narrowklass_nv());
  1387 #else
  1388   return false;
  1389 #endif
  1392 inline float Type::getf() const {
  1393   assert( _base == FloatCon, "Not a FloatCon" );
  1394   return ((TypeF*)this)->_f;
  1397 inline double Type::getd() const {
  1398   assert( _base == DoubleCon, "Not a DoubleCon" );
  1399   return ((TypeD*)this)->_d;
  1402 inline const TypeInt *Type::is_int() const {
  1403   assert( _base == Int, "Not an Int" );
  1404   return (TypeInt*)this;
  1407 inline const TypeInt *Type::isa_int() const {
  1408   return ( _base == Int ? (TypeInt*)this : NULL);
  1411 inline const TypeLong *Type::is_long() const {
  1412   assert( _base == Long, "Not a Long" );
  1413   return (TypeLong*)this;
  1416 inline const TypeLong *Type::isa_long() const {
  1417   return ( _base == Long ? (TypeLong*)this : NULL);
  1420 inline const TypeF *Type::isa_float() const {
  1421   return ((_base == FloatTop ||
  1422            _base == FloatCon ||
  1423            _base == FloatBot) ? (TypeF*)this : NULL);
  1426 inline const TypeF *Type::is_float_constant() const {
  1427   assert( _base == FloatCon, "Not a Float" );
  1428   return (TypeF*)this;
  1431 inline const TypeF *Type::isa_float_constant() const {
  1432   return ( _base == FloatCon ? (TypeF*)this : NULL);
  1435 inline const TypeD *Type::isa_double() const {
  1436   return ((_base == DoubleTop ||
  1437            _base == DoubleCon ||
  1438            _base == DoubleBot) ? (TypeD*)this : NULL);
  1441 inline const TypeD *Type::is_double_constant() const {
  1442   assert( _base == DoubleCon, "Not a Double" );
  1443   return (TypeD*)this;
  1446 inline const TypeD *Type::isa_double_constant() const {
  1447   return ( _base == DoubleCon ? (TypeD*)this : NULL);
  1450 inline const TypeTuple *Type::is_tuple() const {
  1451   assert( _base == Tuple, "Not a Tuple" );
  1452   return (TypeTuple*)this;
  1455 inline const TypeAry *Type::is_ary() const {
  1456   assert( _base == Array , "Not an Array" );
  1457   return (TypeAry*)this;
  1460 inline const TypeVect *Type::is_vect() const {
  1461   assert( _base >= VectorS && _base <= VectorY, "Not a Vector" );
  1462   return (TypeVect*)this;
  1465 inline const TypeVect *Type::isa_vect() const {
  1466   return (_base >= VectorS && _base <= VectorY) ? (TypeVect*)this : NULL;
  1469 inline const TypePtr *Type::is_ptr() const {
  1470   // AnyPtr is the first Ptr and KlassPtr the last, with no non-ptrs between.
  1471   assert(_base >= AnyPtr && _base <= KlassPtr, "Not a pointer");
  1472   return (TypePtr*)this;
  1475 inline const TypePtr *Type::isa_ptr() const {
  1476   // AnyPtr is the first Ptr and KlassPtr the last, with no non-ptrs between.
  1477   return (_base >= AnyPtr && _base <= KlassPtr) ? (TypePtr*)this : NULL;
  1480 inline const TypeOopPtr *Type::is_oopptr() const {
  1481   // OopPtr is the first and KlassPtr the last, with no non-oops between.
  1482   assert(_base >= OopPtr && _base <= AryPtr, "Not a Java pointer" ) ;
  1483   return (TypeOopPtr*)this;
  1486 inline const TypeOopPtr *Type::isa_oopptr() const {
  1487   // OopPtr is the first and KlassPtr the last, with no non-oops between.
  1488   return (_base >= OopPtr && _base <= AryPtr) ? (TypeOopPtr*)this : NULL;
  1491 inline const TypeRawPtr *Type::isa_rawptr() const {
  1492   return (_base == RawPtr) ? (TypeRawPtr*)this : NULL;
  1495 inline const TypeRawPtr *Type::is_rawptr() const {
  1496   assert( _base == RawPtr, "Not a raw pointer" );
  1497   return (TypeRawPtr*)this;
  1500 inline const TypeInstPtr *Type::isa_instptr() const {
  1501   return (_base == InstPtr) ? (TypeInstPtr*)this : NULL;
  1504 inline const TypeInstPtr *Type::is_instptr() const {
  1505   assert( _base == InstPtr, "Not an object pointer" );
  1506   return (TypeInstPtr*)this;
  1509 inline const TypeAryPtr *Type::isa_aryptr() const {
  1510   return (_base == AryPtr) ? (TypeAryPtr*)this : NULL;
  1513 inline const TypeAryPtr *Type::is_aryptr() const {
  1514   assert( _base == AryPtr, "Not an array pointer" );
  1515   return (TypeAryPtr*)this;
  1518 inline const TypeNarrowOop *Type::is_narrowoop() const {
  1519   // OopPtr is the first and KlassPtr the last, with no non-oops between.
  1520   assert(_base == NarrowOop, "Not a narrow oop" ) ;
  1521   return (TypeNarrowOop*)this;
  1524 inline const TypeNarrowOop *Type::isa_narrowoop() const {
  1525   // OopPtr is the first and KlassPtr the last, with no non-oops between.
  1526   return (_base == NarrowOop) ? (TypeNarrowOop*)this : NULL;
  1529 inline const TypeNarrowKlass *Type::is_narrowklass() const {
  1530   assert(_base == NarrowKlass, "Not a narrow oop" ) ;
  1531   return (TypeNarrowKlass*)this;
  1534 inline const TypeNarrowKlass *Type::isa_narrowklass() const {
  1535   return (_base == NarrowKlass) ? (TypeNarrowKlass*)this : NULL;
  1538 inline const TypeMetadataPtr *Type::is_metadataptr() const {
  1539   // MetadataPtr is the first and CPCachePtr the last
  1540   assert(_base == MetadataPtr, "Not a metadata pointer" ) ;
  1541   return (TypeMetadataPtr*)this;
  1544 inline const TypeMetadataPtr *Type::isa_metadataptr() const {
  1545   return (_base == MetadataPtr) ? (TypeMetadataPtr*)this : NULL;
  1548 inline const TypeKlassPtr *Type::isa_klassptr() const {
  1549   return (_base == KlassPtr) ? (TypeKlassPtr*)this : NULL;
  1552 inline const TypeKlassPtr *Type::is_klassptr() const {
  1553   assert( _base == KlassPtr, "Not a klass pointer" );
  1554   return (TypeKlassPtr*)this;
  1557 inline const TypePtr* Type::make_ptr() const {
  1558   return (_base == NarrowOop) ? is_narrowoop()->get_ptrtype() :
  1559     ((_base == NarrowKlass) ? is_narrowklass()->get_ptrtype() :
  1560      (isa_ptr() ? is_ptr() : NULL));
  1563 inline const TypeOopPtr* Type::make_oopptr() const {
  1564   return (_base == NarrowOop) ? is_narrowoop()->get_ptrtype()->is_oopptr() : is_oopptr();
  1567 inline const TypeNarrowOop* Type::make_narrowoop() const {
  1568   return (_base == NarrowOop) ? is_narrowoop() :
  1569                                 (isa_ptr() ? TypeNarrowOop::make(is_ptr()) : NULL);
  1572 inline const TypeNarrowKlass* Type::make_narrowklass() const {
  1573   return (_base == NarrowKlass) ? is_narrowklass() :
  1574                                 (isa_ptr() ? TypeNarrowKlass::make(is_ptr()) : NULL);
  1577 inline bool Type::is_floatingpoint() const {
  1578   if( (_base == FloatCon)  || (_base == FloatBot) ||
  1579       (_base == DoubleCon) || (_base == DoubleBot) )
  1580     return true;
  1581   return false;
  1584 inline bool Type::is_ptr_to_boxing_obj() const {
  1585   const TypeInstPtr* tp = isa_instptr();
  1586   return (tp != NULL) && (tp->offset() == 0) &&
  1587          tp->klass()->is_instance_klass()  &&
  1588          tp->klass()->as_instance_klass()->is_box_klass();
  1592 // ===============================================================
  1593 // Things that need to be 64-bits in the 64-bit build but
  1594 // 32-bits in the 32-bit build.  Done this way to get full
  1595 // optimization AND strong typing.
  1596 #ifdef _LP64
  1598 // For type queries and asserts
  1599 #define is_intptr_t  is_long
  1600 #define isa_intptr_t isa_long
  1601 #define find_intptr_t_type find_long_type
  1602 #define find_intptr_t_con  find_long_con
  1603 #define TypeX        TypeLong
  1604 #define Type_X       Type::Long
  1605 #define TypeX_X      TypeLong::LONG
  1606 #define TypeX_ZERO   TypeLong::ZERO
  1607 // For 'ideal_reg' machine registers
  1608 #define Op_RegX      Op_RegL
  1609 // For phase->intcon variants
  1610 #define MakeConX     longcon
  1611 #define ConXNode     ConLNode
  1612 // For array index arithmetic
  1613 #define MulXNode     MulLNode
  1614 #define AndXNode     AndLNode
  1615 #define OrXNode      OrLNode
  1616 #define CmpXNode     CmpLNode
  1617 #define SubXNode     SubLNode
  1618 #define LShiftXNode  LShiftLNode
  1619 // For object size computation:
  1620 #define AddXNode     AddLNode
  1621 #define RShiftXNode  RShiftLNode
  1622 // For card marks and hashcodes
  1623 #define URShiftXNode URShiftLNode
  1624 // UseOptoBiasInlining
  1625 #define XorXNode     XorLNode
  1626 #define StoreXConditionalNode StoreLConditionalNode
  1627 // Opcodes
  1628 #define Op_LShiftX   Op_LShiftL
  1629 #define Op_AndX      Op_AndL
  1630 #define Op_AddX      Op_AddL
  1631 #define Op_SubX      Op_SubL
  1632 #define Op_XorX      Op_XorL
  1633 #define Op_URShiftX  Op_URShiftL
  1634 // conversions
  1635 #define ConvI2X(x)   ConvI2L(x)
  1636 #define ConvL2X(x)   (x)
  1637 #define ConvX2I(x)   ConvL2I(x)
  1638 #define ConvX2L(x)   (x)
  1640 #else
  1642 // For type queries and asserts
  1643 #define is_intptr_t  is_int
  1644 #define isa_intptr_t isa_int
  1645 #define find_intptr_t_type find_int_type
  1646 #define find_intptr_t_con  find_int_con
  1647 #define TypeX        TypeInt
  1648 #define Type_X       Type::Int
  1649 #define TypeX_X      TypeInt::INT
  1650 #define TypeX_ZERO   TypeInt::ZERO
  1651 // For 'ideal_reg' machine registers
  1652 #define Op_RegX      Op_RegI
  1653 // For phase->intcon variants
  1654 #define MakeConX     intcon
  1655 #define ConXNode     ConINode
  1656 // For array index arithmetic
  1657 #define MulXNode     MulINode
  1658 #define AndXNode     AndINode
  1659 #define OrXNode      OrINode
  1660 #define CmpXNode     CmpINode
  1661 #define SubXNode     SubINode
  1662 #define LShiftXNode  LShiftINode
  1663 // For object size computation:
  1664 #define AddXNode     AddINode
  1665 #define RShiftXNode  RShiftINode
  1666 // For card marks and hashcodes
  1667 #define URShiftXNode URShiftINode
  1668 // UseOptoBiasInlining
  1669 #define XorXNode     XorINode
  1670 #define StoreXConditionalNode StoreIConditionalNode
  1671 // Opcodes
  1672 #define Op_LShiftX   Op_LShiftI
  1673 #define Op_AndX      Op_AndI
  1674 #define Op_AddX      Op_AddI
  1675 #define Op_SubX      Op_SubI
  1676 #define Op_XorX      Op_XorI
  1677 #define Op_URShiftX  Op_URShiftI
  1678 // conversions
  1679 #define ConvI2X(x)   (x)
  1680 #define ConvL2X(x)   ConvL2I(x)
  1681 #define ConvX2I(x)   (x)
  1682 #define ConvX2L(x)   ConvI2L(x)
  1684 #endif
  1686 #endif // SHARE_VM_OPTO_TYPE_HPP

mercurial