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