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