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                                         bool is_autobox_cache = false);
 417 
 418   // Speculative type helper methods. See TypePtr.
 419   virtual const TypePtr* speculative() const                                  { return NULL; }
 420   virtual ciKlass* speculative_type() const                                   { return NULL; }
 421   virtual ciKlass* speculative_type_not_null() const                          { return NULL; }
 422   virtual bool speculative_maybe_null() const                                 { return true; }
 423   virtual const Type* remove_speculative() const                              { return this; }
 424   virtual const Type* cleanup_speculative() const                             { return this; }
 425   virtual bool would_improve_type(ciKlass* exact_kls, int inline_depth) const { return exact_kls != NULL; }
 426   virtual bool would_improve_ptr(bool maybe_null) const                       { return !maybe_null; }
 427   const Type* maybe_remove_speculative(bool include_speculative) const;
 428 
 429   virtual bool maybe_null() const { return true; }
 430 
 431 private:
 432   // support arrays
 433   static const BasicType _basic_type[];
 434   static const Type*        _zero_type[T_CONFLICT+1];
 435   static const Type* _const_basic_type[T_CONFLICT+1];
 436 };
 437 
 438 //------------------------------TypeF------------------------------------------
 439 // Class of Float-Constant Types.
 440 class TypeF : public Type {
 441   TypeF( float f ) : Type(FloatCon), _f(f) {};
 442 public:
 443   virtual bool eq( const Type *t ) const;
 444   virtual int  hash() const;             // Type specific hashing
 445   virtual bool singleton(void) const;    // TRUE if type is a singleton
 446   virtual bool empty(void) const;        // TRUE if type is vacuous
 447 public:
 448   const float _f;               // Float constant
 449 
 450   static const TypeF *make(float f);
 451 
 452   virtual bool        is_finite() const;  // Has a finite value
 453   virtual bool        is_nan()    const;  // Is not a number (NaN)
 454 
 455   virtual const Type *xmeet( const Type *t ) const;
 456   virtual const Type *xdual() const;    // Compute dual right now.
 457   // Convenience common pre-built types.
 458   static const TypeF *ZERO; // positive zero only
 459   static const TypeF *ONE;
 460 #ifndef PRODUCT
 461   virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
 462 #endif
 463 };
 464 
 465 //------------------------------TypeD------------------------------------------
 466 // Class of Double-Constant Types.
 467 class TypeD : public Type {
 468   TypeD( double d ) : Type(DoubleCon), _d(d) {};
 469 public:
 470   virtual bool eq( const Type *t ) const;
 471   virtual int  hash() const;             // Type specific hashing
 472   virtual bool singleton(void) const;    // TRUE if type is a singleton
 473   virtual bool empty(void) const;        // TRUE if type is vacuous
 474 public:
 475   const double _d;              // Double constant
 476 
 477   static const TypeD *make(double d);
 478 
 479   virtual bool        is_finite() const;  // Has a finite value
 480   virtual bool        is_nan()    const;  // Is not a number (NaN)
 481 
 482   virtual const Type *xmeet( const Type *t ) const;
 483   virtual const Type *xdual() const;    // Compute dual right now.
 484   // Convenience common pre-built types.
 485   static const TypeD *ZERO; // positive zero only
 486   static const TypeD *ONE;
 487 #ifndef PRODUCT
 488   virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
 489 #endif
 490 };
 491 
 492 //------------------------------TypeInt----------------------------------------
 493 // Class of integer ranges, the set of integers between a lower bound and an
 494 // upper bound, inclusive.
 495 class TypeInt : public Type {
 496   TypeInt( jint lo, jint hi, int w );
 497 protected:
 498   virtual const Type *filter_helper(const Type *kills, bool include_speculative) const;
 499 
 500 public:
 501   typedef jint NativeType;
 502   virtual bool eq( const Type *t ) const;
 503   virtual int  hash() const;             // Type specific hashing
 504   virtual bool singleton(void) const;    // TRUE if type is a singleton
 505   virtual bool empty(void) const;        // TRUE if type is vacuous
 506   const jint _lo, _hi;          // Lower bound, upper bound
 507   const short _widen;           // Limit on times we widen this sucker
 508 
 509   static const TypeInt *make(jint lo);
 510   // must always specify w
 511   static const TypeInt *make(jint lo, jint hi, int w);
 512 
 513   // Check for single integer
 514   int is_con() const { return _lo==_hi; }
 515   bool is_con(int i) const { return is_con() && _lo == i; }
 516   jint get_con() const { assert( is_con(), "" );  return _lo; }
 517 
 518   virtual bool        is_finite() const;  // Has a finite value
 519 
 520   virtual const Type *xmeet( const Type *t ) const;
 521   virtual const Type *xdual() const;    // Compute dual right now.
 522   virtual const Type *widen( const Type *t, const Type* limit_type ) const;
 523   virtual const Type *narrow( const Type *t ) const;
 524   // Do not kill _widen bits.
 525   // Convenience common pre-built types.
 526   static const TypeInt *MINUS_1;
 527   static const TypeInt *ZERO;
 528   static const TypeInt *ONE;
 529   static const TypeInt *BOOL;
 530   static const TypeInt *CC;
 531   static const TypeInt *CC_LT;  // [-1]  == MINUS_1
 532   static const TypeInt *CC_GT;  // [1]   == ONE
 533   static const TypeInt *CC_EQ;  // [0]   == ZERO
 534   static const TypeInt *CC_LE;  // [-1,0]
 535   static const TypeInt *CC_GE;  // [0,1] == BOOL (!)
 536   static const TypeInt *BYTE;
 537   static const TypeInt *UBYTE;
 538   static const TypeInt *CHAR;
 539   static const TypeInt *SHORT;
 540   static const TypeInt *POS;
 541   static const TypeInt *POS1;
 542   static const TypeInt *INT;
 543   static const TypeInt *SYMINT; // symmetric range [-max_jint..max_jint]
 544   static const TypeInt *TYPE_DOMAIN; // alias for TypeInt::INT
 545 
 546   static const TypeInt *as_self(const Type *t) { return t->is_int(); }
 547 #ifndef PRODUCT
 548   virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
 549 #endif
 550 };
 551 
 552 
 553 //------------------------------TypeLong---------------------------------------
 554 // Class of long integer ranges, the set of integers between a lower bound and
 555 // an upper bound, inclusive.
 556 class TypeLong : public Type {
 557   TypeLong( jlong lo, jlong hi, int w );
 558 protected:
 559   // Do not kill _widen bits.
 560   virtual const Type *filter_helper(const Type *kills, bool include_speculative) const;
 561 public:
 562   typedef jlong NativeType;
 563   virtual bool eq( const Type *t ) const;
 564   virtual int  hash() const;             // Type specific hashing
 565   virtual bool singleton(void) const;    // TRUE if type is a singleton
 566   virtual bool empty(void) const;        // TRUE if type is vacuous
 567 public:
 568   const jlong _lo, _hi;         // Lower bound, upper bound
 569   const short _widen;           // Limit on times we widen this sucker
 570 
 571   static const TypeLong *make(jlong lo);
 572   // must always specify w
 573   static const TypeLong *make(jlong lo, jlong hi, int w);
 574 
 575   // Check for single integer
 576   int is_con() const { return _lo==_hi; }
 577   bool is_con(int i) const { return is_con() && _lo == i; }
 578   jlong get_con() const { assert( is_con(), "" ); return _lo; }
 579 
 580   // Check for positive 32-bit value.
 581   int is_positive_int() const { return _lo >= 0 && _hi <= (jlong)max_jint; }
 582 
 583   virtual bool        is_finite() const;  // Has a finite value
 584 
 585 
 586   virtual const Type *xmeet( const Type *t ) const;
 587   virtual const Type *xdual() const;    // Compute dual right now.
 588   virtual const Type *widen( const Type *t, const Type* limit_type ) const;
 589   virtual const Type *narrow( const Type *t ) const;
 590   // Convenience common pre-built types.
 591   static const TypeLong *MINUS_1;
 592   static const TypeLong *ZERO;
 593   static const TypeLong *ONE;
 594   static const TypeLong *POS;
 595   static const TypeLong *LONG;
 596   static const TypeLong *INT;    // 32-bit subrange [min_jint..max_jint]
 597   static const TypeLong *UINT;   // 32-bit unsigned [0..max_juint]
 598   static const TypeLong *TYPE_DOMAIN; // alias for TypeLong::LONG
 599 
 600   // static convenience methods.
 601   static const TypeLong *as_self(const Type *t) { return t->is_long(); }
 602 
 603 #ifndef PRODUCT
 604   virtual void dump2( Dict &d, uint, outputStream *st  ) const;// Specialized per-Type dumping
 605 #endif
 606 };
 607 
 608 //------------------------------TypeTuple--------------------------------------
 609 // Class of Tuple Types, essentially type collections for function signatures
 610 // and class layouts.  It happens to also be a fast cache for the HotSpot
 611 // signature types.
 612 class TypeTuple : public Type {
 613   TypeTuple( uint cnt, const Type **fields ) : Type(Tuple), _cnt(cnt), _fields(fields) { }
 614 
 615   const uint          _cnt;              // Count of fields
 616   const Type ** const _fields;           // Array of field types
 617 
 618 public:
 619   virtual bool eq( const Type *t ) const;
 620   virtual int  hash() const;             // Type specific hashing
 621   virtual bool singleton(void) const;    // TRUE if type is a singleton
 622   virtual bool empty(void) const;        // TRUE if type is vacuous
 623 
 624   // Accessors:
 625   uint cnt() const { return _cnt; }
 626   const Type* field_at(uint i) const {
 627     assert(i < _cnt, "oob");
 628     return _fields[i];
 629   }
 630   void set_field_at(uint i, const Type* t) {
 631     assert(i < _cnt, "oob");
 632     _fields[i] = t;
 633   }
 634 
 635   static const TypeTuple *make( uint cnt, const Type **fields );
 636   static const TypeTuple *make_range(ciSignature *sig);
 637   static const TypeTuple *make_domain(ciInstanceKlass* recv, ciSignature *sig);
 638 
 639   // Subroutine call type with space allocated for argument types
 640   // Memory for Control, I_O, Memory, FramePtr, and ReturnAdr is allocated implicitly
 641   static const Type **fields( uint arg_cnt );
 642 
 643   virtual const Type *xmeet( const Type *t ) const;
 644   virtual const Type *xdual() const;    // Compute dual right now.
 645   // Convenience common pre-built types.
 646   static const TypeTuple *IFBOTH;
 647   static const TypeTuple *IFFALSE;
 648   static const TypeTuple *IFTRUE;
 649   static const TypeTuple *IFNEITHER;
 650   static const TypeTuple *LOOPBODY;
 651   static const TypeTuple *MEMBAR;
 652   static const TypeTuple *STORECONDITIONAL;
 653   static const TypeTuple *START_I2C;
 654   static const TypeTuple *INT_PAIR;
 655   static const TypeTuple *LONG_PAIR;
 656   static const TypeTuple *INT_CC_PAIR;
 657   static const TypeTuple *LONG_CC_PAIR;
 658 #ifndef PRODUCT
 659   virtual void dump2( Dict &d, uint, outputStream *st  ) const; // Specialized per-Type dumping
 660 #endif
 661 };
 662 
 663 //------------------------------TypeAry----------------------------------------
 664 // Class of Array Types
 665 class TypeAry : public Type {
 666   TypeAry(const Type* elem, const TypeInt* size, bool stable) : Type(Array),
 667       _elem(elem), _size(size), _stable(stable) {}
 668 public:
 669   virtual bool eq( const Type *t ) const;
 670   virtual int  hash() const;             // Type specific hashing
 671   virtual bool singleton(void) const;    // TRUE if type is a singleton
 672   virtual bool empty(void) const;        // TRUE if type is vacuous
 673 
 674 private:
 675   const Type *_elem;            // Element type of array
 676   const TypeInt *_size;         // Elements in array
 677   const bool _stable;           // Are elements @Stable?
 678   friend class TypeAryPtr;
 679 
 680 public:
 681   static const TypeAry* make(const Type* elem, const TypeInt* size, bool stable = false);
 682 
 683   virtual const Type *xmeet( const Type *t ) const;
 684   virtual const Type *xdual() const;    // Compute dual right now.
 685   bool ary_must_be_exact() const;  // true if arrays of such are never generic
 686   virtual const Type* remove_speculative() const;
 687   virtual const Type* cleanup_speculative() const;
 688 #ifdef ASSERT
 689   // One type is interface, the other is oop
 690   virtual bool interface_vs_oop(const Type *t) const;
 691 #endif
 692 #ifndef PRODUCT
 693   virtual void dump2( Dict &d, uint, outputStream *st  ) const; // Specialized per-Type dumping
 694 #endif
 695 };
 696 
 697 //------------------------------TypeVect---------------------------------------
 698 // Class of Vector Types
 699 class TypeVect : public Type {
 700   const Type*   _elem;  // Vector's element type
 701   const uint  _length;  // Elements in vector (power of 2)
 702 
 703 protected:
 704   TypeVect(TYPES t, const Type* elem, uint length) : Type(t),
 705     _elem(elem), _length(length) {}
 706 
 707 public:
 708   const Type* element_type() const { return _elem; }
 709   BasicType element_basic_type() const { return _elem->array_element_basic_type(); }
 710   uint length() const { return _length; }
 711   uint length_in_bytes() const {
 712    return _length * type2aelembytes(element_basic_type());
 713   }
 714 
 715   virtual bool eq(const Type *t) const;
 716   virtual int  hash() const;             // Type specific hashing
 717   virtual bool singleton(void) const;    // TRUE if type is a singleton
 718   virtual bool empty(void) const;        // TRUE if type is vacuous
 719 
 720   static const TypeVect *make(const BasicType elem_bt, uint length) {
 721     // Use bottom primitive type.
 722     return make(get_const_basic_type(elem_bt), length);
 723   }
 724   // Used directly by Replicate nodes to construct singleton vector.
 725   static const TypeVect *make(const Type* elem, uint length);
 726 
 727   virtual const Type *xmeet( const Type *t) const;
 728   virtual const Type *xdual() const;     // Compute dual right now.
 729 
 730   static const TypeVect *VECTS;
 731   static const TypeVect *VECTD;
 732   static const TypeVect *VECTX;
 733   static const TypeVect *VECTY;
 734   static const TypeVect *VECTZ;
 735 
 736 #ifndef PRODUCT
 737   virtual void dump2(Dict &d, uint, outputStream *st) const; // Specialized per-Type dumping
 738 #endif
 739 };
 740 
 741 class TypeVectS : public TypeVect {
 742   friend class TypeVect;
 743   TypeVectS(const Type* elem, uint length) : TypeVect(VectorS, elem, length) {}
 744 };
 745 
 746 class TypeVectD : public TypeVect {
 747   friend class TypeVect;
 748   TypeVectD(const Type* elem, uint length) : TypeVect(VectorD, elem, length) {}
 749 };
 750 
 751 class TypeVectX : public TypeVect {
 752   friend class TypeVect;
 753   TypeVectX(const Type* elem, uint length) : TypeVect(VectorX, elem, length) {}
 754 };
 755 
 756 class TypeVectY : public TypeVect {
 757   friend class TypeVect;
 758   TypeVectY(const Type* elem, uint length) : TypeVect(VectorY, elem, length) {}
 759 };
 760 
 761 class TypeVectZ : public TypeVect {
 762   friend class TypeVect;
 763   TypeVectZ(const Type* elem, uint length) : TypeVect(VectorZ, elem, length) {}
 764 };
 765 
 766 //------------------------------TypePtr----------------------------------------
 767 // Class of machine Pointer Types: raw data, instances or arrays.
 768 // If the _base enum is AnyPtr, then this refers to all of the above.
 769 // Otherwise the _base will indicate which subset of pointers is affected,
 770 // and the class will be inherited from.
 771 class TypePtr : public Type {
 772   friend class TypeNarrowPtr;
 773 public:
 774   enum PTR { TopPTR, AnyNull, Constant, Null, NotNull, BotPTR, lastPTR };
 775 protected:
 776   TypePtr(TYPES t, PTR ptr, int offset,
 777           const TypePtr* speculative = NULL,
 778           int inline_depth = InlineDepthBottom) :
 779     Type(t), _ptr(ptr), _offset(offset), _speculative(speculative),
 780     _inline_depth(inline_depth) {}
 781   static const PTR ptr_meet[lastPTR][lastPTR];
 782   static const PTR ptr_dual[lastPTR];
 783   static const char * const ptr_msg[lastPTR];
 784 
 785   enum {
 786     InlineDepthBottom = INT_MAX,
 787     InlineDepthTop = -InlineDepthBottom
 788   };
 789 
 790   // Extra type information profiling gave us. We propagate it the
 791   // same way the rest of the type info is propagated. If we want to
 792   // use it, then we have to emit a guard: this part of the type is
 793   // not something we know but something we speculate about the type.
 794   const TypePtr*   _speculative;
 795   // For speculative types, we record at what inlining depth the
 796   // profiling point that provided the data is. We want to favor
 797   // profile data coming from outer scopes which are likely better for
 798   // the current compilation.
 799   int _inline_depth;
 800 
 801   // utility methods to work on the speculative part of the type
 802   const TypePtr* dual_speculative() const;
 803   const TypePtr* xmeet_speculative(const TypePtr* other) const;
 804   bool eq_speculative(const TypePtr* other) const;
 805   int hash_speculative() const;
 806   const TypePtr* add_offset_speculative(intptr_t offset) const;
 807 #ifndef PRODUCT
 808   void dump_speculative(outputStream *st) const;
 809 #endif
 810 
 811   // utility methods to work on the inline depth of the type
 812   int dual_inline_depth() const;
 813   int meet_inline_depth(int depth) const;
 814 #ifndef PRODUCT
 815   void dump_inline_depth(outputStream *st) const;
 816 #endif
 817 
 818 public:
 819   const int _offset;            // Offset into oop, with TOP & BOT
 820   const PTR _ptr;               // Pointer equivalence class
 821 
 822   const int offset() const { return _offset; }
 823   const PTR ptr()    const { return _ptr; }
 824 
 825   static const TypePtr *make(TYPES t, PTR ptr, int offset,
 826                              const TypePtr* speculative = NULL,
 827                              int inline_depth = InlineDepthBottom);
 828 
 829   // Return a 'ptr' version of this type
 830   virtual const Type *cast_to_ptr_type(PTR ptr) const;
 831 
 832   virtual intptr_t get_con() const;
 833 
 834   int xadd_offset( intptr_t offset ) const;
 835   virtual const TypePtr *add_offset( intptr_t offset ) const;
 836   virtual bool eq(const Type *t) const;
 837   virtual int  hash() const;             // Type specific hashing
 838 
 839   virtual bool singleton(void) const;    // TRUE if type is a singleton
 840   virtual bool empty(void) const;        // TRUE if type is vacuous
 841   virtual const Type *xmeet( const Type *t ) const;
 842   virtual const Type *xmeet_helper( const Type *t ) const;
 843   int meet_offset( int offset ) const;
 844   int dual_offset( ) const;
 845   virtual const Type *xdual() const;    // Compute dual right now.
 846 
 847   // meet, dual and join over pointer equivalence sets
 848   PTR meet_ptr( const PTR in_ptr ) const { return ptr_meet[in_ptr][ptr()]; }
 849   PTR dual_ptr()                   const { return ptr_dual[ptr()];      }
 850 
 851   // This is textually confusing unless one recalls that
 852   // join(t) == dual()->meet(t->dual())->dual().
 853   PTR join_ptr( const PTR in_ptr ) const {
 854     return ptr_dual[ ptr_meet[ ptr_dual[in_ptr] ] [ dual_ptr() ] ];
 855   }
 856 
 857   // Speculative type helper methods.
 858   virtual const TypePtr* speculative() const { return _speculative; }
 859   int inline_depth() const                   { return _inline_depth; }
 860   virtual ciKlass* speculative_type() const;
 861   virtual ciKlass* speculative_type_not_null() const;
 862   virtual bool speculative_maybe_null() const;
 863   virtual const Type* remove_speculative() const;
 864   virtual const Type* cleanup_speculative() const;
 865   virtual bool would_improve_type(ciKlass* exact_kls, int inline_depth) const;
 866   virtual bool would_improve_ptr(bool maybe_null) const;
 867   virtual const TypePtr* with_inline_depth(int depth) const;
 868 
 869   virtual bool maybe_null() const { return meet_ptr(Null) == ptr(); }
 870 
 871   // Tests for relation to centerline of type lattice:
 872   static bool above_centerline(PTR ptr) { return (ptr <= AnyNull); }
 873   static bool below_centerline(PTR ptr) { return (ptr >= NotNull); }
 874   // Convenience common pre-built types.
 875   static const TypePtr *NULL_PTR;
 876   static const TypePtr *NOTNULL;
 877   static const TypePtr *BOTTOM;
 878 #ifndef PRODUCT
 879   virtual void dump2( Dict &d, uint depth, outputStream *st  ) const;
 880 #endif
 881 };
 882 
 883 //------------------------------TypeRawPtr-------------------------------------
 884 // Class of raw pointers, pointers to things other than Oops.  Examples
 885 // include the stack pointer, top of heap, card-marking area, handles, etc.
 886 class TypeRawPtr : public TypePtr {
 887 protected:
 888   TypeRawPtr( PTR ptr, address bits ) : TypePtr(RawPtr,ptr,0), _bits(bits){}
 889 public:
 890   virtual bool eq( const Type *t ) const;
 891   virtual int  hash() const;     // Type specific hashing
 892 
 893   const address _bits;          // Constant value, if applicable
 894 
 895   static const TypeRawPtr *make( PTR ptr );
 896   static const TypeRawPtr *make( address bits );
 897 
 898   // Return a 'ptr' version of this type
 899   virtual const Type *cast_to_ptr_type(PTR ptr) const;
 900 
 901   virtual intptr_t get_con() const;
 902 
 903   virtual const TypePtr *add_offset( intptr_t offset ) const;
 904 
 905   virtual const Type *xmeet( const Type *t ) const;
 906   virtual const Type *xdual() const;    // Compute dual right now.
 907   // Convenience common pre-built types.
 908   static const TypeRawPtr *BOTTOM;
 909   static const TypeRawPtr *NOTNULL;
 910 #ifndef PRODUCT
 911   virtual void dump2( Dict &d, uint depth, outputStream *st  ) const;
 912 #endif
 913 };
 914 
 915 //------------------------------TypeOopPtr-------------------------------------
 916 // Some kind of oop (Java pointer), either klass or instance or array.
 917 class TypeOopPtr : public TypePtr {
 918 protected:
 919   TypeOopPtr(TYPES t, PTR ptr, ciKlass* k, bool xk, ciObject* o, int offset, int instance_id,
 920              const TypePtr* speculative, int inline_depth);
 921 public:
 922   virtual bool eq( const Type *t ) const;
 923   virtual int  hash() const;             // Type specific hashing
 924   virtual bool singleton(void) const;    // TRUE if type is a singleton
 925   enum {
 926    InstanceTop = -1,   // undefined instance
 927    InstanceBot = 0     // any possible instance
 928   };
 929 protected:
 930 
 931   // Oop is NULL, unless this is a constant oop.
 932   ciObject*     _const_oop;   // Constant oop
 933   // If _klass is NULL, then so is _sig.  This is an unloaded klass.
 934   ciKlass*      _klass;       // Klass object
 935   // Does the type exclude subclasses of the klass?  (Inexact == polymorphic.)
 936   bool          _klass_is_exact;
 937   bool          _is_ptr_to_narrowoop;
 938   bool          _is_ptr_to_narrowklass;
 939   bool          _is_ptr_to_boxed_value;
 940 
 941   // If not InstanceTop or InstanceBot, indicates that this is
 942   // a particular instance of this type which is distinct.
 943   // This is the the node index of the allocation node creating this instance.
 944   int           _instance_id;
 945 
 946   static const TypeOopPtr* make_from_klass_common(ciKlass* klass, bool klass_change, bool try_for_exact);
 947 
 948   int dual_instance_id() const;
 949   int meet_instance_id(int uid) const;
 950 
 951   // Do not allow interface-vs.-noninterface joins to collapse to top.
 952   virtual const Type *filter_helper(const Type *kills, bool include_speculative) const;
 953 
 954 public:
 955   // Creates a type given a klass. Correctly handles multi-dimensional arrays
 956   // Respects UseUniqueSubclasses.
 957   // If the klass is final, the resulting type will be exact.
 958   static const TypeOopPtr* make_from_klass(ciKlass* klass) {
 959     return make_from_klass_common(klass, true, false);
 960   }
 961   // Same as before, but will produce an exact type, even if
 962   // the klass is not final, as long as it has exactly one implementation.
 963   static const TypeOopPtr* make_from_klass_unique(ciKlass* klass) {
 964     return make_from_klass_common(klass, true, true);
 965   }
 966   // Same as before, but does not respects UseUniqueSubclasses.
 967   // Use this only for creating array element types.
 968   static const TypeOopPtr* make_from_klass_raw(ciKlass* klass) {
 969     return make_from_klass_common(klass, false, false);
 970   }
 971   // Creates a singleton type given an object.
 972   // If the object cannot be rendered as a constant,
 973   // may return a non-singleton type.
 974   // If require_constant, produce a NULL if a singleton is not possible.
 975   static const TypeOopPtr* make_from_constant(ciObject* o,
 976                                               bool require_constant = false,
 977                                               bool not_null_elements = 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   // Convenience common pre-built types.
1188   static const TypeAryPtr *RANGE;
1189   static const TypeAryPtr *OOPS;
1190   static const TypeAryPtr *NARROWOOPS;
1191   static const TypeAryPtr *BYTES;
1192   static const TypeAryPtr *SHORTS;
1193   static const TypeAryPtr *CHARS;
1194   static const TypeAryPtr *INTS;
1195   static const TypeAryPtr *LONGS;
1196   static const TypeAryPtr *FLOATS;
1197   static const TypeAryPtr *DOUBLES;
1198   // selects one of the above:
1199   static const TypeAryPtr *get_array_body_type(BasicType elem) {
1200     assert((uint)elem <= T_CONFLICT && _array_body_type[elem] != NULL, "bad elem type");
1201     return _array_body_type[elem];
1202   }
1203   static const TypeAryPtr *_array_body_type[T_CONFLICT+1];
1204   // sharpen the type of an int which is used as an array size
1205 #ifdef ASSERT
1206   // One type is interface, the other is oop
1207   virtual bool interface_vs_oop(const Type *t) const;
1208 #endif
1209 #ifndef PRODUCT
1210   virtual void dump2( Dict &d, uint depth, outputStream *st ) const; // Specialized per-Type dumping
1211 #endif
1212 };
1213 
1214 //------------------------------TypeMetadataPtr-------------------------------------
1215 // Some kind of metadata, either Method*, MethodData* or CPCacheOop
1216 class TypeMetadataPtr : public TypePtr {
1217 protected:
1218   TypeMetadataPtr(PTR ptr, ciMetadata* metadata, int offset);
1219   // Do not allow interface-vs.-noninterface joins to collapse to top.
1220   virtual const Type *filter_helper(const Type *kills, bool include_speculative) const;
1221 public:
1222   virtual bool eq( const Type *t ) const;
1223   virtual int  hash() const;             // Type specific hashing
1224   virtual bool singleton(void) const;    // TRUE if type is a singleton
1225 
1226 private:
1227   ciMetadata*   _metadata;
1228 
1229 public:
1230   static const TypeMetadataPtr* make(PTR ptr, ciMetadata* m, int offset);
1231 
1232   static const TypeMetadataPtr* make(ciMethod* m);
1233   static const TypeMetadataPtr* make(ciMethodData* m);
1234 
1235   ciMetadata* metadata() const { return _metadata; }
1236 
1237   virtual const Type *cast_to_ptr_type(PTR ptr) const;
1238 
1239   virtual const TypePtr *add_offset( intptr_t offset ) const;
1240 
1241   virtual const Type *xmeet( const Type *t ) const;
1242   virtual const Type *xdual() const;    // Compute dual right now.
1243 
1244   virtual intptr_t get_con() const;
1245 
1246   // Convenience common pre-built types.
1247   static const TypeMetadataPtr *BOTTOM;
1248 
1249 #ifndef PRODUCT
1250   virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
1251 #endif
1252 };
1253 
1254 //------------------------------TypeKlassPtr-----------------------------------
1255 // Class of Java Klass pointers
1256 class TypeKlassPtr : public TypePtr {
1257   TypeKlassPtr( PTR ptr, ciKlass* klass, int offset );
1258 
1259 protected:
1260   virtual const Type *filter_helper(const Type *kills, bool include_speculative) const;
1261  public:
1262   virtual bool eq( const Type *t ) const;
1263   virtual int hash() const;             // Type specific hashing
1264   virtual bool singleton(void) const;    // TRUE if type is a singleton
1265  private:
1266 
1267   static const TypeKlassPtr* make_from_klass_common(ciKlass* klass, bool klass_change, bool try_for_exact);
1268 
1269   ciKlass* _klass;
1270 
1271   // Does the type exclude subclasses of the klass?  (Inexact == polymorphic.)
1272   bool          _klass_is_exact;
1273 
1274 public:
1275   ciSymbol* name()  const { return klass()->name(); }
1276 
1277   ciKlass* klass() const { return  _klass; }
1278   bool klass_is_exact()    const { return _klass_is_exact; }
1279 
1280   bool  is_loaded() const { return klass()->is_loaded(); }
1281 
1282   // Creates a type given a klass. Correctly handles multi-dimensional arrays
1283   // Respects UseUniqueSubclasses.
1284   // If the klass is final, the resulting type will be exact.
1285   static const TypeKlassPtr* make_from_klass(ciKlass* klass) {
1286     return make_from_klass_common(klass, true, false);
1287   }
1288   // Same as before, but will produce an exact type, even if
1289   // the klass is not final, as long as it has exactly one implementation.
1290   static const TypeKlassPtr* make_from_klass_unique(ciKlass* klass) {
1291     return make_from_klass_common(klass, true, true);
1292   }
1293   // Same as before, but does not respects UseUniqueSubclasses.
1294   // Use this only for creating array element types.
1295   static const TypeKlassPtr* make_from_klass_raw(ciKlass* klass) {
1296     return make_from_klass_common(klass, false, false);
1297   }
1298 
1299   // Make a generic (unclassed) pointer to metadata.
1300   static const TypeKlassPtr* make(PTR ptr, int offset);
1301 
1302   // ptr to klass 'k'
1303   static const TypeKlassPtr *make( ciKlass* k ) { return make( TypePtr::Constant, k, 0); }
1304   // ptr to klass 'k' with offset
1305   static const TypeKlassPtr *make( ciKlass* k, int offset ) { return make( TypePtr::Constant, k, offset); }
1306   // ptr to klass 'k' or sub-klass
1307   static const TypeKlassPtr *make( PTR ptr, ciKlass* k, int offset);
1308 
1309   virtual const Type *cast_to_ptr_type(PTR ptr) const;
1310 
1311   virtual const Type *cast_to_exactness(bool klass_is_exact) const;
1312 
1313   // corresponding pointer to instance, for a given class
1314   const TypeOopPtr* as_instance_type() const;
1315 
1316   virtual const TypePtr *add_offset( intptr_t offset ) const;
1317   virtual const Type    *xmeet( const Type *t ) const;
1318   virtual const Type    *xdual() const;      // Compute dual right now.
1319 
1320   virtual intptr_t get_con() const;
1321 
1322   // Convenience common pre-built types.
1323   static const TypeKlassPtr* OBJECT; // Not-null object klass or below
1324   static const TypeKlassPtr* OBJECT_OR_NULL; // Maybe-null version of same
1325 #ifndef PRODUCT
1326   virtual void dump2( Dict &d, uint depth, outputStream *st ) const; // Specialized per-Type dumping
1327 #endif
1328 };
1329 
1330 class TypeNarrowPtr : public Type {
1331 protected:
1332   const TypePtr* _ptrtype; // Could be TypePtr::NULL_PTR
1333 
1334   TypeNarrowPtr(TYPES t, const TypePtr* ptrtype): _ptrtype(ptrtype),
1335                                                   Type(t) {
1336     assert(ptrtype->offset() == 0 ||
1337            ptrtype->offset() == OffsetBot ||
1338            ptrtype->offset() == OffsetTop, "no real offsets");
1339   }
1340 
1341   virtual const TypeNarrowPtr *isa_same_narrowptr(const Type *t) const = 0;
1342   virtual const TypeNarrowPtr *is_same_narrowptr(const Type *t) const = 0;
1343   virtual const TypeNarrowPtr *make_same_narrowptr(const TypePtr *t) const = 0;
1344   virtual const TypeNarrowPtr *make_hash_same_narrowptr(const TypePtr *t) const = 0;
1345   // Do not allow interface-vs.-noninterface joins to collapse to top.
1346   virtual const Type *filter_helper(const Type *kills, bool include_speculative) const;
1347 public:
1348   virtual bool eq( const Type *t ) const;
1349   virtual int  hash() const;             // Type specific hashing
1350   virtual bool singleton(void) const;    // TRUE if type is a singleton
1351 
1352   virtual const Type *xmeet( const Type *t ) const;
1353   virtual const Type *xdual() const;    // Compute dual right now.
1354 
1355   virtual intptr_t get_con() const;
1356 
1357   virtual bool empty(void) const;        // TRUE if type is vacuous
1358 
1359   // returns the equivalent ptr type for this compressed pointer
1360   const TypePtr *get_ptrtype() const {
1361     return _ptrtype;
1362   }
1363 
1364 #ifndef PRODUCT
1365   virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
1366 #endif
1367 };
1368 
1369 //------------------------------TypeNarrowOop----------------------------------
1370 // A compressed reference to some kind of Oop.  This type wraps around
1371 // a preexisting TypeOopPtr and forwards most of it's operations to
1372 // the underlying type.  It's only real purpose is to track the
1373 // oopness of the compressed oop value when we expose the conversion
1374 // between the normal and the compressed form.
1375 class TypeNarrowOop : public TypeNarrowPtr {
1376 protected:
1377   TypeNarrowOop( const TypePtr* ptrtype): TypeNarrowPtr(NarrowOop, ptrtype) {
1378   }
1379 
1380   virtual const TypeNarrowPtr *isa_same_narrowptr(const Type *t) const {
1381     return t->isa_narrowoop();
1382   }
1383 
1384   virtual const TypeNarrowPtr *is_same_narrowptr(const Type *t) const {
1385     return t->is_narrowoop();
1386   }
1387 
1388   virtual const TypeNarrowPtr *make_same_narrowptr(const TypePtr *t) const {
1389     return new TypeNarrowOop(t);
1390   }
1391 
1392   virtual const TypeNarrowPtr *make_hash_same_narrowptr(const TypePtr *t) const {
1393     return (const TypeNarrowPtr*)((new TypeNarrowOop(t))->hashcons());
1394   }
1395 
1396 public:
1397 
1398   static const TypeNarrowOop *make( const TypePtr* type);
1399 
1400   static const TypeNarrowOop* make_from_constant(ciObject* con, bool require_constant = false) {
1401     return make(TypeOopPtr::make_from_constant(con, require_constant));
1402   }
1403 
1404   static const TypeNarrowOop *BOTTOM;
1405   static const TypeNarrowOop *NULL_PTR;
1406 
1407   virtual const Type* remove_speculative() const;
1408   virtual const Type* cleanup_speculative() const;
1409 
1410 #ifndef PRODUCT
1411   virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
1412 #endif
1413 };
1414 
1415 //------------------------------TypeNarrowKlass----------------------------------
1416 // A compressed reference to klass pointer.  This type wraps around a
1417 // preexisting TypeKlassPtr and forwards most of it's operations to
1418 // the underlying type.
1419 class TypeNarrowKlass : public TypeNarrowPtr {
1420 protected:
1421   TypeNarrowKlass( const TypePtr* ptrtype): TypeNarrowPtr(NarrowKlass, ptrtype) {
1422   }
1423 
1424   virtual const TypeNarrowPtr *isa_same_narrowptr(const Type *t) const {
1425     return t->isa_narrowklass();
1426   }
1427 
1428   virtual const TypeNarrowPtr *is_same_narrowptr(const Type *t) const {
1429     return t->is_narrowklass();
1430   }
1431 
1432   virtual const TypeNarrowPtr *make_same_narrowptr(const TypePtr *t) const {
1433     return new TypeNarrowKlass(t);
1434   }
1435 
1436   virtual const TypeNarrowPtr *make_hash_same_narrowptr(const TypePtr *t) const {
1437     return (const TypeNarrowPtr*)((new TypeNarrowKlass(t))->hashcons());
1438   }
1439 
1440 public:
1441   static const TypeNarrowKlass *make( const TypePtr* type);
1442 
1443   // static const TypeNarrowKlass *BOTTOM;
1444   static const TypeNarrowKlass *NULL_PTR;
1445 
1446 #ifndef PRODUCT
1447   virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
1448 #endif
1449 };
1450 
1451 //------------------------------TypeFunc---------------------------------------
1452 // Class of Array Types
1453 class TypeFunc : public Type {
1454   TypeFunc( const TypeTuple *domain, const TypeTuple *range ) : Type(Function),  _domain(domain), _range(range) {}
1455   virtual bool eq( const Type *t ) const;
1456   virtual int  hash() const;             // Type specific hashing
1457   virtual bool singleton(void) const;    // TRUE if type is a singleton
1458   virtual bool empty(void) const;        // TRUE if type is vacuous
1459 
1460   const TypeTuple* const _domain;     // Domain of inputs
1461   const TypeTuple* const _range;      // Range of results
1462 
1463 public:
1464   // Constants are shared among ADLC and VM
1465   enum { Control    = AdlcVMDeps::Control,
1466          I_O        = AdlcVMDeps::I_O,
1467          Memory     = AdlcVMDeps::Memory,
1468          FramePtr   = AdlcVMDeps::FramePtr,
1469          ReturnAdr  = AdlcVMDeps::ReturnAdr,
1470          Parms      = AdlcVMDeps::Parms
1471   };
1472 
1473 
1474   // Accessors:
1475   const TypeTuple* domain() const { return _domain; }
1476   const TypeTuple* range()  const { return _range; }
1477 
1478   static const TypeFunc *make(ciMethod* method);
1479   static const TypeFunc *make(ciSignature signature, const Type* extra);
1480   static const TypeFunc *make(const TypeTuple* domain, const TypeTuple* range);
1481 
1482   virtual const Type *xmeet( const Type *t ) const;
1483   virtual const Type *xdual() const;    // Compute dual right now.
1484 
1485   BasicType return_type() const;
1486 
1487 #ifndef PRODUCT
1488   virtual void dump2( Dict &d, uint depth, outputStream *st ) const; // Specialized per-Type dumping
1489 #endif
1490   // Convenience common pre-built types.
1491 };
1492 
1493 //------------------------------accessors--------------------------------------
1494 inline bool Type::is_ptr_to_narrowoop() const {
1495 #ifdef _LP64
1496   return (isa_oopptr() != NULL && is_oopptr()->is_ptr_to_narrowoop_nv());
1497 #else
1498   return false;
1499 #endif
1500 }
1501 
1502 inline bool Type::is_ptr_to_narrowklass() const {
1503 #ifdef _LP64
1504   return (isa_oopptr() != NULL && is_oopptr()->is_ptr_to_narrowklass_nv());
1505 #else
1506   return false;
1507 #endif
1508 }
1509 
1510 inline float Type::getf() const {
1511   assert( _base == FloatCon, "Not a FloatCon" );
1512   return ((TypeF*)this)->_f;
1513 }
1514 
1515 inline double Type::getd() const {
1516   assert( _base == DoubleCon, "Not a DoubleCon" );
1517   return ((TypeD*)this)->_d;
1518 }
1519 
1520 inline const TypeInt *Type::is_int() const {
1521   assert( _base == Int, "Not an Int" );
1522   return (TypeInt*)this;
1523 }
1524 
1525 inline const TypeInt *Type::isa_int() const {
1526   return ( _base == Int ? (TypeInt*)this : NULL);
1527 }
1528 
1529 inline const TypeLong *Type::is_long() const {
1530   assert( _base == Long, "Not a Long" );
1531   return (TypeLong*)this;
1532 }
1533 
1534 inline const TypeLong *Type::isa_long() const {
1535   return ( _base == Long ? (TypeLong*)this : NULL);
1536 }
1537 
1538 inline const TypeF *Type::isa_float() const {
1539   return ((_base == FloatTop ||
1540            _base == FloatCon ||
1541            _base == FloatBot) ? (TypeF*)this : NULL);
1542 }
1543 
1544 inline const TypeF *Type::is_float_constant() const {
1545   assert( _base == FloatCon, "Not a Float" );
1546   return (TypeF*)this;
1547 }
1548 
1549 inline const TypeF *Type::isa_float_constant() const {
1550   return ( _base == FloatCon ? (TypeF*)this : NULL);
1551 }
1552 
1553 inline const TypeD *Type::isa_double() const {
1554   return ((_base == DoubleTop ||
1555            _base == DoubleCon ||
1556            _base == DoubleBot) ? (TypeD*)this : NULL);
1557 }
1558 
1559 inline const TypeD *Type::is_double_constant() const {
1560   assert( _base == DoubleCon, "Not a Double" );
1561   return (TypeD*)this;
1562 }
1563 
1564 inline const TypeD *Type::isa_double_constant() const {
1565   return ( _base == DoubleCon ? (TypeD*)this : NULL);
1566 }
1567 
1568 inline const TypeTuple *Type::is_tuple() const {
1569   assert( _base == Tuple, "Not a Tuple" );
1570   return (TypeTuple*)this;
1571 }
1572 
1573 inline const TypeAry *Type::is_ary() const {
1574   assert( _base == Array , "Not an Array" );
1575   return (TypeAry*)this;
1576 }
1577 
1578 inline const TypeVect *Type::is_vect() const {
1579   assert( _base >= VectorS && _base <= VectorZ, "Not a Vector" );
1580   return (TypeVect*)this;
1581 }
1582 
1583 inline const TypeVect *Type::isa_vect() const {
1584   return (_base >= VectorS && _base <= VectorZ) ? (TypeVect*)this : NULL;
1585 }
1586 
1587 inline const TypePtr *Type::is_ptr() const {
1588   // AnyPtr is the first Ptr and KlassPtr the last, with no non-ptrs between.
1589   assert(_base >= AnyPtr && _base <= KlassPtr, "Not a pointer");
1590   return (TypePtr*)this;
1591 }
1592 
1593 inline const TypePtr *Type::isa_ptr() const {
1594   // AnyPtr is the first Ptr and KlassPtr the last, with no non-ptrs between.
1595   return (_base >= AnyPtr && _base <= KlassPtr) ? (TypePtr*)this : NULL;
1596 }
1597 
1598 inline const TypeOopPtr *Type::is_oopptr() const {
1599   // OopPtr is the first and KlassPtr the last, with no non-oops between.
1600   assert(_base >= OopPtr && _base <= AryPtr, "Not a Java pointer" ) ;
1601   return (TypeOopPtr*)this;
1602 }
1603 
1604 inline const TypeOopPtr *Type::isa_oopptr() const {
1605   // OopPtr is the first and KlassPtr the last, with no non-oops between.
1606   return (_base >= OopPtr && _base <= AryPtr) ? (TypeOopPtr*)this : NULL;
1607 }
1608 
1609 inline const TypeRawPtr *Type::isa_rawptr() const {
1610   return (_base == RawPtr) ? (TypeRawPtr*)this : NULL;
1611 }
1612 
1613 inline const TypeRawPtr *Type::is_rawptr() const {
1614   assert( _base == RawPtr, "Not a raw pointer" );
1615   return (TypeRawPtr*)this;
1616 }
1617 
1618 inline const TypeInstPtr *Type::isa_instptr() const {
1619   return (_base == InstPtr) ? (TypeInstPtr*)this : NULL;
1620 }
1621 
1622 inline const TypeInstPtr *Type::is_instptr() const {
1623   assert( _base == InstPtr, "Not an object pointer" );
1624   return (TypeInstPtr*)this;
1625 }
1626 
1627 inline const TypeAryPtr *Type::isa_aryptr() const {
1628   return (_base == AryPtr) ? (TypeAryPtr*)this : NULL;
1629 }
1630 
1631 inline const TypeAryPtr *Type::is_aryptr() const {
1632   assert( _base == AryPtr, "Not an array pointer" );
1633   return (TypeAryPtr*)this;
1634 }
1635 
1636 inline const TypeNarrowOop *Type::is_narrowoop() const {
1637   // OopPtr is the first and KlassPtr the last, with no non-oops between.
1638   assert(_base == NarrowOop, "Not a narrow oop" ) ;
1639   return (TypeNarrowOop*)this;
1640 }
1641 
1642 inline const TypeNarrowOop *Type::isa_narrowoop() const {
1643   // OopPtr is the first and KlassPtr the last, with no non-oops between.
1644   return (_base == NarrowOop) ? (TypeNarrowOop*)this : NULL;
1645 }
1646 
1647 inline const TypeNarrowKlass *Type::is_narrowklass() const {
1648   assert(_base == NarrowKlass, "Not a narrow oop" ) ;
1649   return (TypeNarrowKlass*)this;
1650 }
1651 
1652 inline const TypeNarrowKlass *Type::isa_narrowklass() const {
1653   return (_base == NarrowKlass) ? (TypeNarrowKlass*)this : NULL;
1654 }
1655 
1656 inline const TypeMetadataPtr *Type::is_metadataptr() const {
1657   // MetadataPtr is the first and CPCachePtr the last
1658   assert(_base == MetadataPtr, "Not a metadata pointer" ) ;
1659   return (TypeMetadataPtr*)this;
1660 }
1661 
1662 inline const TypeMetadataPtr *Type::isa_metadataptr() const {
1663   return (_base == MetadataPtr) ? (TypeMetadataPtr*)this : NULL;
1664 }
1665 
1666 inline const TypeKlassPtr *Type::isa_klassptr() const {
1667   return (_base == KlassPtr) ? (TypeKlassPtr*)this : NULL;
1668 }
1669 
1670 inline const TypeKlassPtr *Type::is_klassptr() const {
1671   assert( _base == KlassPtr, "Not a klass pointer" );
1672   return (TypeKlassPtr*)this;
1673 }
1674 
1675 inline const TypePtr* Type::make_ptr() const {
1676   return (_base == NarrowOop) ? is_narrowoop()->get_ptrtype() :
1677     ((_base == NarrowKlass) ? is_narrowklass()->get_ptrtype() :
1678      (isa_ptr() ? is_ptr() : NULL));
1679 }
1680 
1681 inline const TypeOopPtr* Type::make_oopptr() const {
1682   return (_base == NarrowOop) ? is_narrowoop()->get_ptrtype()->is_oopptr() : is_oopptr();
1683 }
1684 
1685 inline const TypeNarrowOop* Type::make_narrowoop() const {
1686   return (_base == NarrowOop) ? is_narrowoop() :
1687                                 (isa_ptr() ? TypeNarrowOop::make(is_ptr()) : NULL);
1688 }
1689 
1690 inline const TypeNarrowKlass* Type::make_narrowklass() const {
1691   return (_base == NarrowKlass) ? is_narrowklass() :
1692                                 (isa_ptr() ? TypeNarrowKlass::make(is_ptr()) : NULL);
1693 }
1694 
1695 inline bool Type::is_floatingpoint() const {
1696   if( (_base == FloatCon)  || (_base == FloatBot) ||
1697       (_base == DoubleCon) || (_base == DoubleBot) )
1698     return true;
1699   return false;
1700 }
1701 
1702 inline bool Type::is_ptr_to_boxing_obj() const {
1703   const TypeInstPtr* tp = isa_instptr();
1704   return (tp != NULL) && (tp->offset() == 0) &&
1705          tp->klass()->is_instance_klass()  &&
1706          tp->klass()->as_instance_klass()->is_box_klass();
1707 }
1708 
1709 
1710 // ===============================================================
1711 // Things that need to be 64-bits in the 64-bit build but
1712 // 32-bits in the 32-bit build.  Done this way to get full
1713 // optimization AND strong typing.
1714 #ifdef _LP64
1715 
1716 // For type queries and asserts
1717 #define is_intptr_t  is_long
1718 #define isa_intptr_t isa_long
1719 #define find_intptr_t_type find_long_type
1720 #define find_intptr_t_con  find_long_con
1721 #define TypeX        TypeLong
1722 #define Type_X       Type::Long
1723 #define TypeX_X      TypeLong::LONG
1724 #define TypeX_ZERO   TypeLong::ZERO
1725 // For 'ideal_reg' machine registers
1726 #define Op_RegX      Op_RegL
1727 // For phase->intcon variants
1728 #define MakeConX     longcon
1729 #define ConXNode     ConLNode
1730 // For array index arithmetic
1731 #define MulXNode     MulLNode
1732 #define AndXNode     AndLNode
1733 #define OrXNode      OrLNode
1734 #define CmpXNode     CmpLNode
1735 #define SubXNode     SubLNode
1736 #define LShiftXNode  LShiftLNode
1737 // For object size computation:
1738 #define AddXNode     AddLNode
1739 #define RShiftXNode  RShiftLNode
1740 // For card marks and hashcodes
1741 #define URShiftXNode URShiftLNode
1742 // UseOptoBiasInlining
1743 #define XorXNode     XorLNode
1744 #define StoreXConditionalNode StoreLConditionalNode
1745 // Opcodes
1746 #define Op_LShiftX   Op_LShiftL
1747 #define Op_AndX      Op_AndL
1748 #define Op_AddX      Op_AddL
1749 #define Op_SubX      Op_SubL
1750 #define Op_XorX      Op_XorL
1751 #define Op_URShiftX  Op_URShiftL
1752 // conversions
1753 #define ConvI2X(x)   ConvI2L(x)
1754 #define ConvL2X(x)   (x)
1755 #define ConvX2I(x)   ConvL2I(x)
1756 #define ConvX2L(x)   (x)
1757 #define ConvX2UL(x)  (x)
1758 
1759 #else
1760 
1761 // For type queries and asserts
1762 #define is_intptr_t  is_int
1763 #define isa_intptr_t isa_int
1764 #define find_intptr_t_type find_int_type
1765 #define find_intptr_t_con  find_int_con
1766 #define TypeX        TypeInt
1767 #define Type_X       Type::Int
1768 #define TypeX_X      TypeInt::INT
1769 #define TypeX_ZERO   TypeInt::ZERO
1770 // For 'ideal_reg' machine registers
1771 #define Op_RegX      Op_RegI
1772 // For phase->intcon variants
1773 #define MakeConX     intcon
1774 #define ConXNode     ConINode
1775 // For array index arithmetic
1776 #define MulXNode     MulINode
1777 #define AndXNode     AndINode
1778 #define OrXNode      OrINode
1779 #define CmpXNode     CmpINode
1780 #define SubXNode     SubINode
1781 #define LShiftXNode  LShiftINode
1782 // For object size computation:
1783 #define AddXNode     AddINode
1784 #define RShiftXNode  RShiftINode
1785 // For card marks and hashcodes
1786 #define URShiftXNode URShiftINode
1787 // UseOptoBiasInlining
1788 #define XorXNode     XorINode
1789 #define StoreXConditionalNode StoreIConditionalNode
1790 // Opcodes
1791 #define Op_LShiftX   Op_LShiftI
1792 #define Op_AndX      Op_AndI
1793 #define Op_AddX      Op_AddI
1794 #define Op_SubX      Op_SubI
1795 #define Op_XorX      Op_XorI
1796 #define Op_URShiftX  Op_URShiftI
1797 // conversions
1798 #define ConvI2X(x)   (x)
1799 #define ConvL2X(x)   ConvL2I(x)
1800 #define ConvX2I(x)   (x)
1801 #define ConvX2L(x)   ConvI2L(x)
1802 #define ConvX2UL(x)  ConvI2UL(x)
1803 
1804 #endif
1805 
1806 #endif // SHARE_VM_OPTO_TYPE_HPP