type.hpp revision 2273:1d1603768966
1207536Smav/* 2207536Smav * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved. 3207536Smav * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4207536Smav * 5207536Smav * This code is free software; you can redistribute it and/or modify it 6207536Smav * under the terms of the GNU General Public License version 2 only, as 7207536Smav * published by the Free Software Foundation. 8207536Smav * 9207536Smav * This code is distributed in the hope that it will be useful, but WITHOUT 10207536Smav * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11207536Smav * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12207536Smav * version 2 for more details (a copy is included in the LICENSE file that 13207536Smav * accompanied this code). 14207536Smav * 15207536Smav * You should have received a copy of the GNU General Public License version 16207536Smav * 2 along with this work; if not, write to the Free Software Foundation, 17207536Smav * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18207536Smav * 19207536Smav * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20207536Smav * or visit www.oracle.com if you need additional information or have any 21207536Smav * questions. 22207536Smav * 23207536Smav */ 24207536Smav 25207536Smav#ifndef SHARE_VM_OPTO_TYPE_HPP 26207536Smav#define SHARE_VM_OPTO_TYPE_HPP 27207536Smav 28207536Smav#include "libadt/port.hpp" 29207536Smav#include "opto/adlcVMDeps.hpp" 30207536Smav#include "runtime/handles.hpp" 31207536Smav 32207536Smav// Portions of code courtesy of Clifford Click 33207536Smav 34207536Smav// Optimization - Graph Style 35207536Smav 36207536Smav 37207536Smav// This class defines a Type lattice. The lattice is used in the constant 38207536Smav// propagation algorithms, and for some type-checking of the iloc code. 39207536Smav// Basic types include RSD's (lower bound, upper bound, stride for integers), 40207536Smav// float & double precision constants, sets of data-labels and code-labels. 41207536Smav// The complete lattice is described below. Subtypes have no relationship to 42207536Smav// up or down in the lattice; that is entirely determined by the behavior of 43207536Smav// the MEET/JOIN functions. 44207536Smav 45207536Smavclass Dict; 46220097Smavclass Type; 47220097Smavclass TypeD; 48207536Smavclass TypeF; 49207536Smavclass TypeInt; 50207536Smavclass TypeLong; 51207536Smavclass TypeNarrowOop; 52207536Smavclass TypeAry; 53207536Smavclass TypeTuple; 54207536Smavclass TypePtr; 55207536Smavclass TypeRawPtr; 56207536Smavclass TypeOopPtr; 57207536Smavclass TypeInstPtr; 58207536Smavclass TypeAryPtr; 59207536Smavclass TypeKlassPtr; 60207536Smav 61207536Smav//------------------------------Type------------------------------------------- 62207536Smav// Basic Type object, represents a set of primitive Values. 63207536Smav// Types are hash-cons'd into a private class dictionary, so only one of each 64207536Smav// different kind of Type exists. Types are never modified after creation, so 65207536Smav// all their interesting fields are constant. 66238873Shrsclass Type { 67207536Smavpublic: 68207536Smav enum TYPES { 69257240Szbb Bad=0, // Type check 70257240Szbb Control, // Control of code (not in lattice) 71207536Smav Top, // Top of the lattice 72207536Smav Int, // Integer range (lo-hi) 73207536Smav Long, // Long integer range (lo-hi) 74207536Smav Half, // Placeholder half of doubleword 75207536Smav NarrowOop, // Compressed oop pointer 76207536Smav 77207536Smav Tuple, // Method signature or object layout 78207536Smav Array, // Array types 79207536Smav 80207536Smav AnyPtr, // Any old raw, klass, inst, or array pointer 81261410Sian RawPtr, // Raw (non-oop) pointers 82261410Sian OopPtr, // Any and all Java heap entities 83261410Sian InstPtr, // Instance pointers (non-array objects) 84220097Smav AryPtr, // Array pointers 85220097Smav KlassPtr, // Klass pointers 86220097Smav // (Ptr order matters: See is_ptr, isa_ptr, is_oopptr, isa_oopptr.) 87207536Smav 88207536Smav Function, // Function signature 89207536Smav Abio, // Abstract I/O 90207536Smav Return_Address, // Subroutine return address 91207536Smav Memory, // Abstract store 92207536Smav FloatTop, // No float value 93207536Smav FloatCon, // Floating point constant 94280393Smav FloatBot, // Any float value 95207536Smav DoubleTop, // No double value 96207536Smav DoubleCon, // Double precision constant 97207536Smav DoubleBot, // Any double value 98207536Smav Bottom, // Bottom of lattice 99207536Smav lastype // Bogus ending type (not in lattice) 100207536Smav }; 101207536Smav 102207536Smav // Signal values for offsets from a base pointer 103207536Smav enum OFFSET_SIGNALS { 104207536Smav OffsetTop = -2000000000, // undefined offset 105207536Smav OffsetBot = -2000000001 // any possible offset 106207536Smav }; 107207536Smav 108207536Smav // Min and max WIDEN values. 109207536Smav enum WIDEN { 110207536Smav WidenMin = 0, 111207536Smav WidenMax = 3 112207536Smav }; 113207536Smav 114207536Smavprivate: 115207536Smav // Dictionary of types shared among compilations. 116207536Smav static Dict* _shared_type_dict; 117271461Smav 118207536Smav static int uhash( const Type *const t ); 119207536Smav // Structural equality check. Assumes that cmp() has already compared 120207536Smav // the _base types and thus knows it can cast 't' appropriately. 121207536Smav virtual bool eq( const Type *t ) const; 122207536Smav 123207536Smav // Top-level hash-table of types 124207536Smav static Dict *type_dict() { 125207536Smav return Compile::current()->type_dict(); 126207536Smav } 127207536Smav 128207536Smav // DUAL operation: reflect around lattice centerline. Used instead of 129207536Smav // join to ensure my lattice is symmetric up and down. Dual is computed 130207536Smav // lazily, on demand, and cached in _dual. 131207536Smav const Type *_dual; // Cached dual value 132207536Smav // Table for efficient dualing of base types 133207536Smav static const TYPES dual_type[lastype]; 134207536Smav 135207536Smavprotected: 136207536Smav // Each class of type is also identified by its base. 137207536Smav const TYPES _base; // Enum of Types type 138207536Smav 139207536Smav Type( TYPES t ) : _dual(NULL), _base(t) {} // Simple types 140207536Smav // ~Type(); // Use fast deallocation 141207536Smav const Type *hashcons(); // Hash-cons the type 142207536Smav 143207536Smavpublic: 144207536Smav 145236952Smav inline void* operator new( size_t x ) { 146236952Smav Compile* compile = Compile::current(); 147207536Smav compile->set_type_last_size(x); 148208414Smav void *temp = compile->type_arena()->Amalloc_D(x); 149208414Smav compile->set_type_hwm(temp); 150207536Smav return temp; 151207536Smav } 152207536Smav inline void operator delete( void* ptr ) { 153207536Smav Compile* compile = Compile::current(); 154207536Smav compile->type_arena()->Afree(ptr,compile->type_last_size()); 155207536Smav } 156207536Smav 157207536Smav // Initialize the type system for a particular compilation. 158207536Smav static void Initialize(Compile* compile); 159207536Smav 160207536Smav // Initialize the types shared by all compilations. 161207536Smav static void Initialize_shared(Compile* compile); 162207536Smav 163207536Smav TYPES base() const { 164207536Smav assert(_base > Bad && _base < lastype, "sanity"); 165207536Smav return _base; 166207536Smav } 167207536Smav 168207536Smav // Create a new hash-consd type 169207536Smav static const Type *make(enum TYPES); 170207536Smav // Test for equivalence of types 171207536Smav static int cmp( const Type *const t1, const Type *const t2 ); 172207536Smav // Test for higher or equal in lattice 173207536Smav int higher_equal( const Type *t ) const { return !cmp(meet(t),t); } 174207536Smav 175207536Smav // MEET operation; lower in lattice. 176207536Smav const Type *meet( const Type *t ) const; 177207536Smav // WIDEN: 'widens' for Ints and other range types 178207536Smav virtual const Type *widen( const Type *old, const Type* limit ) const { return this; } 179207536Smav // NARROW: complement for widen, used by pessimistic phases 180207536Smav virtual const Type *narrow( const Type *old ) const { return this; } 181207536Smav 182207536Smav // DUAL operation: reflect around lattice centerline. Used instead of 183207536Smav // join to ensure my lattice is symmetric up and down. 184207536Smav const Type *dual() const { return _dual; } 185207536Smav 186207536Smav // Compute meet dependent on base type 187227849Shselasky virtual const Type *xmeet( const Type *t ) const; 188227701Shselasky virtual const Type *xdual() const; // Compute dual right now. 189207536Smav 190207536Smav // JOIN operation; higher in lattice. Done by finding the dual of the 191207536Smav // meet of the dual of the 2 inputs. 192207536Smav const Type *join( const Type *t ) const { 193207536Smav return dual()->meet(t->dual())->dual(); } 194207536Smav 195207536Smav // Modified version of JOIN adapted to the needs Node::Value. 196207536Smav // Normalizes all empty values to TOP. Does not kill _widen bits. 197207536Smav // Currently, it also works around limitations involving interface types. 198207536Smav virtual const Type *filter( const Type *kills ) const; 199207536Smav 200207536Smav#ifdef ASSERT 201207536Smav // One type is interface, the other is oop 202207536Smav virtual bool interface_vs_oop(const Type *t) const; 203207536Smav#endif 204207536Smav 205207536Smav // Returns true if this pointer points at memory which contains a 206207536Smav // compressed oop references. 207207536Smav bool is_ptr_to_narrowoop() const; 208207536Smav 209207536Smav // Convenience access 210207536Smav float getf() const; 211207536Smav double getd() const; 212207536Smav 213207536Smav const TypeInt *is_int() const; 214207536Smav const TypeInt *isa_int() const; // Returns NULL if not an Int 215207536Smav const TypeLong *is_long() const; 216207536Smav const TypeLong *isa_long() const; // Returns NULL if not a Long 217207536Smav const TypeD *is_double_constant() const; // Asserts it is a DoubleCon 218207536Smav const TypeD *isa_double_constant() const; // Returns NULL if not a DoubleCon 219207536Smav const TypeF *is_float_constant() const; // Asserts it is a FloatCon 220207536Smav const TypeF *isa_float_constant() const; // Returns NULL if not a FloatCon 221207536Smav const TypeTuple *is_tuple() const; // Collection of fields, NOT a pointer 222207536Smav const TypeAry *is_ary() const; // Array, NOT array pointer 223207536Smav const TypePtr *is_ptr() const; // Asserts it is a ptr type 224207536Smav const TypePtr *isa_ptr() const; // Returns NULL if not ptr type 225207536Smav const TypeRawPtr *isa_rawptr() const; // NOT Java oop 226207536Smav const TypeRawPtr *is_rawptr() const; // Asserts is rawptr 227207536Smav const TypeNarrowOop *is_narrowoop() const; // Java-style GC'd pointer 228230865Sraj const TypeNarrowOop *isa_narrowoop() const; // Returns NULL if not oop ptr type 229230865Sraj const TypeOopPtr *isa_oopptr() const; // Returns NULL if not oop ptr type 230230865Sraj const TypeOopPtr *is_oopptr() const; // Java-style GC'd pointer 231207536Smav const TypeKlassPtr *isa_klassptr() const; // Returns NULL if not KlassPtr 232207536Smav const TypeKlassPtr *is_klassptr() const; // assert if not KlassPtr 233207536Smav const TypeInstPtr *isa_instptr() const; // Returns NULL if not InstPtr 234207536Smav const TypeInstPtr *is_instptr() const; // Instance 235207536Smav const TypeAryPtr *isa_aryptr() const; // Returns NULL if not AryPtr 236207536Smav const TypeAryPtr *is_aryptr() const; // Array oop 237207536Smav virtual bool is_finite() const; // Has a finite value 238207536Smav virtual bool is_nan() const; // Is not a number (NaN) 239207536Smav 240207536Smav // Returns this ptr type or the equivalent ptr type for this compressed pointer. 241207536Smav const TypePtr* make_ptr() const; 242207536Smav 243207536Smav // Returns this oopptr type or the equivalent oopptr type for this compressed pointer. 244207536Smav // Asserts if the underlying type is not an oopptr or narrowoop. 245207536Smav const TypeOopPtr* make_oopptr() const; 246207536Smav 247207536Smav // Returns this compressed pointer or the equivalent compressed version 248207536Smav // of this pointer type. 249207536Smav const TypeNarrowOop* make_narrowoop() const; 250207536Smav 251207536Smav // Special test for register pressure heuristic 252207536Smav bool is_floatingpoint() const; // True if Float or Double base type 253207536Smav 254207536Smav // Do you have memory, directly or through a tuple? 255207536Smav bool has_memory( ) const; 256207536Smav 257207536Smav // Are you a pointer type or not? 258207536Smav bool isa_oop_ptr() const; 259207536Smav 260207536Smav // TRUE if type is a singleton 261207536Smav virtual bool singleton(void) const; 262207536Smav 263207536Smav // TRUE if type is above the lattice centerline, and is therefore vacuous 264207536Smav virtual bool empty(void) const; 265207536Smav 266207536Smav // Return a hash for this type. The hash function is public so ConNode 267207536Smav // (constants) can hash on their constant, which is represented by a Type. 268207536Smav virtual int hash() const; 269207536Smav 270207536Smav // Map ideal registers (machine types) to ideal types 271207536Smav static const Type *mreg2type[]; 272207536Smav 273207536Smav // Printing, statistics 274207536Smav static const char * const msg[lastype]; // Printable strings 275207536Smav#ifndef PRODUCT 276207536Smav void dump_on(outputStream *st) const; 277207536Smav void dump() const { 278207536Smav dump_on(tty); 279207536Smav } 280207536Smav virtual void dump2( Dict &d, uint depth, outputStream *st ) const; 281207536Smav static void dump_stats(); 282207536Smav static void verify_lastype(); // Check that arrays match type enum 283207536Smav#endif 284207536Smav void typerr(const Type *t) const; // Mixing types error 285207536Smav 286207536Smav // Create basic type 287207536Smav static const Type* get_const_basic_type(BasicType type) { 288207536Smav assert((uint)type <= T_CONFLICT && _const_basic_type[type] != NULL, "bad type"); 289207536Smav return _const_basic_type[type]; 290207536Smav } 291207536Smav 292207536Smav // Mapping to the array element's basic type. 293207536Smav BasicType array_element_basic_type() const; 294207536Smav 295207536Smav // Create standard type for a ciType: 296207536Smav static const Type* get_const_type(ciType* type); 297207536Smav 298207536Smav // Create standard zero value: 299207536Smav static const Type* get_zero_type(BasicType type) { 300207536Smav assert((uint)type <= T_CONFLICT && _zero_type[type] != NULL, "bad type"); 301207536Smav return _zero_type[type]; 302207536Smav } 303207536Smav 304207536Smav // Report if this is a zero value (not top). 305230865Sraj bool is_zero_type() const { 306207536Smav BasicType type = basic_type(); 307207536Smav if (type == T_VOID || type >= T_CONFLICT) 308207536Smav return false; 309207536Smav else 310207536Smav return (this == _zero_type[type]); 311230865Sraj } 312207536Smav 313207536Smav // Convenience common pre-built types. 314230865Sraj static const Type *ABIO; 315230865Sraj static const Type *BOTTOM; 316230865Sraj static const Type *CONTROL; 317230865Sraj static const Type *DOUBLE; 318230865Sraj static const Type *FLOAT; 319230865Sraj static const Type *HALF; 320230865Sraj static const Type *MEMORY; 321207536Smav static const Type *MULTI; 322207536Smav static const Type *RETURN_ADDRESS; 323207536Smav static const Type *TOP; 324230865Sraj 325207536Smav // Mapping from compiler type to VM BasicType 326207536Smav BasicType basic_type() const { return _basic_type[_base]; } 327207536Smav 328207536Smav // Mapping from CI type system to compiler type: 329207536Smav static const Type* get_typeflow_type(ciType* type); 330207536Smav 331207536Smavprivate: 332207536Smav // support arrays 333207536Smav static const BasicType _basic_type[]; 334207536Smav static const Type* _zero_type[T_CONFLICT+1]; 335207536Smav static const Type* _const_basic_type[T_CONFLICT+1]; 336207536Smav}; 337207536Smav 338207536Smav//------------------------------TypeF------------------------------------------ 339207536Smav// Class of Float-Constant Types. 340207536Smavclass TypeF : public Type { 341207536Smav TypeF( float f ) : Type(FloatCon), _f(f) {}; 342207536Smavpublic: 343207536Smav virtual bool eq( const Type *t ) const; 344207536Smav virtual int hash() const; // Type specific hashing 345207536Smav virtual bool singleton(void) const; // TRUE if type is a singleton 346207536Smav virtual bool empty(void) const; // TRUE if type is vacuous 347207536Smavpublic: 348207536Smav const float _f; // Float constant 349207536Smav 350207536Smav static const TypeF *make(float f); 351207536Smav 352207536Smav virtual bool is_finite() const; // Has a finite value 353207536Smav virtual bool is_nan() const; // Is not a number (NaN) 354207536Smav 355207536Smav virtual const Type *xmeet( const Type *t ) const; 356207536Smav virtual const Type *xdual() const; // Compute dual right now. 357207536Smav // Convenience common pre-built types. 358207536Smav static const TypeF *ZERO; // positive zero only 359207536Smav static const TypeF *ONE; 360207536Smav#ifndef PRODUCT 361207536Smav virtual void dump2( Dict &d, uint depth, outputStream *st ) const; 362207536Smav#endif 363207536Smav}; 364207536Smav 365207536Smav//------------------------------TypeD------------------------------------------ 366207536Smav// Class of Double-Constant Types. 367207536Smavclass TypeD : public Type { 368207536Smav TypeD( double d ) : Type(DoubleCon), _d(d) {}; 369207536Smavpublic: 370207536Smav virtual bool eq( const Type *t ) const; 371207536Smav virtual int hash() const; // Type specific hashing 372207536Smav virtual bool singleton(void) const; // TRUE if type is a singleton 373207536Smav virtual bool empty(void) const; // TRUE if type is vacuous 374207536Smavpublic: 375207536Smav const double _d; // Double constant 376207536Smav 377207536Smav static const TypeD *make(double d); 378207536Smav 379207536Smav virtual bool is_finite() const; // Has a finite value 380207536Smav virtual bool is_nan() const; // Is not a number (NaN) 381207536Smav 382207536Smav virtual const Type *xmeet( const Type *t ) const; 383207536Smav virtual const Type *xdual() const; // Compute dual right now. 384207536Smav // Convenience common pre-built types. 385207536Smav static const TypeD *ZERO; // positive zero only 386207536Smav static const TypeD *ONE; 387207536Smav#ifndef PRODUCT 388207536Smav virtual void dump2( Dict &d, uint depth, outputStream *st ) const; 389207536Smav#endif 390207536Smav}; 391207536Smav 392207536Smav//------------------------------TypeInt---------------------------------------- 393207536Smav// Class of integer ranges, the set of integers between a lower bound and an 394207536Smav// upper bound, inclusive. 395207536Smavclass TypeInt : public Type { 396207536Smav TypeInt( jint lo, jint hi, int w ); 397207536Smavpublic: 398207536Smav virtual bool eq( const Type *t ) const; 399207536Smav virtual int hash() const; // Type specific hashing 400207536Smav virtual bool singleton(void) const; // TRUE if type is a singleton 401207536Smav virtual bool empty(void) const; // TRUE if type is vacuous 402207536Smavpublic: 403207536Smav const jint _lo, _hi; // Lower bound, upper bound 404207536Smav const short _widen; // Limit on times we widen this sucker 405207536Smav 406207536Smav static const TypeInt *make(jint lo); 407207536Smav // must always specify w 408207536Smav static const TypeInt *make(jint lo, jint hi, int w); 409207536Smav 410207536Smav // Check for single integer 411207536Smav int is_con() const { return _lo==_hi; } 412207536Smav bool is_con(int i) const { return is_con() && _lo == i; } 413207536Smav jint get_con() const { assert( is_con(), "" ); return _lo; } 414207536Smav 415207536Smav virtual bool is_finite() const; // Has a finite value 416207536Smav 417207536Smav virtual const Type *xmeet( const Type *t ) const; 418207536Smav virtual const Type *xdual() const; // Compute dual right now. 419207536Smav virtual const Type *widen( const Type *t, const Type* limit_type ) const; 420207536Smav virtual const Type *narrow( const Type *t ) const; 421207536Smav // Do not kill _widen bits. 422207536Smav virtual const Type *filter( const Type *kills ) const; 423207536Smav // Convenience common pre-built types. 424207536Smav static const TypeInt *MINUS_1; 425207536Smav static const TypeInt *ZERO; 426207536Smav static const TypeInt *ONE; 427207536Smav static const TypeInt *BOOL; 428207536Smav static const TypeInt *CC; 429208410Smav static const TypeInt *CC_LT; // [-1] == MINUS_1 430208410Smav static const TypeInt *CC_GT; // [1] == ONE 431208410Smav static const TypeInt *CC_EQ; // [0] == ZERO 432208410Smav static const TypeInt *CC_LE; // [-1,0] 433208410Smav static const TypeInt *CC_GE; // [0,1] == BOOL (!) 434208410Smav static const TypeInt *BYTE; 435208410Smav static const TypeInt *UBYTE; 436208410Smav static const TypeInt *CHAR; 437208410Smav static const TypeInt *SHORT; 438208410Smav static const TypeInt *POS; 439249622Smav static const TypeInt *POS1; 440249622Smav static const TypeInt *INT; 441249622Smav static const TypeInt *SYMINT; // symmetric range [-max_jint..max_jint] 442249622Smav#ifndef PRODUCT 443249622Smav virtual void dump2( Dict &d, uint depth, outputStream *st ) const; 444249622Smav#endif 445249622Smav}; 446207536Smav 447207536Smav 448207536Smav//------------------------------TypeLong--------------------------------------- 449207536Smav// Class of long integer ranges, the set of integers between a lower bound and 450207536Smav// an upper bound, inclusive. 451207536Smavclass TypeLong : public Type { 452207536Smav TypeLong( jlong lo, jlong hi, int w ); 453207536Smavpublic: 454207536Smav virtual bool eq( const Type *t ) const; 455207536Smav virtual int hash() const; // Type specific hashing 456207536Smav virtual bool singleton(void) const; // TRUE if type is a singleton 457249622Smav virtual bool empty(void) const; // TRUE if type is vacuous 458249622Smavpublic: 459207536Smav const jlong _lo, _hi; // Lower bound, upper bound 460207536Smav const short _widen; // Limit on times we widen this sucker 461207536Smav 462207536Smav static const TypeLong *make(jlong lo); 463220097Smav // must always specify w 464207536Smav static const TypeLong *make(jlong lo, jlong hi, int w); 465207536Smav 466207536Smav // Check for single integer 467220097Smav int is_con() const { return _lo==_hi; } 468220097Smav bool is_con(int i) const { return is_con() && _lo == i; } 469220097Smav jlong get_con() const { assert( is_con(), "" ); return _lo; } 470 471 virtual bool is_finite() const; // Has a finite value 472 473 virtual const Type *xmeet( const Type *t ) const; 474 virtual const Type *xdual() const; // Compute dual right now. 475 virtual const Type *widen( const Type *t, const Type* limit_type ) const; 476 virtual const Type *narrow( const Type *t ) const; 477 // Do not kill _widen bits. 478 virtual const Type *filter( const Type *kills ) const; 479 // Convenience common pre-built types. 480 static const TypeLong *MINUS_1; 481 static const TypeLong *ZERO; 482 static const TypeLong *ONE; 483 static const TypeLong *POS; 484 static const TypeLong *LONG; 485 static const TypeLong *INT; // 32-bit subrange [min_jint..max_jint] 486 static const TypeLong *UINT; // 32-bit unsigned [0..max_juint] 487#ifndef PRODUCT 488 virtual void dump2( Dict &d, uint, outputStream *st ) const;// Specialized per-Type dumping 489#endif 490}; 491 492//------------------------------TypeTuple-------------------------------------- 493// Class of Tuple Types, essentially type collections for function signatures 494// and class layouts. It happens to also be a fast cache for the HotSpot 495// signature types. 496class TypeTuple : public Type { 497 TypeTuple( uint cnt, const Type **fields ) : Type(Tuple), _cnt(cnt), _fields(fields) { } 498public: 499 virtual bool eq( const Type *t ) const; 500 virtual int hash() const; // Type specific hashing 501 virtual bool singleton(void) const; // TRUE if type is a singleton 502 virtual bool empty(void) const; // TRUE if type is vacuous 503 504public: 505 const uint _cnt; // Count of fields 506 const Type ** const _fields; // Array of field types 507 508 // Accessors: 509 uint cnt() const { return _cnt; } 510 const Type* field_at(uint i) const { 511 assert(i < _cnt, "oob"); 512 return _fields[i]; 513 } 514 void set_field_at(uint i, const Type* t) { 515 assert(i < _cnt, "oob"); 516 _fields[i] = t; 517 } 518 519 static const TypeTuple *make( uint cnt, const Type **fields ); 520 static const TypeTuple *make_range(ciSignature *sig); 521 static const TypeTuple *make_domain(ciInstanceKlass* recv, ciSignature *sig); 522 523 // Subroutine call type with space allocated for argument types 524 static const Type **fields( uint arg_cnt ); 525 526 virtual const Type *xmeet( const Type *t ) const; 527 virtual const Type *xdual() const; // Compute dual right now. 528 // Convenience common pre-built types. 529 static const TypeTuple *IFBOTH; 530 static const TypeTuple *IFFALSE; 531 static const TypeTuple *IFTRUE; 532 static const TypeTuple *IFNEITHER; 533 static const TypeTuple *LOOPBODY; 534 static const TypeTuple *MEMBAR; 535 static const TypeTuple *STORECONDITIONAL; 536 static const TypeTuple *START_I2C; 537 static const TypeTuple *INT_PAIR; 538 static const TypeTuple *LONG_PAIR; 539#ifndef PRODUCT 540 virtual void dump2( Dict &d, uint, outputStream *st ) const; // Specialized per-Type dumping 541#endif 542}; 543 544//------------------------------TypeAry---------------------------------------- 545// Class of Array Types 546class TypeAry : public Type { 547 TypeAry( const Type *elem, const TypeInt *size) : Type(Array), 548 _elem(elem), _size(size) {} 549public: 550 virtual bool eq( const Type *t ) const; 551 virtual int hash() const; // Type specific hashing 552 virtual bool singleton(void) const; // TRUE if type is a singleton 553 virtual bool empty(void) const; // TRUE if type is vacuous 554 555private: 556 const Type *_elem; // Element type of array 557 const TypeInt *_size; // Elements in array 558 friend class TypeAryPtr; 559 560public: 561 static const TypeAry *make( const Type *elem, const TypeInt *size); 562 563 virtual const Type *xmeet( const Type *t ) const; 564 virtual const Type *xdual() const; // Compute dual right now. 565 bool ary_must_be_exact() const; // true if arrays of such are never generic 566#ifdef ASSERT 567 // One type is interface, the other is oop 568 virtual bool interface_vs_oop(const Type *t) const; 569#endif 570#ifndef PRODUCT 571 virtual void dump2( Dict &d, uint, outputStream *st ) const; // Specialized per-Type dumping 572#endif 573}; 574 575//------------------------------TypePtr---------------------------------------- 576// Class of machine Pointer Types: raw data, instances or arrays. 577// If the _base enum is AnyPtr, then this refers to all of the above. 578// Otherwise the _base will indicate which subset of pointers is affected, 579// and the class will be inherited from. 580class TypePtr : public Type { 581 friend class TypeNarrowOop; 582public: 583 enum PTR { TopPTR, AnyNull, Constant, Null, NotNull, BotPTR, lastPTR }; 584protected: 585 TypePtr( TYPES t, PTR ptr, int offset ) : Type(t), _ptr(ptr), _offset(offset) {} 586 virtual bool eq( const Type *t ) const; 587 virtual int hash() const; // Type specific hashing 588 static const PTR ptr_meet[lastPTR][lastPTR]; 589 static const PTR ptr_dual[lastPTR]; 590 static const char * const ptr_msg[lastPTR]; 591 592public: 593 const int _offset; // Offset into oop, with TOP & BOT 594 const PTR _ptr; // Pointer equivalence class 595 596 const int offset() const { return _offset; } 597 const PTR ptr() const { return _ptr; } 598 599 static const TypePtr *make( TYPES t, PTR ptr, int offset ); 600 601 // Return a 'ptr' version of this type 602 virtual const Type *cast_to_ptr_type(PTR ptr) const; 603 604 virtual intptr_t get_con() const; 605 606 int xadd_offset( intptr_t offset ) const; 607 virtual const TypePtr *add_offset( intptr_t offset ) const; 608 609 virtual bool singleton(void) const; // TRUE if type is a singleton 610 virtual bool empty(void) const; // TRUE if type is vacuous 611 virtual const Type *xmeet( const Type *t ) const; 612 int meet_offset( int offset ) const; 613 int dual_offset( ) const; 614 virtual const Type *xdual() const; // Compute dual right now. 615 616 // meet, dual and join over pointer equivalence sets 617 PTR meet_ptr( const PTR in_ptr ) const { return ptr_meet[in_ptr][ptr()]; } 618 PTR dual_ptr() const { return ptr_dual[ptr()]; } 619 620 // This is textually confusing unless one recalls that 621 // join(t) == dual()->meet(t->dual())->dual(). 622 PTR join_ptr( const PTR in_ptr ) const { 623 return ptr_dual[ ptr_meet[ ptr_dual[in_ptr] ] [ dual_ptr() ] ]; 624 } 625 626 // Tests for relation to centerline of type lattice: 627 static bool above_centerline(PTR ptr) { return (ptr <= AnyNull); } 628 static bool below_centerline(PTR ptr) { return (ptr >= NotNull); } 629 // Convenience common pre-built types. 630 static const TypePtr *NULL_PTR; 631 static const TypePtr *NOTNULL; 632 static const TypePtr *BOTTOM; 633#ifndef PRODUCT 634 virtual void dump2( Dict &d, uint depth, outputStream *st ) const; 635#endif 636}; 637 638//------------------------------TypeRawPtr------------------------------------- 639// Class of raw pointers, pointers to things other than Oops. Examples 640// include the stack pointer, top of heap, card-marking area, handles, etc. 641class TypeRawPtr : public TypePtr { 642protected: 643 TypeRawPtr( PTR ptr, address bits ) : TypePtr(RawPtr,ptr,0), _bits(bits){} 644public: 645 virtual bool eq( const Type *t ) const; 646 virtual int hash() const; // Type specific hashing 647 648 const address _bits; // Constant value, if applicable 649 650 static const TypeRawPtr *make( PTR ptr ); 651 static const TypeRawPtr *make( address bits ); 652 653 // Return a 'ptr' version of this type 654 virtual const Type *cast_to_ptr_type(PTR ptr) const; 655 656 virtual intptr_t get_con() const; 657 658 virtual const TypePtr *add_offset( intptr_t offset ) const; 659 660 virtual const Type *xmeet( const Type *t ) const; 661 virtual const Type *xdual() const; // Compute dual right now. 662 // Convenience common pre-built types. 663 static const TypeRawPtr *BOTTOM; 664 static const TypeRawPtr *NOTNULL; 665#ifndef PRODUCT 666 virtual void dump2( Dict &d, uint depth, outputStream *st ) const; 667#endif 668}; 669 670//------------------------------TypeOopPtr------------------------------------- 671// Some kind of oop (Java pointer), either klass or instance or array. 672class TypeOopPtr : public TypePtr { 673protected: 674 TypeOopPtr( TYPES t, PTR ptr, ciKlass* k, bool xk, ciObject* o, int offset, int instance_id ); 675public: 676 virtual bool eq( const Type *t ) const; 677 virtual int hash() const; // Type specific hashing 678 virtual bool singleton(void) const; // TRUE if type is a singleton 679 enum { 680 InstanceTop = -1, // undefined instance 681 InstanceBot = 0 // any possible instance 682 }; 683protected: 684 685 // Oop is NULL, unless this is a constant oop. 686 ciObject* _const_oop; // Constant oop 687 // If _klass is NULL, then so is _sig. This is an unloaded klass. 688 ciKlass* _klass; // Klass object 689 // Does the type exclude subclasses of the klass? (Inexact == polymorphic.) 690 bool _klass_is_exact; 691 bool _is_ptr_to_narrowoop; 692 693 // If not InstanceTop or InstanceBot, indicates that this is 694 // a particular instance of this type which is distinct. 695 // This is the the node index of the allocation node creating this instance. 696 int _instance_id; 697 698 static const TypeOopPtr* make_from_klass_common(ciKlass* klass, bool klass_change, bool try_for_exact); 699 700 int dual_instance_id() const; 701 int meet_instance_id(int uid) const; 702 703public: 704 // Creates a type given a klass. Correctly handles multi-dimensional arrays 705 // Respects UseUniqueSubclasses. 706 // If the klass is final, the resulting type will be exact. 707 static const TypeOopPtr* make_from_klass(ciKlass* klass) { 708 return make_from_klass_common(klass, true, false); 709 } 710 // Same as before, but will produce an exact type, even if 711 // the klass is not final, as long as it has exactly one implementation. 712 static const TypeOopPtr* make_from_klass_unique(ciKlass* klass) { 713 return make_from_klass_common(klass, true, true); 714 } 715 // Same as before, but does not respects UseUniqueSubclasses. 716 // Use this only for creating array element types. 717 static const TypeOopPtr* make_from_klass_raw(ciKlass* klass) { 718 return make_from_klass_common(klass, false, false); 719 } 720 // Creates a singleton type given an object. 721 // If the object cannot be rendered as a constant, 722 // may return a non-singleton type. 723 // If require_constant, produce a NULL if a singleton is not possible. 724 static const TypeOopPtr* make_from_constant(ciObject* o, bool require_constant = false); 725 726 // Make a generic (unclassed) pointer to an oop. 727 static const TypeOopPtr* make(PTR ptr, int offset, int instance_id); 728 729 ciObject* const_oop() const { return _const_oop; } 730 virtual ciKlass* klass() const { return _klass; } 731 bool klass_is_exact() const { return _klass_is_exact; } 732 733 // Returns true if this pointer points at memory which contains a 734 // compressed oop references. 735 bool is_ptr_to_narrowoop_nv() const { return _is_ptr_to_narrowoop; } 736 737 bool is_known_instance() const { return _instance_id > 0; } 738 int instance_id() const { return _instance_id; } 739 bool is_known_instance_field() const { return is_known_instance() && _offset >= 0; } 740 741 virtual intptr_t get_con() const; 742 743 virtual const Type *cast_to_ptr_type(PTR ptr) const; 744 745 virtual const Type *cast_to_exactness(bool klass_is_exact) const; 746 747 virtual const TypeOopPtr *cast_to_instance_id(int instance_id) const; 748 749 // corresponding pointer to klass, for a given instance 750 const TypeKlassPtr* as_klass_type() const; 751 752 virtual const TypePtr *add_offset( intptr_t offset ) const; 753 754 virtual const Type *xmeet( const Type *t ) const; 755 virtual const Type *xdual() const; // Compute dual right now. 756 757 // Do not allow interface-vs.-noninterface joins to collapse to top. 758 virtual const Type *filter( const Type *kills ) const; 759 760 // Convenience common pre-built type. 761 static const TypeOopPtr *BOTTOM; 762#ifndef PRODUCT 763 virtual void dump2( Dict &d, uint depth, outputStream *st ) const; 764#endif 765}; 766 767//------------------------------TypeInstPtr------------------------------------ 768// Class of Java object pointers, pointing either to non-array Java instances 769// or to a klassOop (including array klasses). 770class TypeInstPtr : public TypeOopPtr { 771 TypeInstPtr( PTR ptr, ciKlass* k, bool xk, ciObject* o, int offset, int instance_id ); 772 virtual bool eq( const Type *t ) const; 773 virtual int hash() const; // Type specific hashing 774 775 ciSymbol* _name; // class name 776 777 public: 778 ciSymbol* name() const { return _name; } 779 780 bool is_loaded() const { return _klass->is_loaded(); } 781 782 // Make a pointer to a constant oop. 783 static const TypeInstPtr *make(ciObject* o) { 784 return make(TypePtr::Constant, o->klass(), true, o, 0); 785 } 786 787 // Make a pointer to a constant oop with offset. 788 static const TypeInstPtr *make(ciObject* o, int offset) { 789 return make(TypePtr::Constant, o->klass(), true, o, offset); 790 } 791 792 // Make a pointer to some value of type klass. 793 static const TypeInstPtr *make(PTR ptr, ciKlass* klass) { 794 return make(ptr, klass, false, NULL, 0); 795 } 796 797 // Make a pointer to some non-polymorphic value of exactly type klass. 798 static const TypeInstPtr *make_exact(PTR ptr, ciKlass* klass) { 799 return make(ptr, klass, true, NULL, 0); 800 } 801 802 // Make a pointer to some value of type klass with offset. 803 static const TypeInstPtr *make(PTR ptr, ciKlass* klass, int offset) { 804 return make(ptr, klass, false, NULL, offset); 805 } 806 807 // Make a pointer to an oop. 808 static const TypeInstPtr *make(PTR ptr, ciKlass* k, bool xk, ciObject* o, int offset, int instance_id = InstanceBot ); 809 810 // If this is a java.lang.Class constant, return the type for it or NULL. 811 // Pass to Type::get_const_type to turn it to a type, which will usually 812 // be a TypeInstPtr, but may also be a TypeInt::INT for int.class, etc. 813 ciType* java_mirror_type() const; 814 815 virtual const Type *cast_to_ptr_type(PTR ptr) const; 816 817 virtual const Type *cast_to_exactness(bool klass_is_exact) const; 818 819 virtual const TypeOopPtr *cast_to_instance_id(int instance_id) const; 820 821 virtual const TypePtr *add_offset( intptr_t offset ) const; 822 823 virtual const Type *xmeet( const Type *t ) const; 824 virtual const TypeInstPtr *xmeet_unloaded( const TypeInstPtr *t ) const; 825 virtual const Type *xdual() const; // Compute dual right now. 826 827 // Convenience common pre-built types. 828 static const TypeInstPtr *NOTNULL; 829 static const TypeInstPtr *BOTTOM; 830 static const TypeInstPtr *MIRROR; 831 static const TypeInstPtr *MARK; 832 static const TypeInstPtr *KLASS; 833#ifndef PRODUCT 834 virtual void dump2( Dict &d, uint depth, outputStream *st ) const; // Specialized per-Type dumping 835#endif 836}; 837 838//------------------------------TypeAryPtr------------------------------------- 839// Class of Java array pointers 840class TypeAryPtr : public TypeOopPtr { 841 TypeAryPtr( PTR ptr, ciObject* o, const TypeAry *ary, ciKlass* k, bool xk, int offset, int instance_id ) : TypeOopPtr(AryPtr,ptr,k,xk,o,offset, instance_id), _ary(ary) { 842#ifdef ASSERT 843 if (k != NULL) { 844 // Verify that specified klass and TypeAryPtr::klass() follow the same rules. 845 ciKlass* ck = compute_klass(true); 846 if (k != ck) { 847 this->dump(); tty->cr(); 848 tty->print(" k: "); 849 k->print(); tty->cr(); 850 tty->print("ck: "); 851 if (ck != NULL) ck->print(); 852 else tty->print("<NULL>"); 853 tty->cr(); 854 assert(false, "unexpected TypeAryPtr::_klass"); 855 } 856 } 857#endif 858 } 859 virtual bool eq( const Type *t ) const; 860 virtual int hash() const; // Type specific hashing 861 const TypeAry *_ary; // Array we point into 862 863 ciKlass* compute_klass(DEBUG_ONLY(bool verify = false)) const; 864 865public: 866 // Accessors 867 ciKlass* klass() const; 868 const TypeAry* ary() const { return _ary; } 869 const Type* elem() const { return _ary->_elem; } 870 const TypeInt* size() const { return _ary->_size; } 871 872 static const TypeAryPtr *make( PTR ptr, const TypeAry *ary, ciKlass* k, bool xk, int offset, int instance_id = InstanceBot); 873 // Constant pointer to array 874 static const TypeAryPtr *make( PTR ptr, ciObject* o, const TypeAry *ary, ciKlass* k, bool xk, int offset, int instance_id = InstanceBot); 875 876 // Return a 'ptr' version of this type 877 virtual const Type *cast_to_ptr_type(PTR ptr) const; 878 879 virtual const Type *cast_to_exactness(bool klass_is_exact) const; 880 881 virtual const TypeOopPtr *cast_to_instance_id(int instance_id) const; 882 883 virtual const TypeAryPtr* cast_to_size(const TypeInt* size) const; 884 virtual const TypeInt* narrow_size_type(const TypeInt* size) const; 885 886 virtual bool empty(void) const; // TRUE if type is vacuous 887 virtual const TypePtr *add_offset( intptr_t offset ) const; 888 889 virtual const Type *xmeet( const Type *t ) const; 890 virtual const Type *xdual() const; // Compute dual right now. 891 892 // Convenience common pre-built types. 893 static const TypeAryPtr *RANGE; 894 static const TypeAryPtr *OOPS; 895 static const TypeAryPtr *NARROWOOPS; 896 static const TypeAryPtr *BYTES; 897 static const TypeAryPtr *SHORTS; 898 static const TypeAryPtr *CHARS; 899 static const TypeAryPtr *INTS; 900 static const TypeAryPtr *LONGS; 901 static const TypeAryPtr *FLOATS; 902 static const TypeAryPtr *DOUBLES; 903 // selects one of the above: 904 static const TypeAryPtr *get_array_body_type(BasicType elem) { 905 assert((uint)elem <= T_CONFLICT && _array_body_type[elem] != NULL, "bad elem type"); 906 return _array_body_type[elem]; 907 } 908 static const TypeAryPtr *_array_body_type[T_CONFLICT+1]; 909 // sharpen the type of an int which is used as an array size 910#ifdef ASSERT 911 // One type is interface, the other is oop 912 virtual bool interface_vs_oop(const Type *t) const; 913#endif 914#ifndef PRODUCT 915 virtual void dump2( Dict &d, uint depth, outputStream *st ) const; // Specialized per-Type dumping 916#endif 917}; 918 919//------------------------------TypeKlassPtr----------------------------------- 920// Class of Java Klass pointers 921class TypeKlassPtr : public TypeOopPtr { 922 TypeKlassPtr( PTR ptr, ciKlass* klass, int offset ); 923 924 virtual bool eq( const Type *t ) const; 925 virtual int hash() const; // Type specific hashing 926 927public: 928 ciSymbol* name() const { return _klass->name(); } 929 930 bool is_loaded() const { return _klass->is_loaded(); } 931 932 // ptr to klass 'k' 933 static const TypeKlassPtr *make( ciKlass* k ) { return make( TypePtr::Constant, k, 0); } 934 // ptr to klass 'k' with offset 935 static const TypeKlassPtr *make( ciKlass* k, int offset ) { return make( TypePtr::Constant, k, offset); } 936 // ptr to klass 'k' or sub-klass 937 static const TypeKlassPtr *make( PTR ptr, ciKlass* k, int offset); 938 939 virtual const Type *cast_to_ptr_type(PTR ptr) const; 940 941 virtual const Type *cast_to_exactness(bool klass_is_exact) const; 942 943 // corresponding pointer to instance, for a given class 944 const TypeOopPtr* as_instance_type() const; 945 946 virtual const TypePtr *add_offset( intptr_t offset ) const; 947 virtual const Type *xmeet( const Type *t ) const; 948 virtual const Type *xdual() const; // Compute dual right now. 949 950 // Convenience common pre-built types. 951 static const TypeKlassPtr* OBJECT; // Not-null object klass or below 952 static const TypeKlassPtr* OBJECT_OR_NULL; // Maybe-null version of same 953#ifndef PRODUCT 954 virtual void dump2( Dict &d, uint depth, outputStream *st ) const; // Specialized per-Type dumping 955#endif 956}; 957 958//------------------------------TypeNarrowOop---------------------------------- 959// A compressed reference to some kind of Oop. This type wraps around 960// a preexisting TypeOopPtr and forwards most of it's operations to 961// the underlying type. It's only real purpose is to track the 962// oopness of the compressed oop value when we expose the conversion 963// between the normal and the compressed form. 964class TypeNarrowOop : public Type { 965protected: 966 const TypePtr* _ptrtype; // Could be TypePtr::NULL_PTR 967 968 TypeNarrowOop( const TypePtr* ptrtype): Type(NarrowOop), 969 _ptrtype(ptrtype) { 970 assert(ptrtype->offset() == 0 || 971 ptrtype->offset() == OffsetBot || 972 ptrtype->offset() == OffsetTop, "no real offsets"); 973 } 974public: 975 virtual bool eq( const Type *t ) const; 976 virtual int hash() const; // Type specific hashing 977 virtual bool singleton(void) const; // TRUE if type is a singleton 978 979 virtual const Type *xmeet( const Type *t ) const; 980 virtual const Type *xdual() const; // Compute dual right now. 981 982 virtual intptr_t get_con() const; 983 984 // Do not allow interface-vs.-noninterface joins to collapse to top. 985 virtual const Type *filter( const Type *kills ) const; 986 987 virtual bool empty(void) const; // TRUE if type is vacuous 988 989 static const TypeNarrowOop *make( const TypePtr* type); 990 991 static const TypeNarrowOop* make_from_constant(ciObject* con, bool require_constant = false) { 992 return make(TypeOopPtr::make_from_constant(con, require_constant)); 993 } 994 995 // returns the equivalent ptr type for this compressed pointer 996 const TypePtr *get_ptrtype() const { 997 return _ptrtype; 998 } 999 1000 static const TypeNarrowOop *BOTTOM; 1001 static const TypeNarrowOop *NULL_PTR; 1002 1003#ifndef PRODUCT 1004 virtual void dump2( Dict &d, uint depth, outputStream *st ) const; 1005#endif 1006}; 1007 1008//------------------------------TypeFunc--------------------------------------- 1009// Class of Array Types 1010class TypeFunc : public Type { 1011 TypeFunc( const TypeTuple *domain, const TypeTuple *range ) : Type(Function), _domain(domain), _range(range) {} 1012 virtual bool eq( const Type *t ) const; 1013 virtual int hash() const; // Type specific hashing 1014 virtual bool singleton(void) const; // TRUE if type is a singleton 1015 virtual bool empty(void) const; // TRUE if type is vacuous 1016public: 1017 // Constants are shared among ADLC and VM 1018 enum { Control = AdlcVMDeps::Control, 1019 I_O = AdlcVMDeps::I_O, 1020 Memory = AdlcVMDeps::Memory, 1021 FramePtr = AdlcVMDeps::FramePtr, 1022 ReturnAdr = AdlcVMDeps::ReturnAdr, 1023 Parms = AdlcVMDeps::Parms 1024 }; 1025 1026 const TypeTuple* const _domain; // Domain of inputs 1027 const TypeTuple* const _range; // Range of results 1028 1029 // Accessors: 1030 const TypeTuple* domain() const { return _domain; } 1031 const TypeTuple* range() const { return _range; } 1032 1033 static const TypeFunc *make(ciMethod* method); 1034 static const TypeFunc *make(ciSignature signature, const Type* extra); 1035 static const TypeFunc *make(const TypeTuple* domain, const TypeTuple* range); 1036 1037 virtual const Type *xmeet( const Type *t ) const; 1038 virtual const Type *xdual() const; // Compute dual right now. 1039 1040 BasicType return_type() const; 1041 1042#ifndef PRODUCT 1043 virtual void dump2( Dict &d, uint depth, outputStream *st ) const; // Specialized per-Type dumping 1044 void print_flattened() const; // Print a 'flattened' signature 1045#endif 1046 // Convenience common pre-built types. 1047}; 1048 1049//------------------------------accessors-------------------------------------- 1050inline bool Type::is_ptr_to_narrowoop() const { 1051#ifdef _LP64 1052 return (isa_oopptr() != NULL && is_oopptr()->is_ptr_to_narrowoop_nv()); 1053#else 1054 return false; 1055#endif 1056} 1057 1058inline float Type::getf() const { 1059 assert( _base == FloatCon, "Not a FloatCon" ); 1060 return ((TypeF*)this)->_f; 1061} 1062 1063inline double Type::getd() const { 1064 assert( _base == DoubleCon, "Not a DoubleCon" ); 1065 return ((TypeD*)this)->_d; 1066} 1067 1068inline const TypeF *Type::is_float_constant() const { 1069 assert( _base == FloatCon, "Not a Float" ); 1070 return (TypeF*)this; 1071} 1072 1073inline const TypeF *Type::isa_float_constant() const { 1074 return ( _base == FloatCon ? (TypeF*)this : NULL); 1075} 1076 1077inline const TypeD *Type::is_double_constant() const { 1078 assert( _base == DoubleCon, "Not a Double" ); 1079 return (TypeD*)this; 1080} 1081 1082inline const TypeD *Type::isa_double_constant() const { 1083 return ( _base == DoubleCon ? (TypeD*)this : NULL); 1084} 1085 1086inline const TypeInt *Type::is_int() const { 1087 assert( _base == Int, "Not an Int" ); 1088 return (TypeInt*)this; 1089} 1090 1091inline const TypeInt *Type::isa_int() const { 1092 return ( _base == Int ? (TypeInt*)this : NULL); 1093} 1094 1095inline const TypeLong *Type::is_long() const { 1096 assert( _base == Long, "Not a Long" ); 1097 return (TypeLong*)this; 1098} 1099 1100inline const TypeLong *Type::isa_long() const { 1101 return ( _base == Long ? (TypeLong*)this : NULL); 1102} 1103 1104inline const TypeTuple *Type::is_tuple() const { 1105 assert( _base == Tuple, "Not a Tuple" ); 1106 return (TypeTuple*)this; 1107} 1108 1109inline const TypeAry *Type::is_ary() const { 1110 assert( _base == Array , "Not an Array" ); 1111 return (TypeAry*)this; 1112} 1113 1114inline const TypePtr *Type::is_ptr() const { 1115 // AnyPtr is the first Ptr and KlassPtr the last, with no non-ptrs between. 1116 assert(_base >= AnyPtr && _base <= KlassPtr, "Not a pointer"); 1117 return (TypePtr*)this; 1118} 1119 1120inline const TypePtr *Type::isa_ptr() const { 1121 // AnyPtr is the first Ptr and KlassPtr the last, with no non-ptrs between. 1122 return (_base >= AnyPtr && _base <= KlassPtr) ? (TypePtr*)this : NULL; 1123} 1124 1125inline const TypeOopPtr *Type::is_oopptr() const { 1126 // OopPtr is the first and KlassPtr the last, with no non-oops between. 1127 assert(_base >= OopPtr && _base <= KlassPtr, "Not a Java pointer" ) ; 1128 return (TypeOopPtr*)this; 1129} 1130 1131inline const TypeOopPtr *Type::isa_oopptr() const { 1132 // OopPtr is the first and KlassPtr the last, with no non-oops between. 1133 return (_base >= OopPtr && _base <= KlassPtr) ? (TypeOopPtr*)this : NULL; 1134} 1135 1136inline const TypeRawPtr *Type::isa_rawptr() const { 1137 return (_base == RawPtr) ? (TypeRawPtr*)this : NULL; 1138} 1139 1140inline const TypeRawPtr *Type::is_rawptr() const { 1141 assert( _base == RawPtr, "Not a raw pointer" ); 1142 return (TypeRawPtr*)this; 1143} 1144 1145inline const TypeInstPtr *Type::isa_instptr() const { 1146 return (_base == InstPtr) ? (TypeInstPtr*)this : NULL; 1147} 1148 1149inline const TypeInstPtr *Type::is_instptr() const { 1150 assert( _base == InstPtr, "Not an object pointer" ); 1151 return (TypeInstPtr*)this; 1152} 1153 1154inline const TypeAryPtr *Type::isa_aryptr() const { 1155 return (_base == AryPtr) ? (TypeAryPtr*)this : NULL; 1156} 1157 1158inline const TypeAryPtr *Type::is_aryptr() const { 1159 assert( _base == AryPtr, "Not an array pointer" ); 1160 return (TypeAryPtr*)this; 1161} 1162 1163inline const TypeNarrowOop *Type::is_narrowoop() const { 1164 // OopPtr is the first and KlassPtr the last, with no non-oops between. 1165 assert(_base == NarrowOop, "Not a narrow oop" ) ; 1166 return (TypeNarrowOop*)this; 1167} 1168 1169inline const TypeNarrowOop *Type::isa_narrowoop() const { 1170 // OopPtr is the first and KlassPtr the last, with no non-oops between. 1171 return (_base == NarrowOop) ? (TypeNarrowOop*)this : NULL; 1172} 1173 1174inline const TypeKlassPtr *Type::isa_klassptr() const { 1175 return (_base == KlassPtr) ? (TypeKlassPtr*)this : NULL; 1176} 1177 1178inline const TypeKlassPtr *Type::is_klassptr() const { 1179 assert( _base == KlassPtr, "Not a klass pointer" ); 1180 return (TypeKlassPtr*)this; 1181} 1182 1183inline const TypePtr* Type::make_ptr() const { 1184 return (_base == NarrowOop) ? is_narrowoop()->get_ptrtype() : 1185 (isa_ptr() ? is_ptr() : NULL); 1186} 1187 1188inline const TypeOopPtr* Type::make_oopptr() const { 1189 return (_base == NarrowOop) ? is_narrowoop()->get_ptrtype()->is_oopptr() : is_oopptr(); 1190} 1191 1192inline const TypeNarrowOop* Type::make_narrowoop() const { 1193 return (_base == NarrowOop) ? is_narrowoop() : 1194 (isa_ptr() ? TypeNarrowOop::make(is_ptr()) : NULL); 1195} 1196 1197inline bool Type::is_floatingpoint() const { 1198 if( (_base == FloatCon) || (_base == FloatBot) || 1199 (_base == DoubleCon) || (_base == DoubleBot) ) 1200 return true; 1201 return false; 1202} 1203 1204 1205// =============================================================== 1206// Things that need to be 64-bits in the 64-bit build but 1207// 32-bits in the 32-bit build. Done this way to get full 1208// optimization AND strong typing. 1209#ifdef _LP64 1210 1211// For type queries and asserts 1212#define is_intptr_t is_long 1213#define isa_intptr_t isa_long 1214#define find_intptr_t_type find_long_type 1215#define find_intptr_t_con find_long_con 1216#define TypeX TypeLong 1217#define Type_X Type::Long 1218#define TypeX_X TypeLong::LONG 1219#define TypeX_ZERO TypeLong::ZERO 1220// For 'ideal_reg' machine registers 1221#define Op_RegX Op_RegL 1222// For phase->intcon variants 1223#define MakeConX longcon 1224#define ConXNode ConLNode 1225// For array index arithmetic 1226#define MulXNode MulLNode 1227#define AndXNode AndLNode 1228#define OrXNode OrLNode 1229#define CmpXNode CmpLNode 1230#define SubXNode SubLNode 1231#define LShiftXNode LShiftLNode 1232// For object size computation: 1233#define AddXNode AddLNode 1234#define RShiftXNode RShiftLNode 1235// For card marks and hashcodes 1236#define URShiftXNode URShiftLNode 1237// UseOptoBiasInlining 1238#define XorXNode XorLNode 1239#define StoreXConditionalNode StoreLConditionalNode 1240// Opcodes 1241#define Op_LShiftX Op_LShiftL 1242#define Op_AndX Op_AndL 1243#define Op_AddX Op_AddL 1244#define Op_SubX Op_SubL 1245#define Op_XorX Op_XorL 1246#define Op_URShiftX Op_URShiftL 1247// conversions 1248#define ConvI2X(x) ConvI2L(x) 1249#define ConvL2X(x) (x) 1250#define ConvX2I(x) ConvL2I(x) 1251#define ConvX2L(x) (x) 1252 1253#else 1254 1255// For type queries and asserts 1256#define is_intptr_t is_int 1257#define isa_intptr_t isa_int 1258#define find_intptr_t_type find_int_type 1259#define find_intptr_t_con find_int_con 1260#define TypeX TypeInt 1261#define Type_X Type::Int 1262#define TypeX_X TypeInt::INT 1263#define TypeX_ZERO TypeInt::ZERO 1264// For 'ideal_reg' machine registers 1265#define Op_RegX Op_RegI 1266// For phase->intcon variants 1267#define MakeConX intcon 1268#define ConXNode ConINode 1269// For array index arithmetic 1270#define MulXNode MulINode 1271#define AndXNode AndINode 1272#define OrXNode OrINode 1273#define CmpXNode CmpINode 1274#define SubXNode SubINode 1275#define LShiftXNode LShiftINode 1276// For object size computation: 1277#define AddXNode AddINode 1278#define RShiftXNode RShiftINode 1279// For card marks and hashcodes 1280#define URShiftXNode URShiftINode 1281// UseOptoBiasInlining 1282#define XorXNode XorINode 1283#define StoreXConditionalNode StoreIConditionalNode 1284// Opcodes 1285#define Op_LShiftX Op_LShiftI 1286#define Op_AndX Op_AndI 1287#define Op_AddX Op_AddI 1288#define Op_SubX Op_SubI 1289#define Op_XorX Op_XorI 1290#define Op_URShiftX Op_URShiftI 1291// conversions 1292#define ConvI2X(x) (x) 1293#define ConvL2X(x) ConvL2I(x) 1294#define ConvX2I(x) (x) 1295#define ConvX2L(x) ConvI2L(x) 1296 1297#endif 1298 1299#endif // SHARE_VM_OPTO_TYPE_HPP 1300