1 /*
   2  * Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #ifndef SHARE_OPTO_TYPE_HPP
  26 #define SHARE_OPTO_TYPE_HPP
  27 
  28 #include "opto/adlcVMDeps.hpp"
  29 #include "runtime/handles.hpp"
  30 
  31 // Portions of code courtesy of Clifford Click
  32 
  33 // Optimization - Graph Style
  34 
  35 
  36 // This class defines a Type lattice.  The lattice is used in the constant
  37 // propagation algorithms, and for some type-checking of the iloc code.
  38 // Basic types include RSD's (lower bound, upper bound, stride for integers),
  39 // float & double precision constants, sets of data-labels and code-labels.
  40 // The complete lattice is described below.  Subtypes have no relationship to
  41 // up or down in the lattice; that is entirely determined by the behavior of
  42 // the MEET/JOIN functions.
  43 
  44 class Dict;
  45 class Type;
  46 class   TypeD;
  47 class   TypeF;
  48 class   TypeInt;
  49 class   TypeLong;
  50 class   TypeNarrowPtr;
  51 class     TypeNarrowOop;
  52 class     TypeNarrowKlass;
  53 class   TypeAry;
  54 class   TypeTuple;
  55 class   TypeVect;
  56 class     TypeVectA;
  57 class     TypeVectS;
  58 class     TypeVectD;
  59 class     TypeVectX;
  60 class     TypeVectY;
  61 class     TypeVectZ;
  62 class   TypePtr;
  63 class     TypeRawPtr;
  64 class     TypeOopPtr;
  65 class       TypeInstPtr;
  66 class       TypeAryPtr;
  67 class     TypeKlassPtr;
  68 class     TypeMetadataPtr;
  69 
  70 //------------------------------Type-------------------------------------------
  71 // Basic Type object, represents a set of primitive Values.
  72 // Types are hash-cons'd into a private class dictionary, so only one of each
  73 // different kind of Type exists.  Types are never modified after creation, so
  74 // all their interesting fields are constant.
  75 class Type {
  76   friend class VMStructs;
  77 
  78 public:
  79   enum TYPES {
  80     Bad=0,                      // Type check
  81     Control,                    // Control of code (not in lattice)
  82     Top,                        // Top of the lattice
  83     Int,                        // Integer range (lo-hi)
  84     Long,                       // Long integer range (lo-hi)
  85     Half,                       // Placeholder half of doubleword
  86     NarrowOop,                  // Compressed oop pointer
  87     NarrowKlass,                // Compressed klass pointer
  88 
  89     Tuple,                      // Method signature or object layout
  90     Array,                      // Array types
  91     VectorA,                    // (Scalable) Vector types for vector length agnostic
  92     VectorS,                    //  32bit Vector types
  93     VectorD,                    //  64bit Vector types
  94     VectorX,                    // 128bit Vector types
  95     VectorY,                    // 256bit Vector types
  96     VectorZ,                    // 512bit Vector types
  97 
  98     AnyPtr,                     // Any old raw, klass, inst, or array pointer
  99     RawPtr,                     // Raw (non-oop) pointers
 100     OopPtr,                     // Any and all Java heap entities
 101     InstPtr,                    // Instance pointers (non-array objects)
 102     AryPtr,                     // Array pointers
 103     // (Ptr order matters:  See is_ptr, isa_ptr, is_oopptr, isa_oopptr.)
 104 
 105     MetadataPtr,                // Generic metadata
 106     KlassPtr,                   // Klass pointers
 107 
 108     Function,                   // Function signature
 109     Abio,                       // Abstract I/O
 110     Return_Address,             // Subroutine return address
 111     Memory,                     // Abstract store
 112     FloatTop,                   // No float value
 113     FloatCon,                   // Floating point constant
 114     FloatBot,                   // Any float value
 115     DoubleTop,                  // No double value
 116     DoubleCon,                  // Double precision constant
 117     DoubleBot,                  // Any double value
 118     Bottom,                     // Bottom of lattice
 119     lastype                     // Bogus ending type (not in lattice)
 120   };
 121 
 122   // Signal values for offsets from a base pointer
 123   enum OFFSET_SIGNALS {
 124     OffsetTop = -2000000000,    // undefined offset
 125     OffsetBot = -2000000001     // any possible offset
 126   };
 127 
 128   // Min and max WIDEN values.
 129   enum WIDEN {
 130     WidenMin = 0,
 131     WidenMax = 3
 132   };
 133 
 134 private:
 135   typedef struct {
 136     TYPES                dual_type;
 137     BasicType            basic_type;
 138     const char*          msg;
 139     bool                 isa_oop;
 140     uint                 ideal_reg;
 141     relocInfo::relocType reloc;
 142   } TypeInfo;
 143 
 144   // Dictionary of types shared among compilations.
 145   static Dict* _shared_type_dict;
 146   static const TypeInfo _type_info[];
 147 
 148   static int uhash( const Type *const t );
 149   // Structural equality check.  Assumes that cmp() has already compared
 150   // the _base types and thus knows it can cast 't' appropriately.
 151   virtual bool eq( const Type *t ) const;
 152 
 153   // Top-level hash-table of types
 154   static Dict *type_dict() {
 155     return Compile::current()->type_dict();
 156   }
 157 
 158   // DUAL operation: reflect around lattice centerline.  Used instead of
 159   // join to ensure my lattice is symmetric up and down.  Dual is computed
 160   // lazily, on demand, and cached in _dual.
 161   const Type *_dual;            // Cached dual value
 162   // Table for efficient dualing of base types
 163   static const TYPES dual_type[lastype];
 164 
 165 #ifdef ASSERT
 166   // One type is interface, the other is oop
 167   virtual bool interface_vs_oop_helper(const Type *t) const;
 168 #endif
 169 
 170   const Type *meet_helper(const Type *t, bool include_speculative) const;
 171   void check_symmetrical(const Type *t, const Type *mt) const;
 172 
 173 protected:
 174   // Each class of type is also identified by its base.
 175   const TYPES _base;            // Enum of Types type
 176 
 177   Type( TYPES t ) : _dual(NULL),  _base(t) {} // Simple types
 178   // ~Type();                   // Use fast deallocation
 179   const Type *hashcons();       // Hash-cons the type
 180   virtual const Type *filter_helper(const Type *kills, bool include_speculative) const;
 181   const Type *join_helper(const Type *t, bool include_speculative) const {
 182     return dual()->meet_helper(t->dual(), include_speculative)->dual();
 183   }
 184 
 185 public:
 186 
 187   inline void* operator new( size_t x ) throw() {
 188     Compile* compile = Compile::current();
 189     compile->set_type_last_size(x);
 190     return compile->type_arena()->Amalloc_D(x);
 191   }
 192   inline void operator delete( void* ptr ) {
 193     Compile* compile = Compile::current();
 194     compile->type_arena()->Afree(ptr,compile->type_last_size());
 195   }
 196 
 197   // Initialize the type system for a particular compilation.
 198   static void Initialize(Compile* compile);
 199 
 200   // Initialize the types shared by all compilations.
 201   static void Initialize_shared(Compile* compile);
 202 
 203   TYPES base() const {
 204     assert(_base > Bad && _base < lastype, "sanity");
 205     return _base;
 206   }
 207 
 208   // Create a new hash-consd type
 209   static const Type *make(enum TYPES);
 210   // Test for equivalence of types
 211   static int cmp( const Type *const t1, const Type *const t2 );
 212   // Test for higher or equal in lattice
 213   // Variant that drops the speculative part of the types
 214   bool higher_equal(const Type *t) const {
 215     return !cmp(meet(t),t->remove_speculative());
 216   }
 217   // Variant that keeps the speculative part of the types
 218   bool higher_equal_speculative(const Type *t) const {
 219     return !cmp(meet_speculative(t),t);
 220   }
 221 
 222   // MEET operation; lower in lattice.
 223   // Variant that drops the speculative part of the types
 224   const Type *meet(const Type *t) const {
 225     return meet_helper(t, false);
 226   }
 227   // Variant that keeps the speculative part of the types
 228   const Type *meet_speculative(const Type *t) const {
 229     return meet_helper(t, true)->cleanup_speculative();
 230   }
 231   // WIDEN: 'widens' for Ints and other range types
 232   virtual const Type *widen( const Type *old, const Type* limit ) const { return this; }
 233   // NARROW: complement for widen, used by pessimistic phases
 234   virtual const Type *narrow( const Type *old ) const { return this; }
 235 
 236   // DUAL operation: reflect around lattice centerline.  Used instead of
 237   // join to ensure my lattice is symmetric up and down.
 238   const Type *dual() const { return _dual; }
 239 
 240   // Compute meet dependent on base type
 241   virtual const Type *xmeet( const Type *t ) const;
 242   virtual const Type *xdual() const;    // Compute dual right now.
 243 
 244   // JOIN operation; higher in lattice.  Done by finding the dual of the
 245   // meet of the dual of the 2 inputs.
 246   // Variant that drops the speculative part of the types
 247   const Type *join(const Type *t) const {
 248     return join_helper(t, false);
 249   }
 250   // Variant that keeps the speculative part of the types
 251   const Type *join_speculative(const Type *t) const {
 252     return join_helper(t, true)->cleanup_speculative();
 253   }
 254 
 255   // Modified version of JOIN adapted to the needs Node::Value.
 256   // Normalizes all empty values to TOP.  Does not kill _widen bits.
 257   // Currently, it also works around limitations involving interface types.
 258   // Variant that drops the speculative part of the types
 259   const Type *filter(const Type *kills) const {
 260     return filter_helper(kills, false);
 261   }
 262   // Variant that keeps the speculative part of the types
 263   const Type *filter_speculative(const Type *kills) const {
 264     return filter_helper(kills, true)->cleanup_speculative();
 265   }
 266 
 267 #ifdef ASSERT
 268   // One type is interface, the other is oop
 269   virtual bool interface_vs_oop(const Type *t) const;
 270 #endif
 271 
 272   // Returns true if this pointer points at memory which contains a
 273   // compressed oop references.
 274   bool is_ptr_to_narrowoop() const;
 275   bool is_ptr_to_narrowklass() const;
 276 
 277   bool is_ptr_to_boxing_obj() const;
 278 
 279 
 280   // Convenience access
 281   float getf() const;
 282   double getd() const;
 283 
 284   const TypeInt    *is_int() const;
 285   const TypeInt    *isa_int() const;             // Returns NULL if not an Int
 286   const TypeLong   *is_long() const;
 287   const TypeLong   *isa_long() const;            // Returns NULL if not a Long
 288   const TypeD      *isa_double() const;          // Returns NULL if not a Double{Top,Con,Bot}
 289   const TypeD      *is_double_constant() const;  // Asserts it is a DoubleCon
 290   const TypeD      *isa_double_constant() const; // Returns NULL if not a DoubleCon
 291   const TypeF      *isa_float() const;           // Returns NULL if not a Float{Top,Con,Bot}
 292   const TypeF      *is_float_constant() const;   // Asserts it is a FloatCon
 293   const TypeF      *isa_float_constant() const;  // Returns NULL if not a FloatCon
 294   const TypeTuple  *is_tuple() const;            // Collection of fields, NOT a pointer
 295   const TypeAry    *is_ary() const;              // Array, NOT array pointer
 296   const TypeAry    *isa_ary() const;             // Returns NULL of not ary
 297   const TypeVect   *is_vect() const;             // Vector
 298   const TypeVect   *isa_vect() const;            // Returns NULL if not a Vector
 299   const TypePtr    *is_ptr() const;              // Asserts it is a ptr type
 300   const TypePtr    *isa_ptr() const;             // Returns NULL if not ptr type
 301   const TypeRawPtr *isa_rawptr() const;          // NOT Java oop
 302   const TypeRawPtr *is_rawptr() const;           // Asserts is rawptr
 303   const TypeNarrowOop  *is_narrowoop() const;    // Java-style GC'd pointer
 304   const TypeNarrowOop  *isa_narrowoop() const;   // Returns NULL if not oop ptr type
 305   const TypeNarrowKlass *is_narrowklass() const; // compressed klass pointer
 306   const TypeNarrowKlass *isa_narrowklass() const;// Returns NULL if not oop ptr type
 307   const TypeOopPtr   *isa_oopptr() const;        // Returns NULL if not oop ptr type
 308   const TypeOopPtr   *is_oopptr() const;         // Java-style GC'd pointer
 309   const TypeInstPtr  *isa_instptr() const;       // Returns NULL if not InstPtr
 310   const TypeInstPtr  *is_instptr() const;        // Instance
 311   const TypeAryPtr   *isa_aryptr() const;        // Returns NULL if not AryPtr
 312   const TypeAryPtr   *is_aryptr() const;         // Array oop
 313 
 314   const TypeMetadataPtr   *isa_metadataptr() const;   // Returns NULL if not oop ptr type
 315   const TypeMetadataPtr   *is_metadataptr() const;    // Java-style GC'd pointer
 316   const TypeKlassPtr      *isa_klassptr() const;      // Returns NULL if not KlassPtr
 317   const TypeKlassPtr      *is_klassptr() const;       // assert if not KlassPtr
 318 
 319   virtual bool      is_finite() const;           // Has a finite value
 320   virtual bool      is_nan()    const;           // Is not a number (NaN)
 321 
 322   // Returns this ptr type or the equivalent ptr type for this compressed pointer.
 323   const TypePtr* make_ptr() const;
 324 
 325   // Returns this oopptr type or the equivalent oopptr type for this compressed pointer.
 326   // Asserts if the underlying type is not an oopptr or narrowoop.
 327   const TypeOopPtr* make_oopptr() const;
 328 
 329   // Returns this compressed pointer or the equivalent compressed version
 330   // of this pointer type.
 331   const TypeNarrowOop* make_narrowoop() const;
 332 
 333   // Returns this compressed klass pointer or the equivalent
 334   // compressed version of this pointer type.
 335   const TypeNarrowKlass* make_narrowklass() const;
 336 
 337   // Special test for register pressure heuristic
 338   bool is_floatingpoint() const;        // True if Float or Double base type
 339 
 340   // Do you have memory, directly or through a tuple?
 341   bool has_memory( ) const;
 342 
 343   // TRUE if type is a singleton
 344   virtual bool singleton(void) const;
 345 
 346   // TRUE if type is above the lattice centerline, and is therefore vacuous
 347   virtual bool empty(void) const;
 348 
 349   // Return a hash for this type.  The hash function is public so ConNode
 350   // (constants) can hash on their constant, which is represented by a Type.
 351   virtual int hash() const;
 352 
 353   // Map ideal registers (machine types) to ideal types
 354   static const Type *mreg2type[];
 355 
 356   // Printing, statistics
 357 #ifndef PRODUCT
 358   void         dump_on(outputStream *st) const;
 359   void         dump() const {
 360     dump_on(tty);
 361   }
 362   virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
 363   static  void dump_stats();
 364 
 365   static const char* str(const Type* t);
 366 #endif
 367   void typerr(const Type *t) const; // Mixing types error
 368 
 369   // Create basic type
 370   static const Type* get_const_basic_type(BasicType type) {
 371     assert((uint)type <= T_CONFLICT && _const_basic_type[type] != NULL, "bad type");
 372     return _const_basic_type[type];
 373   }
 374 
 375   // For two instance arrays of same dimension, return the base element types.
 376   // Otherwise or if the arrays have different dimensions, return NULL.
 377   static void get_arrays_base_elements(const Type *a1, const Type *a2,
 378                                        const TypeInstPtr **e1, const TypeInstPtr **e2);
 379 
 380   // Mapping to the array element's basic type.
 381   BasicType array_element_basic_type() const;
 382 
 383   // Create standard type for a ciType:
 384   static const Type* get_const_type(ciType* type);
 385 
 386   // Create standard zero value:
 387   static const Type* get_zero_type(BasicType type) {
 388     assert((uint)type <= T_CONFLICT && _zero_type[type] != NULL, "bad type");
 389     return _zero_type[type];
 390   }
 391 
 392   // Report if this is a zero value (not top).
 393   bool is_zero_type() const {
 394     BasicType type = basic_type();
 395     if (type == T_VOID || type >= T_CONFLICT)
 396       return false;
 397     else
 398       return (this == _zero_type[type]);
 399   }
 400 
 401   // Convenience common pre-built types.
 402   static const Type *ABIO;
 403   static const Type *BOTTOM;
 404   static const Type *CONTROL;
 405   static const Type *DOUBLE;
 406   static const Type *FLOAT;
 407   static const Type *HALF;
 408   static const Type *MEMORY;
 409   static const Type *MULTI;
 410   static const Type *RETURN_ADDRESS;
 411   static const Type *TOP;
 412 
 413   // Mapping from compiler type to VM BasicType
 414   BasicType basic_type() const       { return _type_info[_base].basic_type; }
 415   uint ideal_reg() const             { return _type_info[_base].ideal_reg; }
 416   const char* msg() const            { return _type_info[_base].msg; }
 417   bool isa_oop_ptr() const           { return _type_info[_base].isa_oop; }
 418   relocInfo::relocType reloc() const { return _type_info[_base].reloc; }
 419 
 420   // Mapping from CI type system to compiler type:
 421   static const Type* get_typeflow_type(ciType* type);
 422 
 423   static const Type* make_from_constant(ciConstant constant,
 424                                         bool require_constant = false,
 425                                         int stable_dimension = 0,
 426                                         bool is_narrow = false,
 427                                         bool is_autobox_cache = false);
 428 
 429   static const Type* make_constant_from_field(ciInstance* holder,
 430                                               int off,
 431                                               bool is_unsigned_load,
 432                                               BasicType loadbt);
 433 
 434   static const Type* make_constant_from_field(ciField* field,
 435                                               ciInstance* holder,
 436                                               BasicType loadbt,
 437                                               bool is_unsigned_load);
 438 
 439   static const Type* make_constant_from_array_element(ciArray* array,
 440                                                       int off,
 441                                                       int stable_dimension,
 442                                                       BasicType loadbt,
 443                                                       bool is_unsigned_load);
 444 
 445   // Speculative type helper methods. See TypePtr.
 446   virtual const TypePtr* speculative() const                                  { return NULL; }
 447   virtual ciKlass* speculative_type() const                                   { return NULL; }
 448   virtual ciKlass* speculative_type_not_null() const                          { return NULL; }
 449   virtual bool speculative_maybe_null() const                                 { return true; }
 450   virtual bool speculative_always_null() const                                { return true; }
 451   virtual const Type* remove_speculative() const                              { return this; }
 452   virtual const Type* cleanup_speculative() const                             { return this; }
 453   virtual bool would_improve_type(ciKlass* exact_kls, int inline_depth) const { return exact_kls != NULL; }
 454   virtual bool would_improve_ptr(ProfilePtrKind ptr_kind) const { return ptr_kind == ProfileAlwaysNull || ptr_kind == ProfileNeverNull; }
 455   const Type* maybe_remove_speculative(bool include_speculative) const;
 456 
 457   virtual bool maybe_null() const { return true; }
 458   virtual bool is_known_instance() const { return false; }
 459 
 460 private:
 461   // support arrays
 462   static const Type*        _zero_type[T_CONFLICT+1];
 463   static const Type* _const_basic_type[T_CONFLICT+1];
 464 };
 465 
 466 //------------------------------TypeF------------------------------------------
 467 // Class of Float-Constant Types.
 468 class TypeF : public Type {
 469   TypeF( float f ) : Type(FloatCon), _f(f) {};
 470 public:
 471   virtual bool eq( const Type *t ) const;
 472   virtual int  hash() const;             // Type specific hashing
 473   virtual bool singleton(void) const;    // TRUE if type is a singleton
 474   virtual bool empty(void) const;        // TRUE if type is vacuous
 475 public:
 476   const float _f;               // Float constant
 477 
 478   static const TypeF *make(float f);
 479 
 480   virtual bool        is_finite() const;  // Has a finite value
 481   virtual bool        is_nan()    const;  // Is not a number (NaN)
 482 
 483   virtual const Type *xmeet( const Type *t ) const;
 484   virtual const Type *xdual() const;    // Compute dual right now.
 485   // Convenience common pre-built types.
 486   static const TypeF *ZERO; // positive zero only
 487   static const TypeF *ONE;
 488   static const TypeF *POS_INF;
 489   static const TypeF *NEG_INF;
 490 #ifndef PRODUCT
 491   virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
 492 #endif
 493 };
 494 
 495 //------------------------------TypeD------------------------------------------
 496 // Class of Double-Constant Types.
 497 class TypeD : public Type {
 498   TypeD( double d ) : Type(DoubleCon), _d(d) {};
 499 public:
 500   virtual bool eq( const Type *t ) const;
 501   virtual int  hash() const;             // Type specific hashing
 502   virtual bool singleton(void) const;    // TRUE if type is a singleton
 503   virtual bool empty(void) const;        // TRUE if type is vacuous
 504 public:
 505   const double _d;              // Double constant
 506 
 507   static const TypeD *make(double d);
 508 
 509   virtual bool        is_finite() const;  // Has a finite value
 510   virtual bool        is_nan()    const;  // Is not a number (NaN)
 511 
 512   virtual const Type *xmeet( const Type *t ) const;
 513   virtual const Type *xdual() const;    // Compute dual right now.
 514   // Convenience common pre-built types.
 515   static const TypeD *ZERO; // positive zero only
 516   static const TypeD *ONE;
 517   static const TypeD *POS_INF;
 518   static const TypeD *NEG_INF;
 519 #ifndef PRODUCT
 520   virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
 521 #endif
 522 };
 523 
 524 //------------------------------TypeInt----------------------------------------
 525 // Class of integer ranges, the set of integers between a lower bound and an
 526 // upper bound, inclusive.
 527 class TypeInt : public Type {
 528   TypeInt( jint lo, jint hi, int w );
 529 protected:
 530   virtual const Type *filter_helper(const Type *kills, bool include_speculative) const;
 531 
 532 public:
 533   typedef jint NativeType;
 534   virtual bool eq( const Type *t ) const;
 535   virtual int  hash() const;             // Type specific hashing
 536   virtual bool singleton(void) const;    // TRUE if type is a singleton
 537   virtual bool empty(void) const;        // TRUE if type is vacuous
 538   const jint _lo, _hi;          // Lower bound, upper bound
 539   const short _widen;           // Limit on times we widen this sucker
 540 
 541   static const TypeInt *make(jint lo);
 542   // must always specify w
 543   static const TypeInt *make(jint lo, jint hi, int w);
 544 
 545   // Check for single integer
 546   int is_con() const { return _lo==_hi; }
 547   bool is_con(int i) const { return is_con() && _lo == i; }
 548   jint get_con() const { assert( is_con(), "" );  return _lo; }
 549 
 550   virtual bool        is_finite() const;  // Has a finite value
 551 
 552   virtual const Type *xmeet( const Type *t ) const;
 553   virtual const Type *xdual() const;    // Compute dual right now.
 554   virtual const Type *widen( const Type *t, const Type* limit_type ) const;
 555   virtual const Type *narrow( const Type *t ) const;
 556   // Do not kill _widen bits.
 557   // Convenience common pre-built types.
 558   static const TypeInt *MINUS_1;
 559   static const TypeInt *ZERO;
 560   static const TypeInt *ONE;
 561   static const TypeInt *BOOL;
 562   static const TypeInt *CC;
 563   static const TypeInt *CC_LT;  // [-1]  == MINUS_1
 564   static const TypeInt *CC_GT;  // [1]   == ONE
 565   static const TypeInt *CC_EQ;  // [0]   == ZERO
 566   static const TypeInt *CC_LE;  // [-1,0]
 567   static const TypeInt *CC_GE;  // [0,1] == BOOL (!)
 568   static const TypeInt *BYTE;
 569   static const TypeInt *UBYTE;
 570   static const TypeInt *CHAR;
 571   static const TypeInt *SHORT;
 572   static const TypeInt *POS;
 573   static const TypeInt *POS1;
 574   static const TypeInt *INT;
 575   static const TypeInt *SYMINT; // symmetric range [-max_jint..max_jint]
 576   static const TypeInt *TYPE_DOMAIN; // alias for TypeInt::INT
 577 
 578   static const TypeInt *as_self(const Type *t) { return t->is_int(); }
 579 #ifndef PRODUCT
 580   virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
 581 #endif
 582 };
 583 
 584 
 585 //------------------------------TypeLong---------------------------------------
 586 // Class of long integer ranges, the set of integers between a lower bound and
 587 // an upper bound, inclusive.
 588 class TypeLong : public Type {
 589   TypeLong( jlong lo, jlong hi, int w );
 590 protected:
 591   // Do not kill _widen bits.
 592   virtual const Type *filter_helper(const Type *kills, bool include_speculative) const;
 593 public:
 594   typedef jlong NativeType;
 595   virtual bool eq( const Type *t ) const;
 596   virtual int  hash() const;             // Type specific hashing
 597   virtual bool singleton(void) const;    // TRUE if type is a singleton
 598   virtual bool empty(void) const;        // TRUE if type is vacuous
 599 public:
 600   const jlong _lo, _hi;         // Lower bound, upper bound
 601   const short _widen;           // Limit on times we widen this sucker
 602 
 603   static const TypeLong *make(jlong lo);
 604   // must always specify w
 605   static const TypeLong *make(jlong lo, jlong hi, int w);
 606 
 607   // Check for single integer
 608   int is_con() const { return _lo==_hi; }
 609   bool is_con(int i) const { return is_con() && _lo == i; }
 610   jlong get_con() const { assert( is_con(), "" ); return _lo; }
 611 
 612   // Check for positive 32-bit value.
 613   int is_positive_int() const { return _lo >= 0 && _hi <= (jlong)max_jint; }
 614 
 615   virtual bool        is_finite() const;  // Has a finite value
 616 
 617 
 618   virtual const Type *xmeet( const Type *t ) const;
 619   virtual const Type *xdual() const;    // Compute dual right now.
 620   virtual const Type *widen( const Type *t, const Type* limit_type ) const;
 621   virtual const Type *narrow( const Type *t ) const;
 622   // Convenience common pre-built types.
 623   static const TypeLong *MINUS_1;
 624   static const TypeLong *ZERO;
 625   static const TypeLong *ONE;
 626   static const TypeLong *POS;
 627   static const TypeLong *LONG;
 628   static const TypeLong *INT;    // 32-bit subrange [min_jint..max_jint]
 629   static const TypeLong *UINT;   // 32-bit unsigned [0..max_juint]
 630   static const TypeLong *TYPE_DOMAIN; // alias for TypeLong::LONG
 631 
 632   // static convenience methods.
 633   static const TypeLong *as_self(const Type *t) { return t->is_long(); }
 634 
 635 #ifndef PRODUCT
 636   virtual void dump2( Dict &d, uint, outputStream *st  ) const;// Specialized per-Type dumping
 637 #endif
 638 };
 639 
 640 //------------------------------TypeTuple--------------------------------------
 641 // Class of Tuple Types, essentially type collections for function signatures
 642 // and class layouts.  It happens to also be a fast cache for the HotSpot
 643 // signature types.
 644 class TypeTuple : public Type {
 645   TypeTuple( uint cnt, const Type **fields ) : Type(Tuple), _cnt(cnt), _fields(fields) { }
 646 
 647   const uint          _cnt;              // Count of fields
 648   const Type ** const _fields;           // Array of field types
 649 
 650 public:
 651   virtual bool eq( const Type *t ) const;
 652   virtual int  hash() const;             // Type specific hashing
 653   virtual bool singleton(void) const;    // TRUE if type is a singleton
 654   virtual bool empty(void) const;        // TRUE if type is vacuous
 655 
 656   // Accessors:
 657   uint cnt() const { return _cnt; }
 658   const Type* field_at(uint i) const {
 659     assert(i < _cnt, "oob");
 660     return _fields[i];
 661   }
 662   void set_field_at(uint i, const Type* t) {
 663     assert(i < _cnt, "oob");
 664     _fields[i] = t;
 665   }
 666 
 667   static const TypeTuple *make( uint cnt, const Type **fields );
 668   static const TypeTuple *make_range(ciSignature *sig);
 669   static const TypeTuple *make_domain(ciInstanceKlass* recv, ciSignature *sig);
 670 
 671   // Subroutine call type with space allocated for argument types
 672   // Memory for Control, I_O, Memory, FramePtr, and ReturnAdr is allocated implicitly
 673   static const Type **fields( uint arg_cnt );
 674 
 675   virtual const Type *xmeet( const Type *t ) const;
 676   virtual const Type *xdual() const;    // Compute dual right now.
 677   // Convenience common pre-built types.
 678   static const TypeTuple *IFBOTH;
 679   static const TypeTuple *IFFALSE;
 680   static const TypeTuple *IFTRUE;
 681   static const TypeTuple *IFNEITHER;
 682   static const TypeTuple *LOOPBODY;
 683   static const TypeTuple *MEMBAR;
 684   static const TypeTuple *STORECONDITIONAL;
 685   static const TypeTuple *START_I2C;
 686   static const TypeTuple *INT_PAIR;
 687   static const TypeTuple *LONG_PAIR;
 688   static const TypeTuple *INT_CC_PAIR;
 689   static const TypeTuple *LONG_CC_PAIR;
 690 #ifndef PRODUCT
 691   virtual void dump2( Dict &d, uint, outputStream *st  ) const; // Specialized per-Type dumping
 692 #endif
 693 };
 694 
 695 //------------------------------TypeAry----------------------------------------
 696 // Class of Array Types
 697 class TypeAry : public Type {
 698   TypeAry(const Type* elem, const TypeInt* size, bool stable) : Type(Array),
 699       _elem(elem), _size(size), _stable(stable) {}
 700 public:
 701   virtual bool eq( const Type *t ) const;
 702   virtual int  hash() const;             // Type specific hashing
 703   virtual bool singleton(void) const;    // TRUE if type is a singleton
 704   virtual bool empty(void) const;        // TRUE if type is vacuous
 705 
 706 private:
 707   const Type *_elem;            // Element type of array
 708   const TypeInt *_size;         // Elements in array
 709   const bool _stable;           // Are elements @Stable?
 710   friend class TypeAryPtr;
 711 
 712 public:
 713   static const TypeAry* make(const Type* elem, const TypeInt* size, bool stable = false);
 714 
 715   virtual const Type *xmeet( const Type *t ) const;
 716   virtual const Type *xdual() const;    // Compute dual right now.
 717   bool ary_must_be_exact() const;  // true if arrays of such are never generic
 718   virtual const Type* remove_speculative() const;
 719   virtual const Type* cleanup_speculative() const;
 720 #ifdef ASSERT
 721   // One type is interface, the other is oop
 722   virtual bool interface_vs_oop(const Type *t) const;
 723 #endif
 724 #ifndef PRODUCT
 725   virtual void dump2( Dict &d, uint, outputStream *st  ) const; // Specialized per-Type dumping
 726 #endif
 727 };
 728 
 729 //------------------------------TypeVect---------------------------------------
 730 // Class of Vector Types
 731 class TypeVect : public Type {
 732   const Type*   _elem;  // Vector's element type
 733   const uint  _length;  // Elements in vector (power of 2)
 734 
 735 protected:
 736   TypeVect(TYPES t, const Type* elem, uint length) : Type(t),
 737     _elem(elem), _length(length) {}
 738 
 739 public:
 740   const Type* element_type() const { return _elem; }
 741   BasicType element_basic_type() const { return _elem->array_element_basic_type(); }
 742   uint length() const { return _length; }
 743   uint length_in_bytes() const {
 744    return _length * type2aelembytes(element_basic_type());
 745   }
 746 
 747   virtual bool eq(const Type *t) const;
 748   virtual int  hash() const;             // Type specific hashing
 749   virtual bool singleton(void) const;    // TRUE if type is a singleton
 750   virtual bool empty(void) const;        // TRUE if type is vacuous
 751 
 752   static const TypeVect *make(const BasicType elem_bt, uint length) {
 753     // Use bottom primitive type.
 754     return make(get_const_basic_type(elem_bt), length);
 755   }
 756   // Used directly by Replicate nodes to construct singleton vector.
 757   static const TypeVect *make(const Type* elem, uint length);
 758 
 759   virtual const Type *xmeet( const Type *t) const;
 760   virtual const Type *xdual() const;     // Compute dual right now.
 761 
 762   static const TypeVect *VECTA;
 763   static const TypeVect *VECTS;
 764   static const TypeVect *VECTD;
 765   static const TypeVect *VECTX;
 766   static const TypeVect *VECTY;
 767   static const TypeVect *VECTZ;
 768 
 769 #ifndef PRODUCT
 770   virtual void dump2(Dict &d, uint, outputStream *st) const; // Specialized per-Type dumping
 771 #endif
 772 };
 773 
 774 class TypeVectA : public TypeVect {
 775   friend class TypeVect;
 776   TypeVectA(const Type* elem, uint length) : TypeVect(VectorA, elem, length) {}
 777 };
 778 
 779 class TypeVectS : public TypeVect {
 780   friend class TypeVect;
 781   TypeVectS(const Type* elem, uint length) : TypeVect(VectorS, elem, length) {}
 782 };
 783 
 784 class TypeVectD : public TypeVect {
 785   friend class TypeVect;
 786   TypeVectD(const Type* elem, uint length) : TypeVect(VectorD, elem, length) {}
 787 };
 788 
 789 class TypeVectX : public TypeVect {
 790   friend class TypeVect;
 791   TypeVectX(const Type* elem, uint length) : TypeVect(VectorX, elem, length) {}
 792 };
 793 
 794 class TypeVectY : public TypeVect {
 795   friend class TypeVect;
 796   TypeVectY(const Type* elem, uint length) : TypeVect(VectorY, elem, length) {}
 797 };
 798 
 799 class TypeVectZ : public TypeVect {
 800   friend class TypeVect;
 801   TypeVectZ(const Type* elem, uint length) : TypeVect(VectorZ, elem, length) {}
 802 };
 803 
 804 //------------------------------TypePtr----------------------------------------
 805 // Class of machine Pointer Types: raw data, instances or arrays.
 806 // If the _base enum is AnyPtr, then this refers to all of the above.
 807 // Otherwise the _base will indicate which subset of pointers is affected,
 808 // and the class will be inherited from.
 809 class TypePtr : public Type {
 810   friend class TypeNarrowPtr;
 811 public:
 812   enum PTR { TopPTR, AnyNull, Constant, Null, NotNull, BotPTR, lastPTR };
 813 protected:
 814   TypePtr(TYPES t, PTR ptr, int offset,
 815           const TypePtr* speculative = NULL,
 816           int inline_depth = InlineDepthBottom) :
 817     Type(t), _speculative(speculative), _inline_depth(inline_depth), _offset(offset),
 818     _ptr(ptr) {}
 819   static const PTR ptr_meet[lastPTR][lastPTR];
 820   static const PTR ptr_dual[lastPTR];
 821   static const char * const ptr_msg[lastPTR];
 822 
 823   enum {
 824     InlineDepthBottom = INT_MAX,
 825     InlineDepthTop = -InlineDepthBottom
 826   };
 827 
 828   // Extra type information profiling gave us. We propagate it the
 829   // same way the rest of the type info is propagated. If we want to
 830   // use it, then we have to emit a guard: this part of the type is
 831   // not something we know but something we speculate about the type.
 832   const TypePtr*   _speculative;
 833   // For speculative types, we record at what inlining depth the
 834   // profiling point that provided the data is. We want to favor
 835   // profile data coming from outer scopes which are likely better for
 836   // the current compilation.
 837   int _inline_depth;
 838 
 839   // utility methods to work on the speculative part of the type
 840   const TypePtr* dual_speculative() const;
 841   const TypePtr* xmeet_speculative(const TypePtr* other) const;
 842   bool eq_speculative(const TypePtr* other) const;
 843   int hash_speculative() const;
 844   const TypePtr* add_offset_speculative(intptr_t offset) const;
 845 #ifndef PRODUCT
 846   void dump_speculative(outputStream *st) const;
 847 #endif
 848 
 849   // utility methods to work on the inline depth of the type
 850   int dual_inline_depth() const;
 851   int meet_inline_depth(int depth) const;
 852 #ifndef PRODUCT
 853   void dump_inline_depth(outputStream *st) const;
 854 #endif
 855 
 856 public:
 857   const int _offset;            // Offset into oop, with TOP & BOT
 858   const PTR _ptr;               // Pointer equivalence class
 859 
 860   const int offset() const { return _offset; }
 861   const PTR ptr()    const { return _ptr; }
 862 
 863   static const TypePtr *make(TYPES t, PTR ptr, int offset,
 864                              const TypePtr* speculative = NULL,
 865                              int inline_depth = InlineDepthBottom);
 866 
 867   // Return a 'ptr' version of this type
 868   virtual const Type *cast_to_ptr_type(PTR ptr) const;
 869 
 870   virtual intptr_t get_con() const;
 871 
 872   int xadd_offset( intptr_t offset ) const;
 873   virtual const TypePtr *add_offset( intptr_t offset ) const;
 874   virtual bool eq(const Type *t) const;
 875   virtual int  hash() const;             // Type specific hashing
 876 
 877   virtual bool singleton(void) const;    // TRUE if type is a singleton
 878   virtual bool empty(void) const;        // TRUE if type is vacuous
 879   virtual const Type *xmeet( const Type *t ) const;
 880   virtual const Type *xmeet_helper( const Type *t ) const;
 881   int meet_offset( int offset ) const;
 882   int dual_offset( ) const;
 883   virtual const Type *xdual() const;    // Compute dual right now.
 884 
 885   // meet, dual and join over pointer equivalence sets
 886   PTR meet_ptr( const PTR in_ptr ) const { return ptr_meet[in_ptr][ptr()]; }
 887   PTR dual_ptr()                   const { return ptr_dual[ptr()];      }
 888 
 889   // This is textually confusing unless one recalls that
 890   // join(t) == dual()->meet(t->dual())->dual().
 891   PTR join_ptr( const PTR in_ptr ) const {
 892     return ptr_dual[ ptr_meet[ ptr_dual[in_ptr] ] [ dual_ptr() ] ];
 893   }
 894 
 895   // Speculative type helper methods.
 896   virtual const TypePtr* speculative() const { return _speculative; }
 897   int inline_depth() const                   { return _inline_depth; }
 898   virtual ciKlass* speculative_type() const;
 899   virtual ciKlass* speculative_type_not_null() const;
 900   virtual bool speculative_maybe_null() const;
 901   virtual bool speculative_always_null() const;
 902   virtual const Type* remove_speculative() const;
 903   virtual const Type* cleanup_speculative() const;
 904   virtual bool would_improve_type(ciKlass* exact_kls, int inline_depth) const;
 905   virtual bool would_improve_ptr(ProfilePtrKind maybe_null) const;
 906   virtual const TypePtr* with_inline_depth(int depth) const;
 907 
 908   virtual bool maybe_null() const { return meet_ptr(Null) == ptr(); }
 909 
 910   // Tests for relation to centerline of type lattice:
 911   static bool above_centerline(PTR ptr) { return (ptr <= AnyNull); }
 912   static bool below_centerline(PTR ptr) { return (ptr >= NotNull); }
 913   // Convenience common pre-built types.
 914   static const TypePtr *NULL_PTR;
 915   static const TypePtr *NOTNULL;
 916   static const TypePtr *BOTTOM;
 917 #ifndef PRODUCT
 918   virtual void dump2( Dict &d, uint depth, outputStream *st  ) const;
 919 #endif
 920 };
 921 
 922 //------------------------------TypeRawPtr-------------------------------------
 923 // Class of raw pointers, pointers to things other than Oops.  Examples
 924 // include the stack pointer, top of heap, card-marking area, handles, etc.
 925 class TypeRawPtr : public TypePtr {
 926 protected:
 927   TypeRawPtr( PTR ptr, address bits ) : TypePtr(RawPtr,ptr,0), _bits(bits){}
 928 public:
 929   virtual bool eq( const Type *t ) const;
 930   virtual int  hash() const;     // Type specific hashing
 931 
 932   const address _bits;          // Constant value, if applicable
 933 
 934   static const TypeRawPtr *make( PTR ptr );
 935   static const TypeRawPtr *make( address bits );
 936 
 937   // Return a 'ptr' version of this type
 938   virtual const Type *cast_to_ptr_type(PTR ptr) const;
 939 
 940   virtual intptr_t get_con() const;
 941 
 942   virtual const TypePtr *add_offset( intptr_t offset ) const;
 943 
 944   virtual const Type *xmeet( const Type *t ) const;
 945   virtual const Type *xdual() const;    // Compute dual right now.
 946   // Convenience common pre-built types.
 947   static const TypeRawPtr *BOTTOM;
 948   static const TypeRawPtr *NOTNULL;
 949 #ifndef PRODUCT
 950   virtual void dump2( Dict &d, uint depth, outputStream *st  ) const;
 951 #endif
 952 };
 953 
 954 //------------------------------TypeOopPtr-------------------------------------
 955 // Some kind of oop (Java pointer), either instance or array.
 956 class TypeOopPtr : public TypePtr {
 957 protected:
 958   TypeOopPtr(TYPES t, PTR ptr, ciKlass* k, bool xk, ciObject* o, int offset, int instance_id,
 959              const TypePtr* speculative, int inline_depth);
 960 public:
 961   virtual bool eq( const Type *t ) const;
 962   virtual int  hash() const;             // Type specific hashing
 963   virtual bool singleton(void) const;    // TRUE if type is a singleton
 964   enum {
 965    InstanceTop = -1,   // undefined instance
 966    InstanceBot = 0     // any possible instance
 967   };
 968 protected:
 969 
 970   // Oop is NULL, unless this is a constant oop.
 971   ciObject*     _const_oop;   // Constant oop
 972   // If _klass is NULL, then so is _sig.  This is an unloaded klass.
 973   ciKlass*      _klass;       // Klass object
 974   // Does the type exclude subclasses of the klass?  (Inexact == polymorphic.)
 975   bool          _klass_is_exact;
 976   bool          _is_ptr_to_narrowoop;
 977   bool          _is_ptr_to_narrowklass;
 978   bool          _is_ptr_to_boxed_value;
 979 
 980   // If not InstanceTop or InstanceBot, indicates that this is
 981   // a particular instance of this type which is distinct.
 982   // This is the node index of the allocation node creating this instance.
 983   int           _instance_id;
 984 
 985   static const TypeOopPtr* make_from_klass_common(ciKlass* klass, bool klass_change, bool try_for_exact);
 986 
 987   int dual_instance_id() const;
 988   int meet_instance_id(int uid) const;
 989 
 990   // Do not allow interface-vs.-noninterface joins to collapse to top.
 991   virtual const Type *filter_helper(const Type *kills, bool include_speculative) const;
 992 
 993 public:
 994   // Creates a type given a klass. Correctly handles multi-dimensional arrays
 995   // Respects UseUniqueSubclasses.
 996   // If the klass is final, the resulting type will be exact.
 997   static const TypeOopPtr* make_from_klass(ciKlass* klass) {
 998     return make_from_klass_common(klass, true, false);
 999   }
1000   // Same as before, but will produce an exact type, even if
1001   // the klass is not final, as long as it has exactly one implementation.
1002   static const TypeOopPtr* make_from_klass_unique(ciKlass* klass) {
1003     return make_from_klass_common(klass, true, true);
1004   }
1005   // Same as before, but does not respects UseUniqueSubclasses.
1006   // Use this only for creating array element types.
1007   static const TypeOopPtr* make_from_klass_raw(ciKlass* klass) {
1008     return make_from_klass_common(klass, false, false);
1009   }
1010   // Creates a singleton type given an object.
1011   // If the object cannot be rendered as a constant,
1012   // may return a non-singleton type.
1013   // If require_constant, produce a NULL if a singleton is not possible.
1014   static const TypeOopPtr* make_from_constant(ciObject* o,
1015                                               bool require_constant = false);
1016 
1017   // Make a generic (unclassed) pointer to an oop.
1018   static const TypeOopPtr* make(PTR ptr, int offset, int instance_id,
1019                                 const TypePtr* speculative = NULL,
1020                                 int inline_depth = InlineDepthBottom);
1021 
1022   ciObject* const_oop()    const { return _const_oop; }
1023   virtual ciKlass* klass() const { return _klass;     }
1024   bool klass_is_exact()    const { return _klass_is_exact; }
1025 
1026   // Returns true if this pointer points at memory which contains a
1027   // compressed oop references.
1028   bool is_ptr_to_narrowoop_nv() const { return _is_ptr_to_narrowoop; }
1029   bool is_ptr_to_narrowklass_nv() const { return _is_ptr_to_narrowklass; }
1030   bool is_ptr_to_boxed_value()   const { return _is_ptr_to_boxed_value; }
1031   bool is_known_instance()       const { return _instance_id > 0; }
1032   int  instance_id()             const { return _instance_id; }
1033   bool is_known_instance_field() const { return is_known_instance() && _offset >= 0; }
1034 
1035   virtual intptr_t get_con() const;
1036 
1037   virtual const Type *cast_to_ptr_type(PTR ptr) const;
1038 
1039   virtual const Type *cast_to_exactness(bool klass_is_exact) const;
1040 
1041   virtual const TypeOopPtr *cast_to_instance_id(int instance_id) const;
1042 
1043   // corresponding pointer to klass, for a given instance
1044   const TypeKlassPtr* as_klass_type() const;
1045 
1046   virtual const TypePtr *add_offset( intptr_t offset ) const;
1047 
1048   // Speculative type helper methods.
1049   virtual const Type* remove_speculative() const;
1050   virtual const Type* cleanup_speculative() const;
1051   virtual bool would_improve_type(ciKlass* exact_kls, int inline_depth) const;
1052   virtual const TypePtr* with_inline_depth(int depth) const;
1053 
1054   virtual const TypePtr* with_instance_id(int instance_id) const;
1055 
1056   virtual const Type *xdual() const;    // Compute dual right now.
1057   // the core of the computation of the meet for TypeOopPtr and for its subclasses
1058   virtual const Type *xmeet_helper(const Type *t) const;
1059 
1060   // Convenience common pre-built type.
1061   static const TypeOopPtr *BOTTOM;
1062 #ifndef PRODUCT
1063   virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
1064 #endif
1065 };
1066 
1067 //------------------------------TypeInstPtr------------------------------------
1068 // Class of Java object pointers, pointing either to non-array Java instances
1069 // or to a Klass* (including array klasses).
1070 class TypeInstPtr : public TypeOopPtr {
1071   TypeInstPtr(PTR ptr, ciKlass* k, bool xk, ciObject* o, int offset, int instance_id,
1072               const TypePtr* speculative, int inline_depth);
1073   virtual bool eq( const Type *t ) const;
1074   virtual int  hash() const;             // Type specific hashing
1075 
1076   ciSymbol*  _name;        // class name
1077 
1078  public:
1079   ciSymbol* name()         const { return _name; }
1080 
1081   bool  is_loaded() const { return _klass->is_loaded(); }
1082 
1083   // Make a pointer to a constant oop.
1084   static const TypeInstPtr *make(ciObject* o) {
1085     return make(TypePtr::Constant, o->klass(), true, o, 0, InstanceBot);
1086   }
1087   // Make a pointer to a constant oop with offset.
1088   static const TypeInstPtr *make(ciObject* o, int offset) {
1089     return make(TypePtr::Constant, o->klass(), true, o, offset, InstanceBot);
1090   }
1091 
1092   // Make a pointer to some value of type klass.
1093   static const TypeInstPtr *make(PTR ptr, ciKlass* klass) {
1094     return make(ptr, klass, false, NULL, 0, InstanceBot);
1095   }
1096 
1097   // Make a pointer to some non-polymorphic value of exactly type klass.
1098   static const TypeInstPtr *make_exact(PTR ptr, ciKlass* klass) {
1099     return make(ptr, klass, true, NULL, 0, InstanceBot);
1100   }
1101 
1102   // Make a pointer to some value of type klass with offset.
1103   static const TypeInstPtr *make(PTR ptr, ciKlass* klass, int offset) {
1104     return make(ptr, klass, false, NULL, offset, InstanceBot);
1105   }
1106 
1107   // Make a pointer to an oop.
1108   static const TypeInstPtr *make(PTR ptr, ciKlass* k, bool xk, ciObject* o, int offset,
1109                                  int instance_id = InstanceBot,
1110                                  const TypePtr* speculative = NULL,
1111                                  int inline_depth = InlineDepthBottom);
1112 
1113   /** Create constant type for a constant boxed value */
1114   const Type* get_const_boxed_value() const;
1115 
1116   // If this is a java.lang.Class constant, return the type for it or NULL.
1117   // Pass to Type::get_const_type to turn it to a type, which will usually
1118   // be a TypeInstPtr, but may also be a TypeInt::INT for int.class, etc.
1119   ciType* java_mirror_type() const;
1120 
1121   virtual const Type *cast_to_ptr_type(PTR ptr) const;
1122 
1123   virtual const Type *cast_to_exactness(bool klass_is_exact) const;
1124 
1125   virtual const TypeOopPtr *cast_to_instance_id(int instance_id) const;
1126 
1127   virtual const TypePtr *add_offset( intptr_t offset ) const;
1128 
1129   // Speculative type helper methods.
1130   virtual const Type* remove_speculative() const;
1131   virtual const TypePtr* with_inline_depth(int depth) const;
1132   virtual const TypePtr* with_instance_id(int instance_id) const;
1133 
1134   // the core of the computation of the meet of 2 types
1135   virtual const Type *xmeet_helper(const Type *t) const;
1136   virtual const TypeInstPtr *xmeet_unloaded( const TypeInstPtr *t ) const;
1137   virtual const Type *xdual() const;    // Compute dual right now.
1138 
1139   // Convenience common pre-built types.
1140   static const TypeInstPtr *NOTNULL;
1141   static const TypeInstPtr *BOTTOM;
1142   static const TypeInstPtr *MIRROR;
1143   static const TypeInstPtr *MARK;
1144   static const TypeInstPtr *KLASS;
1145 #ifndef PRODUCT
1146   virtual void dump2( Dict &d, uint depth, outputStream *st ) const; // Specialized per-Type dumping
1147 #endif
1148 };
1149 
1150 //------------------------------TypeAryPtr-------------------------------------
1151 // Class of Java array pointers
1152 class TypeAryPtr : public TypeOopPtr {
1153   TypeAryPtr( PTR ptr, ciObject* o, const TypeAry *ary, ciKlass* k, bool xk,
1154               int offset, int instance_id, bool is_autobox_cache,
1155               const TypePtr* speculative, int inline_depth)
1156     : TypeOopPtr(AryPtr,ptr,k,xk,o,offset, instance_id, speculative, inline_depth),
1157     _ary(ary),
1158     _is_autobox_cache(is_autobox_cache)
1159  {
1160 #ifdef ASSERT
1161     if (k != NULL) {
1162       // Verify that specified klass and TypeAryPtr::klass() follow the same rules.
1163       ciKlass* ck = compute_klass(true);
1164       if (k != ck) {
1165         this->dump(); tty->cr();
1166         tty->print(" k: ");
1167         k->print(); tty->cr();
1168         tty->print("ck: ");
1169         if (ck != NULL) ck->print();
1170         else tty->print("<NULL>");
1171         tty->cr();
1172         assert(false, "unexpected TypeAryPtr::_klass");
1173       }
1174     }
1175 #endif
1176   }
1177   virtual bool eq( const Type *t ) const;
1178   virtual int hash() const;     // Type specific hashing
1179   const TypeAry *_ary;          // Array we point into
1180   const bool     _is_autobox_cache;
1181 
1182   ciKlass* compute_klass(DEBUG_ONLY(bool verify = false)) const;
1183 
1184 public:
1185   // Accessors
1186   ciKlass* klass() const;
1187   const TypeAry* ary() const  { return _ary; }
1188   const Type*    elem() const { return _ary->_elem; }
1189   const TypeInt* size() const { return _ary->_size; }
1190   bool      is_stable() const { return _ary->_stable; }
1191 
1192   bool is_autobox_cache() const { return _is_autobox_cache; }
1193 
1194   static const TypeAryPtr *make(PTR ptr, const TypeAry *ary, ciKlass* k, bool xk, int offset,
1195                                 int instance_id = InstanceBot,
1196                                 const TypePtr* speculative = NULL,
1197                                 int inline_depth = InlineDepthBottom);
1198   // Constant pointer to array
1199   static const TypeAryPtr *make(PTR ptr, ciObject* o, const TypeAry *ary, ciKlass* k, bool xk, int offset,
1200                                 int instance_id = InstanceBot,
1201                                 const TypePtr* speculative = NULL,
1202                                 int inline_depth = InlineDepthBottom, bool is_autobox_cache = false);
1203 
1204   // Return a 'ptr' version of this type
1205   virtual const Type *cast_to_ptr_type(PTR ptr) const;
1206 
1207   virtual const Type *cast_to_exactness(bool klass_is_exact) const;
1208 
1209   virtual const TypeOopPtr *cast_to_instance_id(int instance_id) const;
1210 
1211   virtual const TypeAryPtr* cast_to_size(const TypeInt* size) const;
1212   virtual const TypeInt* narrow_size_type(const TypeInt* size) const;
1213 
1214   virtual bool empty(void) const;        // TRUE if type is vacuous
1215   virtual const TypePtr *add_offset( intptr_t offset ) const;
1216 
1217   // Speculative type helper methods.
1218   virtual const Type* remove_speculative() const;
1219   virtual const TypePtr* with_inline_depth(int depth) const;
1220   virtual const TypePtr* with_instance_id(int instance_id) const;
1221 
1222   // the core of the computation of the meet of 2 types
1223   virtual const Type *xmeet_helper(const Type *t) const;
1224   virtual const Type *xdual() const;    // Compute dual right now.
1225 
1226   const TypeAryPtr* cast_to_stable(bool stable, int stable_dimension = 1) const;
1227   int stable_dimension() const;
1228 
1229   const TypeAryPtr* cast_to_autobox_cache(bool cache) const;
1230 
1231   static jint max_array_length(BasicType etype) ;
1232 
1233   // Convenience common pre-built types.
1234   static const TypeAryPtr *RANGE;
1235   static const TypeAryPtr *OOPS;
1236   static const TypeAryPtr *NARROWOOPS;
1237   static const TypeAryPtr *BYTES;
1238   static const TypeAryPtr *SHORTS;
1239   static const TypeAryPtr *CHARS;
1240   static const TypeAryPtr *INTS;
1241   static const TypeAryPtr *LONGS;
1242   static const TypeAryPtr *FLOATS;
1243   static const TypeAryPtr *DOUBLES;
1244   // selects one of the above:
1245   static const TypeAryPtr *get_array_body_type(BasicType elem) {
1246     assert((uint)elem <= T_CONFLICT && _array_body_type[elem] != NULL, "bad elem type");
1247     return _array_body_type[elem];
1248   }
1249   static const TypeAryPtr *_array_body_type[T_CONFLICT+1];
1250   // sharpen the type of an int which is used as an array size
1251 #ifdef ASSERT
1252   // One type is interface, the other is oop
1253   virtual bool interface_vs_oop(const Type *t) const;
1254 #endif
1255 #ifndef PRODUCT
1256   virtual void dump2( Dict &d, uint depth, outputStream *st ) const; // Specialized per-Type dumping
1257 #endif
1258 };
1259 
1260 //------------------------------TypeMetadataPtr-------------------------------------
1261 // Some kind of metadata, either Method*, MethodData* or CPCacheOop
1262 class TypeMetadataPtr : public TypePtr {
1263 protected:
1264   TypeMetadataPtr(PTR ptr, ciMetadata* metadata, int offset);
1265   // Do not allow interface-vs.-noninterface joins to collapse to top.
1266   virtual const Type *filter_helper(const Type *kills, bool include_speculative) const;
1267 public:
1268   virtual bool eq( const Type *t ) const;
1269   virtual int  hash() const;             // Type specific hashing
1270   virtual bool singleton(void) const;    // TRUE if type is a singleton
1271 
1272 private:
1273   ciMetadata*   _metadata;
1274 
1275 public:
1276   static const TypeMetadataPtr* make(PTR ptr, ciMetadata* m, int offset);
1277 
1278   static const TypeMetadataPtr* make(ciMethod* m);
1279   static const TypeMetadataPtr* make(ciMethodData* m);
1280 
1281   ciMetadata* metadata() const { return _metadata; }
1282 
1283   virtual const Type *cast_to_ptr_type(PTR ptr) const;
1284 
1285   virtual const TypePtr *add_offset( intptr_t offset ) const;
1286 
1287   virtual const Type *xmeet( const Type *t ) const;
1288   virtual const Type *xdual() const;    // Compute dual right now.
1289 
1290   virtual intptr_t get_con() const;
1291 
1292   // Convenience common pre-built types.
1293   static const TypeMetadataPtr *BOTTOM;
1294 
1295 #ifndef PRODUCT
1296   virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
1297 #endif
1298 };
1299 
1300 //------------------------------TypeKlassPtr-----------------------------------
1301 // Class of Java Klass pointers
1302 class TypeKlassPtr : public TypePtr {
1303   TypeKlassPtr( PTR ptr, ciKlass* klass, int offset );
1304 
1305 protected:
1306   virtual const Type *filter_helper(const Type *kills, bool include_speculative) const;
1307  public:
1308   virtual bool eq( const Type *t ) const;
1309   virtual int hash() const;             // Type specific hashing
1310   virtual bool singleton(void) const;    // TRUE if type is a singleton
1311  private:
1312 
1313   static const TypeKlassPtr* make_from_klass_common(ciKlass* klass, bool klass_change, bool try_for_exact);
1314 
1315   ciKlass* _klass;
1316 
1317   // Does the type exclude subclasses of the klass?  (Inexact == polymorphic.)
1318   bool          _klass_is_exact;
1319 
1320 public:
1321   ciSymbol* name()  const { return klass()->name(); }
1322 
1323   ciKlass* klass() const { return  _klass; }
1324   bool klass_is_exact()    const { return _klass_is_exact; }
1325 
1326   bool  is_loaded() const { return klass()->is_loaded(); }
1327 
1328   // Creates a type given a klass. Correctly handles multi-dimensional arrays
1329   // Respects UseUniqueSubclasses.
1330   // If the klass is final, the resulting type will be exact.
1331   static const TypeKlassPtr* make_from_klass(ciKlass* klass) {
1332     return make_from_klass_common(klass, true, false);
1333   }
1334   // Same as before, but will produce an exact type, even if
1335   // the klass is not final, as long as it has exactly one implementation.
1336   static const TypeKlassPtr* make_from_klass_unique(ciKlass* klass) {
1337     return make_from_klass_common(klass, true, true);
1338   }
1339   // Same as before, but does not respects UseUniqueSubclasses.
1340   // Use this only for creating array element types.
1341   static const TypeKlassPtr* make_from_klass_raw(ciKlass* klass) {
1342     return make_from_klass_common(klass, false, false);
1343   }
1344 
1345   // Make a generic (unclassed) pointer to metadata.
1346   static const TypeKlassPtr* make(PTR ptr, int offset);
1347 
1348   // ptr to klass 'k'
1349   static const TypeKlassPtr *make( ciKlass* k ) { return make( TypePtr::Constant, k, 0); }
1350   // ptr to klass 'k' with offset
1351   static const TypeKlassPtr *make( ciKlass* k, int offset ) { return make( TypePtr::Constant, k, offset); }
1352   // ptr to klass 'k' or sub-klass
1353   static const TypeKlassPtr *make( PTR ptr, ciKlass* k, int offset);
1354 
1355   virtual const Type *cast_to_ptr_type(PTR ptr) const;
1356 
1357   virtual const Type *cast_to_exactness(bool klass_is_exact) const;
1358 
1359   // corresponding pointer to instance, for a given class
1360   const TypeOopPtr* as_instance_type() const;
1361 
1362   virtual const TypePtr *add_offset( intptr_t offset ) const;
1363   virtual const Type    *xmeet( const Type *t ) const;
1364   virtual const Type    *xdual() const;      // Compute dual right now.
1365 
1366   virtual intptr_t get_con() const;
1367 
1368   // Convenience common pre-built types.
1369   static const TypeKlassPtr* OBJECT; // Not-null object klass or below
1370   static const TypeKlassPtr* OBJECT_OR_NULL; // Maybe-null version of same
1371 #ifndef PRODUCT
1372   virtual void dump2( Dict &d, uint depth, outputStream *st ) const; // Specialized per-Type dumping
1373 #endif
1374 };
1375 
1376 class TypeNarrowPtr : public Type {
1377 protected:
1378   const TypePtr* _ptrtype; // Could be TypePtr::NULL_PTR
1379 
1380   TypeNarrowPtr(TYPES t, const TypePtr* ptrtype): Type(t),
1381                                                   _ptrtype(ptrtype) {
1382     assert(ptrtype->offset() == 0 ||
1383            ptrtype->offset() == OffsetBot ||
1384            ptrtype->offset() == OffsetTop, "no real offsets");
1385   }
1386 
1387   virtual const TypeNarrowPtr *isa_same_narrowptr(const Type *t) const = 0;
1388   virtual const TypeNarrowPtr *is_same_narrowptr(const Type *t) const = 0;
1389   virtual const TypeNarrowPtr *make_same_narrowptr(const TypePtr *t) const = 0;
1390   virtual const TypeNarrowPtr *make_hash_same_narrowptr(const TypePtr *t) const = 0;
1391   // Do not allow interface-vs.-noninterface joins to collapse to top.
1392   virtual const Type *filter_helper(const Type *kills, bool include_speculative) const;
1393 public:
1394   virtual bool eq( const Type *t ) const;
1395   virtual int  hash() const;             // Type specific hashing
1396   virtual bool singleton(void) const;    // TRUE if type is a singleton
1397 
1398   virtual const Type *xmeet( const Type *t ) const;
1399   virtual const Type *xdual() const;    // Compute dual right now.
1400 
1401   virtual intptr_t get_con() const;
1402 
1403   virtual bool empty(void) const;        // TRUE if type is vacuous
1404 
1405   // returns the equivalent ptr type for this compressed pointer
1406   const TypePtr *get_ptrtype() const {
1407     return _ptrtype;
1408   }
1409 
1410   bool is_known_instance() const {
1411     return _ptrtype->is_known_instance();
1412   }
1413 
1414 #ifndef PRODUCT
1415   virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
1416 #endif
1417 };
1418 
1419 //------------------------------TypeNarrowOop----------------------------------
1420 // A compressed reference to some kind of Oop.  This type wraps around
1421 // a preexisting TypeOopPtr and forwards most of it's operations to
1422 // the underlying type.  It's only real purpose is to track the
1423 // oopness of the compressed oop value when we expose the conversion
1424 // between the normal and the compressed form.
1425 class TypeNarrowOop : public TypeNarrowPtr {
1426 protected:
1427   TypeNarrowOop( const TypePtr* ptrtype): TypeNarrowPtr(NarrowOop, ptrtype) {
1428   }
1429 
1430   virtual const TypeNarrowPtr *isa_same_narrowptr(const Type *t) const {
1431     return t->isa_narrowoop();
1432   }
1433 
1434   virtual const TypeNarrowPtr *is_same_narrowptr(const Type *t) const {
1435     return t->is_narrowoop();
1436   }
1437 
1438   virtual const TypeNarrowPtr *make_same_narrowptr(const TypePtr *t) const {
1439     return new TypeNarrowOop(t);
1440   }
1441 
1442   virtual const TypeNarrowPtr *make_hash_same_narrowptr(const TypePtr *t) const {
1443     return (const TypeNarrowPtr*)((new TypeNarrowOop(t))->hashcons());
1444   }
1445 
1446 public:
1447 
1448   static const TypeNarrowOop *make( const TypePtr* type);
1449 
1450   static const TypeNarrowOop* make_from_constant(ciObject* con, bool require_constant = false) {
1451     return make(TypeOopPtr::make_from_constant(con, require_constant));
1452   }
1453 
1454   static const TypeNarrowOop *BOTTOM;
1455   static const TypeNarrowOop *NULL_PTR;
1456 
1457   virtual const Type* remove_speculative() const;
1458   virtual const Type* cleanup_speculative() const;
1459 
1460 #ifndef PRODUCT
1461   virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
1462 #endif
1463 };
1464 
1465 //------------------------------TypeNarrowKlass----------------------------------
1466 // A compressed reference to klass pointer.  This type wraps around a
1467 // preexisting TypeKlassPtr and forwards most of it's operations to
1468 // the underlying type.
1469 class TypeNarrowKlass : public TypeNarrowPtr {
1470 protected:
1471   TypeNarrowKlass( const TypePtr* ptrtype): TypeNarrowPtr(NarrowKlass, ptrtype) {
1472   }
1473 
1474   virtual const TypeNarrowPtr *isa_same_narrowptr(const Type *t) const {
1475     return t->isa_narrowklass();
1476   }
1477 
1478   virtual const TypeNarrowPtr *is_same_narrowptr(const Type *t) const {
1479     return t->is_narrowklass();
1480   }
1481 
1482   virtual const TypeNarrowPtr *make_same_narrowptr(const TypePtr *t) const {
1483     return new TypeNarrowKlass(t);
1484   }
1485 
1486   virtual const TypeNarrowPtr *make_hash_same_narrowptr(const TypePtr *t) const {
1487     return (const TypeNarrowPtr*)((new TypeNarrowKlass(t))->hashcons());
1488   }
1489 
1490 public:
1491   static const TypeNarrowKlass *make( const TypePtr* type);
1492 
1493   // static const TypeNarrowKlass *BOTTOM;
1494   static const TypeNarrowKlass *NULL_PTR;
1495 
1496 #ifndef PRODUCT
1497   virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
1498 #endif
1499 };
1500 
1501 //------------------------------TypeFunc---------------------------------------
1502 // Class of Array Types
1503 class TypeFunc : public Type {
1504   TypeFunc( const TypeTuple *domain, const TypeTuple *range ) : Type(Function),  _domain(domain), _range(range) {}
1505   virtual bool eq( const Type *t ) const;
1506   virtual int  hash() const;             // Type specific hashing
1507   virtual bool singleton(void) const;    // TRUE if type is a singleton
1508   virtual bool empty(void) const;        // TRUE if type is vacuous
1509 
1510   const TypeTuple* const _domain;     // Domain of inputs
1511   const TypeTuple* const _range;      // Range of results
1512 
1513 public:
1514   // Constants are shared among ADLC and VM
1515   enum { Control    = AdlcVMDeps::Control,
1516          I_O        = AdlcVMDeps::I_O,
1517          Memory     = AdlcVMDeps::Memory,
1518          FramePtr   = AdlcVMDeps::FramePtr,
1519          ReturnAdr  = AdlcVMDeps::ReturnAdr,
1520          Parms      = AdlcVMDeps::Parms
1521   };
1522 
1523 
1524   // Accessors:
1525   const TypeTuple* domain() const { return _domain; }
1526   const TypeTuple* range()  const { return _range; }
1527 
1528   static const TypeFunc *make(ciMethod* method);
1529   static const TypeFunc *make(ciSignature signature, const Type* extra);
1530   static const TypeFunc *make(const TypeTuple* domain, const TypeTuple* range);
1531 
1532   virtual const Type *xmeet( const Type *t ) const;
1533   virtual const Type *xdual() const;    // Compute dual right now.
1534 
1535   BasicType return_type() const;
1536 
1537 #ifndef PRODUCT
1538   virtual void dump2( Dict &d, uint depth, outputStream *st ) const; // Specialized per-Type dumping
1539 #endif
1540   // Convenience common pre-built types.
1541 };
1542 
1543 //------------------------------accessors--------------------------------------
1544 inline bool Type::is_ptr_to_narrowoop() const {
1545 #ifdef _LP64
1546   return (isa_oopptr() != NULL && is_oopptr()->is_ptr_to_narrowoop_nv());
1547 #else
1548   return false;
1549 #endif
1550 }
1551 
1552 inline bool Type::is_ptr_to_narrowklass() const {
1553 #ifdef _LP64
1554   return (isa_oopptr() != NULL && is_oopptr()->is_ptr_to_narrowklass_nv());
1555 #else
1556   return false;
1557 #endif
1558 }
1559 
1560 inline float Type::getf() const {
1561   assert( _base == FloatCon, "Not a FloatCon" );
1562   return ((TypeF*)this)->_f;
1563 }
1564 
1565 inline double Type::getd() const {
1566   assert( _base == DoubleCon, "Not a DoubleCon" );
1567   return ((TypeD*)this)->_d;
1568 }
1569 
1570 inline const TypeInt *Type::is_int() const {
1571   assert( _base == Int, "Not an Int" );
1572   return (TypeInt*)this;
1573 }
1574 
1575 inline const TypeInt *Type::isa_int() const {
1576   return ( _base == Int ? (TypeInt*)this : NULL);
1577 }
1578 
1579 inline const TypeLong *Type::is_long() const {
1580   assert( _base == Long, "Not a Long" );
1581   return (TypeLong*)this;
1582 }
1583 
1584 inline const TypeLong *Type::isa_long() const {
1585   return ( _base == Long ? (TypeLong*)this : NULL);
1586 }
1587 
1588 inline const TypeF *Type::isa_float() const {
1589   return ((_base == FloatTop ||
1590            _base == FloatCon ||
1591            _base == FloatBot) ? (TypeF*)this : NULL);
1592 }
1593 
1594 inline const TypeF *Type::is_float_constant() const {
1595   assert( _base == FloatCon, "Not a Float" );
1596   return (TypeF*)this;
1597 }
1598 
1599 inline const TypeF *Type::isa_float_constant() const {
1600   return ( _base == FloatCon ? (TypeF*)this : NULL);
1601 }
1602 
1603 inline const TypeD *Type::isa_double() const {
1604   return ((_base == DoubleTop ||
1605            _base == DoubleCon ||
1606            _base == DoubleBot) ? (TypeD*)this : NULL);
1607 }
1608 
1609 inline const TypeD *Type::is_double_constant() const {
1610   assert( _base == DoubleCon, "Not a Double" );
1611   return (TypeD*)this;
1612 }
1613 
1614 inline const TypeD *Type::isa_double_constant() const {
1615   return ( _base == DoubleCon ? (TypeD*)this : NULL);
1616 }
1617 
1618 inline const TypeTuple *Type::is_tuple() const {
1619   assert( _base == Tuple, "Not a Tuple" );
1620   return (TypeTuple*)this;
1621 }
1622 
1623 inline const TypeAry *Type::is_ary() const {
1624   assert( _base == Array , "Not an Array" );
1625   return (TypeAry*)this;
1626 }
1627 
1628 inline const TypeAry *Type::isa_ary() const {
1629   return ((_base == Array) ? (TypeAry*)this : NULL);
1630 }
1631 
1632 inline const TypeVect *Type::is_vect() const {
1633   assert( _base >= VectorA && _base <= VectorZ, "Not a Vector" );
1634   return (TypeVect*)this;
1635 }
1636 
1637 inline const TypeVect *Type::isa_vect() const {
1638   return (_base >= VectorA && _base <= VectorZ) ? (TypeVect*)this : NULL;
1639 }
1640 
1641 inline const TypePtr *Type::is_ptr() const {
1642   // AnyPtr is the first Ptr and KlassPtr the last, with no non-ptrs between.
1643   assert(_base >= AnyPtr && _base <= KlassPtr, "Not a pointer");
1644   return (TypePtr*)this;
1645 }
1646 
1647 inline const TypePtr *Type::isa_ptr() const {
1648   // AnyPtr is the first Ptr and KlassPtr the last, with no non-ptrs between.
1649   return (_base >= AnyPtr && _base <= KlassPtr) ? (TypePtr*)this : NULL;
1650 }
1651 
1652 inline const TypeOopPtr *Type::is_oopptr() const {
1653   // OopPtr is the first and KlassPtr the last, with no non-oops between.
1654   assert(_base >= OopPtr && _base <= AryPtr, "Not a Java pointer" ) ;
1655   return (TypeOopPtr*)this;
1656 }
1657 
1658 inline const TypeOopPtr *Type::isa_oopptr() const {
1659   // OopPtr is the first and KlassPtr the last, with no non-oops between.
1660   return (_base >= OopPtr && _base <= AryPtr) ? (TypeOopPtr*)this : NULL;
1661 }
1662 
1663 inline const TypeRawPtr *Type::isa_rawptr() const {
1664   return (_base == RawPtr) ? (TypeRawPtr*)this : NULL;
1665 }
1666 
1667 inline const TypeRawPtr *Type::is_rawptr() const {
1668   assert( _base == RawPtr, "Not a raw pointer" );
1669   return (TypeRawPtr*)this;
1670 }
1671 
1672 inline const TypeInstPtr *Type::isa_instptr() const {
1673   return (_base == InstPtr) ? (TypeInstPtr*)this : NULL;
1674 }
1675 
1676 inline const TypeInstPtr *Type::is_instptr() const {
1677   assert( _base == InstPtr, "Not an object pointer" );
1678   return (TypeInstPtr*)this;
1679 }
1680 
1681 inline const TypeAryPtr *Type::isa_aryptr() const {
1682   return (_base == AryPtr) ? (TypeAryPtr*)this : NULL;
1683 }
1684 
1685 inline const TypeAryPtr *Type::is_aryptr() const {
1686   assert( _base == AryPtr, "Not an array pointer" );
1687   return (TypeAryPtr*)this;
1688 }
1689 
1690 inline const TypeNarrowOop *Type::is_narrowoop() const {
1691   // OopPtr is the first and KlassPtr the last, with no non-oops between.
1692   assert(_base == NarrowOop, "Not a narrow oop" ) ;
1693   return (TypeNarrowOop*)this;
1694 }
1695 
1696 inline const TypeNarrowOop *Type::isa_narrowoop() const {
1697   // OopPtr is the first and KlassPtr the last, with no non-oops between.
1698   return (_base == NarrowOop) ? (TypeNarrowOop*)this : NULL;
1699 }
1700 
1701 inline const TypeNarrowKlass *Type::is_narrowklass() const {
1702   assert(_base == NarrowKlass, "Not a narrow oop" ) ;
1703   return (TypeNarrowKlass*)this;
1704 }
1705 
1706 inline const TypeNarrowKlass *Type::isa_narrowklass() const {
1707   return (_base == NarrowKlass) ? (TypeNarrowKlass*)this : NULL;
1708 }
1709 
1710 inline const TypeMetadataPtr *Type::is_metadataptr() const {
1711   // MetadataPtr is the first and CPCachePtr the last
1712   assert(_base == MetadataPtr, "Not a metadata pointer" ) ;
1713   return (TypeMetadataPtr*)this;
1714 }
1715 
1716 inline const TypeMetadataPtr *Type::isa_metadataptr() const {
1717   return (_base == MetadataPtr) ? (TypeMetadataPtr*)this : NULL;
1718 }
1719 
1720 inline const TypeKlassPtr *Type::isa_klassptr() const {
1721   return (_base == KlassPtr) ? (TypeKlassPtr*)this : NULL;
1722 }
1723 
1724 inline const TypeKlassPtr *Type::is_klassptr() const {
1725   assert( _base == KlassPtr, "Not a klass pointer" );
1726   return (TypeKlassPtr*)this;
1727 }
1728 
1729 inline const TypePtr* Type::make_ptr() const {
1730   return (_base == NarrowOop) ? is_narrowoop()->get_ptrtype() :
1731                               ((_base == NarrowKlass) ? is_narrowklass()->get_ptrtype() :
1732                                                        isa_ptr());
1733 }
1734 
1735 inline const TypeOopPtr* Type::make_oopptr() const {
1736   return (_base == NarrowOop) ? is_narrowoop()->get_ptrtype()->isa_oopptr() : isa_oopptr();
1737 }
1738 
1739 inline const TypeNarrowOop* Type::make_narrowoop() const {
1740   return (_base == NarrowOop) ? is_narrowoop() :
1741                                 (isa_ptr() ? TypeNarrowOop::make(is_ptr()) : NULL);
1742 }
1743 
1744 inline const TypeNarrowKlass* Type::make_narrowklass() const {
1745   return (_base == NarrowKlass) ? is_narrowklass() :
1746                                   (isa_ptr() ? TypeNarrowKlass::make(is_ptr()) : NULL);
1747 }
1748 
1749 inline bool Type::is_floatingpoint() const {
1750   if( (_base == FloatCon)  || (_base == FloatBot) ||
1751       (_base == DoubleCon) || (_base == DoubleBot) )
1752     return true;
1753   return false;
1754 }
1755 
1756 inline bool Type::is_ptr_to_boxing_obj() const {
1757   const TypeInstPtr* tp = isa_instptr();
1758   return (tp != NULL) && (tp->offset() == 0) &&
1759          tp->klass()->is_instance_klass()  &&
1760          tp->klass()->as_instance_klass()->is_box_klass();
1761 }
1762 
1763 
1764 // ===============================================================
1765 // Things that need to be 64-bits in the 64-bit build but
1766 // 32-bits in the 32-bit build.  Done this way to get full
1767 // optimization AND strong typing.
1768 #ifdef _LP64
1769 
1770 // For type queries and asserts
1771 #define is_intptr_t  is_long
1772 #define isa_intptr_t isa_long
1773 #define find_intptr_t_type find_long_type
1774 #define find_intptr_t_con  find_long_con
1775 #define TypeX        TypeLong
1776 #define Type_X       Type::Long
1777 #define TypeX_X      TypeLong::LONG
1778 #define TypeX_ZERO   TypeLong::ZERO
1779 // For 'ideal_reg' machine registers
1780 #define Op_RegX      Op_RegL
1781 // For phase->intcon variants
1782 #define MakeConX     longcon
1783 #define ConXNode     ConLNode
1784 // For array index arithmetic
1785 #define MulXNode     MulLNode
1786 #define AndXNode     AndLNode
1787 #define OrXNode      OrLNode
1788 #define CmpXNode     CmpLNode
1789 #define SubXNode     SubLNode
1790 #define LShiftXNode  LShiftLNode
1791 // For object size computation:
1792 #define AddXNode     AddLNode
1793 #define RShiftXNode  RShiftLNode
1794 // For card marks and hashcodes
1795 #define URShiftXNode URShiftLNode
1796 // UseOptoBiasInlining
1797 #define XorXNode     XorLNode
1798 #define StoreXConditionalNode StoreLConditionalNode
1799 #define LoadXNode    LoadLNode
1800 #define StoreXNode   StoreLNode
1801 // Opcodes
1802 #define Op_LShiftX   Op_LShiftL
1803 #define Op_AndX      Op_AndL
1804 #define Op_AddX      Op_AddL
1805 #define Op_SubX      Op_SubL
1806 #define Op_XorX      Op_XorL
1807 #define Op_URShiftX  Op_URShiftL
1808 #define Op_LoadX     Op_LoadL
1809 // conversions
1810 #define ConvI2X(x)   ConvI2L(x)
1811 #define ConvL2X(x)   (x)
1812 #define ConvX2I(x)   ConvL2I(x)
1813 #define ConvX2L(x)   (x)
1814 #define ConvX2UL(x)  (x)
1815 
1816 #else
1817 
1818 // For type queries and asserts
1819 #define is_intptr_t  is_int
1820 #define isa_intptr_t isa_int
1821 #define find_intptr_t_type find_int_type
1822 #define find_intptr_t_con  find_int_con
1823 #define TypeX        TypeInt
1824 #define Type_X       Type::Int
1825 #define TypeX_X      TypeInt::INT
1826 #define TypeX_ZERO   TypeInt::ZERO
1827 // For 'ideal_reg' machine registers
1828 #define Op_RegX      Op_RegI
1829 // For phase->intcon variants
1830 #define MakeConX     intcon
1831 #define ConXNode     ConINode
1832 // For array index arithmetic
1833 #define MulXNode     MulINode
1834 #define AndXNode     AndINode
1835 #define OrXNode      OrINode
1836 #define CmpXNode     CmpINode
1837 #define SubXNode     SubINode
1838 #define LShiftXNode  LShiftINode
1839 // For object size computation:
1840 #define AddXNode     AddINode
1841 #define RShiftXNode  RShiftINode
1842 // For card marks and hashcodes
1843 #define URShiftXNode URShiftINode
1844 // UseOptoBiasInlining
1845 #define XorXNode     XorINode
1846 #define StoreXConditionalNode StoreIConditionalNode
1847 #define LoadXNode    LoadINode
1848 #define StoreXNode   StoreINode
1849 // Opcodes
1850 #define Op_LShiftX   Op_LShiftI
1851 #define Op_AndX      Op_AndI
1852 #define Op_AddX      Op_AddI
1853 #define Op_SubX      Op_SubI
1854 #define Op_XorX      Op_XorI
1855 #define Op_URShiftX  Op_URShiftI
1856 #define Op_LoadX     Op_LoadI
1857 // conversions
1858 #define ConvI2X(x)   (x)
1859 #define ConvL2X(x)   ConvL2I(x)
1860 #define ConvX2I(x)   (x)
1861 #define ConvX2L(x)   ConvI2L(x)
1862 #define ConvX2UL(x)  ConvI2UL(x)
1863 
1864 #endif
1865 
1866 #endif // SHARE_OPTO_TYPE_HPP