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