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