src/share/vm/opto/type.hpp

Mon, 31 Oct 2011 03:06:42 -0700

author
twisti
date
Mon, 31 Oct 2011 03:06:42 -0700
changeset 3249
e3b0dcc327b9
parent 3138
f6f3bb0ee072
child 3882
8c92982cbbc4
permissions
-rw-r--r--

7104561: UseRDPCForConstantTableBase doesn't work after shorten branches changes
Reviewed-by: never, kvn

     1 /*
     2  * Copyright (c) 1997, 2011, 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   TypeNarrowOop;
    52 class   TypeAry;
    53 class   TypeTuple;
    54 class   TypePtr;
    55 class     TypeRawPtr;
    56 class     TypeOopPtr;
    57 class       TypeInstPtr;
    58 class       TypeAryPtr;
    59 class       TypeKlassPtr;
    61 //------------------------------Type-------------------------------------------
    62 // Basic Type object, represents a set of primitive Values.
    63 // Types are hash-cons'd into a private class dictionary, so only one of each
    64 // different kind of Type exists.  Types are never modified after creation, so
    65 // all their interesting fields are constant.
    66 class Type {
    67   friend class VMStructs;
    69 public:
    70   enum TYPES {
    71     Bad=0,                      // Type check
    72     Control,                    // Control of code (not in lattice)
    73     Top,                        // Top of the lattice
    74     Int,                        // Integer range (lo-hi)
    75     Long,                       // Long integer range (lo-hi)
    76     Half,                       // Placeholder half of doubleword
    77     NarrowOop,                  // Compressed oop pointer
    79     Tuple,                      // Method signature or object layout
    80     Array,                      // Array types
    82     AnyPtr,                     // Any old raw, klass, inst, or array pointer
    83     RawPtr,                     // Raw (non-oop) pointers
    84     OopPtr,                     // Any and all Java heap entities
    85     InstPtr,                    // Instance pointers (non-array objects)
    86     AryPtr,                     // Array pointers
    87     KlassPtr,                   // Klass pointers
    88     // (Ptr order matters:  See is_ptr, isa_ptr, is_oopptr, isa_oopptr.)
    90     Function,                   // Function signature
    91     Abio,                       // Abstract I/O
    92     Return_Address,             // Subroutine return address
    93     Memory,                     // Abstract store
    94     FloatTop,                   // No float value
    95     FloatCon,                   // Floating point constant
    96     FloatBot,                   // Any float value
    97     DoubleTop,                  // No double value
    98     DoubleCon,                  // Double precision constant
    99     DoubleBot,                  // Any double value
   100     Bottom,                     // Bottom of lattice
   101     lastype                     // Bogus ending type (not in lattice)
   102   };
   104   // Signal values for offsets from a base pointer
   105   enum OFFSET_SIGNALS {
   106     OffsetTop = -2000000000,    // undefined offset
   107     OffsetBot = -2000000001     // any possible offset
   108   };
   110   // Min and max WIDEN values.
   111   enum WIDEN {
   112     WidenMin = 0,
   113     WidenMax = 3
   114   };
   116 private:
   117   // Dictionary of types shared among compilations.
   118   static Dict* _shared_type_dict;
   120   static int uhash( const Type *const t );
   121   // Structural equality check.  Assumes that cmp() has already compared
   122   // the _base types and thus knows it can cast 't' appropriately.
   123   virtual bool eq( const Type *t ) const;
   125   // Top-level hash-table of types
   126   static Dict *type_dict() {
   127     return Compile::current()->type_dict();
   128   }
   130   // DUAL operation: reflect around lattice centerline.  Used instead of
   131   // join to ensure my lattice is symmetric up and down.  Dual is computed
   132   // lazily, on demand, and cached in _dual.
   133   const Type *_dual;            // Cached dual value
   134   // Table for efficient dualing of base types
   135   static const TYPES dual_type[lastype];
   137 protected:
   138   // Each class of type is also identified by its base.
   139   const TYPES _base;            // Enum of Types type
   141   Type( TYPES t ) : _dual(NULL),  _base(t) {} // Simple types
   142   // ~Type();                   // Use fast deallocation
   143   const Type *hashcons();       // Hash-cons the type
   145 public:
   147   inline void* operator new( size_t x ) {
   148     Compile* compile = Compile::current();
   149     compile->set_type_last_size(x);
   150     void *temp = compile->type_arena()->Amalloc_D(x);
   151     compile->set_type_hwm(temp);
   152     return temp;
   153   }
   154   inline void operator delete( void* ptr ) {
   155     Compile* compile = Compile::current();
   156     compile->type_arena()->Afree(ptr,compile->type_last_size());
   157   }
   159   // Initialize the type system for a particular compilation.
   160   static void Initialize(Compile* compile);
   162   // Initialize the types shared by all compilations.
   163   static void Initialize_shared(Compile* compile);
   165   TYPES base() const {
   166     assert(_base > Bad && _base < lastype, "sanity");
   167     return _base;
   168   }
   170   // Create a new hash-consd type
   171   static const Type *make(enum TYPES);
   172   // Test for equivalence of types
   173   static int cmp( const Type *const t1, const Type *const t2 );
   174   // Test for higher or equal in lattice
   175   int higher_equal( const Type *t ) const { return !cmp(meet(t),t); }
   177   // MEET operation; lower in lattice.
   178   const Type *meet( const Type *t ) const;
   179   // WIDEN: 'widens' for Ints and other range types
   180   virtual const Type *widen( const Type *old, const Type* limit ) const { return this; }
   181   // NARROW: complement for widen, used by pessimistic phases
   182   virtual const Type *narrow( const Type *old ) const { return this; }
   184   // DUAL operation: reflect around lattice centerline.  Used instead of
   185   // join to ensure my lattice is symmetric up and down.
   186   const Type *dual() const { return _dual; }
   188   // Compute meet dependent on base type
   189   virtual const Type *xmeet( const Type *t ) const;
   190   virtual const Type *xdual() const;    // Compute dual right now.
   192   // JOIN operation; higher in lattice.  Done by finding the dual of the
   193   // meet of the dual of the 2 inputs.
   194   const Type *join( const Type *t ) const {
   195     return dual()->meet(t->dual())->dual(); }
   197   // Modified version of JOIN adapted to the needs Node::Value.
   198   // Normalizes all empty values to TOP.  Does not kill _widen bits.
   199   // Currently, it also works around limitations involving interface types.
   200   virtual const Type *filter( const Type *kills ) const;
   202 #ifdef ASSERT
   203   // One type is interface, the other is oop
   204   virtual bool interface_vs_oop(const Type *t) const;
   205 #endif
   207   // Returns true if this pointer points at memory which contains a
   208   // compressed oop references.
   209   bool is_ptr_to_narrowoop() const;
   211   // Convenience access
   212   float getf() const;
   213   double getd() const;
   215   const TypeInt    *is_int() const;
   216   const TypeInt    *isa_int() const;             // Returns NULL if not an Int
   217   const TypeLong   *is_long() const;
   218   const TypeLong   *isa_long() const;            // Returns NULL if not a Long
   219   const TypeD      *is_double_constant() const;  // Asserts it is a DoubleCon
   220   const TypeD      *isa_double_constant() const; // Returns NULL if not a DoubleCon
   221   const TypeF      *is_float_constant() const;   // Asserts it is a FloatCon
   222   const TypeF      *isa_float_constant() const;  // Returns NULL if not a FloatCon
   223   const TypeTuple  *is_tuple() const;            // Collection of fields, NOT a pointer
   224   const TypeAry    *is_ary() const;              // Array, NOT array pointer
   225   const TypePtr    *is_ptr() const;              // Asserts it is a ptr type
   226   const TypePtr    *isa_ptr() const;             // Returns NULL if not ptr type
   227   const TypeRawPtr *isa_rawptr() const;          // NOT Java oop
   228   const TypeRawPtr *is_rawptr() const;           // Asserts is rawptr
   229   const TypeNarrowOop  *is_narrowoop() const;    // Java-style GC'd pointer
   230   const TypeNarrowOop  *isa_narrowoop() const;   // Returns NULL if not oop ptr type
   231   const TypeOopPtr   *isa_oopptr() const;        // Returns NULL if not oop ptr type
   232   const TypeOopPtr   *is_oopptr() const;         // Java-style GC'd pointer
   233   const TypeKlassPtr *isa_klassptr() const;      // Returns NULL if not KlassPtr
   234   const TypeKlassPtr *is_klassptr() const;       // assert if not KlassPtr
   235   const TypeInstPtr  *isa_instptr() const;       // Returns NULL if not InstPtr
   236   const TypeInstPtr  *is_instptr() const;        // Instance
   237   const TypeAryPtr   *isa_aryptr() const;        // Returns NULL if not AryPtr
   238   const TypeAryPtr   *is_aryptr() const;         // Array oop
   239   virtual bool      is_finite() const;           // Has a finite value
   240   virtual bool      is_nan()    const;           // Is not a number (NaN)
   242   // Returns this ptr type or the equivalent ptr type for this compressed pointer.
   243   const TypePtr* make_ptr() const;
   245   // Returns this oopptr type or the equivalent oopptr type for this compressed pointer.
   246   // Asserts if the underlying type is not an oopptr or narrowoop.
   247   const TypeOopPtr* make_oopptr() const;
   249   // Returns this compressed pointer or the equivalent compressed version
   250   // of this pointer type.
   251   const TypeNarrowOop* make_narrowoop() const;
   253   // Special test for register pressure heuristic
   254   bool is_floatingpoint() const;        // True if Float or Double base type
   256   // Do you have memory, directly or through a tuple?
   257   bool has_memory( ) const;
   259   // Are you a pointer type or not?
   260   bool isa_oop_ptr() const;
   262   // TRUE if type is a singleton
   263   virtual bool singleton(void) const;
   265   // TRUE if type is above the lattice centerline, and is therefore vacuous
   266   virtual bool empty(void) const;
   268   // Return a hash for this type.  The hash function is public so ConNode
   269   // (constants) can hash on their constant, which is represented by a Type.
   270   virtual int hash() const;
   272   // Map ideal registers (machine types) to ideal types
   273   static const Type *mreg2type[];
   275   // Printing, statistics
   276   static const char * const msg[lastype]; // Printable strings
   277 #ifndef PRODUCT
   278   void         dump_on(outputStream *st) const;
   279   void         dump() const {
   280     dump_on(tty);
   281   }
   282   virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
   283   static  void dump_stats();
   284   static  void verify_lastype();          // Check that arrays match type enum
   285 #endif
   286   void typerr(const Type *t) const; // Mixing types error
   288   // Create basic type
   289   static const Type* get_const_basic_type(BasicType type) {
   290     assert((uint)type <= T_CONFLICT && _const_basic_type[type] != NULL, "bad type");
   291     return _const_basic_type[type];
   292   }
   294   // Mapping to the array element's basic type.
   295   BasicType array_element_basic_type() const;
   297   // Create standard type for a ciType:
   298   static const Type* get_const_type(ciType* type);
   300   // Create standard zero value:
   301   static const Type* get_zero_type(BasicType type) {
   302     assert((uint)type <= T_CONFLICT && _zero_type[type] != NULL, "bad type");
   303     return _zero_type[type];
   304   }
   306   // Report if this is a zero value (not top).
   307   bool is_zero_type() const {
   308     BasicType type = basic_type();
   309     if (type == T_VOID || type >= T_CONFLICT)
   310       return false;
   311     else
   312       return (this == _zero_type[type]);
   313   }
   315   // Convenience common pre-built types.
   316   static const Type *ABIO;
   317   static const Type *BOTTOM;
   318   static const Type *CONTROL;
   319   static const Type *DOUBLE;
   320   static const Type *FLOAT;
   321   static const Type *HALF;
   322   static const Type *MEMORY;
   323   static const Type *MULTI;
   324   static const Type *RETURN_ADDRESS;
   325   static const Type *TOP;
   327   // Mapping from compiler type to VM BasicType
   328   BasicType basic_type() const { return _basic_type[_base]; }
   330   // Mapping from CI type system to compiler type:
   331   static const Type* get_typeflow_type(ciType* type);
   333 private:
   334   // support arrays
   335   static const BasicType _basic_type[];
   336   static const Type*        _zero_type[T_CONFLICT+1];
   337   static const Type* _const_basic_type[T_CONFLICT+1];
   338 };
   340 //------------------------------TypeF------------------------------------------
   341 // Class of Float-Constant Types.
   342 class TypeF : public Type {
   343   TypeF( float f ) : Type(FloatCon), _f(f) {};
   344 public:
   345   virtual bool eq( const Type *t ) const;
   346   virtual int  hash() const;             // Type specific hashing
   347   virtual bool singleton(void) const;    // TRUE if type is a singleton
   348   virtual bool empty(void) const;        // TRUE if type is vacuous
   349 public:
   350   const float _f;               // Float constant
   352   static const TypeF *make(float f);
   354   virtual bool        is_finite() const;  // Has a finite value
   355   virtual bool        is_nan()    const;  // Is not a number (NaN)
   357   virtual const Type *xmeet( const Type *t ) const;
   358   virtual const Type *xdual() const;    // Compute dual right now.
   359   // Convenience common pre-built types.
   360   static const TypeF *ZERO; // positive zero only
   361   static const TypeF *ONE;
   362 #ifndef PRODUCT
   363   virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
   364 #endif
   365 };
   367 //------------------------------TypeD------------------------------------------
   368 // Class of Double-Constant Types.
   369 class TypeD : public Type {
   370   TypeD( double d ) : Type(DoubleCon), _d(d) {};
   371 public:
   372   virtual bool eq( const Type *t ) const;
   373   virtual int  hash() const;             // Type specific hashing
   374   virtual bool singleton(void) const;    // TRUE if type is a singleton
   375   virtual bool empty(void) const;        // TRUE if type is vacuous
   376 public:
   377   const double _d;              // Double constant
   379   static const TypeD *make(double d);
   381   virtual bool        is_finite() const;  // Has a finite value
   382   virtual bool        is_nan()    const;  // Is not a number (NaN)
   384   virtual const Type *xmeet( const Type *t ) const;
   385   virtual const Type *xdual() const;    // Compute dual right now.
   386   // Convenience common pre-built types.
   387   static const TypeD *ZERO; // positive zero only
   388   static const TypeD *ONE;
   389 #ifndef PRODUCT
   390   virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
   391 #endif
   392 };
   394 //------------------------------TypeInt----------------------------------------
   395 // Class of integer ranges, the set of integers between a lower bound and an
   396 // upper bound, inclusive.
   397 class TypeInt : public Type {
   398   TypeInt( jint lo, jint hi, int w );
   399 public:
   400   virtual bool eq( const Type *t ) const;
   401   virtual int  hash() const;             // Type specific hashing
   402   virtual bool singleton(void) const;    // TRUE if type is a singleton
   403   virtual bool empty(void) const;        // TRUE if type is vacuous
   404 public:
   405   const jint _lo, _hi;          // Lower bound, upper bound
   406   const short _widen;           // Limit on times we widen this sucker
   408   static const TypeInt *make(jint lo);
   409   // must always specify w
   410   static const TypeInt *make(jint lo, jint hi, int w);
   412   // Check for single integer
   413   int is_con() const { return _lo==_hi; }
   414   bool is_con(int i) const { return is_con() && _lo == i; }
   415   jint get_con() const { assert( is_con(), "" );  return _lo; }
   417   virtual bool        is_finite() const;  // Has a finite value
   419   virtual const Type *xmeet( const Type *t ) const;
   420   virtual const Type *xdual() const;    // Compute dual right now.
   421   virtual const Type *widen( const Type *t, const Type* limit_type ) const;
   422   virtual const Type *narrow( const Type *t ) const;
   423   // Do not kill _widen bits.
   424   virtual const Type *filter( const Type *kills ) const;
   425   // Convenience common pre-built types.
   426   static const TypeInt *MINUS_1;
   427   static const TypeInt *ZERO;
   428   static const TypeInt *ONE;
   429   static const TypeInt *BOOL;
   430   static const TypeInt *CC;
   431   static const TypeInt *CC_LT;  // [-1]  == MINUS_1
   432   static const TypeInt *CC_GT;  // [1]   == ONE
   433   static const TypeInt *CC_EQ;  // [0]   == ZERO
   434   static const TypeInt *CC_LE;  // [-1,0]
   435   static const TypeInt *CC_GE;  // [0,1] == BOOL (!)
   436   static const TypeInt *BYTE;
   437   static const TypeInt *UBYTE;
   438   static const TypeInt *CHAR;
   439   static const TypeInt *SHORT;
   440   static const TypeInt *POS;
   441   static const TypeInt *POS1;
   442   static const TypeInt *INT;
   443   static const TypeInt *SYMINT; // symmetric range [-max_jint..max_jint]
   444 #ifndef PRODUCT
   445   virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
   446 #endif
   447 };
   450 //------------------------------TypeLong---------------------------------------
   451 // Class of long integer ranges, the set of integers between a lower bound and
   452 // an upper bound, inclusive.
   453 class TypeLong : public Type {
   454   TypeLong( jlong lo, jlong hi, int w );
   455 public:
   456   virtual bool eq( const Type *t ) const;
   457   virtual int  hash() const;             // Type specific hashing
   458   virtual bool singleton(void) const;    // TRUE if type is a singleton
   459   virtual bool empty(void) const;        // TRUE if type is vacuous
   460 public:
   461   const jlong _lo, _hi;         // Lower bound, upper bound
   462   const short _widen;           // Limit on times we widen this sucker
   464   static const TypeLong *make(jlong lo);
   465   // must always specify w
   466   static const TypeLong *make(jlong lo, jlong hi, int w);
   468   // Check for single integer
   469   int is_con() const { return _lo==_hi; }
   470   bool is_con(int i) const { return is_con() && _lo == i; }
   471   jlong get_con() const { assert( is_con(), "" ); return _lo; }
   473   virtual bool        is_finite() const;  // Has a finite value
   475   virtual const Type *xmeet( const Type *t ) const;
   476   virtual const Type *xdual() const;    // Compute dual right now.
   477   virtual const Type *widen( const Type *t, const Type* limit_type ) const;
   478   virtual const Type *narrow( const Type *t ) const;
   479   // Do not kill _widen bits.
   480   virtual const Type *filter( const Type *kills ) const;
   481   // Convenience common pre-built types.
   482   static const TypeLong *MINUS_1;
   483   static const TypeLong *ZERO;
   484   static const TypeLong *ONE;
   485   static const TypeLong *POS;
   486   static const TypeLong *LONG;
   487   static const TypeLong *INT;    // 32-bit subrange [min_jint..max_jint]
   488   static const TypeLong *UINT;   // 32-bit unsigned [0..max_juint]
   489 #ifndef PRODUCT
   490   virtual void dump2( Dict &d, uint, outputStream *st  ) const;// Specialized per-Type dumping
   491 #endif
   492 };
   494 //------------------------------TypeTuple--------------------------------------
   495 // Class of Tuple Types, essentially type collections for function signatures
   496 // and class layouts.  It happens to also be a fast cache for the HotSpot
   497 // signature types.
   498 class TypeTuple : public Type {
   499   TypeTuple( uint cnt, const Type **fields ) : Type(Tuple), _cnt(cnt), _fields(fields) { }
   500 public:
   501   virtual bool eq( const Type *t ) const;
   502   virtual int  hash() const;             // Type specific hashing
   503   virtual bool singleton(void) const;    // TRUE if type is a singleton
   504   virtual bool empty(void) const;        // TRUE if type is vacuous
   506 public:
   507   const uint          _cnt;              // Count of fields
   508   const Type ** const _fields;           // Array of field types
   510   // Accessors:
   511   uint cnt() const { return _cnt; }
   512   const Type* field_at(uint i) const {
   513     assert(i < _cnt, "oob");
   514     return _fields[i];
   515   }
   516   void set_field_at(uint i, const Type* t) {
   517     assert(i < _cnt, "oob");
   518     _fields[i] = t;
   519   }
   521   static const TypeTuple *make( uint cnt, const Type **fields );
   522   static const TypeTuple *make_range(ciSignature *sig);
   523   static const TypeTuple *make_domain(ciInstanceKlass* recv, ciSignature *sig);
   525   // Subroutine call type with space allocated for argument types
   526   static const Type **fields( uint arg_cnt );
   528   virtual const Type *xmeet( const Type *t ) const;
   529   virtual const Type *xdual() const;    // Compute dual right now.
   530   // Convenience common pre-built types.
   531   static const TypeTuple *IFBOTH;
   532   static const TypeTuple *IFFALSE;
   533   static const TypeTuple *IFTRUE;
   534   static const TypeTuple *IFNEITHER;
   535   static const TypeTuple *LOOPBODY;
   536   static const TypeTuple *MEMBAR;
   537   static const TypeTuple *STORECONDITIONAL;
   538   static const TypeTuple *START_I2C;
   539   static const TypeTuple *INT_PAIR;
   540   static const TypeTuple *LONG_PAIR;
   541 #ifndef PRODUCT
   542   virtual void dump2( Dict &d, uint, outputStream *st  ) const; // Specialized per-Type dumping
   543 #endif
   544 };
   546 //------------------------------TypeAry----------------------------------------
   547 // Class of Array Types
   548 class TypeAry : public Type {
   549   TypeAry( const Type *elem, const TypeInt *size) : Type(Array),
   550     _elem(elem), _size(size) {}
   551 public:
   552   virtual bool eq( const Type *t ) const;
   553   virtual int  hash() const;             // Type specific hashing
   554   virtual bool singleton(void) const;    // TRUE if type is a singleton
   555   virtual bool empty(void) const;        // TRUE if type is vacuous
   557 private:
   558   const Type *_elem;            // Element type of array
   559   const TypeInt *_size;         // Elements in array
   560   friend class TypeAryPtr;
   562 public:
   563   static const TypeAry *make(  const Type *elem, const TypeInt *size);
   565   virtual const Type *xmeet( const Type *t ) const;
   566   virtual const Type *xdual() const;    // Compute dual right now.
   567   bool ary_must_be_exact() const;  // true if arrays of such are never generic
   568 #ifdef ASSERT
   569   // One type is interface, the other is oop
   570   virtual bool interface_vs_oop(const Type *t) const;
   571 #endif
   572 #ifndef PRODUCT
   573   virtual void dump2( Dict &d, uint, outputStream *st  ) const; // Specialized per-Type dumping
   574 #endif
   575 };
   577 //------------------------------TypePtr----------------------------------------
   578 // Class of machine Pointer Types: raw data, instances or arrays.
   579 // If the _base enum is AnyPtr, then this refers to all of the above.
   580 // Otherwise the _base will indicate which subset of pointers is affected,
   581 // and the class will be inherited from.
   582 class TypePtr : public Type {
   583   friend class TypeNarrowOop;
   584 public:
   585   enum PTR { TopPTR, AnyNull, Constant, Null, NotNull, BotPTR, lastPTR };
   586 protected:
   587   TypePtr( TYPES t, PTR ptr, int offset ) : Type(t), _ptr(ptr), _offset(offset) {}
   588   virtual bool eq( const Type *t ) const;
   589   virtual int  hash() const;             // Type specific hashing
   590   static const PTR ptr_meet[lastPTR][lastPTR];
   591   static const PTR ptr_dual[lastPTR];
   592   static const char * const ptr_msg[lastPTR];
   594 public:
   595   const int _offset;            // Offset into oop, with TOP & BOT
   596   const PTR _ptr;               // Pointer equivalence class
   598   const int offset() const { return _offset; }
   599   const PTR ptr()    const { return _ptr; }
   601   static const TypePtr *make( TYPES t, PTR ptr, int offset );
   603   // Return a 'ptr' version of this type
   604   virtual const Type *cast_to_ptr_type(PTR ptr) const;
   606   virtual intptr_t get_con() const;
   608   int xadd_offset( intptr_t offset ) const;
   609   virtual const TypePtr *add_offset( intptr_t offset ) const;
   611   virtual bool singleton(void) const;    // TRUE if type is a singleton
   612   virtual bool empty(void) const;        // TRUE if type is vacuous
   613   virtual const Type *xmeet( const Type *t ) const;
   614   int meet_offset( int offset ) const;
   615   int dual_offset( ) const;
   616   virtual const Type *xdual() const;    // Compute dual right now.
   618   // meet, dual and join over pointer equivalence sets
   619   PTR meet_ptr( const PTR in_ptr ) const { return ptr_meet[in_ptr][ptr()]; }
   620   PTR dual_ptr()                   const { return ptr_dual[ptr()];      }
   622   // This is textually confusing unless one recalls that
   623   // join(t) == dual()->meet(t->dual())->dual().
   624   PTR join_ptr( const PTR in_ptr ) const {
   625     return ptr_dual[ ptr_meet[ ptr_dual[in_ptr] ] [ dual_ptr() ] ];
   626   }
   628   // Tests for relation to centerline of type lattice:
   629   static bool above_centerline(PTR ptr) { return (ptr <= AnyNull); }
   630   static bool below_centerline(PTR ptr) { return (ptr >= NotNull); }
   631   // Convenience common pre-built types.
   632   static const TypePtr *NULL_PTR;
   633   static const TypePtr *NOTNULL;
   634   static const TypePtr *BOTTOM;
   635 #ifndef PRODUCT
   636   virtual void dump2( Dict &d, uint depth, outputStream *st  ) const;
   637 #endif
   638 };
   640 //------------------------------TypeRawPtr-------------------------------------
   641 // Class of raw pointers, pointers to things other than Oops.  Examples
   642 // include the stack pointer, top of heap, card-marking area, handles, etc.
   643 class TypeRawPtr : public TypePtr {
   644 protected:
   645   TypeRawPtr( PTR ptr, address bits ) : TypePtr(RawPtr,ptr,0), _bits(bits){}
   646 public:
   647   virtual bool eq( const Type *t ) const;
   648   virtual int  hash() const;     // Type specific hashing
   650   const address _bits;          // Constant value, if applicable
   652   static const TypeRawPtr *make( PTR ptr );
   653   static const TypeRawPtr *make( address bits );
   655   // Return a 'ptr' version of this type
   656   virtual const Type *cast_to_ptr_type(PTR ptr) const;
   658   virtual intptr_t get_con() const;
   660   virtual const TypePtr *add_offset( intptr_t offset ) const;
   662   virtual const Type *xmeet( const Type *t ) const;
   663   virtual const Type *xdual() const;    // Compute dual right now.
   664   // Convenience common pre-built types.
   665   static const TypeRawPtr *BOTTOM;
   666   static const TypeRawPtr *NOTNULL;
   667 #ifndef PRODUCT
   668   virtual void dump2( Dict &d, uint depth, outputStream *st  ) const;
   669 #endif
   670 };
   672 //------------------------------TypeOopPtr-------------------------------------
   673 // Some kind of oop (Java pointer), either klass or instance or array.
   674 class TypeOopPtr : public TypePtr {
   675 protected:
   676   TypeOopPtr( TYPES t, PTR ptr, ciKlass* k, bool xk, ciObject* o, int offset, int instance_id );
   677 public:
   678   virtual bool eq( const Type *t ) const;
   679   virtual int  hash() const;             // Type specific hashing
   680   virtual bool singleton(void) const;    // TRUE if type is a singleton
   681   enum {
   682    InstanceTop = -1,   // undefined instance
   683    InstanceBot = 0     // any possible instance
   684   };
   685 protected:
   687   // Oop is NULL, unless this is a constant oop.
   688   ciObject*     _const_oop;   // Constant oop
   689   // If _klass is NULL, then so is _sig.  This is an unloaded klass.
   690   ciKlass*      _klass;       // Klass object
   691   // Does the type exclude subclasses of the klass?  (Inexact == polymorphic.)
   692   bool          _klass_is_exact;
   693   bool          _is_ptr_to_narrowoop;
   695   // If not InstanceTop or InstanceBot, indicates that this is
   696   // a particular instance of this type which is distinct.
   697   // This is the the node index of the allocation node creating this instance.
   698   int           _instance_id;
   700   static const TypeOopPtr* make_from_klass_common(ciKlass* klass, bool klass_change, bool try_for_exact);
   702   int dual_instance_id() const;
   703   int meet_instance_id(int uid) const;
   705 public:
   706   // Creates a type given a klass. Correctly handles multi-dimensional arrays
   707   // Respects UseUniqueSubclasses.
   708   // If the klass is final, the resulting type will be exact.
   709   static const TypeOopPtr* make_from_klass(ciKlass* klass) {
   710     return make_from_klass_common(klass, true, false);
   711   }
   712   // Same as before, but will produce an exact type, even if
   713   // the klass is not final, as long as it has exactly one implementation.
   714   static const TypeOopPtr* make_from_klass_unique(ciKlass* klass) {
   715     return make_from_klass_common(klass, true, true);
   716   }
   717   // Same as before, but does not respects UseUniqueSubclasses.
   718   // Use this only for creating array element types.
   719   static const TypeOopPtr* make_from_klass_raw(ciKlass* klass) {
   720     return make_from_klass_common(klass, false, false);
   721   }
   722   // Creates a singleton type given an object.
   723   // If the object cannot be rendered as a constant,
   724   // may return a non-singleton type.
   725   // If require_constant, produce a NULL if a singleton is not possible.
   726   static const TypeOopPtr* make_from_constant(ciObject* o, bool require_constant = false);
   728   // Make a generic (unclassed) pointer to an oop.
   729   static const TypeOopPtr* make(PTR ptr, int offset, int instance_id);
   731   ciObject* const_oop()    const { return _const_oop; }
   732   virtual ciKlass* klass() const { return _klass;     }
   733   bool klass_is_exact()    const { return _klass_is_exact; }
   735   // Returns true if this pointer points at memory which contains a
   736   // compressed oop references.
   737   bool is_ptr_to_narrowoop_nv() const { return _is_ptr_to_narrowoop; }
   739   bool is_known_instance()       const { return _instance_id > 0; }
   740   int  instance_id()             const { return _instance_id; }
   741   bool is_known_instance_field() const { return is_known_instance() && _offset >= 0; }
   743   virtual intptr_t get_con() const;
   745   virtual const Type *cast_to_ptr_type(PTR ptr) const;
   747   virtual const Type *cast_to_exactness(bool klass_is_exact) const;
   749   virtual const TypeOopPtr *cast_to_instance_id(int instance_id) const;
   751   // corresponding pointer to klass, for a given instance
   752   const TypeKlassPtr* as_klass_type() const;
   754   virtual const TypePtr *add_offset( intptr_t offset ) const;
   756   virtual const Type *xmeet( const Type *t ) const;
   757   virtual const Type *xdual() const;    // Compute dual right now.
   759   // Do not allow interface-vs.-noninterface joins to collapse to top.
   760   virtual const Type *filter( const Type *kills ) const;
   762   // Convenience common pre-built type.
   763   static const TypeOopPtr *BOTTOM;
   764 #ifndef PRODUCT
   765   virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
   766 #endif
   767 };
   769 //------------------------------TypeInstPtr------------------------------------
   770 // Class of Java object pointers, pointing either to non-array Java instances
   771 // or to a klassOop (including array klasses).
   772 class TypeInstPtr : public TypeOopPtr {
   773   TypeInstPtr( PTR ptr, ciKlass* k, bool xk, ciObject* o, int offset, int instance_id );
   774   virtual bool eq( const Type *t ) const;
   775   virtual int  hash() const;             // Type specific hashing
   777   ciSymbol*  _name;        // class name
   779  public:
   780   ciSymbol* name()         const { return _name; }
   782   bool  is_loaded() const { return _klass->is_loaded(); }
   784   // Make a pointer to a constant oop.
   785   static const TypeInstPtr *make(ciObject* o) {
   786     return make(TypePtr::Constant, o->klass(), true, o, 0);
   787   }
   789   // Make a pointer to a constant oop with offset.
   790   static const TypeInstPtr *make(ciObject* o, int offset) {
   791     return make(TypePtr::Constant, o->klass(), true, o, offset);
   792   }
   794   // Make a pointer to some value of type klass.
   795   static const TypeInstPtr *make(PTR ptr, ciKlass* klass) {
   796     return make(ptr, klass, false, NULL, 0);
   797   }
   799   // Make a pointer to some non-polymorphic value of exactly type klass.
   800   static const TypeInstPtr *make_exact(PTR ptr, ciKlass* klass) {
   801     return make(ptr, klass, true, NULL, 0);
   802   }
   804   // Make a pointer to some value of type klass with offset.
   805   static const TypeInstPtr *make(PTR ptr, ciKlass* klass, int offset) {
   806     return make(ptr, klass, false, NULL, offset);
   807   }
   809   // Make a pointer to an oop.
   810   static const TypeInstPtr *make(PTR ptr, ciKlass* k, bool xk, ciObject* o, int offset, int instance_id = InstanceBot );
   812   // If this is a java.lang.Class constant, return the type for it or NULL.
   813   // Pass to Type::get_const_type to turn it to a type, which will usually
   814   // be a TypeInstPtr, but may also be a TypeInt::INT for int.class, etc.
   815   ciType* java_mirror_type() const;
   817   virtual const Type *cast_to_ptr_type(PTR ptr) const;
   819   virtual const Type *cast_to_exactness(bool klass_is_exact) const;
   821   virtual const TypeOopPtr *cast_to_instance_id(int instance_id) const;
   823   virtual const TypePtr *add_offset( intptr_t offset ) const;
   825   virtual const Type *xmeet( const Type *t ) const;
   826   virtual const TypeInstPtr *xmeet_unloaded( const TypeInstPtr *t ) const;
   827   virtual const Type *xdual() const;    // Compute dual right now.
   829   // Convenience common pre-built types.
   830   static const TypeInstPtr *NOTNULL;
   831   static const TypeInstPtr *BOTTOM;
   832   static const TypeInstPtr *MIRROR;
   833   static const TypeInstPtr *MARK;
   834   static const TypeInstPtr *KLASS;
   835 #ifndef PRODUCT
   836   virtual void dump2( Dict &d, uint depth, outputStream *st ) const; // Specialized per-Type dumping
   837 #endif
   838 };
   840 //------------------------------TypeAryPtr-------------------------------------
   841 // Class of Java array pointers
   842 class TypeAryPtr : public TypeOopPtr {
   843   TypeAryPtr( PTR ptr, ciObject* o, const TypeAry *ary, ciKlass* k, bool xk, int offset, int instance_id ) : TypeOopPtr(AryPtr,ptr,k,xk,o,offset, instance_id), _ary(ary) {
   844 #ifdef ASSERT
   845     if (k != NULL) {
   846       // Verify that specified klass and TypeAryPtr::klass() follow the same rules.
   847       ciKlass* ck = compute_klass(true);
   848       if (k != ck) {
   849         this->dump(); tty->cr();
   850         tty->print(" k: ");
   851         k->print(); tty->cr();
   852         tty->print("ck: ");
   853         if (ck != NULL) ck->print();
   854         else tty->print("<NULL>");
   855         tty->cr();
   856         assert(false, "unexpected TypeAryPtr::_klass");
   857       }
   858     }
   859 #endif
   860   }
   861   virtual bool eq( const Type *t ) const;
   862   virtual int hash() const;     // Type specific hashing
   863   const TypeAry *_ary;          // Array we point into
   865   ciKlass* compute_klass(DEBUG_ONLY(bool verify = false)) const;
   867 public:
   868   // Accessors
   869   ciKlass* klass() const;
   870   const TypeAry* ary() const  { return _ary; }
   871   const Type*    elem() const { return _ary->_elem; }
   872   const TypeInt* size() const { return _ary->_size; }
   874   static const TypeAryPtr *make( PTR ptr, const TypeAry *ary, ciKlass* k, bool xk, int offset, int instance_id = InstanceBot);
   875   // Constant pointer to array
   876   static const TypeAryPtr *make( PTR ptr, ciObject* o, const TypeAry *ary, ciKlass* k, bool xk, int offset, int instance_id = InstanceBot);
   878   // Return a 'ptr' version of this type
   879   virtual const Type *cast_to_ptr_type(PTR ptr) const;
   881   virtual const Type *cast_to_exactness(bool klass_is_exact) const;
   883   virtual const TypeOopPtr *cast_to_instance_id(int instance_id) const;
   885   virtual const TypeAryPtr* cast_to_size(const TypeInt* size) const;
   886   virtual const TypeInt* narrow_size_type(const TypeInt* size) const;
   888   virtual bool empty(void) const;        // TRUE if type is vacuous
   889   virtual const TypePtr *add_offset( intptr_t offset ) const;
   891   virtual const Type *xmeet( const Type *t ) const;
   892   virtual const Type *xdual() const;    // Compute dual right now.
   894   // Convenience common pre-built types.
   895   static const TypeAryPtr *RANGE;
   896   static const TypeAryPtr *OOPS;
   897   static const TypeAryPtr *NARROWOOPS;
   898   static const TypeAryPtr *BYTES;
   899   static const TypeAryPtr *SHORTS;
   900   static const TypeAryPtr *CHARS;
   901   static const TypeAryPtr *INTS;
   902   static const TypeAryPtr *LONGS;
   903   static const TypeAryPtr *FLOATS;
   904   static const TypeAryPtr *DOUBLES;
   905   // selects one of the above:
   906   static const TypeAryPtr *get_array_body_type(BasicType elem) {
   907     assert((uint)elem <= T_CONFLICT && _array_body_type[elem] != NULL, "bad elem type");
   908     return _array_body_type[elem];
   909   }
   910   static const TypeAryPtr *_array_body_type[T_CONFLICT+1];
   911   // sharpen the type of an int which is used as an array size
   912 #ifdef ASSERT
   913   // One type is interface, the other is oop
   914   virtual bool interface_vs_oop(const Type *t) const;
   915 #endif
   916 #ifndef PRODUCT
   917   virtual void dump2( Dict &d, uint depth, outputStream *st ) const; // Specialized per-Type dumping
   918 #endif
   919 };
   921 //------------------------------TypeKlassPtr-----------------------------------
   922 // Class of Java Klass pointers
   923 class TypeKlassPtr : public TypeOopPtr {
   924   TypeKlassPtr( PTR ptr, ciKlass* klass, int offset );
   926   virtual bool eq( const Type *t ) const;
   927   virtual int hash() const;             // Type specific hashing
   929 public:
   930   ciSymbol* name()  const { return _klass->name(); }
   932   bool  is_loaded() const { return _klass->is_loaded(); }
   934   // ptr to klass 'k'
   935   static const TypeKlassPtr *make( ciKlass* k ) { return make( TypePtr::Constant, k, 0); }
   936   // ptr to klass 'k' with offset
   937   static const TypeKlassPtr *make( ciKlass* k, int offset ) { return make( TypePtr::Constant, k, offset); }
   938   // ptr to klass 'k' or sub-klass
   939   static const TypeKlassPtr *make( PTR ptr, ciKlass* k, int offset);
   941   virtual const Type *cast_to_ptr_type(PTR ptr) const;
   943   virtual const Type *cast_to_exactness(bool klass_is_exact) const;
   945   // corresponding pointer to instance, for a given class
   946   const TypeOopPtr* as_instance_type() const;
   948   virtual const TypePtr *add_offset( intptr_t offset ) const;
   949   virtual const Type    *xmeet( const Type *t ) const;
   950   virtual const Type    *xdual() const;      // Compute dual right now.
   952   // Convenience common pre-built types.
   953   static const TypeKlassPtr* OBJECT; // Not-null object klass or below
   954   static const TypeKlassPtr* OBJECT_OR_NULL; // Maybe-null version of same
   955 #ifndef PRODUCT
   956   virtual void dump2( Dict &d, uint depth, outputStream *st ) const; // Specialized per-Type dumping
   957 #endif
   958 };
   960 //------------------------------TypeNarrowOop----------------------------------
   961 // A compressed reference to some kind of Oop.  This type wraps around
   962 // a preexisting TypeOopPtr and forwards most of it's operations to
   963 // the underlying type.  It's only real purpose is to track the
   964 // oopness of the compressed oop value when we expose the conversion
   965 // between the normal and the compressed form.
   966 class TypeNarrowOop : public Type {
   967 protected:
   968   const TypePtr* _ptrtype; // Could be TypePtr::NULL_PTR
   970   TypeNarrowOop( const TypePtr* ptrtype): Type(NarrowOop),
   971     _ptrtype(ptrtype) {
   972     assert(ptrtype->offset() == 0 ||
   973            ptrtype->offset() == OffsetBot ||
   974            ptrtype->offset() == OffsetTop, "no real offsets");
   975   }
   976 public:
   977   virtual bool eq( const Type *t ) const;
   978   virtual int  hash() const;             // Type specific hashing
   979   virtual bool singleton(void) const;    // TRUE if type is a singleton
   981   virtual const Type *xmeet( const Type *t ) const;
   982   virtual const Type *xdual() const;    // Compute dual right now.
   984   virtual intptr_t get_con() const;
   986   // Do not allow interface-vs.-noninterface joins to collapse to top.
   987   virtual const Type *filter( const Type *kills ) const;
   989   virtual bool empty(void) const;        // TRUE if type is vacuous
   991   static const TypeNarrowOop *make( const TypePtr* type);
   993   static const TypeNarrowOop* make_from_constant(ciObject* con, bool require_constant = false) {
   994     return make(TypeOopPtr::make_from_constant(con, require_constant));
   995   }
   997   // returns the equivalent ptr type for this compressed pointer
   998   const TypePtr *get_ptrtype() const {
   999     return _ptrtype;
  1002   static const TypeNarrowOop *BOTTOM;
  1003   static const TypeNarrowOop *NULL_PTR;
  1005 #ifndef PRODUCT
  1006   virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
  1007 #endif
  1008 };
  1010 //------------------------------TypeFunc---------------------------------------
  1011 // Class of Array Types
  1012 class TypeFunc : public Type {
  1013   TypeFunc( const TypeTuple *domain, const TypeTuple *range ) : Type(Function),  _domain(domain), _range(range) {}
  1014   virtual bool eq( const Type *t ) const;
  1015   virtual int  hash() const;             // Type specific hashing
  1016   virtual bool singleton(void) const;    // TRUE if type is a singleton
  1017   virtual bool empty(void) const;        // TRUE if type is vacuous
  1018 public:
  1019   // Constants are shared among ADLC and VM
  1020   enum { Control    = AdlcVMDeps::Control,
  1021          I_O        = AdlcVMDeps::I_O,
  1022          Memory     = AdlcVMDeps::Memory,
  1023          FramePtr   = AdlcVMDeps::FramePtr,
  1024          ReturnAdr  = AdlcVMDeps::ReturnAdr,
  1025          Parms      = AdlcVMDeps::Parms
  1026   };
  1028   const TypeTuple* const _domain;     // Domain of inputs
  1029   const TypeTuple* const _range;      // Range of results
  1031   // Accessors:
  1032   const TypeTuple* domain() const { return _domain; }
  1033   const TypeTuple* range()  const { return _range; }
  1035   static const TypeFunc *make(ciMethod* method);
  1036   static const TypeFunc *make(ciSignature signature, const Type* extra);
  1037   static const TypeFunc *make(const TypeTuple* domain, const TypeTuple* range);
  1039   virtual const Type *xmeet( const Type *t ) const;
  1040   virtual const Type *xdual() const;    // Compute dual right now.
  1042   BasicType return_type() const;
  1044 #ifndef PRODUCT
  1045   virtual void dump2( Dict &d, uint depth, outputStream *st ) const; // Specialized per-Type dumping
  1046   void print_flattened() const; // Print a 'flattened' signature
  1047 #endif
  1048   // Convenience common pre-built types.
  1049 };
  1051 //------------------------------accessors--------------------------------------
  1052 inline bool Type::is_ptr_to_narrowoop() const {
  1053 #ifdef _LP64
  1054   return (isa_oopptr() != NULL && is_oopptr()->is_ptr_to_narrowoop_nv());
  1055 #else
  1056   return false;
  1057 #endif
  1060 inline float Type::getf() const {
  1061   assert( _base == FloatCon, "Not a FloatCon" );
  1062   return ((TypeF*)this)->_f;
  1065 inline double Type::getd() const {
  1066   assert( _base == DoubleCon, "Not a DoubleCon" );
  1067   return ((TypeD*)this)->_d;
  1070 inline const TypeF *Type::is_float_constant() const {
  1071   assert( _base == FloatCon, "Not a Float" );
  1072   return (TypeF*)this;
  1075 inline const TypeF *Type::isa_float_constant() const {
  1076   return ( _base == FloatCon ? (TypeF*)this : NULL);
  1079 inline const TypeD *Type::is_double_constant() const {
  1080   assert( _base == DoubleCon, "Not a Double" );
  1081   return (TypeD*)this;
  1084 inline const TypeD *Type::isa_double_constant() const {
  1085   return ( _base == DoubleCon ? (TypeD*)this : NULL);
  1088 inline const TypeInt *Type::is_int() const {
  1089   assert( _base == Int, "Not an Int" );
  1090   return (TypeInt*)this;
  1093 inline const TypeInt *Type::isa_int() const {
  1094   return ( _base == Int ? (TypeInt*)this : NULL);
  1097 inline const TypeLong *Type::is_long() const {
  1098   assert( _base == Long, "Not a Long" );
  1099   return (TypeLong*)this;
  1102 inline const TypeLong *Type::isa_long() const {
  1103   return ( _base == Long ? (TypeLong*)this : NULL);
  1106 inline const TypeTuple *Type::is_tuple() const {
  1107   assert( _base == Tuple, "Not a Tuple" );
  1108   return (TypeTuple*)this;
  1111 inline const TypeAry *Type::is_ary() const {
  1112   assert( _base == Array , "Not an Array" );
  1113   return (TypeAry*)this;
  1116 inline const TypePtr *Type::is_ptr() const {
  1117   // AnyPtr is the first Ptr and KlassPtr the last, with no non-ptrs between.
  1118   assert(_base >= AnyPtr && _base <= KlassPtr, "Not a pointer");
  1119   return (TypePtr*)this;
  1122 inline const TypePtr *Type::isa_ptr() const {
  1123   // AnyPtr is the first Ptr and KlassPtr the last, with no non-ptrs between.
  1124   return (_base >= AnyPtr && _base <= KlassPtr) ? (TypePtr*)this : NULL;
  1127 inline const TypeOopPtr *Type::is_oopptr() const {
  1128   // OopPtr is the first and KlassPtr the last, with no non-oops between.
  1129   assert(_base >= OopPtr && _base <= KlassPtr, "Not a Java pointer" ) ;
  1130   return (TypeOopPtr*)this;
  1133 inline const TypeOopPtr *Type::isa_oopptr() const {
  1134   // OopPtr is the first and KlassPtr the last, with no non-oops between.
  1135   return (_base >= OopPtr && _base <= KlassPtr) ? (TypeOopPtr*)this : NULL;
  1138 inline const TypeRawPtr *Type::isa_rawptr() const {
  1139   return (_base == RawPtr) ? (TypeRawPtr*)this : NULL;
  1142 inline const TypeRawPtr *Type::is_rawptr() const {
  1143   assert( _base == RawPtr, "Not a raw pointer" );
  1144   return (TypeRawPtr*)this;
  1147 inline const TypeInstPtr *Type::isa_instptr() const {
  1148   return (_base == InstPtr) ? (TypeInstPtr*)this : NULL;
  1151 inline const TypeInstPtr *Type::is_instptr() const {
  1152   assert( _base == InstPtr, "Not an object pointer" );
  1153   return (TypeInstPtr*)this;
  1156 inline const TypeAryPtr *Type::isa_aryptr() const {
  1157   return (_base == AryPtr) ? (TypeAryPtr*)this : NULL;
  1160 inline const TypeAryPtr *Type::is_aryptr() const {
  1161   assert( _base == AryPtr, "Not an array pointer" );
  1162   return (TypeAryPtr*)this;
  1165 inline const TypeNarrowOop *Type::is_narrowoop() const {
  1166   // OopPtr is the first and KlassPtr the last, with no non-oops between.
  1167   assert(_base == NarrowOop, "Not a narrow oop" ) ;
  1168   return (TypeNarrowOop*)this;
  1171 inline const TypeNarrowOop *Type::isa_narrowoop() const {
  1172   // OopPtr is the first and KlassPtr the last, with no non-oops between.
  1173   return (_base == NarrowOop) ? (TypeNarrowOop*)this : NULL;
  1176 inline const TypeKlassPtr *Type::isa_klassptr() const {
  1177   return (_base == KlassPtr) ? (TypeKlassPtr*)this : NULL;
  1180 inline const TypeKlassPtr *Type::is_klassptr() const {
  1181   assert( _base == KlassPtr, "Not a klass pointer" );
  1182   return (TypeKlassPtr*)this;
  1185 inline const TypePtr* Type::make_ptr() const {
  1186   return (_base == NarrowOop) ? is_narrowoop()->get_ptrtype() :
  1187                                 (isa_ptr() ? is_ptr() : NULL);
  1190 inline const TypeOopPtr* Type::make_oopptr() const {
  1191   return (_base == NarrowOop) ? is_narrowoop()->get_ptrtype()->is_oopptr() : is_oopptr();
  1194 inline const TypeNarrowOop* Type::make_narrowoop() const {
  1195   return (_base == NarrowOop) ? is_narrowoop() :
  1196                                 (isa_ptr() ? TypeNarrowOop::make(is_ptr()) : NULL);
  1199 inline bool Type::is_floatingpoint() const {
  1200   if( (_base == FloatCon)  || (_base == FloatBot) ||
  1201       (_base == DoubleCon) || (_base == DoubleBot) )
  1202     return true;
  1203   return false;
  1207 // ===============================================================
  1208 // Things that need to be 64-bits in the 64-bit build but
  1209 // 32-bits in the 32-bit build.  Done this way to get full
  1210 // optimization AND strong typing.
  1211 #ifdef _LP64
  1213 // For type queries and asserts
  1214 #define is_intptr_t  is_long
  1215 #define isa_intptr_t isa_long
  1216 #define find_intptr_t_type find_long_type
  1217 #define find_intptr_t_con  find_long_con
  1218 #define TypeX        TypeLong
  1219 #define Type_X       Type::Long
  1220 #define TypeX_X      TypeLong::LONG
  1221 #define TypeX_ZERO   TypeLong::ZERO
  1222 // For 'ideal_reg' machine registers
  1223 #define Op_RegX      Op_RegL
  1224 // For phase->intcon variants
  1225 #define MakeConX     longcon
  1226 #define ConXNode     ConLNode
  1227 // For array index arithmetic
  1228 #define MulXNode     MulLNode
  1229 #define AndXNode     AndLNode
  1230 #define OrXNode      OrLNode
  1231 #define CmpXNode     CmpLNode
  1232 #define SubXNode     SubLNode
  1233 #define LShiftXNode  LShiftLNode
  1234 // For object size computation:
  1235 #define AddXNode     AddLNode
  1236 #define RShiftXNode  RShiftLNode
  1237 // For card marks and hashcodes
  1238 #define URShiftXNode URShiftLNode
  1239 // UseOptoBiasInlining
  1240 #define XorXNode     XorLNode
  1241 #define StoreXConditionalNode StoreLConditionalNode
  1242 // Opcodes
  1243 #define Op_LShiftX   Op_LShiftL
  1244 #define Op_AndX      Op_AndL
  1245 #define Op_AddX      Op_AddL
  1246 #define Op_SubX      Op_SubL
  1247 #define Op_XorX      Op_XorL
  1248 #define Op_URShiftX  Op_URShiftL
  1249 // conversions
  1250 #define ConvI2X(x)   ConvI2L(x)
  1251 #define ConvL2X(x)   (x)
  1252 #define ConvX2I(x)   ConvL2I(x)
  1253 #define ConvX2L(x)   (x)
  1255 #else
  1257 // For type queries and asserts
  1258 #define is_intptr_t  is_int
  1259 #define isa_intptr_t isa_int
  1260 #define find_intptr_t_type find_int_type
  1261 #define find_intptr_t_con  find_int_con
  1262 #define TypeX        TypeInt
  1263 #define Type_X       Type::Int
  1264 #define TypeX_X      TypeInt::INT
  1265 #define TypeX_ZERO   TypeInt::ZERO
  1266 // For 'ideal_reg' machine registers
  1267 #define Op_RegX      Op_RegI
  1268 // For phase->intcon variants
  1269 #define MakeConX     intcon
  1270 #define ConXNode     ConINode
  1271 // For array index arithmetic
  1272 #define MulXNode     MulINode
  1273 #define AndXNode     AndINode
  1274 #define OrXNode      OrINode
  1275 #define CmpXNode     CmpINode
  1276 #define SubXNode     SubINode
  1277 #define LShiftXNode  LShiftINode
  1278 // For object size computation:
  1279 #define AddXNode     AddINode
  1280 #define RShiftXNode  RShiftINode
  1281 // For card marks and hashcodes
  1282 #define URShiftXNode URShiftINode
  1283 // UseOptoBiasInlining
  1284 #define XorXNode     XorINode
  1285 #define StoreXConditionalNode StoreIConditionalNode
  1286 // Opcodes
  1287 #define Op_LShiftX   Op_LShiftI
  1288 #define Op_AndX      Op_AndI
  1289 #define Op_AddX      Op_AddI
  1290 #define Op_SubX      Op_SubI
  1291 #define Op_XorX      Op_XorI
  1292 #define Op_URShiftX  Op_URShiftI
  1293 // conversions
  1294 #define ConvI2X(x)   (x)
  1295 #define ConvL2X(x)   ConvL2I(x)
  1296 #define ConvX2I(x)   (x)
  1297 #define ConvX2L(x)   ConvI2L(x)
  1299 #endif
  1301 #endif // SHARE_VM_OPTO_TYPE_HPP

mercurial