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