1 /*
   2  * Copyright (c) 1997, 2021, 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 "opto/adlcVMDeps.hpp"
  29 #include "runtime/handles.hpp"

  30 
  31 // Portions of code courtesy of Clifford Click
  32 
  33 // Optimization - Graph Style
  34 
  35 
  36 // This class defines a Type lattice.  The lattice is used in the constant
  37 // propagation algorithms, and for some type-checking of the iloc code.
  38 // Basic types include RSD's (lower bound, upper bound, stride for integers),
  39 // float & double precision constants, sets of data-labels and code-labels.
  40 // The complete lattice is described below.  Subtypes have no relationship to
  41 // up or down in the lattice; that is entirely determined by the behavior of
  42 // the MEET/JOIN functions.
  43 
  44 class Dict;
  45 class Type;
  46 class   TypeD;
  47 class   TypeF;
  48 class   TypeInteger;
  49 class     TypeInt;
  50 class     TypeLong;
  51 class   TypeNarrowPtr;
  52 class     TypeNarrowOop;
  53 class     TypeNarrowKlass;
  54 class   TypeAry;
  55 class   TypeTuple;

  56 class   TypeVect;
  57 class     TypeVectA;
  58 class     TypeVectS;
  59 class     TypeVectD;
  60 class     TypeVectX;
  61 class     TypeVectY;
  62 class     TypeVectZ;
  63 class     TypeVectMask;
  64 class   TypePtr;
  65 class     TypeRawPtr;
  66 class     TypeOopPtr;
  67 class       TypeInstPtr;
  68 class       TypeAryPtr;
  69 class     TypeKlassPtr;
  70 class       TypeInstKlassPtr;
  71 class       TypeAryKlassPtr;
  72 class     TypeMetadataPtr;
  73 
  74 //------------------------------Type-------------------------------------------
  75 // Basic Type object, represents a set of primitive Values.
  76 // Types are hash-cons'd into a private class dictionary, so only one of each
  77 // different kind of Type exists.  Types are never modified after creation, so
  78 // all their interesting fields are constant.
  79 class Type {
  80   friend class VMStructs;
  81 
  82 public:
  83   enum TYPES {
  84     Bad=0,                      // Type check
  85     Control,                    // Control of code (not in lattice)
  86     Top,                        // Top of the lattice
  87     Int,                        // Integer range (lo-hi)
  88     Long,                       // Long integer range (lo-hi)
  89     Half,                       // Placeholder half of doubleword
  90     NarrowOop,                  // Compressed oop pointer
  91     NarrowKlass,                // Compressed klass pointer
  92 
  93     Tuple,                      // Method signature or object layout
  94     Array,                      // Array types
  95 
  96     VectorMask,                 // Vector predicate/mask type
  97     VectorA,                    // (Scalable) Vector types for vector length agnostic
  98     VectorS,                    //  32bit Vector types
  99     VectorD,                    //  64bit Vector types
 100     VectorX,                    // 128bit Vector types
 101     VectorY,                    // 256bit Vector types
 102     VectorZ,                    // 512bit Vector types

 103 
 104     AnyPtr,                     // Any old raw, klass, inst, or array pointer
 105     RawPtr,                     // Raw (non-oop) pointers
 106     OopPtr,                     // Any and all Java heap entities
 107     InstPtr,                    // Instance pointers (non-array objects)
 108     AryPtr,                     // Array pointers
 109     // (Ptr order matters:  See is_ptr, isa_ptr, is_oopptr, isa_oopptr.)
 110 
 111     MetadataPtr,                // Generic metadata
 112     KlassPtr,                   // Klass pointers
 113     InstKlassPtr,
 114     AryKlassPtr,
 115 
 116     Function,                   // Function signature
 117     Abio,                       // Abstract I/O
 118     Return_Address,             // Subroutine return address
 119     Memory,                     // Abstract store
 120     FloatTop,                   // No float value
 121     FloatCon,                   // Floating point constant
 122     FloatBot,                   // Any float value
 123     DoubleTop,                  // No double value
 124     DoubleCon,                  // Double precision constant
 125     DoubleBot,                  // Any double value
 126     Bottom,                     // Bottom of lattice
 127     lastype                     // Bogus ending type (not in lattice)
 128   };
 129 
 130   // Signal values for offsets from a base pointer
 131   enum OFFSET_SIGNALS {
 132     OffsetTop = -2000000000,    // undefined offset
 133     OffsetBot = -2000000001     // any possible offset
 134   };
 135 
























 136   // Min and max WIDEN values.
 137   enum WIDEN {
 138     WidenMin = 0,
 139     WidenMax = 3
 140   };
 141 
 142 private:
 143   typedef struct {
 144     TYPES                dual_type;
 145     BasicType            basic_type;
 146     const char*          msg;
 147     bool                 isa_oop;
 148     uint                 ideal_reg;
 149     relocInfo::relocType reloc;
 150   } TypeInfo;
 151 
 152   // Dictionary of types shared among compilations.
 153   static Dict* _shared_type_dict;
 154   static const TypeInfo _type_info[];
 155 
 156   static int uhash( const Type *const t );
 157   // Structural equality check.  Assumes that cmp() has already compared
 158   // the _base types and thus knows it can cast 't' appropriately.
 159   virtual bool eq( const Type *t ) const;
 160 
 161   // Top-level hash-table of types
 162   static Dict *type_dict() {
 163     return Compile::current()->type_dict();
 164   }
 165 
 166   // DUAL operation: reflect around lattice centerline.  Used instead of
 167   // join to ensure my lattice is symmetric up and down.  Dual is computed
 168   // lazily, on demand, and cached in _dual.
 169   const Type *_dual;            // Cached dual value
 170 
 171 #ifdef ASSERT
 172   // One type is interface, the other is oop
 173   virtual bool interface_vs_oop_helper(const Type *t) const;
 174 #endif
 175 
 176   const Type *meet_helper(const Type *t, bool include_speculative) const;
 177   void check_symmetrical(const Type *t, const Type *mt) const;
 178 
 179 protected:
 180   // Each class of type is also identified by its base.
 181   const TYPES _base;            // Enum of Types type
 182 
 183   Type( TYPES t ) : _dual(NULL),  _base(t) {} // Simple types
 184   // ~Type();                   // Use fast deallocation
 185   const Type *hashcons();       // Hash-cons the type
 186   virtual const Type *filter_helper(const Type *kills, bool include_speculative) const;
 187   const Type *join_helper(const Type *t, bool include_speculative) const {
 188     return dual()->meet_helper(t->dual(), include_speculative)->dual();
 189   }
 190 
 191 public:
 192 
 193   inline void* operator new( size_t x ) throw() {
 194     Compile* compile = Compile::current();
 195     compile->set_type_last_size(x);
 196     return compile->type_arena()->AmallocWords(x);
 197   }
 198   inline void operator delete( void* ptr ) {
 199     Compile* compile = Compile::current();
 200     compile->type_arena()->Afree(ptr,compile->type_last_size());
 201   }
 202 
 203   // Initialize the type system for a particular compilation.
 204   static void Initialize(Compile* compile);
 205 
 206   // Initialize the types shared by all compilations.
 207   static void Initialize_shared(Compile* compile);
 208 
 209   TYPES base() const {
 210     assert(_base > Bad && _base < lastype, "sanity");
 211     return _base;
 212   }
 213 
 214   // Create a new hash-consd type
 215   static const Type *make(enum TYPES);
 216   // Test for equivalence of types
 217   static int cmp( const Type *const t1, const Type *const t2 );
 218   // Test for higher or equal in lattice
 219   // Variant that drops the speculative part of the types
 220   bool higher_equal(const Type *t) const {
 221     return !cmp(meet(t),t->remove_speculative());
 222   }
 223   // Variant that keeps the speculative part of the types
 224   bool higher_equal_speculative(const Type *t) const {
 225     return !cmp(meet_speculative(t),t);
 226   }
 227 
 228   // MEET operation; lower in lattice.
 229   // Variant that drops the speculative part of the types
 230   const Type *meet(const Type *t) const {
 231     return meet_helper(t, false);
 232   }
 233   // Variant that keeps the speculative part of the types
 234   const Type *meet_speculative(const Type *t) const {
 235     return meet_helper(t, true)->cleanup_speculative();
 236   }
 237   // WIDEN: 'widens' for Ints and other range types
 238   virtual const Type *widen( const Type *old, const Type* limit ) const { return this; }
 239   // NARROW: complement for widen, used by pessimistic phases
 240   virtual const Type *narrow( const Type *old ) const { return this; }
 241 
 242   // DUAL operation: reflect around lattice centerline.  Used instead of
 243   // join to ensure my lattice is symmetric up and down.
 244   const Type *dual() const { return _dual; }
 245 
 246   // Compute meet dependent on base type
 247   virtual const Type *xmeet( const Type *t ) const;
 248   virtual const Type *xdual() const;    // Compute dual right now.
 249 
 250   // JOIN operation; higher in lattice.  Done by finding the dual of the
 251   // meet of the dual of the 2 inputs.
 252   // Variant that drops the speculative part of the types
 253   const Type *join(const Type *t) const {
 254     return join_helper(t, false);
 255   }
 256   // Variant that keeps the speculative part of the types
 257   const Type *join_speculative(const Type *t) const {
 258     return join_helper(t, true)->cleanup_speculative();
 259   }
 260 
 261   // Modified version of JOIN adapted to the needs Node::Value.
 262   // Normalizes all empty values to TOP.  Does not kill _widen bits.
 263   // Currently, it also works around limitations involving interface types.
 264   // Variant that drops the speculative part of the types
 265   const Type *filter(const Type *kills) const {
 266     return filter_helper(kills, false);
 267   }
 268   // Variant that keeps the speculative part of the types
 269   const Type *filter_speculative(const Type *kills) const {
 270     return filter_helper(kills, true)->cleanup_speculative();
 271   }
 272 
 273 #ifdef ASSERT
 274   // One type is interface, the other is oop
 275   virtual bool interface_vs_oop(const Type *t) const;
 276 #endif
 277 
 278   // Returns true if this pointer points at memory which contains a
 279   // compressed oop references.
 280   bool is_ptr_to_narrowoop() const;
 281   bool is_ptr_to_narrowklass() const;
 282 
 283   bool is_ptr_to_boxing_obj() const;
 284 
 285 
 286   // Convenience access
 287   float getf() const;
 288   double getd() const;
 289 
 290   const TypeInt    *is_int() const;
 291   const TypeInt    *isa_int() const;             // Returns NULL if not an Int
 292   const TypeInteger* is_integer(BasicType bt) const;
 293   const TypeInteger* isa_integer(BasicType bt) const;
 294   const TypeLong   *is_long() const;
 295   const TypeLong   *isa_long() const;            // Returns NULL if not a Long
 296   const TypeD      *isa_double() const;          // Returns NULL if not a Double{Top,Con,Bot}
 297   const TypeD      *is_double_constant() const;  // Asserts it is a DoubleCon
 298   const TypeD      *isa_double_constant() const; // Returns NULL if not a DoubleCon
 299   const TypeF      *isa_float() const;           // Returns NULL if not a Float{Top,Con,Bot}
 300   const TypeF      *is_float_constant() const;   // Asserts it is a FloatCon
 301   const TypeF      *isa_float_constant() const;  // Returns NULL if not a FloatCon
 302   const TypeTuple  *is_tuple() const;            // Collection of fields, NOT a pointer
 303   const TypeAry    *is_ary() const;              // Array, NOT array pointer
 304   const TypeAry    *isa_ary() const;             // Returns NULL of not ary
 305   const TypeVect   *is_vect() const;             // Vector
 306   const TypeVect   *isa_vect() const;            // Returns NULL if not a Vector
 307   const TypeVectMask *is_vectmask() const;       // Predicate/Mask Vector
 308   const TypeVectMask *isa_vectmask() const;      // Returns NULL if not a Vector Predicate/Mask
 309   const TypePtr    *is_ptr() const;              // Asserts it is a ptr type
 310   const TypePtr    *isa_ptr() const;             // Returns NULL if not ptr type
 311   const TypeRawPtr *isa_rawptr() const;          // NOT Java oop
 312   const TypeRawPtr *is_rawptr() const;           // Asserts is rawptr
 313   const TypeNarrowOop  *is_narrowoop() const;    // Java-style GC'd pointer
 314   const TypeNarrowOop  *isa_narrowoop() const;   // Returns NULL if not oop ptr type
 315   const TypeNarrowKlass *is_narrowklass() const; // compressed klass pointer
 316   const TypeNarrowKlass *isa_narrowklass() const;// Returns NULL if not oop ptr type
 317   const TypeOopPtr   *isa_oopptr() const;        // Returns NULL if not oop ptr type
 318   const TypeOopPtr   *is_oopptr() const;         // Java-style GC'd pointer
 319   const TypeInstPtr  *isa_instptr() const;       // Returns NULL if not InstPtr
 320   const TypeInstPtr  *is_instptr() const;        // Instance
 321   const TypeAryPtr   *isa_aryptr() const;        // Returns NULL if not AryPtr
 322   const TypeAryPtr   *is_aryptr() const;         // Array oop


 323 
 324   const TypeMetadataPtr   *isa_metadataptr() const;   // Returns NULL if not oop ptr type
 325   const TypeMetadataPtr   *is_metadataptr() const;    // Java-style GC'd pointer
 326   const TypeKlassPtr      *isa_klassptr() const;      // Returns NULL if not KlassPtr
 327   const TypeKlassPtr      *is_klassptr() const;       // assert if not KlassPtr
 328   const TypeInstKlassPtr  *isa_instklassptr() const;  // Returns NULL if not IntKlassPtr
 329   const TypeInstKlassPtr  *is_instklassptr() const;   // assert if not IntKlassPtr
 330   const TypeAryKlassPtr   *isa_aryklassptr() const;   // Returns NULL if not AryKlassPtr
 331   const TypeAryKlassPtr   *is_aryklassptr() const;    // assert if not AryKlassPtr
 332 
 333   virtual bool      is_finite() const;           // Has a finite value
 334   virtual bool      is_nan()    const;           // Is not a number (NaN)
 335 



 336   // Returns this ptr type or the equivalent ptr type for this compressed pointer.
 337   const TypePtr* make_ptr() const;
 338 
 339   // Returns this oopptr type or the equivalent oopptr type for this compressed pointer.
 340   // Asserts if the underlying type is not an oopptr or narrowoop.
 341   const TypeOopPtr* make_oopptr() const;
 342 
 343   // Returns this compressed pointer or the equivalent compressed version
 344   // of this pointer type.
 345   const TypeNarrowOop* make_narrowoop() const;
 346 
 347   // Returns this compressed klass pointer or the equivalent
 348   // compressed version of this pointer type.
 349   const TypeNarrowKlass* make_narrowklass() const;
 350 
 351   // Special test for register pressure heuristic
 352   bool is_floatingpoint() const;        // True if Float or Double base type
 353 
 354   // Do you have memory, directly or through a tuple?
 355   bool has_memory( ) const;
 356 
 357   // TRUE if type is a singleton
 358   virtual bool singleton(void) const;
 359 
 360   // TRUE if type is above the lattice centerline, and is therefore vacuous
 361   virtual bool empty(void) const;
 362 
 363   // Return a hash for this type.  The hash function is public so ConNode
 364   // (constants) can hash on their constant, which is represented by a Type.
 365   virtual int hash() const;
 366 
 367   // Map ideal registers (machine types) to ideal types
 368   static const Type *mreg2type[];
 369 
 370   // Printing, statistics
 371 #ifndef PRODUCT
 372   void         dump_on(outputStream *st) const;
 373   void         dump() const {
 374     dump_on(tty);
 375   }
 376   virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
 377   static  void dump_stats();
 378   // Groups of types, for debugging and visualization only.
 379   enum class Category {
 380     Data,
 381     Memory,
 382     Mixed,   // Tuples with types of different categories.
 383     Control,
 384     Other,   // {Type::Top, Type::Abio, Type::Bottom}.
 385     Undef    // {Type::Bad, Type::lastype}, for completeness.
 386   };
 387   // Return the category of this type.
 388   Category category() const;
 389 
 390   static const char* str(const Type* t);
 391 #endif // !PRODUCT
 392   void typerr(const Type *t) const; // Mixing types error
 393 
 394   // Create basic type
 395   static const Type* get_const_basic_type(BasicType type) {
 396     assert((uint)type <= T_CONFLICT && _const_basic_type[type] != NULL, "bad type");
 397     return _const_basic_type[type];
 398   }
 399 
 400   // For two instance arrays of same dimension, return the base element types.
 401   // Otherwise or if the arrays have different dimensions, return NULL.
 402   static void get_arrays_base_elements(const Type *a1, const Type *a2,
 403                                        const TypeInstPtr **e1, const TypeInstPtr **e2);
 404 
 405   // Mapping to the array element's basic type.
 406   BasicType array_element_basic_type() const;
 407 
 408   // Create standard type for a ciType:
 409   static const Type* get_const_type(ciType* type);
 410 
 411   // Create standard zero value:
 412   static const Type* get_zero_type(BasicType type) {
 413     assert((uint)type <= T_CONFLICT && _zero_type[type] != NULL, "bad type");
 414     return _zero_type[type];
 415   }
 416 
 417   // Report if this is a zero value (not top).
 418   bool is_zero_type() const {
 419     BasicType type = basic_type();
 420     if (type == T_VOID || type >= T_CONFLICT)
 421       return false;
 422     else
 423       return (this == _zero_type[type]);
 424   }
 425 
 426   // Convenience common pre-built types.
 427   static const Type *ABIO;
 428   static const Type *BOTTOM;
 429   static const Type *CONTROL;
 430   static const Type *DOUBLE;
 431   static const Type *FLOAT;
 432   static const Type *HALF;
 433   static const Type *MEMORY;
 434   static const Type *MULTI;
 435   static const Type *RETURN_ADDRESS;
 436   static const Type *TOP;
 437 
 438   // Mapping from compiler type to VM BasicType
 439   BasicType basic_type() const       { return _type_info[_base].basic_type; }
 440   uint ideal_reg() const             { return _type_info[_base].ideal_reg; }
 441   const char* msg() const            { return _type_info[_base].msg; }
 442   bool isa_oop_ptr() const           { return _type_info[_base].isa_oop; }
 443   relocInfo::relocType reloc() const { return _type_info[_base].reloc; }
 444 
 445   // Mapping from CI type system to compiler type:
 446   static const Type* get_typeflow_type(ciType* type);
 447 
 448   static const Type* make_from_constant(ciConstant constant,
 449                                         bool require_constant = false,
 450                                         int stable_dimension = 0,
 451                                         bool is_narrow = false,
 452                                         bool is_autobox_cache = false);
 453 
 454   static const Type* make_constant_from_field(ciInstance* holder,
 455                                               int off,
 456                                               bool is_unsigned_load,
 457                                               BasicType loadbt);
 458 
 459   static const Type* make_constant_from_field(ciField* field,
 460                                               ciInstance* holder,
 461                                               BasicType loadbt,
 462                                               bool is_unsigned_load);
 463 
 464   static const Type* make_constant_from_array_element(ciArray* array,
 465                                                       int off,
 466                                                       int stable_dimension,
 467                                                       BasicType loadbt,
 468                                                       bool is_unsigned_load);
 469 
 470   // Speculative type helper methods. See TypePtr.
 471   virtual const TypePtr* speculative() const                                  { return NULL; }
 472   virtual ciKlass* speculative_type() const                                   { return NULL; }
 473   virtual ciKlass* speculative_type_not_null() const                          { return NULL; }
 474   virtual bool speculative_maybe_null() const                                 { return true; }
 475   virtual bool speculative_always_null() const                                { return true; }
 476   virtual const Type* remove_speculative() const                              { return this; }
 477   virtual const Type* cleanup_speculative() const                             { return this; }
 478   virtual bool would_improve_type(ciKlass* exact_kls, int inline_depth) const { return exact_kls != NULL; }
 479   virtual bool would_improve_ptr(ProfilePtrKind ptr_kind) const { return ptr_kind == ProfileAlwaysNull || ptr_kind == ProfileNeverNull; }
 480   const Type* maybe_remove_speculative(bool include_speculative) const;
 481 
 482   virtual bool maybe_null() const { return true; }
 483   virtual bool is_known_instance() const { return false; }
 484 
 485 private:
 486   // support arrays
 487   static const Type*        _zero_type[T_CONFLICT+1];
 488   static const Type* _const_basic_type[T_CONFLICT+1];
 489 };
 490 
 491 //------------------------------TypeF------------------------------------------
 492 // Class of Float-Constant Types.
 493 class TypeF : public Type {
 494   TypeF( float f ) : Type(FloatCon), _f(f) {};
 495 public:
 496   virtual bool eq( const Type *t ) const;
 497   virtual int  hash() const;             // Type specific hashing
 498   virtual bool singleton(void) const;    // TRUE if type is a singleton
 499   virtual bool empty(void) const;        // TRUE if type is vacuous
 500 public:
 501   const float _f;               // Float constant
 502 
 503   static const TypeF *make(float f);
 504 
 505   virtual bool        is_finite() const;  // Has a finite value
 506   virtual bool        is_nan()    const;  // Is not a number (NaN)
 507 
 508   virtual const Type *xmeet( const Type *t ) const;
 509   virtual const Type *xdual() const;    // Compute dual right now.
 510   // Convenience common pre-built types.
 511   static const TypeF *MAX;
 512   static const TypeF *MIN;
 513   static const TypeF *ZERO; // positive zero only
 514   static const TypeF *ONE;
 515   static const TypeF *POS_INF;
 516   static const TypeF *NEG_INF;
 517 #ifndef PRODUCT
 518   virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
 519 #endif
 520 };
 521 
 522 //------------------------------TypeD------------------------------------------
 523 // Class of Double-Constant Types.
 524 class TypeD : public Type {
 525   TypeD( double d ) : Type(DoubleCon), _d(d) {};
 526 public:
 527   virtual bool eq( const Type *t ) const;
 528   virtual int  hash() const;             // Type specific hashing
 529   virtual bool singleton(void) const;    // TRUE if type is a singleton
 530   virtual bool empty(void) const;        // TRUE if type is vacuous
 531 public:
 532   const double _d;              // Double constant
 533 
 534   static const TypeD *make(double d);
 535 
 536   virtual bool        is_finite() const;  // Has a finite value
 537   virtual bool        is_nan()    const;  // Is not a number (NaN)
 538 
 539   virtual const Type *xmeet( const Type *t ) const;
 540   virtual const Type *xdual() const;    // Compute dual right now.
 541   // Convenience common pre-built types.
 542   static const TypeD *MAX;
 543   static const TypeD *MIN;
 544   static const TypeD *ZERO; // positive zero only
 545   static const TypeD *ONE;
 546   static const TypeD *POS_INF;
 547   static const TypeD *NEG_INF;
 548 #ifndef PRODUCT
 549   virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
 550 #endif
 551 };
 552 
 553 class TypeInteger : public Type {
 554 protected:
 555   TypeInteger(TYPES t) : Type(t) {}
 556 
 557 public:
 558   virtual jlong hi_as_long() const = 0;
 559   virtual jlong lo_as_long() const = 0;
 560   jlong get_con_as_long(BasicType bt) const;
 561 
 562   static const TypeInteger* make(jlong lo, jlong hi, int w, BasicType bt);
 563 
 564   static const TypeInteger* bottom(BasicType type);
 565 };
 566 
 567 
 568 
 569 //------------------------------TypeInt----------------------------------------
 570 // Class of integer ranges, the set of integers between a lower bound and an
 571 // upper bound, inclusive.
 572 class TypeInt : public TypeInteger {
 573   TypeInt( jint lo, jint hi, int w );
 574 protected:
 575   virtual const Type *filter_helper(const Type *kills, bool include_speculative) const;
 576 
 577 public:
 578   typedef jint NativeType;
 579   virtual bool eq( const Type *t ) const;
 580   virtual int  hash() const;             // Type specific hashing
 581   virtual bool singleton(void) const;    // TRUE if type is a singleton
 582   virtual bool empty(void) const;        // TRUE if type is vacuous
 583   const jint _lo, _hi;          // Lower bound, upper bound
 584   const short _widen;           // Limit on times we widen this sucker
 585 
 586   static const TypeInt *make(jint lo);
 587   // must always specify w
 588   static const TypeInt *make(jint lo, jint hi, int w);
 589 
 590   // Check for single integer
 591   int is_con() const { return _lo==_hi; }
 592   bool is_con(int i) const { return is_con() && _lo == i; }
 593   jint get_con() const { assert( is_con(), "" );  return _lo; }
 594 
 595   virtual bool        is_finite() const;  // Has a finite value
 596 
 597   virtual const Type *xmeet( const Type *t ) const;
 598   virtual const Type *xdual() const;    // Compute dual right now.
 599   virtual const Type *widen( const Type *t, const Type* limit_type ) const;
 600   virtual const Type *narrow( const Type *t ) const;
 601 
 602   virtual jlong hi_as_long() const { return _hi; }
 603   virtual jlong lo_as_long() const { return _lo; }
 604 
 605   // Do not kill _widen bits.
 606   // Convenience common pre-built types.
 607   static const TypeInt *MAX;
 608   static const TypeInt *MIN;
 609   static const TypeInt *MINUS_1;
 610   static const TypeInt *ZERO;
 611   static const TypeInt *ONE;
 612   static const TypeInt *BOOL;
 613   static const TypeInt *CC;
 614   static const TypeInt *CC_LT;  // [-1]  == MINUS_1
 615   static const TypeInt *CC_GT;  // [1]   == ONE
 616   static const TypeInt *CC_EQ;  // [0]   == ZERO
 617   static const TypeInt *CC_LE;  // [-1,0]
 618   static const TypeInt *CC_GE;  // [0,1] == BOOL (!)
 619   static const TypeInt *BYTE;
 620   static const TypeInt *UBYTE;
 621   static const TypeInt *CHAR;
 622   static const TypeInt *SHORT;
 623   static const TypeInt *POS;
 624   static const TypeInt *POS1;
 625   static const TypeInt *INT;
 626   static const TypeInt *SYMINT; // symmetric range [-max_jint..max_jint]
 627   static const TypeInt *TYPE_DOMAIN; // alias for TypeInt::INT
 628 
 629   static const TypeInt *as_self(const Type *t) { return t->is_int(); }
 630 #ifndef PRODUCT
 631   virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
 632 #endif
 633 };
 634 
 635 
 636 //------------------------------TypeLong---------------------------------------
 637 // Class of long integer ranges, the set of integers between a lower bound and
 638 // an upper bound, inclusive.
 639 class TypeLong : public TypeInteger {
 640   TypeLong( jlong lo, jlong hi, int w );
 641 protected:
 642   // Do not kill _widen bits.
 643   virtual const Type *filter_helper(const Type *kills, bool include_speculative) const;
 644 public:
 645   typedef jlong NativeType;
 646   virtual bool eq( const Type *t ) const;
 647   virtual int  hash() const;             // Type specific hashing
 648   virtual bool singleton(void) const;    // TRUE if type is a singleton
 649   virtual bool empty(void) const;        // TRUE if type is vacuous
 650 public:
 651   const jlong _lo, _hi;         // Lower bound, upper bound
 652   const short _widen;           // Limit on times we widen this sucker
 653 
 654   static const TypeLong *make(jlong lo);
 655   // must always specify w
 656   static const TypeLong *make(jlong lo, jlong hi, int w);
 657 
 658   // Check for single integer
 659   int is_con() const { return _lo==_hi; }
 660   bool is_con(int i) const { return is_con() && _lo == i; }
 661   jlong get_con() const { assert( is_con(), "" ); return _lo; }
 662 
 663   // Check for positive 32-bit value.
 664   int is_positive_int() const { return _lo >= 0 && _hi <= (jlong)max_jint; }
 665 
 666   virtual bool        is_finite() const;  // Has a finite value
 667 
 668   virtual jlong hi_as_long() const { return _hi; }
 669   virtual jlong lo_as_long() const { return _lo; }
 670 
 671   virtual const Type *xmeet( const Type *t ) const;
 672   virtual const Type *xdual() const;    // Compute dual right now.
 673   virtual const Type *widen( const Type *t, const Type* limit_type ) const;
 674   virtual const Type *narrow( const Type *t ) const;
 675   // Convenience common pre-built types.
 676   static const TypeLong *MAX;
 677   static const TypeLong *MIN;
 678   static const TypeLong *MINUS_1;
 679   static const TypeLong *ZERO;
 680   static const TypeLong *ONE;
 681   static const TypeLong *POS;
 682   static const TypeLong *LONG;
 683   static const TypeLong *INT;    // 32-bit subrange [min_jint..max_jint]
 684   static const TypeLong *UINT;   // 32-bit unsigned [0..max_juint]
 685   static const TypeLong *TYPE_DOMAIN; // alias for TypeLong::LONG
 686 
 687   // static convenience methods.
 688   static const TypeLong *as_self(const Type *t) { return t->is_long(); }
 689 
 690 #ifndef PRODUCT
 691   virtual void dump2( Dict &d, uint, outputStream *st  ) const;// Specialized per-Type dumping
 692 #endif
 693 };
 694 
 695 //------------------------------TypeTuple--------------------------------------
 696 // Class of Tuple Types, essentially type collections for function signatures
 697 // and class layouts.  It happens to also be a fast cache for the HotSpot
 698 // signature types.
 699 class TypeTuple : public Type {
 700   TypeTuple( uint cnt, const Type **fields ) : Type(Tuple), _cnt(cnt), _fields(fields) { }
 701 
 702   const uint          _cnt;              // Count of fields
 703   const Type ** const _fields;           // Array of field types
 704 
 705 public:
 706   virtual bool eq( const Type *t ) const;
 707   virtual int  hash() const;             // Type specific hashing
 708   virtual bool singleton(void) const;    // TRUE if type is a singleton
 709   virtual bool empty(void) const;        // TRUE if type is vacuous
 710 
 711   // Accessors:
 712   uint cnt() const { return _cnt; }
 713   const Type* field_at(uint i) const {
 714     assert(i < _cnt, "oob");
 715     return _fields[i];
 716   }
 717   void set_field_at(uint i, const Type* t) {
 718     assert(i < _cnt, "oob");
 719     _fields[i] = t;
 720   }
 721 
 722   static const TypeTuple *make( uint cnt, const Type **fields );
 723   static const TypeTuple *make_range(ciSignature *sig);
 724   static const TypeTuple *make_domain(ciInstanceKlass* recv, ciSignature *sig);
 725 
 726   // Subroutine call type with space allocated for argument types
 727   // Memory for Control, I_O, Memory, FramePtr, and ReturnAdr is allocated implicitly
 728   static const Type **fields( uint arg_cnt );
 729 
 730   virtual const Type *xmeet( const Type *t ) const;
 731   virtual const Type *xdual() const;    // Compute dual right now.
 732   // Convenience common pre-built types.
 733   static const TypeTuple *IFBOTH;
 734   static const TypeTuple *IFFALSE;
 735   static const TypeTuple *IFTRUE;
 736   static const TypeTuple *IFNEITHER;
 737   static const TypeTuple *LOOPBODY;
 738   static const TypeTuple *MEMBAR;
 739   static const TypeTuple *STORECONDITIONAL;
 740   static const TypeTuple *START_I2C;
 741   static const TypeTuple *INT_PAIR;
 742   static const TypeTuple *LONG_PAIR;
 743   static const TypeTuple *INT_CC_PAIR;
 744   static const TypeTuple *LONG_CC_PAIR;
 745 #ifndef PRODUCT
 746   virtual void dump2( Dict &d, uint, outputStream *st  ) const; // Specialized per-Type dumping
 747 #endif
 748 };
 749 
 750 //------------------------------TypeAry----------------------------------------
 751 // Class of Array Types
 752 class TypeAry : public Type {
 753   TypeAry(const Type* elem, const TypeInt* size, bool stable) : Type(Array),
 754       _elem(elem), _size(size), _stable(stable) {}
 755 public:
 756   virtual bool eq( const Type *t ) const;
 757   virtual int  hash() const;             // Type specific hashing
 758   virtual bool singleton(void) const;    // TRUE if type is a singleton
 759   virtual bool empty(void) const;        // TRUE if type is vacuous
 760 
 761 private:
 762   const Type *_elem;            // Element type of array
 763   const TypeInt *_size;         // Elements in array
 764   const bool _stable;           // Are elements @Stable?





 765   friend class TypeAryPtr;
 766 
 767 public:
 768   static const TypeAry* make(const Type* elem, const TypeInt* size, bool stable = false);

 769 
 770   virtual const Type *xmeet( const Type *t ) const;
 771   virtual const Type *xdual() const;    // Compute dual right now.
 772   bool ary_must_be_exact() const;  // true if arrays of such are never generic
 773   virtual const Type* remove_speculative() const;
 774   virtual const Type* cleanup_speculative() const;

 775 #ifdef ASSERT
 776   // One type is interface, the other is oop
 777   virtual bool interface_vs_oop(const Type *t) const;
 778 #endif
 779 #ifndef PRODUCT
 780   virtual void dump2( Dict &d, uint, outputStream *st  ) const; // Specialized per-Type dumping
 781 #endif
 782 };
 783 







































 784 //------------------------------TypeVect---------------------------------------
 785 // Class of Vector Types
 786 class TypeVect : public Type {
 787   const Type*   _elem;  // Vector's element type
 788   const uint  _length;  // Elements in vector (power of 2)
 789 
 790 protected:
 791   TypeVect(TYPES t, const Type* elem, uint length) : Type(t),
 792     _elem(elem), _length(length) {}
 793 
 794 public:
 795   const Type* element_type() const { return _elem; }
 796   BasicType element_basic_type() const { return _elem->array_element_basic_type(); }
 797   uint length() const { return _length; }
 798   uint length_in_bytes() const {
 799    return _length * type2aelembytes(element_basic_type());
 800   }
 801 
 802   virtual bool eq(const Type *t) const;
 803   virtual int  hash() const;             // Type specific hashing
 804   virtual bool singleton(void) const;    // TRUE if type is a singleton
 805   virtual bool empty(void) const;        // TRUE if type is vacuous
 806 
 807   static const TypeVect *make(const BasicType elem_bt, uint length) {
 808     // Use bottom primitive type.
 809     return make(get_const_basic_type(elem_bt), length);
 810   }
 811   // Used directly by Replicate nodes to construct singleton vector.
 812   static const TypeVect *make(const Type* elem, uint length);
 813 
 814   static const TypeVect *makemask(const BasicType elem_bt, uint length) {
 815     // Use bottom primitive type.
 816     return makemask(get_const_basic_type(elem_bt), length);
 817   }
 818   static const TypeVect *makemask(const Type* elem, uint length);
 819 
 820 
 821   virtual const Type *xmeet( const Type *t) const;
 822   virtual const Type *xdual() const;     // Compute dual right now.
 823 
 824   static const TypeVect *VECTA;
 825   static const TypeVect *VECTS;
 826   static const TypeVect *VECTD;
 827   static const TypeVect *VECTX;
 828   static const TypeVect *VECTY;
 829   static const TypeVect *VECTZ;
 830   static const TypeVect *VECTMASK;
 831 
 832 #ifndef PRODUCT
 833   virtual void dump2(Dict &d, uint, outputStream *st) const; // Specialized per-Type dumping
 834 #endif
 835 };
 836 
 837 class TypeVectA : public TypeVect {
 838   friend class TypeVect;
 839   TypeVectA(const Type* elem, uint length) : TypeVect(VectorA, elem, length) {}
 840 };
 841 
 842 class TypeVectS : public TypeVect {
 843   friend class TypeVect;
 844   TypeVectS(const Type* elem, uint length) : TypeVect(VectorS, elem, length) {}
 845 };
 846 
 847 class TypeVectD : public TypeVect {
 848   friend class TypeVect;
 849   TypeVectD(const Type* elem, uint length) : TypeVect(VectorD, elem, length) {}
 850 };
 851 
 852 class TypeVectX : public TypeVect {
 853   friend class TypeVect;
 854   TypeVectX(const Type* elem, uint length) : TypeVect(VectorX, elem, length) {}
 855 };
 856 
 857 class TypeVectY : public TypeVect {
 858   friend class TypeVect;
 859   TypeVectY(const Type* elem, uint length) : TypeVect(VectorY, elem, length) {}
 860 };
 861 
 862 class TypeVectZ : public TypeVect {
 863   friend class TypeVect;
 864   TypeVectZ(const Type* elem, uint length) : TypeVect(VectorZ, elem, length) {}
 865 };
 866 
 867 class TypeVectMask : public TypeVect {
 868 public:
 869   friend class TypeVect;
 870   TypeVectMask(const Type* elem, uint length) : TypeVect(VectorMask, elem, length) {}
 871   virtual bool eq(const Type *t) const;
 872   virtual const Type *xdual() const;
 873 };
 874 
 875 //------------------------------TypePtr----------------------------------------
 876 // Class of machine Pointer Types: raw data, instances or arrays.
 877 // If the _base enum is AnyPtr, then this refers to all of the above.
 878 // Otherwise the _base will indicate which subset of pointers is affected,
 879 // and the class will be inherited from.
 880 class TypePtr : public Type {
 881   friend class TypeNarrowPtr;
 882 public:
 883   enum PTR { TopPTR, AnyNull, Constant, Null, NotNull, BotPTR, lastPTR };
 884 protected:
 885   TypePtr(TYPES t, PTR ptr, int offset,
 886           const TypePtr* speculative = NULL,
 887           int inline_depth = InlineDepthBottom) :
 888     Type(t), _speculative(speculative), _inline_depth(inline_depth), _offset(offset),
 889     _ptr(ptr) {}
 890   static const PTR ptr_meet[lastPTR][lastPTR];
 891   static const PTR ptr_dual[lastPTR];
 892   static const char * const ptr_msg[lastPTR];
 893 
 894   enum {
 895     InlineDepthBottom = INT_MAX,
 896     InlineDepthTop = -InlineDepthBottom
 897   };
 898 
 899   // Extra type information profiling gave us. We propagate it the
 900   // same way the rest of the type info is propagated. If we want to
 901   // use it, then we have to emit a guard: this part of the type is
 902   // not something we know but something we speculate about the type.
 903   const TypePtr*   _speculative;
 904   // For speculative types, we record at what inlining depth the
 905   // profiling point that provided the data is. We want to favor
 906   // profile data coming from outer scopes which are likely better for
 907   // the current compilation.
 908   int _inline_depth;
 909 
 910   // utility methods to work on the speculative part of the type
 911   const TypePtr* dual_speculative() const;
 912   const TypePtr* xmeet_speculative(const TypePtr* other) const;
 913   bool eq_speculative(const TypePtr* other) const;
 914   int hash_speculative() const;
 915   const TypePtr* add_offset_speculative(intptr_t offset) const;
 916 #ifndef PRODUCT
 917   void dump_speculative(outputStream *st) const;
 918 #endif
 919 
 920   // utility methods to work on the inline depth of the type
 921   int dual_inline_depth() const;
 922   int meet_inline_depth(int depth) const;
 923 #ifndef PRODUCT
 924   void dump_inline_depth(outputStream *st) const;
 925 #endif
 926 
 927   // TypeInstPtr (TypeAryPtr resp.) and TypeInstKlassPtr (TypeAryKlassPtr resp.) implement very similar meet logic.
 928   // The logic for meeting 2 instances (2 arrays resp.) is shared in the 2 utility methods below. However the logic for
 929   // the oop and klass versions can be slightly different and extra logic may have to be executed depending on what
 930   // exact case the meet falls into. The MeetResult struct is used by the utility methods to communicate what case was
 931   // encountered so the right logic specific to klasses or oops can be executed.,
 932   enum MeetResult {
 933     QUICK,
 934     UNLOADED,
 935     SUBTYPE,
 936     NOT_SUBTYPE,
 937     LCA
 938   };
 939   static MeetResult
 940   meet_instptr(PTR &ptr, ciKlass* this_klass, ciKlass* tinst_klass, bool this_xk, bool tinst_xk, PTR this_ptr,
 941                PTR tinst_ptr, ciKlass*&res_klass, bool &res_xk);
 942   static MeetResult
 943   meet_aryptr(PTR& ptr, const Type*& elem, ciKlass* this_klass, ciKlass* tap_klass, bool this_xk, bool tap_xk, PTR this_ptr, PTR tap_ptr, ciKlass*& res_klass, bool& res_xk);




 944 
 945 public:
 946   const int _offset;            // Offset into oop, with TOP & BOT
 947   const PTR _ptr;               // Pointer equivalence class
 948 
 949   const int offset() const { return _offset; }
 950   const PTR ptr()    const { return _ptr; }
 951 
 952   static const TypePtr *make(TYPES t, PTR ptr, int offset,
 953                              const TypePtr* speculative = NULL,
 954                              int inline_depth = InlineDepthBottom);
 955 
 956   // Return a 'ptr' version of this type
 957   virtual const Type *cast_to_ptr_type(PTR ptr) const;
 958 
 959   virtual intptr_t get_con() const;
 960 
 961   int xadd_offset( intptr_t offset ) const;
 962   virtual const TypePtr *add_offset( intptr_t offset ) const;


 963   virtual bool eq(const Type *t) const;
 964   virtual int  hash() const;             // Type specific hashing
 965 
 966   virtual bool singleton(void) const;    // TRUE if type is a singleton
 967   virtual bool empty(void) const;        // TRUE if type is vacuous
 968   virtual const Type *xmeet( const Type *t ) const;
 969   virtual const Type *xmeet_helper( const Type *t ) const;
 970   int meet_offset( int offset ) const;
 971   int dual_offset( ) const;
 972   virtual const Type *xdual() const;    // Compute dual right now.
 973 
 974   // meet, dual and join over pointer equivalence sets
 975   PTR meet_ptr( const PTR in_ptr ) const { return ptr_meet[in_ptr][ptr()]; }
 976   PTR dual_ptr()                   const { return ptr_dual[ptr()];      }
 977 
 978   // This is textually confusing unless one recalls that
 979   // join(t) == dual()->meet(t->dual())->dual().
 980   PTR join_ptr( const PTR in_ptr ) const {
 981     return ptr_dual[ ptr_meet[ ptr_dual[in_ptr] ] [ dual_ptr() ] ];
 982   }
 983 
 984   // Speculative type helper methods.
 985   virtual const TypePtr* speculative() const { return _speculative; }
 986   int inline_depth() const                   { return _inline_depth; }
 987   virtual ciKlass* speculative_type() const;
 988   virtual ciKlass* speculative_type_not_null() const;
 989   virtual bool speculative_maybe_null() const;
 990   virtual bool speculative_always_null() const;
 991   virtual const Type* remove_speculative() const;
 992   virtual const Type* cleanup_speculative() const;
 993   virtual bool would_improve_type(ciKlass* exact_kls, int inline_depth) const;
 994   virtual bool would_improve_ptr(ProfilePtrKind maybe_null) const;
 995   virtual const TypePtr* with_inline_depth(int depth) const;
 996 
 997   virtual bool maybe_null() const { return meet_ptr(Null) == ptr(); }
 998 





 999   // Tests for relation to centerline of type lattice:
1000   static bool above_centerline(PTR ptr) { return (ptr <= AnyNull); }
1001   static bool below_centerline(PTR ptr) { return (ptr >= NotNull); }
1002   // Convenience common pre-built types.
1003   static const TypePtr *NULL_PTR;
1004   static const TypePtr *NOTNULL;
1005   static const TypePtr *BOTTOM;
1006 #ifndef PRODUCT
1007   virtual void dump2( Dict &d, uint depth, outputStream *st  ) const;
1008 #endif
1009 };
1010 
1011 //------------------------------TypeRawPtr-------------------------------------
1012 // Class of raw pointers, pointers to things other than Oops.  Examples
1013 // include the stack pointer, top of heap, card-marking area, handles, etc.
1014 class TypeRawPtr : public TypePtr {
1015 protected:
1016   TypeRawPtr( PTR ptr, address bits ) : TypePtr(RawPtr,ptr,0), _bits(bits){}
1017 public:
1018   virtual bool eq( const Type *t ) const;
1019   virtual int  hash() const;     // Type specific hashing
1020 
1021   const address _bits;          // Constant value, if applicable
1022 
1023   static const TypeRawPtr *make( PTR ptr );
1024   static const TypeRawPtr *make( address bits );
1025 
1026   // Return a 'ptr' version of this type
1027   virtual const TypeRawPtr* cast_to_ptr_type(PTR ptr) const;
1028 
1029   virtual intptr_t get_con() const;
1030 
1031   virtual const TypePtr *add_offset( intptr_t offset ) const;
1032 
1033   virtual const Type *xmeet( const Type *t ) const;
1034   virtual const Type *xdual() const;    // Compute dual right now.
1035   // Convenience common pre-built types.
1036   static const TypeRawPtr *BOTTOM;
1037   static const TypeRawPtr *NOTNULL;
1038 #ifndef PRODUCT
1039   virtual void dump2( Dict &d, uint depth, outputStream *st  ) const;
1040 #endif
1041 };
1042 
1043 //------------------------------TypeOopPtr-------------------------------------
1044 // Some kind of oop (Java pointer), either instance or array.
1045 class TypeOopPtr : public TypePtr {
1046 protected:
1047   TypeOopPtr(TYPES t, PTR ptr, ciKlass* k, bool xk, ciObject* o, int offset, int instance_id,
1048              const TypePtr* speculative, int inline_depth);
1049 public:
1050   virtual bool eq( const Type *t ) const;
1051   virtual int  hash() const;             // Type specific hashing
1052   virtual bool singleton(void) const;    // TRUE if type is a singleton
1053   enum {
1054    InstanceTop = -1,   // undefined instance
1055    InstanceBot = 0     // any possible instance
1056   };
1057 protected:
1058 
1059   // Oop is NULL, unless this is a constant oop.
1060   ciObject*     _const_oop;   // Constant oop
1061   // If _klass is NULL, then so is _sig.  This is an unloaded klass.
1062   ciKlass*      _klass;       // Klass object
1063   // Does the type exclude subclasses of the klass?  (Inexact == polymorphic.)
1064   bool          _klass_is_exact;
1065   bool          _is_ptr_to_narrowoop;
1066   bool          _is_ptr_to_narrowklass;
1067   bool          _is_ptr_to_boxed_value;
1068 
1069   // If not InstanceTop or InstanceBot, indicates that this is
1070   // a particular instance of this type which is distinct.
1071   // This is the node index of the allocation node creating this instance.
1072   int           _instance_id;
1073 
1074   static const TypeOopPtr* make_from_klass_common(ciKlass* klass, bool klass_change, bool try_for_exact);
1075 
1076   int dual_instance_id() const;
1077   int meet_instance_id(int uid) const;
1078 
1079   // Do not allow interface-vs.-noninterface joins to collapse to top.
1080   virtual const Type *filter_helper(const Type *kills, bool include_speculative) const;
1081 
1082 public:
1083   // Creates a type given a klass. Correctly handles multi-dimensional arrays
1084   // Respects UseUniqueSubclasses.
1085   // If the klass is final, the resulting type will be exact.
1086   static const TypeOopPtr* make_from_klass(ciKlass* klass) {
1087     return make_from_klass_common(klass, true, false);
1088   }
1089   // Same as before, but will produce an exact type, even if
1090   // the klass is not final, as long as it has exactly one implementation.
1091   static const TypeOopPtr* make_from_klass_unique(ciKlass* klass) {
1092     return make_from_klass_common(klass, true, true);
1093   }
1094   // Same as before, but does not respects UseUniqueSubclasses.
1095   // Use this only for creating array element types.
1096   static const TypeOopPtr* make_from_klass_raw(ciKlass* klass) {
1097     return make_from_klass_common(klass, false, false);
1098   }
1099   // Creates a singleton type given an object.
1100   // If the object cannot be rendered as a constant,
1101   // may return a non-singleton type.
1102   // If require_constant, produce a NULL if a singleton is not possible.
1103   static const TypeOopPtr* make_from_constant(ciObject* o,
1104                                               bool require_constant = false);
1105 
1106   // Make a generic (unclassed) pointer to an oop.
1107   static const TypeOopPtr* make(PTR ptr, int offset, int instance_id,
1108                                 const TypePtr* speculative = NULL,
1109                                 int inline_depth = InlineDepthBottom);
1110 
1111   ciObject* const_oop()    const { return _const_oop; }
1112   virtual ciKlass* klass() const { return _klass;     }
1113   bool klass_is_exact()    const { return _klass_is_exact; }
1114 
1115   // Returns true if this pointer points at memory which contains a
1116   // compressed oop references.
1117   bool is_ptr_to_narrowoop_nv() const { return _is_ptr_to_narrowoop; }
1118   bool is_ptr_to_narrowklass_nv() const { return _is_ptr_to_narrowklass; }
1119   bool is_ptr_to_boxed_value()   const { return _is_ptr_to_boxed_value; }
1120   bool is_known_instance()       const { return _instance_id > 0; }
1121   int  instance_id()             const { return _instance_id; }
1122   bool is_known_instance_field() const { return is_known_instance() && _offset >= 0; }


1123 
1124   virtual intptr_t get_con() const;
1125 
1126   virtual const TypeOopPtr* cast_to_ptr_type(PTR ptr) const;
1127 
1128   virtual const Type *cast_to_exactness(bool klass_is_exact) const;
1129 
1130   virtual const TypeOopPtr *cast_to_instance_id(int instance_id) const;
1131 
1132   // corresponding pointer to klass, for a given instance
1133   virtual const TypeKlassPtr* as_klass_type(bool try_for_exact = false) const;
1134 
1135   virtual const TypePtr *add_offset( intptr_t offset ) const;
1136 
1137   // Speculative type helper methods.
1138   virtual const Type* remove_speculative() const;
1139   virtual const Type* cleanup_speculative() const;
1140   virtual bool would_improve_type(ciKlass* exact_kls, int inline_depth) const;
1141   virtual const TypePtr* with_inline_depth(int depth) const;
1142 
1143   virtual const TypePtr* with_instance_id(int instance_id) const;
1144 
1145   virtual const Type *xdual() const;    // Compute dual right now.
1146   // the core of the computation of the meet for TypeOopPtr and for its subclasses
1147   virtual const Type *xmeet_helper(const Type *t) const;
1148 
1149   // Convenience common pre-built type.
1150   static const TypeOopPtr *BOTTOM;
1151 #ifndef PRODUCT
1152   virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
1153 #endif
1154 };
1155 
1156 //------------------------------TypeInstPtr------------------------------------
1157 // Class of Java object pointers, pointing either to non-array Java instances
1158 // or to a Klass* (including array klasses).
1159 class TypeInstPtr : public TypeOopPtr {
1160   TypeInstPtr(PTR ptr, ciKlass* k, bool xk, ciObject* o, int offset, int instance_id,
1161               const TypePtr* speculative, int inline_depth);

1162   virtual bool eq( const Type *t ) const;
1163   virtual int  hash() const;             // Type specific hashing
1164 
1165   ciSymbol*  _name;        // class name

1166 
1167  public:
1168   ciSymbol* name()         const { return _name; }
1169 
1170   bool  is_loaded() const { return _klass->is_loaded(); }
1171 
1172   // Make a pointer to a constant oop.
1173   static const TypeInstPtr *make(ciObject* o) {
1174     return make(TypePtr::Constant, o->klass(), true, o, 0, InstanceBot);
1175   }
1176   // Make a pointer to a constant oop with offset.
1177   static const TypeInstPtr *make(ciObject* o, int offset) {
1178     return make(TypePtr::Constant, o->klass(), true, o, offset, InstanceBot);
1179   }
1180 
1181   // Make a pointer to some value of type klass.
1182   static const TypeInstPtr *make(PTR ptr, ciKlass* klass) {
1183     return make(ptr, klass, false, NULL, 0, InstanceBot);
1184   }
1185 
1186   // Make a pointer to some non-polymorphic value of exactly type klass.
1187   static const TypeInstPtr *make_exact(PTR ptr, ciKlass* klass) {
1188     return make(ptr, klass, true, NULL, 0, InstanceBot);
1189   }
1190 
1191   // Make a pointer to some value of type klass with offset.
1192   static const TypeInstPtr *make(PTR ptr, ciKlass* klass, int offset) {
1193     return make(ptr, klass, false, NULL, offset, InstanceBot);
1194   }
1195 
1196   // Make a pointer to an oop.
1197   static const TypeInstPtr *make(PTR ptr, ciKlass* k, bool xk, ciObject* o, int offset,

1198                                  int instance_id = InstanceBot,
1199                                  const TypePtr* speculative = NULL,
1200                                  int inline_depth = InlineDepthBottom);
1201 
1202   /** Create constant type for a constant boxed value */
1203   const Type* get_const_boxed_value() const;
1204 
1205   // If this is a java.lang.Class constant, return the type for it or NULL.
1206   // Pass to Type::get_const_type to turn it to a type, which will usually
1207   // be a TypeInstPtr, but may also be a TypeInt::INT for int.class, etc.
1208   ciType* java_mirror_type() const;
1209 
1210   virtual const TypeInstPtr* cast_to_ptr_type(PTR ptr) const;
1211 
1212   virtual const Type *cast_to_exactness(bool klass_is_exact) const;
1213 
1214   virtual const TypeOopPtr *cast_to_instance_id(int instance_id) const;
1215 
1216   virtual const TypePtr *add_offset( intptr_t offset ) const;
1217 
1218   // Speculative type helper methods.
1219   virtual const Type* remove_speculative() const;
1220   virtual const TypePtr* with_inline_depth(int depth) const;
1221   virtual const TypePtr* with_instance_id(int instance_id) const;
1222 



1223   // the core of the computation of the meet of 2 types
1224   virtual const Type *xmeet_helper(const Type *t) const;
1225   virtual const TypeInstPtr *xmeet_unloaded( const TypeInstPtr *t ) const;
1226   virtual const Type *xdual() const;    // Compute dual right now.
1227 
1228   const TypeKlassPtr* as_klass_type(bool try_for_exact = false) const;
1229 
1230   // Convenience common pre-built types.
1231   static const TypeInstPtr *NOTNULL;
1232   static const TypeInstPtr *BOTTOM;
1233   static const TypeInstPtr *MIRROR;
1234   static const TypeInstPtr *MARK;
1235   static const TypeInstPtr *KLASS;
1236 #ifndef PRODUCT
1237   virtual void dump2( Dict &d, uint depth, outputStream *st ) const; // Specialized per-Type dumping
1238 #endif
1239 };
1240 
1241 //------------------------------TypeAryPtr-------------------------------------
1242 // Class of Java array pointers
1243 class TypeAryPtr : public TypeOopPtr {
1244   TypeAryPtr( PTR ptr, ciObject* o, const TypeAry *ary, ciKlass* k, bool xk,
1245               int offset, int instance_id, bool is_autobox_cache,
1246               const TypePtr* speculative, int inline_depth)
1247     : TypeOopPtr(AryPtr,ptr,k,xk,o,offset, instance_id, speculative, inline_depth),
1248     _ary(ary),
1249     _is_autobox_cache(is_autobox_cache)

1250  {
1251 #ifdef ASSERT
1252     if (k != NULL) {
1253       // Verify that specified klass and TypeAryPtr::klass() follow the same rules.
1254       ciKlass* ck = compute_klass(true);
1255       if (k != ck) {
1256         this->dump(); tty->cr();
1257         tty->print(" k: ");
1258         k->print(); tty->cr();
1259         tty->print("ck: ");
1260         if (ck != NULL) ck->print();
1261         else tty->print("<NULL>");
1262         tty->cr();
1263         assert(false, "unexpected TypeAryPtr::_klass");
1264       }
1265     }
1266 #endif
1267   }
1268   virtual bool eq( const Type *t ) const;
1269   virtual int hash() const;     // Type specific hashing
1270   const TypeAry *_ary;          // Array we point into
1271   const bool     _is_autobox_cache;






1272 
1273   ciKlass* compute_klass(DEBUG_ONLY(bool verify = false)) const;
1274 
1275 public:
1276   // Accessors
1277   ciKlass* klass() const;
1278   const TypeAry* ary() const  { return _ary; }
1279   const Type*    elem() const { return _ary->_elem; }
1280   const TypeInt* size() const { return _ary->_size; }
1281   bool      is_stable() const { return _ary->_stable; }
1282 






1283   bool is_autobox_cache() const { return _is_autobox_cache; }
1284 
1285   static const TypeAryPtr *make(PTR ptr, const TypeAry *ary, ciKlass* k, bool xk, int offset,

1286                                 int instance_id = InstanceBot,
1287                                 const TypePtr* speculative = NULL,
1288                                 int inline_depth = InlineDepthBottom);
1289   // Constant pointer to array
1290   static const TypeAryPtr *make(PTR ptr, ciObject* o, const TypeAry *ary, ciKlass* k, bool xk, int offset,

1291                                 int instance_id = InstanceBot,
1292                                 const TypePtr* speculative = NULL,
1293                                 int inline_depth = InlineDepthBottom, bool is_autobox_cache = false);

1294 
1295   // Return a 'ptr' version of this type
1296   virtual const TypeAryPtr* cast_to_ptr_type(PTR ptr) const;
1297 
1298   virtual const Type *cast_to_exactness(bool klass_is_exact) const;
1299 
1300   virtual const TypeOopPtr *cast_to_instance_id(int instance_id) const;
1301 
1302   virtual const TypeAryPtr* cast_to_size(const TypeInt* size) const;
1303   virtual const TypeInt* narrow_size_type(const TypeInt* size) const;
1304 
1305   virtual bool empty(void) const;        // TRUE if type is vacuous
1306   virtual const TypePtr *add_offset( intptr_t offset ) const;
1307 
1308   // Speculative type helper methods.
1309   virtual const Type* remove_speculative() const;

1310   virtual const TypePtr* with_inline_depth(int depth) const;
1311   virtual const TypePtr* with_instance_id(int instance_id) const;
1312 
1313   // the core of the computation of the meet of 2 types
1314   virtual const Type *xmeet_helper(const Type *t) const;
1315   virtual const Type *xdual() const;    // Compute dual right now.
1316 





1317   const TypeAryPtr* cast_to_stable(bool stable, int stable_dimension = 1) const;
1318   int stable_dimension() const;
1319 
1320   const TypeAryPtr* cast_to_autobox_cache() const;
1321 
1322   static jint max_array_length(BasicType etype) ;







1323   virtual const TypeKlassPtr* as_klass_type(bool try_for_exact = false) const;
1324 
1325   // Convenience common pre-built types.
1326   static const TypeAryPtr *RANGE;
1327   static const TypeAryPtr *OOPS;
1328   static const TypeAryPtr *NARROWOOPS;
1329   static const TypeAryPtr *BYTES;
1330   static const TypeAryPtr *SHORTS;
1331   static const TypeAryPtr *CHARS;
1332   static const TypeAryPtr *INTS;
1333   static const TypeAryPtr *LONGS;
1334   static const TypeAryPtr *FLOATS;
1335   static const TypeAryPtr *DOUBLES;

1336   // selects one of the above:
1337   static const TypeAryPtr *get_array_body_type(BasicType elem) {
1338     assert((uint)elem <= T_CONFLICT && _array_body_type[elem] != NULL, "bad elem type");
1339     return _array_body_type[elem];
1340   }
1341   static const TypeAryPtr *_array_body_type[T_CONFLICT+1];
1342   // sharpen the type of an int which is used as an array size
1343 #ifdef ASSERT
1344   // One type is interface, the other is oop
1345   virtual bool interface_vs_oop(const Type *t) const;
1346 #endif
1347 #ifndef PRODUCT
1348   virtual void dump2( Dict &d, uint depth, outputStream *st ) const; // Specialized per-Type dumping
1349 #endif
1350 };
1351 
1352 //------------------------------TypeMetadataPtr-------------------------------------
1353 // Some kind of metadata, either Method*, MethodData* or CPCacheOop
1354 class TypeMetadataPtr : public TypePtr {
1355 protected:
1356   TypeMetadataPtr(PTR ptr, ciMetadata* metadata, int offset);
1357   // Do not allow interface-vs.-noninterface joins to collapse to top.
1358   virtual const Type *filter_helper(const Type *kills, bool include_speculative) const;
1359 public:
1360   virtual bool eq( const Type *t ) const;
1361   virtual int  hash() const;             // Type specific hashing
1362   virtual bool singleton(void) const;    // TRUE if type is a singleton
1363 
1364 private:
1365   ciMetadata*   _metadata;
1366 
1367 public:
1368   static const TypeMetadataPtr* make(PTR ptr, ciMetadata* m, int offset);
1369 
1370   static const TypeMetadataPtr* make(ciMethod* m);
1371   static const TypeMetadataPtr* make(ciMethodData* m);
1372 
1373   ciMetadata* metadata() const { return _metadata; }
1374 
1375   virtual const TypeMetadataPtr* cast_to_ptr_type(PTR ptr) const;
1376 
1377   virtual const TypePtr *add_offset( intptr_t offset ) const;
1378 
1379   virtual const Type *xmeet( const Type *t ) const;
1380   virtual const Type *xdual() const;    // Compute dual right now.
1381 
1382   virtual intptr_t get_con() const;
1383 
1384   // Convenience common pre-built types.
1385   static const TypeMetadataPtr *BOTTOM;
1386 
1387 #ifndef PRODUCT
1388   virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
1389 #endif
1390 };
1391 
1392 //------------------------------TypeKlassPtr-----------------------------------
1393 // Class of Java Klass pointers
1394 class TypeKlassPtr : public TypePtr {
1395 protected:
1396   TypeKlassPtr(TYPES t, PTR ptr, ciKlass* klass, int offset);
1397 
1398   virtual const Type *filter_helper(const Type *kills, bool include_speculative) const;
1399 
1400 public:
1401   virtual bool eq( const Type *t ) const;
1402   virtual int hash() const;
1403   virtual bool singleton(void) const;    // TRUE if type is a singleton
1404   virtual bool must_be_exact() const { ShouldNotReachHere(); return false; }
1405 
1406 protected:
1407 
1408   ciKlass* _klass;
1409 
1410 public:
1411 
1412   virtual ciKlass* klass() const { return  _klass; }
1413   bool klass_is_exact()    const { return _ptr == Constant; }
1414   bool  is_loaded() const { return klass()->is_loaded(); }
1415 
1416   static const TypeKlassPtr* make(ciKlass* klass);
1417   static const TypeKlassPtr *make(PTR ptr, ciKlass* klass, int offset);
1418 
1419 
1420   virtual const TypePtr* cast_to_ptr_type(PTR ptr) const { ShouldNotReachHere(); return NULL; }
1421 
1422   virtual const TypeKlassPtr *cast_to_exactness(bool klass_is_exact) const { ShouldNotReachHere(); return NULL; }
1423 
1424   // corresponding pointer to instance, for a given class
1425   virtual const TypeOopPtr* as_instance_type() const { ShouldNotReachHere(); return NULL; }
1426 
1427   virtual const TypePtr *add_offset( intptr_t offset ) const { ShouldNotReachHere(); return NULL; }
1428   virtual const Type    *xmeet( const Type *t ) const { ShouldNotReachHere(); return NULL; }
1429   virtual const Type    *xdual() const { ShouldNotReachHere(); return NULL; }
1430 
1431   virtual intptr_t get_con() const;
1432 
1433   virtual const TypeKlassPtr* with_offset(intptr_t offset) const { ShouldNotReachHere(); return NULL; }
1434 
1435 #ifndef PRODUCT
1436   virtual void dump2( Dict &d, uint depth, outputStream *st ) const; // Specialized per-Type dumping
1437 #endif
1438 };
1439 
1440 // Instance klass pointer, mirrors TypeInstPtr
1441 class TypeInstKlassPtr : public TypeKlassPtr {
1442 
1443   TypeInstKlassPtr(PTR ptr, ciKlass* klass, int offset)
1444     : TypeKlassPtr(InstKlassPtr, ptr, klass, offset) {
1445   }
1446 
1447   virtual bool must_be_exact() const;
1448 


1449 public:
1450   // Instance klass ignoring any interface
1451   ciInstanceKlass* instance_klass() const { return klass()->as_instance_klass();     }
1452 


1453   static const TypeInstKlassPtr *make(ciKlass* k) {
1454     return make(TypePtr::Constant, k, 0);
1455   }
1456   static const TypeInstKlassPtr *make(PTR ptr, ciKlass* k, int offset);
1457 
1458   virtual const TypePtr* cast_to_ptr_type(PTR ptr) const;
1459 
1460   virtual const TypeKlassPtr *cast_to_exactness(bool klass_is_exact) const;
1461 
1462   // corresponding pointer to instance, for a given class
1463   virtual const TypeOopPtr* as_instance_type() const;
1464   virtual int hash() const;
1465   virtual bool eq(const Type *t) const;
1466 
1467   virtual const TypePtr *add_offset( intptr_t offset ) const;
1468   virtual const Type    *xmeet( const Type *t ) const;
1469   virtual const Type    *xdual() const;
1470   virtual const TypeKlassPtr* with_offset(intptr_t offset) const;
1471 


1472   // Convenience common pre-built types.
1473   static const TypeInstKlassPtr* OBJECT; // Not-null object klass or below
1474   static const TypeInstKlassPtr* OBJECT_OR_NULL; // Maybe-null version of same




1475 };
1476 
1477 // Array klass pointer, mirrors TypeAryPtr
1478 class TypeAryKlassPtr : public TypeKlassPtr {
1479   const Type *_elem;



1480 
1481   TypeAryKlassPtr(PTR ptr, const Type *elem, ciKlass* klass, int offset)
1482     : TypeKlassPtr(AryKlassPtr, ptr, klass, offset), _elem(elem) {
1483   }
1484 
1485   virtual bool must_be_exact() const;
1486 








1487 public:
1488   virtual ciKlass* klass() const;
1489 
1490   // returns base element type, an instance klass (and not interface) for object arrays
1491   const Type* base_element_type(int& dims) const;
1492 
1493   static const TypeAryKlassPtr *make(PTR ptr, ciKlass* k, int offset);
1494   static const TypeAryKlassPtr *make(PTR ptr, const Type *elem, ciKlass* k, int offset);
1495   static const TypeAryKlassPtr* make(ciKlass* klass);
1496 
1497   const Type *elem() const { return _elem; }
1498 
1499   virtual bool eq(const Type *t) const;
1500   virtual int hash() const;             // Type specific hashing
1501 
1502   virtual const TypePtr* cast_to_ptr_type(PTR ptr) const;
1503 
1504   virtual const TypeKlassPtr *cast_to_exactness(bool klass_is_exact) const;
1505 
1506   // corresponding pointer to instance, for a given class
1507   virtual const TypeOopPtr* as_instance_type() const;
1508 
1509   virtual const TypePtr *add_offset( intptr_t offset ) const;
1510   virtual const Type    *xmeet( const Type *t ) const;
1511   virtual const Type    *xdual() const;      // Compute dual right now.
1512 
1513   virtual const TypeKlassPtr* with_offset(intptr_t offset) const;
1514 
1515   virtual bool empty(void) const {
1516     return TypeKlassPtr::empty() || _elem->empty();
1517   }
1518 




1519 #ifndef PRODUCT
1520   virtual void dump2( Dict &d, uint depth, outputStream *st ) const; // Specialized per-Type dumping
1521 #endif
1522 };
1523 
1524 class TypeNarrowPtr : public Type {
1525 protected:
1526   const TypePtr* _ptrtype; // Could be TypePtr::NULL_PTR
1527 
1528   TypeNarrowPtr(TYPES t, const TypePtr* ptrtype): Type(t),
1529                                                   _ptrtype(ptrtype) {
1530     assert(ptrtype->offset() == 0 ||
1531            ptrtype->offset() == OffsetBot ||
1532            ptrtype->offset() == OffsetTop, "no real offsets");
1533   }
1534 
1535   virtual const TypeNarrowPtr *isa_same_narrowptr(const Type *t) const = 0;
1536   virtual const TypeNarrowPtr *is_same_narrowptr(const Type *t) const = 0;
1537   virtual const TypeNarrowPtr *make_same_narrowptr(const TypePtr *t) const = 0;
1538   virtual const TypeNarrowPtr *make_hash_same_narrowptr(const TypePtr *t) const = 0;
1539   // Do not allow interface-vs.-noninterface joins to collapse to top.
1540   virtual const Type *filter_helper(const Type *kills, bool include_speculative) const;
1541 public:
1542   virtual bool eq( const Type *t ) const;
1543   virtual int  hash() const;             // Type specific hashing
1544   virtual bool singleton(void) const;    // TRUE if type is a singleton
1545 
1546   virtual const Type *xmeet( const Type *t ) const;
1547   virtual const Type *xdual() const;    // Compute dual right now.
1548 
1549   virtual intptr_t get_con() const;
1550 
1551   virtual bool empty(void) const;        // TRUE if type is vacuous
1552 
1553   // returns the equivalent ptr type for this compressed pointer
1554   const TypePtr *get_ptrtype() const {
1555     return _ptrtype;
1556   }
1557 
1558   bool is_known_instance() const {
1559     return _ptrtype->is_known_instance();
1560   }
1561 
1562 #ifndef PRODUCT
1563   virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
1564 #endif
1565 };
1566 
1567 //------------------------------TypeNarrowOop----------------------------------
1568 // A compressed reference to some kind of Oop.  This type wraps around
1569 // a preexisting TypeOopPtr and forwards most of it's operations to
1570 // the underlying type.  It's only real purpose is to track the
1571 // oopness of the compressed oop value when we expose the conversion
1572 // between the normal and the compressed form.
1573 class TypeNarrowOop : public TypeNarrowPtr {
1574 protected:
1575   TypeNarrowOop( const TypePtr* ptrtype): TypeNarrowPtr(NarrowOop, ptrtype) {
1576   }
1577 
1578   virtual const TypeNarrowPtr *isa_same_narrowptr(const Type *t) const {
1579     return t->isa_narrowoop();
1580   }
1581 
1582   virtual const TypeNarrowPtr *is_same_narrowptr(const Type *t) const {
1583     return t->is_narrowoop();
1584   }
1585 
1586   virtual const TypeNarrowPtr *make_same_narrowptr(const TypePtr *t) const {
1587     return new TypeNarrowOop(t);
1588   }
1589 
1590   virtual const TypeNarrowPtr *make_hash_same_narrowptr(const TypePtr *t) const {
1591     return (const TypeNarrowPtr*)((new TypeNarrowOop(t))->hashcons());
1592   }
1593 
1594 public:
1595 
1596   static const TypeNarrowOop *make( const TypePtr* type);
1597 
1598   static const TypeNarrowOop* make_from_constant(ciObject* con, bool require_constant = false) {
1599     return make(TypeOopPtr::make_from_constant(con, require_constant));
1600   }
1601 
1602   static const TypeNarrowOop *BOTTOM;
1603   static const TypeNarrowOop *NULL_PTR;
1604 
1605   virtual const Type* remove_speculative() const;
1606   virtual const Type* cleanup_speculative() const;
1607 
1608 #ifndef PRODUCT
1609   virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
1610 #endif
1611 };
1612 
1613 //------------------------------TypeNarrowKlass----------------------------------
1614 // A compressed reference to klass pointer.  This type wraps around a
1615 // preexisting TypeKlassPtr and forwards most of it's operations to
1616 // the underlying type.
1617 class TypeNarrowKlass : public TypeNarrowPtr {
1618 protected:
1619   TypeNarrowKlass( const TypePtr* ptrtype): TypeNarrowPtr(NarrowKlass, ptrtype) {
1620   }
1621 
1622   virtual const TypeNarrowPtr *isa_same_narrowptr(const Type *t) const {
1623     return t->isa_narrowklass();
1624   }
1625 
1626   virtual const TypeNarrowPtr *is_same_narrowptr(const Type *t) const {
1627     return t->is_narrowklass();
1628   }
1629 
1630   virtual const TypeNarrowPtr *make_same_narrowptr(const TypePtr *t) const {
1631     return new TypeNarrowKlass(t);
1632   }
1633 
1634   virtual const TypeNarrowPtr *make_hash_same_narrowptr(const TypePtr *t) const {
1635     return (const TypeNarrowPtr*)((new TypeNarrowKlass(t))->hashcons());
1636   }
1637 
1638 public:
1639   static const TypeNarrowKlass *make( const TypePtr* type);
1640 
1641   // static const TypeNarrowKlass *BOTTOM;
1642   static const TypeNarrowKlass *NULL_PTR;
1643 
1644 #ifndef PRODUCT
1645   virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
1646 #endif
1647 };
1648 
1649 //------------------------------TypeFunc---------------------------------------
1650 // Class of Array Types
1651 class TypeFunc : public Type {
1652   TypeFunc( const TypeTuple *domain, const TypeTuple *range ) : Type(Function),  _domain(domain), _range(range) {}

1653   virtual bool eq( const Type *t ) const;
1654   virtual int  hash() const;             // Type specific hashing
1655   virtual bool singleton(void) const;    // TRUE if type is a singleton
1656   virtual bool empty(void) const;        // TRUE if type is vacuous
1657 
1658   const TypeTuple* const _domain;     // Domain of inputs
1659   const TypeTuple* const _range;      // Range of results











1660 
1661 public:
1662   // Constants are shared among ADLC and VM
1663   enum { Control    = AdlcVMDeps::Control,
1664          I_O        = AdlcVMDeps::I_O,
1665          Memory     = AdlcVMDeps::Memory,
1666          FramePtr   = AdlcVMDeps::FramePtr,
1667          ReturnAdr  = AdlcVMDeps::ReturnAdr,
1668          Parms      = AdlcVMDeps::Parms
1669   };
1670 
1671 
1672   // Accessors:
1673   const TypeTuple* domain() const { return _domain; }
1674   const TypeTuple* range()  const { return _range; }
1675 
1676   static const TypeFunc *make(ciMethod* method);
1677   static const TypeFunc *make(ciSignature signature, const Type* extra);



1678   static const TypeFunc *make(const TypeTuple* domain, const TypeTuple* range);
1679 
1680   virtual const Type *xmeet( const Type *t ) const;
1681   virtual const Type *xdual() const;    // Compute dual right now.
1682 
1683   BasicType return_type() const;
1684 


1685 #ifndef PRODUCT
1686   virtual void dump2( Dict &d, uint depth, outputStream *st ) const; // Specialized per-Type dumping
1687 #endif
1688   // Convenience common pre-built types.
1689 };
1690 
1691 //------------------------------accessors--------------------------------------
1692 inline bool Type::is_ptr_to_narrowoop() const {
1693 #ifdef _LP64
1694   return (isa_oopptr() != NULL && is_oopptr()->is_ptr_to_narrowoop_nv());
1695 #else
1696   return false;
1697 #endif
1698 }
1699 
1700 inline bool Type::is_ptr_to_narrowklass() const {
1701 #ifdef _LP64
1702   return (isa_oopptr() != NULL && is_oopptr()->is_ptr_to_narrowklass_nv());
1703 #else
1704   return false;
1705 #endif
1706 }
1707 
1708 inline float Type::getf() const {
1709   assert( _base == FloatCon, "Not a FloatCon" );
1710   return ((TypeF*)this)->_f;
1711 }
1712 
1713 inline double Type::getd() const {
1714   assert( _base == DoubleCon, "Not a DoubleCon" );
1715   return ((TypeD*)this)->_d;
1716 }
1717 
1718 inline const TypeInteger *Type::is_integer(BasicType bt) const {
1719   assert((bt == T_INT && _base == Int) || (bt == T_LONG && _base == Long), "Not an Int");
1720   return (TypeInteger*)this;
1721 }
1722 
1723 inline const TypeInteger *Type::isa_integer(BasicType bt) const {
1724   return (((bt == T_INT && _base == Int) || (bt == T_LONG && _base == Long)) ? (TypeInteger*)this : NULL);
1725 }
1726 
1727 inline const TypeInt *Type::is_int() const {
1728   assert( _base == Int, "Not an Int" );
1729   return (TypeInt*)this;
1730 }
1731 
1732 inline const TypeInt *Type::isa_int() const {
1733   return ( _base == Int ? (TypeInt*)this : NULL);
1734 }
1735 
1736 inline const TypeLong *Type::is_long() const {
1737   assert( _base == Long, "Not a Long" );
1738   return (TypeLong*)this;
1739 }
1740 
1741 inline const TypeLong *Type::isa_long() const {
1742   return ( _base == Long ? (TypeLong*)this : NULL);
1743 }
1744 
1745 inline const TypeF *Type::isa_float() const {
1746   return ((_base == FloatTop ||
1747            _base == FloatCon ||
1748            _base == FloatBot) ? (TypeF*)this : NULL);
1749 }
1750 
1751 inline const TypeF *Type::is_float_constant() const {
1752   assert( _base == FloatCon, "Not a Float" );
1753   return (TypeF*)this;
1754 }
1755 
1756 inline const TypeF *Type::isa_float_constant() const {
1757   return ( _base == FloatCon ? (TypeF*)this : NULL);
1758 }
1759 
1760 inline const TypeD *Type::isa_double() const {
1761   return ((_base == DoubleTop ||
1762            _base == DoubleCon ||
1763            _base == DoubleBot) ? (TypeD*)this : NULL);
1764 }
1765 
1766 inline const TypeD *Type::is_double_constant() const {
1767   assert( _base == DoubleCon, "Not a Double" );
1768   return (TypeD*)this;
1769 }
1770 
1771 inline const TypeD *Type::isa_double_constant() const {
1772   return ( _base == DoubleCon ? (TypeD*)this : NULL);
1773 }
1774 
1775 inline const TypeTuple *Type::is_tuple() const {
1776   assert( _base == Tuple, "Not a Tuple" );
1777   return (TypeTuple*)this;
1778 }
1779 
1780 inline const TypeAry *Type::is_ary() const {
1781   assert( _base == Array , "Not an Array" );
1782   return (TypeAry*)this;
1783 }
1784 
1785 inline const TypeAry *Type::isa_ary() const {
1786   return ((_base == Array) ? (TypeAry*)this : NULL);
1787 }
1788 
1789 inline const TypeVectMask *Type::is_vectmask() const {
1790   assert( _base == VectorMask, "Not a Vector Mask" );
1791   return (TypeVectMask*)this;
1792 }
1793 
1794 inline const TypeVectMask *Type::isa_vectmask() const {
1795   return (_base == VectorMask) ? (TypeVectMask*)this : NULL;
1796 }
1797 
1798 inline const TypeVect *Type::is_vect() const {
1799   assert( _base >= VectorMask && _base <= VectorZ, "Not a Vector" );
1800   return (TypeVect*)this;
1801 }
1802 
1803 inline const TypeVect *Type::isa_vect() const {
1804   return (_base >= VectorMask && _base <= VectorZ) ? (TypeVect*)this : NULL;
1805 }
1806 
1807 inline const TypePtr *Type::is_ptr() const {
1808   // AnyPtr is the first Ptr and KlassPtr the last, with no non-ptrs between.
1809   assert(_base >= AnyPtr && _base <= AryKlassPtr, "Not a pointer");
1810   return (TypePtr*)this;
1811 }
1812 
1813 inline const TypePtr *Type::isa_ptr() const {
1814   // AnyPtr is the first Ptr and KlassPtr the last, with no non-ptrs between.
1815   return (_base >= AnyPtr && _base <= AryKlassPtr) ? (TypePtr*)this : NULL;
1816 }
1817 
1818 inline const TypeOopPtr *Type::is_oopptr() const {
1819   // OopPtr is the first and KlassPtr the last, with no non-oops between.
1820   assert(_base >= OopPtr && _base <= AryPtr, "Not a Java pointer" ) ;
1821   return (TypeOopPtr*)this;
1822 }
1823 
1824 inline const TypeOopPtr *Type::isa_oopptr() const {
1825   // OopPtr is the first and KlassPtr the last, with no non-oops between.
1826   return (_base >= OopPtr && _base <= AryPtr) ? (TypeOopPtr*)this : NULL;
1827 }
1828 
1829 inline const TypeRawPtr *Type::isa_rawptr() const {
1830   return (_base == RawPtr) ? (TypeRawPtr*)this : NULL;
1831 }
1832 
1833 inline const TypeRawPtr *Type::is_rawptr() const {
1834   assert( _base == RawPtr, "Not a raw pointer" );
1835   return (TypeRawPtr*)this;
1836 }
1837 
1838 inline const TypeInstPtr *Type::isa_instptr() const {
1839   return (_base == InstPtr) ? (TypeInstPtr*)this : NULL;
1840 }
1841 
1842 inline const TypeInstPtr *Type::is_instptr() const {
1843   assert( _base == InstPtr, "Not an object pointer" );
1844   return (TypeInstPtr*)this;
1845 }
1846 
1847 inline const TypeAryPtr *Type::isa_aryptr() const {
1848   return (_base == AryPtr) ? (TypeAryPtr*)this : NULL;
1849 }
1850 
1851 inline const TypeAryPtr *Type::is_aryptr() const {
1852   assert( _base == AryPtr, "Not an array pointer" );
1853   return (TypeAryPtr*)this;
1854 }
1855 









1856 inline const TypeNarrowOop *Type::is_narrowoop() const {
1857   // OopPtr is the first and KlassPtr the last, with no non-oops between.
1858   assert(_base == NarrowOop, "Not a narrow oop" ) ;
1859   return (TypeNarrowOop*)this;
1860 }
1861 
1862 inline const TypeNarrowOop *Type::isa_narrowoop() const {
1863   // OopPtr is the first and KlassPtr the last, with no non-oops between.
1864   return (_base == NarrowOop) ? (TypeNarrowOop*)this : NULL;
1865 }
1866 
1867 inline const TypeNarrowKlass *Type::is_narrowklass() const {
1868   assert(_base == NarrowKlass, "Not a narrow oop" ) ;
1869   return (TypeNarrowKlass*)this;
1870 }
1871 
1872 inline const TypeNarrowKlass *Type::isa_narrowklass() const {
1873   return (_base == NarrowKlass) ? (TypeNarrowKlass*)this : NULL;
1874 }
1875 
1876 inline const TypeMetadataPtr *Type::is_metadataptr() const {
1877   // MetadataPtr is the first and CPCachePtr the last
1878   assert(_base == MetadataPtr, "Not a metadata pointer" ) ;
1879   return (TypeMetadataPtr*)this;
1880 }
1881 
1882 inline const TypeMetadataPtr *Type::isa_metadataptr() const {
1883   return (_base == MetadataPtr) ? (TypeMetadataPtr*)this : NULL;
1884 }
1885 
1886 inline const TypeKlassPtr *Type::isa_klassptr() const {
1887   return (_base >= KlassPtr && _base <= AryKlassPtr ) ? (TypeKlassPtr*)this : NULL;
1888 }
1889 
1890 inline const TypeKlassPtr *Type::is_klassptr() const {
1891   assert(_base >= KlassPtr && _base <= AryKlassPtr, "Not a klass pointer");
1892   return (TypeKlassPtr*)this;
1893 }
1894 
1895 inline const TypeInstKlassPtr *Type::isa_instklassptr() const {
1896   return (_base == InstKlassPtr) ? (TypeInstKlassPtr*)this : NULL;
1897 }
1898 
1899 inline const TypeInstKlassPtr *Type::is_instklassptr() const {
1900   assert(_base == InstKlassPtr, "Not a klass pointer");
1901   return (TypeInstKlassPtr*)this;
1902 }
1903 
1904 inline const TypeAryKlassPtr *Type::isa_aryklassptr() const {
1905   return (_base == AryKlassPtr) ? (TypeAryKlassPtr*)this : NULL;
1906 }
1907 
1908 inline const TypeAryKlassPtr *Type::is_aryklassptr() const {
1909   assert(_base == AryKlassPtr, "Not a klass pointer");
1910   return (TypeAryKlassPtr*)this;
1911 }
1912 
1913 inline const TypePtr* Type::make_ptr() const {
1914   return (_base == NarrowOop) ? is_narrowoop()->get_ptrtype() :
1915                               ((_base == NarrowKlass) ? is_narrowklass()->get_ptrtype() :
1916                                                        isa_ptr());
1917 }
1918 
1919 inline const TypeOopPtr* Type::make_oopptr() const {
1920   return (_base == NarrowOop) ? is_narrowoop()->get_ptrtype()->isa_oopptr() : isa_oopptr();
1921 }
1922 
1923 inline const TypeNarrowOop* Type::make_narrowoop() const {
1924   return (_base == NarrowOop) ? is_narrowoop() :
1925                                 (isa_ptr() ? TypeNarrowOop::make(is_ptr()) : NULL);
1926 }
1927 
1928 inline const TypeNarrowKlass* Type::make_narrowklass() const {
1929   return (_base == NarrowKlass) ? is_narrowklass() :
1930                                   (isa_ptr() ? TypeNarrowKlass::make(is_ptr()) : NULL);
1931 }
1932 
1933 inline bool Type::is_floatingpoint() const {
1934   if( (_base == FloatCon)  || (_base == FloatBot) ||
1935       (_base == DoubleCon) || (_base == DoubleBot) )
1936     return true;
1937   return false;
1938 }
1939 
1940 inline bool Type::is_ptr_to_boxing_obj() const {
1941   const TypeInstPtr* tp = isa_instptr();
1942   return (tp != NULL) && (tp->offset() == 0) &&
1943          tp->klass()->is_instance_klass()  &&
1944          tp->klass()->as_instance_klass()->is_box_klass();



1945 }
1946 
1947 
1948 // ===============================================================
1949 // Things that need to be 64-bits in the 64-bit build but
1950 // 32-bits in the 32-bit build.  Done this way to get full
1951 // optimization AND strong typing.
1952 #ifdef _LP64
1953 
1954 // For type queries and asserts
1955 #define is_intptr_t  is_long
1956 #define isa_intptr_t isa_long
1957 #define find_intptr_t_type find_long_type
1958 #define find_intptr_t_con  find_long_con
1959 #define TypeX        TypeLong
1960 #define Type_X       Type::Long
1961 #define TypeX_X      TypeLong::LONG
1962 #define TypeX_ZERO   TypeLong::ZERO
1963 // For 'ideal_reg' machine registers
1964 #define Op_RegX      Op_RegL
1965 // For phase->intcon variants
1966 #define MakeConX     longcon
1967 #define ConXNode     ConLNode
1968 // For array index arithmetic
1969 #define MulXNode     MulLNode
1970 #define AndXNode     AndLNode
1971 #define OrXNode      OrLNode
1972 #define CmpXNode     CmpLNode

1973 #define SubXNode     SubLNode
1974 #define LShiftXNode  LShiftLNode
1975 // For object size computation:
1976 #define AddXNode     AddLNode
1977 #define RShiftXNode  RShiftLNode
1978 // For card marks and hashcodes
1979 #define URShiftXNode URShiftLNode
1980 // For shenandoahSupport
1981 #define LoadXNode    LoadLNode
1982 #define StoreXNode   StoreLNode
1983 // Opcodes
1984 #define Op_LShiftX   Op_LShiftL
1985 #define Op_AndX      Op_AndL
1986 #define Op_AddX      Op_AddL
1987 #define Op_SubX      Op_SubL
1988 #define Op_XorX      Op_XorL
1989 #define Op_URShiftX  Op_URShiftL
1990 #define Op_LoadX     Op_LoadL

1991 // conversions
1992 #define ConvI2X(x)   ConvI2L(x)
1993 #define ConvL2X(x)   (x)
1994 #define ConvX2I(x)   ConvL2I(x)
1995 #define ConvX2L(x)   (x)
1996 #define ConvX2UL(x)  (x)
1997 
1998 #else
1999 
2000 // For type queries and asserts
2001 #define is_intptr_t  is_int
2002 #define isa_intptr_t isa_int
2003 #define find_intptr_t_type find_int_type
2004 #define find_intptr_t_con  find_int_con
2005 #define TypeX        TypeInt
2006 #define Type_X       Type::Int
2007 #define TypeX_X      TypeInt::INT
2008 #define TypeX_ZERO   TypeInt::ZERO
2009 // For 'ideal_reg' machine registers
2010 #define Op_RegX      Op_RegI
2011 // For phase->intcon variants
2012 #define MakeConX     intcon
2013 #define ConXNode     ConINode
2014 // For array index arithmetic
2015 #define MulXNode     MulINode
2016 #define AndXNode     AndINode
2017 #define OrXNode      OrINode
2018 #define CmpXNode     CmpINode

2019 #define SubXNode     SubINode
2020 #define LShiftXNode  LShiftINode
2021 // For object size computation:
2022 #define AddXNode     AddINode
2023 #define RShiftXNode  RShiftINode
2024 // For card marks and hashcodes
2025 #define URShiftXNode URShiftINode
2026 // For shenandoahSupport
2027 #define LoadXNode    LoadINode
2028 #define StoreXNode   StoreINode
2029 // Opcodes
2030 #define Op_LShiftX   Op_LShiftI
2031 #define Op_AndX      Op_AndI
2032 #define Op_AddX      Op_AddI
2033 #define Op_SubX      Op_SubI
2034 #define Op_XorX      Op_XorI
2035 #define Op_URShiftX  Op_URShiftI
2036 #define Op_LoadX     Op_LoadI

2037 // conversions
2038 #define ConvI2X(x)   (x)
2039 #define ConvL2X(x)   ConvL2I(x)
2040 #define ConvX2I(x)   (x)
2041 #define ConvX2L(x)   ConvI2L(x)
2042 #define ConvX2UL(x)  ConvI2UL(x)
2043 
2044 #endif
2045 
2046 #endif // SHARE_OPTO_TYPE_HPP
--- EOF ---