src/share/vm/opto/type.hpp

Mon, 17 Sep 2012 19:39:07 -0700

author
kvn
date
Mon, 17 Sep 2012 19:39:07 -0700
changeset 4103
137868b7aa6f
parent 4037
da91efe96a93
child 4159
8e47bac5643a
permissions
-rw-r--r--

7196199: java/text/Bidi/Bug6665028.java failed: Bidi run count incorrect
Summary: Save whole XMM/YMM registers in safepoint interrupt handler.
Reviewed-by: roland, twisti

duke@435 1 /*
kvn@3882 2 * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
duke@435 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@435 4 *
duke@435 5 * This code is free software; you can redistribute it and/or modify it
duke@435 6 * under the terms of the GNU General Public License version 2 only, as
duke@435 7 * published by the Free Software Foundation.
duke@435 8 *
duke@435 9 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@435 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@435 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@435 12 * version 2 for more details (a copy is included in the LICENSE file that
duke@435 13 * accompanied this code).
duke@435 14 *
duke@435 15 * You should have received a copy of the GNU General Public License version
duke@435 16 * 2 along with this work; if not, write to the Free Software Foundation,
duke@435 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@435 18 *
trims@1907 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
trims@1907 20 * or visit www.oracle.com if you need additional information or have any
trims@1907 21 * questions.
duke@435 22 *
duke@435 23 */
duke@435 24
stefank@2314 25 #ifndef SHARE_VM_OPTO_TYPE_HPP
stefank@2314 26 #define SHARE_VM_OPTO_TYPE_HPP
stefank@2314 27
stefank@2314 28 #include "libadt/port.hpp"
stefank@2314 29 #include "opto/adlcVMDeps.hpp"
stefank@2314 30 #include "runtime/handles.hpp"
stefank@2314 31
duke@435 32 // Portions of code courtesy of Clifford Click
duke@435 33
duke@435 34 // Optimization - Graph Style
duke@435 35
duke@435 36
duke@435 37 // This class defines a Type lattice. The lattice is used in the constant
duke@435 38 // propagation algorithms, and for some type-checking of the iloc code.
duke@435 39 // Basic types include RSD's (lower bound, upper bound, stride for integers),
duke@435 40 // float & double precision constants, sets of data-labels and code-labels.
duke@435 41 // The complete lattice is described below. Subtypes have no relationship to
duke@435 42 // up or down in the lattice; that is entirely determined by the behavior of
duke@435 43 // the MEET/JOIN functions.
duke@435 44
duke@435 45 class Dict;
duke@435 46 class Type;
duke@435 47 class TypeD;
duke@435 48 class TypeF;
duke@435 49 class TypeInt;
duke@435 50 class TypeLong;
coleenp@548 51 class TypeNarrowOop;
duke@435 52 class TypeAry;
duke@435 53 class TypeTuple;
kvn@3882 54 class TypeVect;
kvn@3882 55 class TypeVectS;
kvn@3882 56 class TypeVectD;
kvn@3882 57 class TypeVectX;
kvn@3882 58 class TypeVectY;
duke@435 59 class TypePtr;
duke@435 60 class TypeRawPtr;
duke@435 61 class TypeOopPtr;
duke@435 62 class TypeInstPtr;
duke@435 63 class TypeAryPtr;
duke@435 64 class TypeKlassPtr;
coleenp@4037 65 class TypeMetadataPtr;
duke@435 66
duke@435 67 //------------------------------Type-------------------------------------------
duke@435 68 // Basic Type object, represents a set of primitive Values.
duke@435 69 // Types are hash-cons'd into a private class dictionary, so only one of each
duke@435 70 // different kind of Type exists. Types are never modified after creation, so
duke@435 71 // all their interesting fields are constant.
duke@435 72 class Type {
never@3138 73 friend class VMStructs;
never@3138 74
duke@435 75 public:
duke@435 76 enum TYPES {
duke@435 77 Bad=0, // Type check
duke@435 78 Control, // Control of code (not in lattice)
duke@435 79 Top, // Top of the lattice
duke@435 80 Int, // Integer range (lo-hi)
duke@435 81 Long, // Long integer range (lo-hi)
duke@435 82 Half, // Placeholder half of doubleword
coleenp@548 83 NarrowOop, // Compressed oop pointer
duke@435 84
duke@435 85 Tuple, // Method signature or object layout
duke@435 86 Array, // Array types
kvn@3882 87 VectorS, // 32bit Vector types
kvn@3882 88 VectorD, // 64bit Vector types
kvn@3882 89 VectorX, // 128bit Vector types
kvn@3882 90 VectorY, // 256bit Vector types
duke@435 91
duke@435 92 AnyPtr, // Any old raw, klass, inst, or array pointer
duke@435 93 RawPtr, // Raw (non-oop) pointers
duke@435 94 OopPtr, // Any and all Java heap entities
duke@435 95 InstPtr, // Instance pointers (non-array objects)
duke@435 96 AryPtr, // Array pointers
coleenp@4037 97 // (Ptr order matters: See is_ptr, isa_ptr, is_oopptr, isa_oopptr.)
coleenp@4037 98
coleenp@4037 99 MetadataPtr, // Generic metadata
duke@435 100 KlassPtr, // Klass pointers
duke@435 101
duke@435 102 Function, // Function signature
duke@435 103 Abio, // Abstract I/O
duke@435 104 Return_Address, // Subroutine return address
duke@435 105 Memory, // Abstract store
duke@435 106 FloatTop, // No float value
duke@435 107 FloatCon, // Floating point constant
duke@435 108 FloatBot, // Any float value
duke@435 109 DoubleTop, // No double value
duke@435 110 DoubleCon, // Double precision constant
duke@435 111 DoubleBot, // Any double value
duke@435 112 Bottom, // Bottom of lattice
duke@435 113 lastype // Bogus ending type (not in lattice)
duke@435 114 };
duke@435 115
duke@435 116 // Signal values for offsets from a base pointer
duke@435 117 enum OFFSET_SIGNALS {
duke@435 118 OffsetTop = -2000000000, // undefined offset
duke@435 119 OffsetBot = -2000000001 // any possible offset
duke@435 120 };
duke@435 121
duke@435 122 // Min and max WIDEN values.
duke@435 123 enum WIDEN {
duke@435 124 WidenMin = 0,
duke@435 125 WidenMax = 3
duke@435 126 };
duke@435 127
duke@435 128 private:
coleenp@4037 129 typedef struct {
coleenp@4037 130 const TYPES dual_type;
coleenp@4037 131 const BasicType basic_type;
coleenp@4037 132 const char* msg;
coleenp@4037 133 const bool isa_oop;
coleenp@4037 134 const int ideal_reg;
coleenp@4037 135 const relocInfo::relocType reloc;
coleenp@4037 136 } TypeInfo;
coleenp@4037 137
duke@435 138 // Dictionary of types shared among compilations.
duke@435 139 static Dict* _shared_type_dict;
coleenp@4037 140 static TypeInfo _type_info[];
duke@435 141
duke@435 142 static int uhash( const Type *const t );
duke@435 143 // Structural equality check. Assumes that cmp() has already compared
duke@435 144 // the _base types and thus knows it can cast 't' appropriately.
duke@435 145 virtual bool eq( const Type *t ) const;
duke@435 146
duke@435 147 // Top-level hash-table of types
duke@435 148 static Dict *type_dict() {
duke@435 149 return Compile::current()->type_dict();
duke@435 150 }
duke@435 151
duke@435 152 // DUAL operation: reflect around lattice centerline. Used instead of
duke@435 153 // join to ensure my lattice is symmetric up and down. Dual is computed
duke@435 154 // lazily, on demand, and cached in _dual.
duke@435 155 const Type *_dual; // Cached dual value
duke@435 156 // Table for efficient dualing of base types
duke@435 157 static const TYPES dual_type[lastype];
duke@435 158
duke@435 159 protected:
duke@435 160 // Each class of type is also identified by its base.
duke@435 161 const TYPES _base; // Enum of Types type
duke@435 162
duke@435 163 Type( TYPES t ) : _dual(NULL), _base(t) {} // Simple types
duke@435 164 // ~Type(); // Use fast deallocation
duke@435 165 const Type *hashcons(); // Hash-cons the type
duke@435 166
duke@435 167 public:
duke@435 168
duke@435 169 inline void* operator new( size_t x ) {
duke@435 170 Compile* compile = Compile::current();
duke@435 171 compile->set_type_last_size(x);
duke@435 172 void *temp = compile->type_arena()->Amalloc_D(x);
duke@435 173 compile->set_type_hwm(temp);
duke@435 174 return temp;
duke@435 175 }
duke@435 176 inline void operator delete( void* ptr ) {
duke@435 177 Compile* compile = Compile::current();
duke@435 178 compile->type_arena()->Afree(ptr,compile->type_last_size());
duke@435 179 }
duke@435 180
duke@435 181 // Initialize the type system for a particular compilation.
duke@435 182 static void Initialize(Compile* compile);
duke@435 183
duke@435 184 // Initialize the types shared by all compilations.
duke@435 185 static void Initialize_shared(Compile* compile);
duke@435 186
duke@435 187 TYPES base() const {
duke@435 188 assert(_base > Bad && _base < lastype, "sanity");
duke@435 189 return _base;
duke@435 190 }
duke@435 191
duke@435 192 // Create a new hash-consd type
duke@435 193 static const Type *make(enum TYPES);
duke@435 194 // Test for equivalence of types
duke@435 195 static int cmp( const Type *const t1, const Type *const t2 );
duke@435 196 // Test for higher or equal in lattice
duke@435 197 int higher_equal( const Type *t ) const { return !cmp(meet(t),t); }
duke@435 198
duke@435 199 // MEET operation; lower in lattice.
duke@435 200 const Type *meet( const Type *t ) const;
duke@435 201 // WIDEN: 'widens' for Ints and other range types
never@1444 202 virtual const Type *widen( const Type *old, const Type* limit ) const { return this; }
duke@435 203 // NARROW: complement for widen, used by pessimistic phases
duke@435 204 virtual const Type *narrow( const Type *old ) const { return this; }
duke@435 205
duke@435 206 // DUAL operation: reflect around lattice centerline. Used instead of
duke@435 207 // join to ensure my lattice is symmetric up and down.
duke@435 208 const Type *dual() const { return _dual; }
duke@435 209
duke@435 210 // Compute meet dependent on base type
duke@435 211 virtual const Type *xmeet( const Type *t ) const;
duke@435 212 virtual const Type *xdual() const; // Compute dual right now.
duke@435 213
duke@435 214 // JOIN operation; higher in lattice. Done by finding the dual of the
duke@435 215 // meet of the dual of the 2 inputs.
duke@435 216 const Type *join( const Type *t ) const {
duke@435 217 return dual()->meet(t->dual())->dual(); }
duke@435 218
duke@435 219 // Modified version of JOIN adapted to the needs Node::Value.
duke@435 220 // Normalizes all empty values to TOP. Does not kill _widen bits.
duke@435 221 // Currently, it also works around limitations involving interface types.
duke@435 222 virtual const Type *filter( const Type *kills ) const;
duke@435 223
kvn@1255 224 #ifdef ASSERT
kvn@1255 225 // One type is interface, the other is oop
kvn@1255 226 virtual bool interface_vs_oop(const Type *t) const;
kvn@1255 227 #endif
kvn@1255 228
coleenp@548 229 // Returns true if this pointer points at memory which contains a
kvn@598 230 // compressed oop references.
kvn@598 231 bool is_ptr_to_narrowoop() const;
coleenp@548 232
duke@435 233 // Convenience access
duke@435 234 float getf() const;
duke@435 235 double getd() const;
duke@435 236
duke@435 237 const TypeInt *is_int() const;
duke@435 238 const TypeInt *isa_int() const; // Returns NULL if not an Int
duke@435 239 const TypeLong *is_long() const;
duke@435 240 const TypeLong *isa_long() const; // Returns NULL if not a Long
duke@435 241 const TypeD *is_double_constant() const; // Asserts it is a DoubleCon
duke@435 242 const TypeD *isa_double_constant() const; // Returns NULL if not a DoubleCon
duke@435 243 const TypeF *is_float_constant() const; // Asserts it is a FloatCon
duke@435 244 const TypeF *isa_float_constant() const; // Returns NULL if not a FloatCon
duke@435 245 const TypeTuple *is_tuple() const; // Collection of fields, NOT a pointer
duke@435 246 const TypeAry *is_ary() const; // Array, NOT array pointer
kvn@3882 247 const TypeVect *is_vect() const; // Vector
kvn@3882 248 const TypeVect *isa_vect() const; // Returns NULL if not a Vector
duke@435 249 const TypePtr *is_ptr() const; // Asserts it is a ptr type
duke@435 250 const TypePtr *isa_ptr() const; // Returns NULL if not ptr type
coleenp@548 251 const TypeRawPtr *isa_rawptr() const; // NOT Java oop
coleenp@548 252 const TypeRawPtr *is_rawptr() const; // Asserts is rawptr
kvn@598 253 const TypeNarrowOop *is_narrowoop() const; // Java-style GC'd pointer
kvn@598 254 const TypeNarrowOop *isa_narrowoop() const; // Returns NULL if not oop ptr type
coleenp@548 255 const TypeOopPtr *isa_oopptr() const; // Returns NULL if not oop ptr type
coleenp@548 256 const TypeOopPtr *is_oopptr() const; // Java-style GC'd pointer
coleenp@548 257 const TypeInstPtr *isa_instptr() const; // Returns NULL if not InstPtr
coleenp@548 258 const TypeInstPtr *is_instptr() const; // Instance
coleenp@548 259 const TypeAryPtr *isa_aryptr() const; // Returns NULL if not AryPtr
coleenp@548 260 const TypeAryPtr *is_aryptr() const; // Array oop
coleenp@4037 261
coleenp@4037 262 const TypeMetadataPtr *isa_metadataptr() const; // Returns NULL if not oop ptr type
coleenp@4037 263 const TypeMetadataPtr *is_metadataptr() const; // Java-style GC'd pointer
coleenp@4037 264 const TypeKlassPtr *isa_klassptr() const; // Returns NULL if not KlassPtr
coleenp@4037 265 const TypeKlassPtr *is_klassptr() const; // assert if not KlassPtr
coleenp@4037 266
duke@435 267 virtual bool is_finite() const; // Has a finite value
duke@435 268 virtual bool is_nan() const; // Is not a number (NaN)
duke@435 269
kvn@656 270 // Returns this ptr type or the equivalent ptr type for this compressed pointer.
kvn@656 271 const TypePtr* make_ptr() const;
never@1262 272
never@1262 273 // Returns this oopptr type or the equivalent oopptr type for this compressed pointer.
never@1262 274 // Asserts if the underlying type is not an oopptr or narrowoop.
never@1262 275 const TypeOopPtr* make_oopptr() const;
never@1262 276
kvn@656 277 // Returns this compressed pointer or the equivalent compressed version
kvn@656 278 // of this pointer type.
kvn@656 279 const TypeNarrowOop* make_narrowoop() const;
kvn@656 280
duke@435 281 // Special test for register pressure heuristic
duke@435 282 bool is_floatingpoint() const; // True if Float or Double base type
duke@435 283
duke@435 284 // Do you have memory, directly or through a tuple?
duke@435 285 bool has_memory( ) const;
duke@435 286
duke@435 287 // TRUE if type is a singleton
duke@435 288 virtual bool singleton(void) const;
duke@435 289
duke@435 290 // TRUE if type is above the lattice centerline, and is therefore vacuous
duke@435 291 virtual bool empty(void) const;
duke@435 292
duke@435 293 // Return a hash for this type. The hash function is public so ConNode
duke@435 294 // (constants) can hash on their constant, which is represented by a Type.
duke@435 295 virtual int hash() const;
duke@435 296
duke@435 297 // Map ideal registers (machine types) to ideal types
duke@435 298 static const Type *mreg2type[];
duke@435 299
duke@435 300 // Printing, statistics
duke@435 301 #ifndef PRODUCT
duke@435 302 void dump_on(outputStream *st) const;
duke@435 303 void dump() const {
duke@435 304 dump_on(tty);
duke@435 305 }
duke@435 306 virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
duke@435 307 static void dump_stats();
duke@435 308 #endif
duke@435 309 void typerr(const Type *t) const; // Mixing types error
duke@435 310
duke@435 311 // Create basic type
duke@435 312 static const Type* get_const_basic_type(BasicType type) {
duke@435 313 assert((uint)type <= T_CONFLICT && _const_basic_type[type] != NULL, "bad type");
duke@435 314 return _const_basic_type[type];
duke@435 315 }
duke@435 316
duke@435 317 // Mapping to the array element's basic type.
duke@435 318 BasicType array_element_basic_type() const;
duke@435 319
duke@435 320 // Create standard type for a ciType:
duke@435 321 static const Type* get_const_type(ciType* type);
duke@435 322
duke@435 323 // Create standard zero value:
duke@435 324 static const Type* get_zero_type(BasicType type) {
duke@435 325 assert((uint)type <= T_CONFLICT && _zero_type[type] != NULL, "bad type");
duke@435 326 return _zero_type[type];
duke@435 327 }
duke@435 328
duke@435 329 // Report if this is a zero value (not top).
duke@435 330 bool is_zero_type() const {
duke@435 331 BasicType type = basic_type();
duke@435 332 if (type == T_VOID || type >= T_CONFLICT)
duke@435 333 return false;
duke@435 334 else
duke@435 335 return (this == _zero_type[type]);
duke@435 336 }
duke@435 337
duke@435 338 // Convenience common pre-built types.
duke@435 339 static const Type *ABIO;
duke@435 340 static const Type *BOTTOM;
duke@435 341 static const Type *CONTROL;
duke@435 342 static const Type *DOUBLE;
duke@435 343 static const Type *FLOAT;
duke@435 344 static const Type *HALF;
duke@435 345 static const Type *MEMORY;
duke@435 346 static const Type *MULTI;
duke@435 347 static const Type *RETURN_ADDRESS;
duke@435 348 static const Type *TOP;
duke@435 349
duke@435 350 // Mapping from compiler type to VM BasicType
coleenp@4037 351 BasicType basic_type() const { return _type_info[_base].basic_type; }
coleenp@4037 352 int ideal_reg() const { return _type_info[_base].ideal_reg; }
coleenp@4037 353 const char* msg() const { return _type_info[_base].msg; }
coleenp@4037 354 bool isa_oop_ptr() const { return _type_info[_base].isa_oop; }
coleenp@4037 355 relocInfo::relocType reloc() const { return _type_info[_base].reloc; }
duke@435 356
duke@435 357 // Mapping from CI type system to compiler type:
duke@435 358 static const Type* get_typeflow_type(ciType* type);
duke@435 359
duke@435 360 private:
duke@435 361 // support arrays
duke@435 362 static const BasicType _basic_type[];
duke@435 363 static const Type* _zero_type[T_CONFLICT+1];
duke@435 364 static const Type* _const_basic_type[T_CONFLICT+1];
duke@435 365 };
duke@435 366
duke@435 367 //------------------------------TypeF------------------------------------------
duke@435 368 // Class of Float-Constant Types.
duke@435 369 class TypeF : public Type {
duke@435 370 TypeF( float f ) : Type(FloatCon), _f(f) {};
duke@435 371 public:
duke@435 372 virtual bool eq( const Type *t ) const;
duke@435 373 virtual int hash() const; // Type specific hashing
duke@435 374 virtual bool singleton(void) const; // TRUE if type is a singleton
duke@435 375 virtual bool empty(void) const; // TRUE if type is vacuous
duke@435 376 public:
duke@435 377 const float _f; // Float constant
duke@435 378
duke@435 379 static const TypeF *make(float f);
duke@435 380
duke@435 381 virtual bool is_finite() const; // Has a finite value
duke@435 382 virtual bool is_nan() const; // Is not a number (NaN)
duke@435 383
duke@435 384 virtual const Type *xmeet( const Type *t ) const;
duke@435 385 virtual const Type *xdual() const; // Compute dual right now.
duke@435 386 // Convenience common pre-built types.
duke@435 387 static const TypeF *ZERO; // positive zero only
duke@435 388 static const TypeF *ONE;
duke@435 389 #ifndef PRODUCT
duke@435 390 virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
duke@435 391 #endif
duke@435 392 };
duke@435 393
duke@435 394 //------------------------------TypeD------------------------------------------
duke@435 395 // Class of Double-Constant Types.
duke@435 396 class TypeD : public Type {
duke@435 397 TypeD( double d ) : Type(DoubleCon), _d(d) {};
duke@435 398 public:
duke@435 399 virtual bool eq( const Type *t ) const;
duke@435 400 virtual int hash() const; // Type specific hashing
duke@435 401 virtual bool singleton(void) const; // TRUE if type is a singleton
duke@435 402 virtual bool empty(void) const; // TRUE if type is vacuous
duke@435 403 public:
duke@435 404 const double _d; // Double constant
duke@435 405
duke@435 406 static const TypeD *make(double d);
duke@435 407
duke@435 408 virtual bool is_finite() const; // Has a finite value
duke@435 409 virtual bool is_nan() const; // Is not a number (NaN)
duke@435 410
duke@435 411 virtual const Type *xmeet( const Type *t ) const;
duke@435 412 virtual const Type *xdual() const; // Compute dual right now.
duke@435 413 // Convenience common pre-built types.
duke@435 414 static const TypeD *ZERO; // positive zero only
duke@435 415 static const TypeD *ONE;
duke@435 416 #ifndef PRODUCT
duke@435 417 virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
duke@435 418 #endif
duke@435 419 };
duke@435 420
duke@435 421 //------------------------------TypeInt----------------------------------------
duke@435 422 // Class of integer ranges, the set of integers between a lower bound and an
duke@435 423 // upper bound, inclusive.
duke@435 424 class TypeInt : public Type {
duke@435 425 TypeInt( jint lo, jint hi, int w );
duke@435 426 public:
duke@435 427 virtual bool eq( const Type *t ) const;
duke@435 428 virtual int hash() const; // Type specific hashing
duke@435 429 virtual bool singleton(void) const; // TRUE if type is a singleton
duke@435 430 virtual bool empty(void) const; // TRUE if type is vacuous
duke@435 431 public:
duke@435 432 const jint _lo, _hi; // Lower bound, upper bound
duke@435 433 const short _widen; // Limit on times we widen this sucker
duke@435 434
duke@435 435 static const TypeInt *make(jint lo);
duke@435 436 // must always specify w
duke@435 437 static const TypeInt *make(jint lo, jint hi, int w);
duke@435 438
duke@435 439 // Check for single integer
duke@435 440 int is_con() const { return _lo==_hi; }
duke@435 441 bool is_con(int i) const { return is_con() && _lo == i; }
duke@435 442 jint get_con() const { assert( is_con(), "" ); return _lo; }
duke@435 443
duke@435 444 virtual bool is_finite() const; // Has a finite value
duke@435 445
duke@435 446 virtual const Type *xmeet( const Type *t ) const;
duke@435 447 virtual const Type *xdual() const; // Compute dual right now.
never@1444 448 virtual const Type *widen( const Type *t, const Type* limit_type ) const;
duke@435 449 virtual const Type *narrow( const Type *t ) const;
duke@435 450 // Do not kill _widen bits.
duke@435 451 virtual const Type *filter( const Type *kills ) const;
duke@435 452 // Convenience common pre-built types.
duke@435 453 static const TypeInt *MINUS_1;
duke@435 454 static const TypeInt *ZERO;
duke@435 455 static const TypeInt *ONE;
duke@435 456 static const TypeInt *BOOL;
duke@435 457 static const TypeInt *CC;
duke@435 458 static const TypeInt *CC_LT; // [-1] == MINUS_1
duke@435 459 static const TypeInt *CC_GT; // [1] == ONE
duke@435 460 static const TypeInt *CC_EQ; // [0] == ZERO
duke@435 461 static const TypeInt *CC_LE; // [-1,0]
duke@435 462 static const TypeInt *CC_GE; // [0,1] == BOOL (!)
duke@435 463 static const TypeInt *BYTE;
twisti@1059 464 static const TypeInt *UBYTE;
duke@435 465 static const TypeInt *CHAR;
duke@435 466 static const TypeInt *SHORT;
duke@435 467 static const TypeInt *POS;
duke@435 468 static const TypeInt *POS1;
duke@435 469 static const TypeInt *INT;
duke@435 470 static const TypeInt *SYMINT; // symmetric range [-max_jint..max_jint]
duke@435 471 #ifndef PRODUCT
duke@435 472 virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
duke@435 473 #endif
duke@435 474 };
duke@435 475
duke@435 476
duke@435 477 //------------------------------TypeLong---------------------------------------
duke@435 478 // Class of long integer ranges, the set of integers between a lower bound and
duke@435 479 // an upper bound, inclusive.
duke@435 480 class TypeLong : public Type {
duke@435 481 TypeLong( jlong lo, jlong hi, int w );
duke@435 482 public:
duke@435 483 virtual bool eq( const Type *t ) const;
duke@435 484 virtual int hash() const; // Type specific hashing
duke@435 485 virtual bool singleton(void) const; // TRUE if type is a singleton
duke@435 486 virtual bool empty(void) const; // TRUE if type is vacuous
duke@435 487 public:
duke@435 488 const jlong _lo, _hi; // Lower bound, upper bound
duke@435 489 const short _widen; // Limit on times we widen this sucker
duke@435 490
duke@435 491 static const TypeLong *make(jlong lo);
duke@435 492 // must always specify w
duke@435 493 static const TypeLong *make(jlong lo, jlong hi, int w);
duke@435 494
duke@435 495 // Check for single integer
duke@435 496 int is_con() const { return _lo==_hi; }
rasbold@580 497 bool is_con(int i) const { return is_con() && _lo == i; }
duke@435 498 jlong get_con() const { assert( is_con(), "" ); return _lo; }
duke@435 499
duke@435 500 virtual bool is_finite() const; // Has a finite value
duke@435 501
duke@435 502 virtual const Type *xmeet( const Type *t ) const;
duke@435 503 virtual const Type *xdual() const; // Compute dual right now.
never@1444 504 virtual const Type *widen( const Type *t, const Type* limit_type ) const;
duke@435 505 virtual const Type *narrow( const Type *t ) const;
duke@435 506 // Do not kill _widen bits.
duke@435 507 virtual const Type *filter( const Type *kills ) const;
duke@435 508 // Convenience common pre-built types.
duke@435 509 static const TypeLong *MINUS_1;
duke@435 510 static const TypeLong *ZERO;
duke@435 511 static const TypeLong *ONE;
duke@435 512 static const TypeLong *POS;
duke@435 513 static const TypeLong *LONG;
duke@435 514 static const TypeLong *INT; // 32-bit subrange [min_jint..max_jint]
duke@435 515 static const TypeLong *UINT; // 32-bit unsigned [0..max_juint]
duke@435 516 #ifndef PRODUCT
duke@435 517 virtual void dump2( Dict &d, uint, outputStream *st ) const;// Specialized per-Type dumping
duke@435 518 #endif
duke@435 519 };
duke@435 520
duke@435 521 //------------------------------TypeTuple--------------------------------------
duke@435 522 // Class of Tuple Types, essentially type collections for function signatures
duke@435 523 // and class layouts. It happens to also be a fast cache for the HotSpot
duke@435 524 // signature types.
duke@435 525 class TypeTuple : public Type {
duke@435 526 TypeTuple( uint cnt, const Type **fields ) : Type(Tuple), _cnt(cnt), _fields(fields) { }
duke@435 527 public:
duke@435 528 virtual bool eq( const Type *t ) const;
duke@435 529 virtual int hash() const; // Type specific hashing
duke@435 530 virtual bool singleton(void) const; // TRUE if type is a singleton
duke@435 531 virtual bool empty(void) const; // TRUE if type is vacuous
duke@435 532
duke@435 533 public:
duke@435 534 const uint _cnt; // Count of fields
duke@435 535 const Type ** const _fields; // Array of field types
duke@435 536
duke@435 537 // Accessors:
duke@435 538 uint cnt() const { return _cnt; }
duke@435 539 const Type* field_at(uint i) const {
duke@435 540 assert(i < _cnt, "oob");
duke@435 541 return _fields[i];
duke@435 542 }
duke@435 543 void set_field_at(uint i, const Type* t) {
duke@435 544 assert(i < _cnt, "oob");
duke@435 545 _fields[i] = t;
duke@435 546 }
duke@435 547
duke@435 548 static const TypeTuple *make( uint cnt, const Type **fields );
duke@435 549 static const TypeTuple *make_range(ciSignature *sig);
duke@435 550 static const TypeTuple *make_domain(ciInstanceKlass* recv, ciSignature *sig);
duke@435 551
duke@435 552 // Subroutine call type with space allocated for argument types
duke@435 553 static const Type **fields( uint arg_cnt );
duke@435 554
duke@435 555 virtual const Type *xmeet( const Type *t ) const;
duke@435 556 virtual const Type *xdual() const; // Compute dual right now.
duke@435 557 // Convenience common pre-built types.
duke@435 558 static const TypeTuple *IFBOTH;
duke@435 559 static const TypeTuple *IFFALSE;
duke@435 560 static const TypeTuple *IFTRUE;
duke@435 561 static const TypeTuple *IFNEITHER;
duke@435 562 static const TypeTuple *LOOPBODY;
duke@435 563 static const TypeTuple *MEMBAR;
duke@435 564 static const TypeTuple *STORECONDITIONAL;
duke@435 565 static const TypeTuple *START_I2C;
duke@435 566 static const TypeTuple *INT_PAIR;
duke@435 567 static const TypeTuple *LONG_PAIR;
duke@435 568 #ifndef PRODUCT
duke@435 569 virtual void dump2( Dict &d, uint, outputStream *st ) const; // Specialized per-Type dumping
duke@435 570 #endif
duke@435 571 };
duke@435 572
duke@435 573 //------------------------------TypeAry----------------------------------------
duke@435 574 // Class of Array Types
duke@435 575 class TypeAry : public Type {
duke@435 576 TypeAry( const Type *elem, const TypeInt *size) : Type(Array),
duke@435 577 _elem(elem), _size(size) {}
duke@435 578 public:
duke@435 579 virtual bool eq( const Type *t ) const;
duke@435 580 virtual int hash() const; // Type specific hashing
duke@435 581 virtual bool singleton(void) const; // TRUE if type is a singleton
duke@435 582 virtual bool empty(void) const; // TRUE if type is vacuous
duke@435 583
duke@435 584 private:
duke@435 585 const Type *_elem; // Element type of array
duke@435 586 const TypeInt *_size; // Elements in array
duke@435 587 friend class TypeAryPtr;
duke@435 588
duke@435 589 public:
duke@435 590 static const TypeAry *make( const Type *elem, const TypeInt *size);
duke@435 591
duke@435 592 virtual const Type *xmeet( const Type *t ) const;
duke@435 593 virtual const Type *xdual() const; // Compute dual right now.
duke@435 594 bool ary_must_be_exact() const; // true if arrays of such are never generic
kvn@1255 595 #ifdef ASSERT
kvn@1255 596 // One type is interface, the other is oop
kvn@1255 597 virtual bool interface_vs_oop(const Type *t) const;
kvn@1255 598 #endif
duke@435 599 #ifndef PRODUCT
duke@435 600 virtual void dump2( Dict &d, uint, outputStream *st ) const; // Specialized per-Type dumping
duke@435 601 #endif
duke@435 602 };
duke@435 603
kvn@3882 604 //------------------------------TypeVect---------------------------------------
kvn@3882 605 // Class of Vector Types
kvn@3882 606 class TypeVect : public Type {
kvn@3882 607 const Type* _elem; // Vector's element type
kvn@3882 608 const uint _length; // Elements in vector (power of 2)
kvn@3882 609
kvn@3882 610 protected:
kvn@3882 611 TypeVect(TYPES t, const Type* elem, uint length) : Type(t),
kvn@3882 612 _elem(elem), _length(length) {}
kvn@3882 613
kvn@3882 614 public:
kvn@3882 615 const Type* element_type() const { return _elem; }
kvn@3882 616 BasicType element_basic_type() const { return _elem->array_element_basic_type(); }
kvn@3882 617 uint length() const { return _length; }
kvn@3882 618 uint length_in_bytes() const {
kvn@3882 619 return _length * type2aelembytes(element_basic_type());
kvn@3882 620 }
kvn@3882 621
kvn@3882 622 virtual bool eq(const Type *t) const;
kvn@3882 623 virtual int hash() const; // Type specific hashing
kvn@3882 624 virtual bool singleton(void) const; // TRUE if type is a singleton
kvn@3882 625 virtual bool empty(void) const; // TRUE if type is vacuous
kvn@3882 626
kvn@3882 627 static const TypeVect *make(const BasicType elem_bt, uint length) {
kvn@3882 628 // Use bottom primitive type.
kvn@3882 629 return make(get_const_basic_type(elem_bt), length);
kvn@3882 630 }
kvn@3882 631 // Used directly by Replicate nodes to construct singleton vector.
kvn@3882 632 static const TypeVect *make(const Type* elem, uint length);
kvn@3882 633
kvn@3882 634 virtual const Type *xmeet( const Type *t) const;
kvn@3882 635 virtual const Type *xdual() const; // Compute dual right now.
kvn@3882 636
kvn@3882 637 static const TypeVect *VECTS;
kvn@3882 638 static const TypeVect *VECTD;
kvn@3882 639 static const TypeVect *VECTX;
kvn@3882 640 static const TypeVect *VECTY;
kvn@3882 641
kvn@3882 642 #ifndef PRODUCT
kvn@3882 643 virtual void dump2(Dict &d, uint, outputStream *st) const; // Specialized per-Type dumping
kvn@3882 644 #endif
kvn@3882 645 };
kvn@3882 646
kvn@3882 647 class TypeVectS : public TypeVect {
kvn@3882 648 friend class TypeVect;
kvn@3882 649 TypeVectS(const Type* elem, uint length) : TypeVect(VectorS, elem, length) {}
kvn@3882 650 };
kvn@3882 651
kvn@3882 652 class TypeVectD : public TypeVect {
kvn@3882 653 friend class TypeVect;
kvn@3882 654 TypeVectD(const Type* elem, uint length) : TypeVect(VectorD, elem, length) {}
kvn@3882 655 };
kvn@3882 656
kvn@3882 657 class TypeVectX : public TypeVect {
kvn@3882 658 friend class TypeVect;
kvn@3882 659 TypeVectX(const Type* elem, uint length) : TypeVect(VectorX, elem, length) {}
kvn@3882 660 };
kvn@3882 661
kvn@3882 662 class TypeVectY : public TypeVect {
kvn@3882 663 friend class TypeVect;
kvn@3882 664 TypeVectY(const Type* elem, uint length) : TypeVect(VectorY, elem, length) {}
kvn@3882 665 };
kvn@3882 666
duke@435 667 //------------------------------TypePtr----------------------------------------
duke@435 668 // Class of machine Pointer Types: raw data, instances or arrays.
duke@435 669 // If the _base enum is AnyPtr, then this refers to all of the above.
duke@435 670 // Otherwise the _base will indicate which subset of pointers is affected,
duke@435 671 // and the class will be inherited from.
duke@435 672 class TypePtr : public Type {
coleenp@548 673 friend class TypeNarrowOop;
duke@435 674 public:
duke@435 675 enum PTR { TopPTR, AnyNull, Constant, Null, NotNull, BotPTR, lastPTR };
duke@435 676 protected:
duke@435 677 TypePtr( TYPES t, PTR ptr, int offset ) : Type(t), _ptr(ptr), _offset(offset) {}
duke@435 678 virtual bool eq( const Type *t ) const;
duke@435 679 virtual int hash() const; // Type specific hashing
duke@435 680 static const PTR ptr_meet[lastPTR][lastPTR];
duke@435 681 static const PTR ptr_dual[lastPTR];
duke@435 682 static const char * const ptr_msg[lastPTR];
duke@435 683
duke@435 684 public:
duke@435 685 const int _offset; // Offset into oop, with TOP & BOT
duke@435 686 const PTR _ptr; // Pointer equivalence class
duke@435 687
duke@435 688 const int offset() const { return _offset; }
duke@435 689 const PTR ptr() const { return _ptr; }
duke@435 690
duke@435 691 static const TypePtr *make( TYPES t, PTR ptr, int offset );
duke@435 692
duke@435 693 // Return a 'ptr' version of this type
duke@435 694 virtual const Type *cast_to_ptr_type(PTR ptr) const;
duke@435 695
duke@435 696 virtual intptr_t get_con() const;
duke@435 697
kvn@741 698 int xadd_offset( intptr_t offset ) const;
kvn@741 699 virtual const TypePtr *add_offset( intptr_t offset ) const;
duke@435 700
duke@435 701 virtual bool singleton(void) const; // TRUE if type is a singleton
duke@435 702 virtual bool empty(void) const; // TRUE if type is vacuous
duke@435 703 virtual const Type *xmeet( const Type *t ) const;
duke@435 704 int meet_offset( int offset ) const;
duke@435 705 int dual_offset( ) const;
duke@435 706 virtual const Type *xdual() const; // Compute dual right now.
duke@435 707
duke@435 708 // meet, dual and join over pointer equivalence sets
duke@435 709 PTR meet_ptr( const PTR in_ptr ) const { return ptr_meet[in_ptr][ptr()]; }
duke@435 710 PTR dual_ptr() const { return ptr_dual[ptr()]; }
duke@435 711
duke@435 712 // This is textually confusing unless one recalls that
duke@435 713 // join(t) == dual()->meet(t->dual())->dual().
duke@435 714 PTR join_ptr( const PTR in_ptr ) const {
duke@435 715 return ptr_dual[ ptr_meet[ ptr_dual[in_ptr] ] [ dual_ptr() ] ];
duke@435 716 }
duke@435 717
duke@435 718 // Tests for relation to centerline of type lattice:
duke@435 719 static bool above_centerline(PTR ptr) { return (ptr <= AnyNull); }
duke@435 720 static bool below_centerline(PTR ptr) { return (ptr >= NotNull); }
duke@435 721 // Convenience common pre-built types.
duke@435 722 static const TypePtr *NULL_PTR;
duke@435 723 static const TypePtr *NOTNULL;
duke@435 724 static const TypePtr *BOTTOM;
duke@435 725 #ifndef PRODUCT
duke@435 726 virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
duke@435 727 #endif
duke@435 728 };
duke@435 729
duke@435 730 //------------------------------TypeRawPtr-------------------------------------
duke@435 731 // Class of raw pointers, pointers to things other than Oops. Examples
duke@435 732 // include the stack pointer, top of heap, card-marking area, handles, etc.
duke@435 733 class TypeRawPtr : public TypePtr {
duke@435 734 protected:
duke@435 735 TypeRawPtr( PTR ptr, address bits ) : TypePtr(RawPtr,ptr,0), _bits(bits){}
duke@435 736 public:
duke@435 737 virtual bool eq( const Type *t ) const;
duke@435 738 virtual int hash() const; // Type specific hashing
duke@435 739
duke@435 740 const address _bits; // Constant value, if applicable
duke@435 741
duke@435 742 static const TypeRawPtr *make( PTR ptr );
duke@435 743 static const TypeRawPtr *make( address bits );
duke@435 744
duke@435 745 // Return a 'ptr' version of this type
duke@435 746 virtual const Type *cast_to_ptr_type(PTR ptr) const;
duke@435 747
duke@435 748 virtual intptr_t get_con() const;
duke@435 749
kvn@741 750 virtual const TypePtr *add_offset( intptr_t offset ) const;
duke@435 751
duke@435 752 virtual const Type *xmeet( const Type *t ) const;
duke@435 753 virtual const Type *xdual() const; // Compute dual right now.
duke@435 754 // Convenience common pre-built types.
duke@435 755 static const TypeRawPtr *BOTTOM;
duke@435 756 static const TypeRawPtr *NOTNULL;
duke@435 757 #ifndef PRODUCT
duke@435 758 virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
duke@435 759 #endif
duke@435 760 };
duke@435 761
duke@435 762 //------------------------------TypeOopPtr-------------------------------------
duke@435 763 // Some kind of oop (Java pointer), either klass or instance or array.
duke@435 764 class TypeOopPtr : public TypePtr {
duke@435 765 protected:
kvn@598 766 TypeOopPtr( TYPES t, PTR ptr, ciKlass* k, bool xk, ciObject* o, int offset, int instance_id );
duke@435 767 public:
duke@435 768 virtual bool eq( const Type *t ) const;
duke@435 769 virtual int hash() const; // Type specific hashing
duke@435 770 virtual bool singleton(void) const; // TRUE if type is a singleton
duke@435 771 enum {
kvn@658 772 InstanceTop = -1, // undefined instance
kvn@658 773 InstanceBot = 0 // any possible instance
duke@435 774 };
duke@435 775 protected:
duke@435 776
duke@435 777 // Oop is NULL, unless this is a constant oop.
duke@435 778 ciObject* _const_oop; // Constant oop
duke@435 779 // If _klass is NULL, then so is _sig. This is an unloaded klass.
duke@435 780 ciKlass* _klass; // Klass object
duke@435 781 // Does the type exclude subclasses of the klass? (Inexact == polymorphic.)
duke@435 782 bool _klass_is_exact;
kvn@598 783 bool _is_ptr_to_narrowoop;
duke@435 784
kvn@658 785 // If not InstanceTop or InstanceBot, indicates that this is
kvn@658 786 // a particular instance of this type which is distinct.
kvn@658 787 // This is the the node index of the allocation node creating this instance.
kvn@658 788 int _instance_id;
duke@435 789
duke@435 790 static const TypeOopPtr* make_from_klass_common(ciKlass* klass, bool klass_change, bool try_for_exact);
duke@435 791
kvn@658 792 int dual_instance_id() const;
kvn@658 793 int meet_instance_id(int uid) const;
duke@435 794
duke@435 795 public:
duke@435 796 // Creates a type given a klass. Correctly handles multi-dimensional arrays
duke@435 797 // Respects UseUniqueSubclasses.
duke@435 798 // If the klass is final, the resulting type will be exact.
duke@435 799 static const TypeOopPtr* make_from_klass(ciKlass* klass) {
duke@435 800 return make_from_klass_common(klass, true, false);
duke@435 801 }
duke@435 802 // Same as before, but will produce an exact type, even if
duke@435 803 // the klass is not final, as long as it has exactly one implementation.
duke@435 804 static const TypeOopPtr* make_from_klass_unique(ciKlass* klass) {
duke@435 805 return make_from_klass_common(klass, true, true);
duke@435 806 }
duke@435 807 // Same as before, but does not respects UseUniqueSubclasses.
duke@435 808 // Use this only for creating array element types.
duke@435 809 static const TypeOopPtr* make_from_klass_raw(ciKlass* klass) {
duke@435 810 return make_from_klass_common(klass, false, false);
duke@435 811 }
duke@435 812 // Creates a singleton type given an object.
jrose@1424 813 // If the object cannot be rendered as a constant,
jrose@1424 814 // may return a non-singleton type.
jrose@1424 815 // If require_constant, produce a NULL if a singleton is not possible.
jrose@1424 816 static const TypeOopPtr* make_from_constant(ciObject* o, bool require_constant = false);
duke@435 817
duke@435 818 // Make a generic (unclassed) pointer to an oop.
kvn@1427 819 static const TypeOopPtr* make(PTR ptr, int offset, int instance_id);
duke@435 820
duke@435 821 ciObject* const_oop() const { return _const_oop; }
duke@435 822 virtual ciKlass* klass() const { return _klass; }
duke@435 823 bool klass_is_exact() const { return _klass_is_exact; }
kvn@598 824
kvn@598 825 // Returns true if this pointer points at memory which contains a
kvn@598 826 // compressed oop references.
kvn@598 827 bool is_ptr_to_narrowoop_nv() const { return _is_ptr_to_narrowoop; }
kvn@598 828
kvn@658 829 bool is_known_instance() const { return _instance_id > 0; }
kvn@658 830 int instance_id() const { return _instance_id; }
kvn@658 831 bool is_known_instance_field() const { return is_known_instance() && _offset >= 0; }
duke@435 832
duke@435 833 virtual intptr_t get_con() const;
duke@435 834
duke@435 835 virtual const Type *cast_to_ptr_type(PTR ptr) const;
duke@435 836
duke@435 837 virtual const Type *cast_to_exactness(bool klass_is_exact) const;
duke@435 838
kvn@658 839 virtual const TypeOopPtr *cast_to_instance_id(int instance_id) const;
duke@435 840
duke@435 841 // corresponding pointer to klass, for a given instance
duke@435 842 const TypeKlassPtr* as_klass_type() const;
duke@435 843
kvn@741 844 virtual const TypePtr *add_offset( intptr_t offset ) const;
duke@435 845
duke@435 846 virtual const Type *xmeet( const Type *t ) const;
duke@435 847 virtual const Type *xdual() const; // Compute dual right now.
duke@435 848
duke@435 849 // Do not allow interface-vs.-noninterface joins to collapse to top.
duke@435 850 virtual const Type *filter( const Type *kills ) const;
duke@435 851
duke@435 852 // Convenience common pre-built type.
duke@435 853 static const TypeOopPtr *BOTTOM;
duke@435 854 #ifndef PRODUCT
duke@435 855 virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
duke@435 856 #endif
duke@435 857 };
duke@435 858
duke@435 859 //------------------------------TypeInstPtr------------------------------------
duke@435 860 // Class of Java object pointers, pointing either to non-array Java instances
coleenp@4037 861 // or to a Klass* (including array klasses).
duke@435 862 class TypeInstPtr : public TypeOopPtr {
duke@435 863 TypeInstPtr( PTR ptr, ciKlass* k, bool xk, ciObject* o, int offset, int instance_id );
duke@435 864 virtual bool eq( const Type *t ) const;
duke@435 865 virtual int hash() const; // Type specific hashing
duke@435 866
duke@435 867 ciSymbol* _name; // class name
duke@435 868
duke@435 869 public:
duke@435 870 ciSymbol* name() const { return _name; }
duke@435 871
duke@435 872 bool is_loaded() const { return _klass->is_loaded(); }
duke@435 873
duke@435 874 // Make a pointer to a constant oop.
duke@435 875 static const TypeInstPtr *make(ciObject* o) {
duke@435 876 return make(TypePtr::Constant, o->klass(), true, o, 0);
duke@435 877 }
duke@435 878 // Make a pointer to a constant oop with offset.
duke@435 879 static const TypeInstPtr *make(ciObject* o, int offset) {
duke@435 880 return make(TypePtr::Constant, o->klass(), true, o, offset);
duke@435 881 }
duke@435 882
duke@435 883 // Make a pointer to some value of type klass.
duke@435 884 static const TypeInstPtr *make(PTR ptr, ciKlass* klass) {
duke@435 885 return make(ptr, klass, false, NULL, 0);
duke@435 886 }
duke@435 887
duke@435 888 // Make a pointer to some non-polymorphic value of exactly type klass.
duke@435 889 static const TypeInstPtr *make_exact(PTR ptr, ciKlass* klass) {
duke@435 890 return make(ptr, klass, true, NULL, 0);
duke@435 891 }
duke@435 892
duke@435 893 // Make a pointer to some value of type klass with offset.
duke@435 894 static const TypeInstPtr *make(PTR ptr, ciKlass* klass, int offset) {
duke@435 895 return make(ptr, klass, false, NULL, offset);
duke@435 896 }
duke@435 897
duke@435 898 // Make a pointer to an oop.
kvn@658 899 static const TypeInstPtr *make(PTR ptr, ciKlass* k, bool xk, ciObject* o, int offset, int instance_id = InstanceBot );
duke@435 900
duke@435 901 // If this is a java.lang.Class constant, return the type for it or NULL.
duke@435 902 // Pass to Type::get_const_type to turn it to a type, which will usually
duke@435 903 // be a TypeInstPtr, but may also be a TypeInt::INT for int.class, etc.
duke@435 904 ciType* java_mirror_type() const;
duke@435 905
duke@435 906 virtual const Type *cast_to_ptr_type(PTR ptr) const;
duke@435 907
duke@435 908 virtual const Type *cast_to_exactness(bool klass_is_exact) const;
duke@435 909
kvn@658 910 virtual const TypeOopPtr *cast_to_instance_id(int instance_id) const;
duke@435 911
kvn@741 912 virtual const TypePtr *add_offset( intptr_t offset ) const;
duke@435 913
duke@435 914 virtual const Type *xmeet( const Type *t ) const;
duke@435 915 virtual const TypeInstPtr *xmeet_unloaded( const TypeInstPtr *t ) const;
duke@435 916 virtual const Type *xdual() const; // Compute dual right now.
duke@435 917
duke@435 918 // Convenience common pre-built types.
duke@435 919 static const TypeInstPtr *NOTNULL;
duke@435 920 static const TypeInstPtr *BOTTOM;
duke@435 921 static const TypeInstPtr *MIRROR;
duke@435 922 static const TypeInstPtr *MARK;
duke@435 923 static const TypeInstPtr *KLASS;
duke@435 924 #ifndef PRODUCT
duke@435 925 virtual void dump2( Dict &d, uint depth, outputStream *st ) const; // Specialized per-Type dumping
duke@435 926 #endif
duke@435 927 };
duke@435 928
duke@435 929 //------------------------------TypeAryPtr-------------------------------------
duke@435 930 // Class of Java array pointers
duke@435 931 class TypeAryPtr : public TypeOopPtr {
kvn@2116 932 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) {
kvn@2116 933 #ifdef ASSERT
kvn@2116 934 if (k != NULL) {
kvn@2116 935 // Verify that specified klass and TypeAryPtr::klass() follow the same rules.
kvn@2116 936 ciKlass* ck = compute_klass(true);
kvn@2147 937 if (k != ck) {
kvn@2116 938 this->dump(); tty->cr();
kvn@2116 939 tty->print(" k: ");
kvn@2116 940 k->print(); tty->cr();
kvn@2116 941 tty->print("ck: ");
kvn@2116 942 if (ck != NULL) ck->print();
kvn@2116 943 else tty->print("<NULL>");
kvn@2116 944 tty->cr();
kvn@2116 945 assert(false, "unexpected TypeAryPtr::_klass");
kvn@2116 946 }
kvn@2116 947 }
kvn@2116 948 #endif
kvn@2116 949 }
duke@435 950 virtual bool eq( const Type *t ) const;
duke@435 951 virtual int hash() const; // Type specific hashing
duke@435 952 const TypeAry *_ary; // Array we point into
duke@435 953
kvn@2116 954 ciKlass* compute_klass(DEBUG_ONLY(bool verify = false)) const;
kvn@2116 955
duke@435 956 public:
duke@435 957 // Accessors
duke@435 958 ciKlass* klass() const;
duke@435 959 const TypeAry* ary() const { return _ary; }
duke@435 960 const Type* elem() const { return _ary->_elem; }
duke@435 961 const TypeInt* size() const { return _ary->_size; }
duke@435 962
kvn@658 963 static const TypeAryPtr *make( PTR ptr, const TypeAry *ary, ciKlass* k, bool xk, int offset, int instance_id = InstanceBot);
duke@435 964 // Constant pointer to array
kvn@658 965 static const TypeAryPtr *make( PTR ptr, ciObject* o, const TypeAry *ary, ciKlass* k, bool xk, int offset, int instance_id = InstanceBot);
duke@435 966
duke@435 967 // Return a 'ptr' version of this type
duke@435 968 virtual const Type *cast_to_ptr_type(PTR ptr) const;
duke@435 969
duke@435 970 virtual const Type *cast_to_exactness(bool klass_is_exact) const;
duke@435 971
kvn@658 972 virtual const TypeOopPtr *cast_to_instance_id(int instance_id) const;
duke@435 973
duke@435 974 virtual const TypeAryPtr* cast_to_size(const TypeInt* size) const;
rasbold@801 975 virtual const TypeInt* narrow_size_type(const TypeInt* size) const;
duke@435 976
duke@435 977 virtual bool empty(void) const; // TRUE if type is vacuous
kvn@741 978 virtual const TypePtr *add_offset( intptr_t offset ) const;
duke@435 979
duke@435 980 virtual const Type *xmeet( const Type *t ) const;
duke@435 981 virtual const Type *xdual() const; // Compute dual right now.
duke@435 982
duke@435 983 // Convenience common pre-built types.
duke@435 984 static const TypeAryPtr *RANGE;
duke@435 985 static const TypeAryPtr *OOPS;
kvn@598 986 static const TypeAryPtr *NARROWOOPS;
duke@435 987 static const TypeAryPtr *BYTES;
duke@435 988 static const TypeAryPtr *SHORTS;
duke@435 989 static const TypeAryPtr *CHARS;
duke@435 990 static const TypeAryPtr *INTS;
duke@435 991 static const TypeAryPtr *LONGS;
duke@435 992 static const TypeAryPtr *FLOATS;
duke@435 993 static const TypeAryPtr *DOUBLES;
duke@435 994 // selects one of the above:
duke@435 995 static const TypeAryPtr *get_array_body_type(BasicType elem) {
duke@435 996 assert((uint)elem <= T_CONFLICT && _array_body_type[elem] != NULL, "bad elem type");
duke@435 997 return _array_body_type[elem];
duke@435 998 }
duke@435 999 static const TypeAryPtr *_array_body_type[T_CONFLICT+1];
duke@435 1000 // sharpen the type of an int which is used as an array size
kvn@1255 1001 #ifdef ASSERT
kvn@1255 1002 // One type is interface, the other is oop
kvn@1255 1003 virtual bool interface_vs_oop(const Type *t) const;
kvn@1255 1004 #endif
duke@435 1005 #ifndef PRODUCT
duke@435 1006 virtual void dump2( Dict &d, uint depth, outputStream *st ) const; // Specialized per-Type dumping
duke@435 1007 #endif
duke@435 1008 };
duke@435 1009
coleenp@4037 1010 //------------------------------TypeMetadataPtr-------------------------------------
coleenp@4037 1011 // Some kind of metadata, either Method*, MethodData* or CPCacheOop
coleenp@4037 1012 class TypeMetadataPtr : public TypePtr {
coleenp@4037 1013 protected:
coleenp@4037 1014 TypeMetadataPtr(PTR ptr, ciMetadata* metadata, int offset);
coleenp@4037 1015 public:
coleenp@4037 1016 virtual bool eq( const Type *t ) const;
coleenp@4037 1017 virtual int hash() const; // Type specific hashing
coleenp@4037 1018 virtual bool singleton(void) const; // TRUE if type is a singleton
coleenp@4037 1019
coleenp@4037 1020 private:
coleenp@4037 1021 ciMetadata* _metadata;
coleenp@4037 1022
coleenp@4037 1023 public:
coleenp@4037 1024 static const TypeMetadataPtr* make(PTR ptr, ciMetadata* m, int offset);
coleenp@4037 1025
coleenp@4037 1026 static const TypeMetadataPtr* make(ciMethod* m);
coleenp@4037 1027 static const TypeMetadataPtr* make(ciMethodData* m);
coleenp@4037 1028
coleenp@4037 1029 ciMetadata* metadata() const { return _metadata; }
coleenp@4037 1030
coleenp@4037 1031 virtual const Type *cast_to_ptr_type(PTR ptr) const;
coleenp@4037 1032
coleenp@4037 1033 virtual const TypePtr *add_offset( intptr_t offset ) const;
coleenp@4037 1034
coleenp@4037 1035 virtual const Type *xmeet( const Type *t ) const;
coleenp@4037 1036 virtual const Type *xdual() const; // Compute dual right now.
coleenp@4037 1037
coleenp@4037 1038 virtual intptr_t get_con() const;
coleenp@4037 1039
coleenp@4037 1040 // Do not allow interface-vs.-noninterface joins to collapse to top.
coleenp@4037 1041 virtual const Type *filter( const Type *kills ) const;
coleenp@4037 1042
coleenp@4037 1043 // Convenience common pre-built types.
coleenp@4037 1044 static const TypeMetadataPtr *BOTTOM;
coleenp@4037 1045
coleenp@4037 1046 #ifndef PRODUCT
coleenp@4037 1047 virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
coleenp@4037 1048 #endif
coleenp@4037 1049 };
coleenp@4037 1050
duke@435 1051 //------------------------------TypeKlassPtr-----------------------------------
duke@435 1052 // Class of Java Klass pointers
coleenp@4037 1053 class TypeKlassPtr : public TypePtr {
duke@435 1054 TypeKlassPtr( PTR ptr, ciKlass* klass, int offset );
duke@435 1055
coleenp@4037 1056 public:
duke@435 1057 virtual bool eq( const Type *t ) const;
duke@435 1058 virtual int hash() const; // Type specific hashing
coleenp@4037 1059 virtual bool singleton(void) const; // TRUE if type is a singleton
coleenp@4037 1060 private:
coleenp@4037 1061
coleenp@4037 1062 static const TypeKlassPtr* make_from_klass_common(ciKlass* klass, bool klass_change, bool try_for_exact);
coleenp@4037 1063
coleenp@4037 1064 ciKlass* _klass;
coleenp@4037 1065
coleenp@4037 1066 // Does the type exclude subclasses of the klass? (Inexact == polymorphic.)
coleenp@4037 1067 bool _klass_is_exact;
duke@435 1068
duke@435 1069 public:
coleenp@4037 1070 ciSymbol* name() const { return klass()->name(); }
duke@435 1071
coleenp@4037 1072 ciKlass* klass() const { return _klass; }
coleenp@4037 1073 bool klass_is_exact() const { return _klass_is_exact; }
coleenp@4037 1074
coleenp@4037 1075 bool is_loaded() const { return klass()->is_loaded(); }
coleenp@4037 1076
coleenp@4037 1077 // Creates a type given a klass. Correctly handles multi-dimensional arrays
coleenp@4037 1078 // Respects UseUniqueSubclasses.
coleenp@4037 1079 // If the klass is final, the resulting type will be exact.
coleenp@4037 1080 static const TypeKlassPtr* make_from_klass(ciKlass* klass) {
coleenp@4037 1081 return make_from_klass_common(klass, true, false);
coleenp@4037 1082 }
coleenp@4037 1083 // Same as before, but will produce an exact type, even if
coleenp@4037 1084 // the klass is not final, as long as it has exactly one implementation.
coleenp@4037 1085 static const TypeKlassPtr* make_from_klass_unique(ciKlass* klass) {
coleenp@4037 1086 return make_from_klass_common(klass, true, true);
coleenp@4037 1087 }
coleenp@4037 1088 // Same as before, but does not respects UseUniqueSubclasses.
coleenp@4037 1089 // Use this only for creating array element types.
coleenp@4037 1090 static const TypeKlassPtr* make_from_klass_raw(ciKlass* klass) {
coleenp@4037 1091 return make_from_klass_common(klass, false, false);
coleenp@4037 1092 }
coleenp@4037 1093
coleenp@4037 1094 // Make a generic (unclassed) pointer to metadata.
coleenp@4037 1095 static const TypeKlassPtr* make(PTR ptr, int offset);
never@990 1096
duke@435 1097 // ptr to klass 'k'
duke@435 1098 static const TypeKlassPtr *make( ciKlass* k ) { return make( TypePtr::Constant, k, 0); }
duke@435 1099 // ptr to klass 'k' with offset
duke@435 1100 static const TypeKlassPtr *make( ciKlass* k, int offset ) { return make( TypePtr::Constant, k, offset); }
duke@435 1101 // ptr to klass 'k' or sub-klass
duke@435 1102 static const TypeKlassPtr *make( PTR ptr, ciKlass* k, int offset);
duke@435 1103
duke@435 1104 virtual const Type *cast_to_ptr_type(PTR ptr) const;
duke@435 1105
duke@435 1106 virtual const Type *cast_to_exactness(bool klass_is_exact) const;
duke@435 1107
duke@435 1108 // corresponding pointer to instance, for a given class
duke@435 1109 const TypeOopPtr* as_instance_type() const;
duke@435 1110
kvn@741 1111 virtual const TypePtr *add_offset( intptr_t offset ) const;
duke@435 1112 virtual const Type *xmeet( const Type *t ) const;
duke@435 1113 virtual const Type *xdual() const; // Compute dual right now.
duke@435 1114
coleenp@4037 1115 virtual intptr_t get_con() const;
coleenp@4037 1116
duke@435 1117 // Convenience common pre-built types.
duke@435 1118 static const TypeKlassPtr* OBJECT; // Not-null object klass or below
duke@435 1119 static const TypeKlassPtr* OBJECT_OR_NULL; // Maybe-null version of same
duke@435 1120 #ifndef PRODUCT
duke@435 1121 virtual void dump2( Dict &d, uint depth, outputStream *st ) const; // Specialized per-Type dumping
duke@435 1122 #endif
duke@435 1123 };
duke@435 1124
kvn@598 1125 //------------------------------TypeNarrowOop----------------------------------
coleenp@548 1126 // A compressed reference to some kind of Oop. This type wraps around
coleenp@548 1127 // a preexisting TypeOopPtr and forwards most of it's operations to
coleenp@548 1128 // the underlying type. It's only real purpose is to track the
coleenp@548 1129 // oopness of the compressed oop value when we expose the conversion
coleenp@548 1130 // between the normal and the compressed form.
coleenp@548 1131 class TypeNarrowOop : public Type {
coleenp@548 1132 protected:
never@1262 1133 const TypePtr* _ptrtype; // Could be TypePtr::NULL_PTR
coleenp@548 1134
never@1262 1135 TypeNarrowOop( const TypePtr* ptrtype): Type(NarrowOop),
never@1262 1136 _ptrtype(ptrtype) {
never@1262 1137 assert(ptrtype->offset() == 0 ||
never@1262 1138 ptrtype->offset() == OffsetBot ||
never@1262 1139 ptrtype->offset() == OffsetTop, "no real offsets");
coleenp@548 1140 }
coleenp@548 1141 public:
coleenp@548 1142 virtual bool eq( const Type *t ) const;
coleenp@548 1143 virtual int hash() const; // Type specific hashing
coleenp@548 1144 virtual bool singleton(void) const; // TRUE if type is a singleton
coleenp@548 1145
coleenp@548 1146 virtual const Type *xmeet( const Type *t ) const;
coleenp@548 1147 virtual const Type *xdual() const; // Compute dual right now.
coleenp@548 1148
coleenp@548 1149 virtual intptr_t get_con() const;
coleenp@548 1150
coleenp@548 1151 // Do not allow interface-vs.-noninterface joins to collapse to top.
coleenp@548 1152 virtual const Type *filter( const Type *kills ) const;
coleenp@548 1153
coleenp@548 1154 virtual bool empty(void) const; // TRUE if type is vacuous
coleenp@548 1155
coleenp@548 1156 static const TypeNarrowOop *make( const TypePtr* type);
coleenp@548 1157
jcoomes@2661 1158 static const TypeNarrowOop* make_from_constant(ciObject* con, bool require_constant = false) {
jcoomes@2661 1159 return make(TypeOopPtr::make_from_constant(con, require_constant));
coleenp@548 1160 }
coleenp@548 1161
kvn@656 1162 // returns the equivalent ptr type for this compressed pointer
never@1262 1163 const TypePtr *get_ptrtype() const {
never@1262 1164 return _ptrtype;
coleenp@548 1165 }
coleenp@548 1166
coleenp@548 1167 static const TypeNarrowOop *BOTTOM;
coleenp@548 1168 static const TypeNarrowOop *NULL_PTR;
coleenp@548 1169
coleenp@548 1170 #ifndef PRODUCT
coleenp@548 1171 virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
coleenp@548 1172 #endif
coleenp@548 1173 };
coleenp@548 1174
duke@435 1175 //------------------------------TypeFunc---------------------------------------
duke@435 1176 // Class of Array Types
duke@435 1177 class TypeFunc : public Type {
duke@435 1178 TypeFunc( const TypeTuple *domain, const TypeTuple *range ) : Type(Function), _domain(domain), _range(range) {}
duke@435 1179 virtual bool eq( const Type *t ) const;
duke@435 1180 virtual int hash() const; // Type specific hashing
duke@435 1181 virtual bool singleton(void) const; // TRUE if type is a singleton
duke@435 1182 virtual bool empty(void) const; // TRUE if type is vacuous
duke@435 1183 public:
duke@435 1184 // Constants are shared among ADLC and VM
duke@435 1185 enum { Control = AdlcVMDeps::Control,
duke@435 1186 I_O = AdlcVMDeps::I_O,
duke@435 1187 Memory = AdlcVMDeps::Memory,
duke@435 1188 FramePtr = AdlcVMDeps::FramePtr,
duke@435 1189 ReturnAdr = AdlcVMDeps::ReturnAdr,
duke@435 1190 Parms = AdlcVMDeps::Parms
duke@435 1191 };
duke@435 1192
duke@435 1193 const TypeTuple* const _domain; // Domain of inputs
duke@435 1194 const TypeTuple* const _range; // Range of results
duke@435 1195
duke@435 1196 // Accessors:
duke@435 1197 const TypeTuple* domain() const { return _domain; }
duke@435 1198 const TypeTuple* range() const { return _range; }
duke@435 1199
duke@435 1200 static const TypeFunc *make(ciMethod* method);
duke@435 1201 static const TypeFunc *make(ciSignature signature, const Type* extra);
duke@435 1202 static const TypeFunc *make(const TypeTuple* domain, const TypeTuple* range);
duke@435 1203
duke@435 1204 virtual const Type *xmeet( const Type *t ) const;
duke@435 1205 virtual const Type *xdual() const; // Compute dual right now.
duke@435 1206
duke@435 1207 BasicType return_type() const;
duke@435 1208
duke@435 1209 #ifndef PRODUCT
duke@435 1210 virtual void dump2( Dict &d, uint depth, outputStream *st ) const; // Specialized per-Type dumping
duke@435 1211 #endif
duke@435 1212 // Convenience common pre-built types.
duke@435 1213 };
duke@435 1214
duke@435 1215 //------------------------------accessors--------------------------------------
kvn@598 1216 inline bool Type::is_ptr_to_narrowoop() const {
kvn@598 1217 #ifdef _LP64
kvn@598 1218 return (isa_oopptr() != NULL && is_oopptr()->is_ptr_to_narrowoop_nv());
kvn@598 1219 #else
kvn@598 1220 return false;
kvn@598 1221 #endif
kvn@598 1222 }
kvn@598 1223
duke@435 1224 inline float Type::getf() const {
duke@435 1225 assert( _base == FloatCon, "Not a FloatCon" );
duke@435 1226 return ((TypeF*)this)->_f;
duke@435 1227 }
duke@435 1228
duke@435 1229 inline double Type::getd() const {
duke@435 1230 assert( _base == DoubleCon, "Not a DoubleCon" );
duke@435 1231 return ((TypeD*)this)->_d;
duke@435 1232 }
duke@435 1233
duke@435 1234 inline const TypeF *Type::is_float_constant() const {
duke@435 1235 assert( _base == FloatCon, "Not a Float" );
duke@435 1236 return (TypeF*)this;
duke@435 1237 }
duke@435 1238
duke@435 1239 inline const TypeF *Type::isa_float_constant() const {
duke@435 1240 return ( _base == FloatCon ? (TypeF*)this : NULL);
duke@435 1241 }
duke@435 1242
duke@435 1243 inline const TypeD *Type::is_double_constant() const {
duke@435 1244 assert( _base == DoubleCon, "Not a Double" );
duke@435 1245 return (TypeD*)this;
duke@435 1246 }
duke@435 1247
duke@435 1248 inline const TypeD *Type::isa_double_constant() const {
duke@435 1249 return ( _base == DoubleCon ? (TypeD*)this : NULL);
duke@435 1250 }
duke@435 1251
duke@435 1252 inline const TypeInt *Type::is_int() const {
duke@435 1253 assert( _base == Int, "Not an Int" );
duke@435 1254 return (TypeInt*)this;
duke@435 1255 }
duke@435 1256
duke@435 1257 inline const TypeInt *Type::isa_int() const {
duke@435 1258 return ( _base == Int ? (TypeInt*)this : NULL);
duke@435 1259 }
duke@435 1260
duke@435 1261 inline const TypeLong *Type::is_long() const {
duke@435 1262 assert( _base == Long, "Not a Long" );
duke@435 1263 return (TypeLong*)this;
duke@435 1264 }
duke@435 1265
duke@435 1266 inline const TypeLong *Type::isa_long() const {
duke@435 1267 return ( _base == Long ? (TypeLong*)this : NULL);
duke@435 1268 }
duke@435 1269
duke@435 1270 inline const TypeTuple *Type::is_tuple() const {
duke@435 1271 assert( _base == Tuple, "Not a Tuple" );
duke@435 1272 return (TypeTuple*)this;
duke@435 1273 }
duke@435 1274
duke@435 1275 inline const TypeAry *Type::is_ary() const {
duke@435 1276 assert( _base == Array , "Not an Array" );
duke@435 1277 return (TypeAry*)this;
duke@435 1278 }
duke@435 1279
kvn@3882 1280 inline const TypeVect *Type::is_vect() const {
kvn@3882 1281 assert( _base >= VectorS && _base <= VectorY, "Not a Vector" );
kvn@3882 1282 return (TypeVect*)this;
kvn@3882 1283 }
kvn@3882 1284
kvn@3882 1285 inline const TypeVect *Type::isa_vect() const {
kvn@3882 1286 return (_base >= VectorS && _base <= VectorY) ? (TypeVect*)this : NULL;
kvn@3882 1287 }
kvn@3882 1288
duke@435 1289 inline const TypePtr *Type::is_ptr() const {
duke@435 1290 // AnyPtr is the first Ptr and KlassPtr the last, with no non-ptrs between.
duke@435 1291 assert(_base >= AnyPtr && _base <= KlassPtr, "Not a pointer");
duke@435 1292 return (TypePtr*)this;
duke@435 1293 }
duke@435 1294
duke@435 1295 inline const TypePtr *Type::isa_ptr() const {
duke@435 1296 // AnyPtr is the first Ptr and KlassPtr the last, with no non-ptrs between.
duke@435 1297 return (_base >= AnyPtr && _base <= KlassPtr) ? (TypePtr*)this : NULL;
duke@435 1298 }
duke@435 1299
duke@435 1300 inline const TypeOopPtr *Type::is_oopptr() const {
duke@435 1301 // OopPtr is the first and KlassPtr the last, with no non-oops between.
coleenp@4037 1302 assert(_base >= OopPtr && _base <= AryPtr, "Not a Java pointer" ) ;
duke@435 1303 return (TypeOopPtr*)this;
duke@435 1304 }
duke@435 1305
duke@435 1306 inline const TypeOopPtr *Type::isa_oopptr() const {
duke@435 1307 // OopPtr is the first and KlassPtr the last, with no non-oops between.
coleenp@4037 1308 return (_base >= OopPtr && _base <= AryPtr) ? (TypeOopPtr*)this : NULL;
duke@435 1309 }
duke@435 1310
coleenp@548 1311 inline const TypeRawPtr *Type::isa_rawptr() const {
coleenp@548 1312 return (_base == RawPtr) ? (TypeRawPtr*)this : NULL;
coleenp@548 1313 }
coleenp@548 1314
duke@435 1315 inline const TypeRawPtr *Type::is_rawptr() const {
duke@435 1316 assert( _base == RawPtr, "Not a raw pointer" );
duke@435 1317 return (TypeRawPtr*)this;
duke@435 1318 }
duke@435 1319
duke@435 1320 inline const TypeInstPtr *Type::isa_instptr() const {
duke@435 1321 return (_base == InstPtr) ? (TypeInstPtr*)this : NULL;
duke@435 1322 }
duke@435 1323
duke@435 1324 inline const TypeInstPtr *Type::is_instptr() const {
duke@435 1325 assert( _base == InstPtr, "Not an object pointer" );
duke@435 1326 return (TypeInstPtr*)this;
duke@435 1327 }
duke@435 1328
duke@435 1329 inline const TypeAryPtr *Type::isa_aryptr() const {
duke@435 1330 return (_base == AryPtr) ? (TypeAryPtr*)this : NULL;
duke@435 1331 }
duke@435 1332
duke@435 1333 inline const TypeAryPtr *Type::is_aryptr() const {
duke@435 1334 assert( _base == AryPtr, "Not an array pointer" );
duke@435 1335 return (TypeAryPtr*)this;
duke@435 1336 }
duke@435 1337
coleenp@548 1338 inline const TypeNarrowOop *Type::is_narrowoop() const {
coleenp@548 1339 // OopPtr is the first and KlassPtr the last, with no non-oops between.
coleenp@548 1340 assert(_base == NarrowOop, "Not a narrow oop" ) ;
coleenp@548 1341 return (TypeNarrowOop*)this;
coleenp@548 1342 }
coleenp@548 1343
coleenp@548 1344 inline const TypeNarrowOop *Type::isa_narrowoop() const {
coleenp@548 1345 // OopPtr is the first and KlassPtr the last, with no non-oops between.
coleenp@548 1346 return (_base == NarrowOop) ? (TypeNarrowOop*)this : NULL;
coleenp@548 1347 }
coleenp@548 1348
coleenp@4037 1349 inline const TypeMetadataPtr *Type::is_metadataptr() const {
coleenp@4037 1350 // MetadataPtr is the first and CPCachePtr the last
coleenp@4037 1351 assert(_base == MetadataPtr, "Not a metadata pointer" ) ;
coleenp@4037 1352 return (TypeMetadataPtr*)this;
coleenp@4037 1353 }
coleenp@4037 1354
coleenp@4037 1355 inline const TypeMetadataPtr *Type::isa_metadataptr() const {
coleenp@4037 1356 return (_base == MetadataPtr) ? (TypeMetadataPtr*)this : NULL;
coleenp@4037 1357 }
coleenp@4037 1358
duke@435 1359 inline const TypeKlassPtr *Type::isa_klassptr() const {
duke@435 1360 return (_base == KlassPtr) ? (TypeKlassPtr*)this : NULL;
duke@435 1361 }
duke@435 1362
duke@435 1363 inline const TypeKlassPtr *Type::is_klassptr() const {
duke@435 1364 assert( _base == KlassPtr, "Not a klass pointer" );
duke@435 1365 return (TypeKlassPtr*)this;
duke@435 1366 }
duke@435 1367
kvn@656 1368 inline const TypePtr* Type::make_ptr() const {
never@1262 1369 return (_base == NarrowOop) ? is_narrowoop()->get_ptrtype() :
kvn@656 1370 (isa_ptr() ? is_ptr() : NULL);
kvn@656 1371 }
kvn@656 1372
never@1262 1373 inline const TypeOopPtr* Type::make_oopptr() const {
never@1262 1374 return (_base == NarrowOop) ? is_narrowoop()->get_ptrtype()->is_oopptr() : is_oopptr();
never@1262 1375 }
never@1262 1376
kvn@656 1377 inline const TypeNarrowOop* Type::make_narrowoop() const {
kvn@656 1378 return (_base == NarrowOop) ? is_narrowoop() :
kvn@656 1379 (isa_ptr() ? TypeNarrowOop::make(is_ptr()) : NULL);
kvn@656 1380 }
kvn@656 1381
duke@435 1382 inline bool Type::is_floatingpoint() const {
duke@435 1383 if( (_base == FloatCon) || (_base == FloatBot) ||
duke@435 1384 (_base == DoubleCon) || (_base == DoubleBot) )
duke@435 1385 return true;
duke@435 1386 return false;
duke@435 1387 }
duke@435 1388
duke@435 1389
duke@435 1390 // ===============================================================
duke@435 1391 // Things that need to be 64-bits in the 64-bit build but
duke@435 1392 // 32-bits in the 32-bit build. Done this way to get full
duke@435 1393 // optimization AND strong typing.
duke@435 1394 #ifdef _LP64
duke@435 1395
duke@435 1396 // For type queries and asserts
duke@435 1397 #define is_intptr_t is_long
duke@435 1398 #define isa_intptr_t isa_long
duke@435 1399 #define find_intptr_t_type find_long_type
duke@435 1400 #define find_intptr_t_con find_long_con
duke@435 1401 #define TypeX TypeLong
duke@435 1402 #define Type_X Type::Long
duke@435 1403 #define TypeX_X TypeLong::LONG
duke@435 1404 #define TypeX_ZERO TypeLong::ZERO
duke@435 1405 // For 'ideal_reg' machine registers
duke@435 1406 #define Op_RegX Op_RegL
duke@435 1407 // For phase->intcon variants
duke@435 1408 #define MakeConX longcon
duke@435 1409 #define ConXNode ConLNode
duke@435 1410 // For array index arithmetic
duke@435 1411 #define MulXNode MulLNode
duke@435 1412 #define AndXNode AndLNode
duke@435 1413 #define OrXNode OrLNode
duke@435 1414 #define CmpXNode CmpLNode
duke@435 1415 #define SubXNode SubLNode
duke@435 1416 #define LShiftXNode LShiftLNode
duke@435 1417 // For object size computation:
duke@435 1418 #define AddXNode AddLNode
never@452 1419 #define RShiftXNode RShiftLNode
duke@435 1420 // For card marks and hashcodes
duke@435 1421 #define URShiftXNode URShiftLNode
kvn@855 1422 // UseOptoBiasInlining
kvn@855 1423 #define XorXNode XorLNode
kvn@855 1424 #define StoreXConditionalNode StoreLConditionalNode
duke@435 1425 // Opcodes
duke@435 1426 #define Op_LShiftX Op_LShiftL
duke@435 1427 #define Op_AndX Op_AndL
duke@435 1428 #define Op_AddX Op_AddL
duke@435 1429 #define Op_SubX Op_SubL
kvn@1286 1430 #define Op_XorX Op_XorL
kvn@1286 1431 #define Op_URShiftX Op_URShiftL
duke@435 1432 // conversions
duke@435 1433 #define ConvI2X(x) ConvI2L(x)
duke@435 1434 #define ConvL2X(x) (x)
duke@435 1435 #define ConvX2I(x) ConvL2I(x)
duke@435 1436 #define ConvX2L(x) (x)
duke@435 1437
duke@435 1438 #else
duke@435 1439
duke@435 1440 // For type queries and asserts
duke@435 1441 #define is_intptr_t is_int
duke@435 1442 #define isa_intptr_t isa_int
duke@435 1443 #define find_intptr_t_type find_int_type
duke@435 1444 #define find_intptr_t_con find_int_con
duke@435 1445 #define TypeX TypeInt
duke@435 1446 #define Type_X Type::Int
duke@435 1447 #define TypeX_X TypeInt::INT
duke@435 1448 #define TypeX_ZERO TypeInt::ZERO
duke@435 1449 // For 'ideal_reg' machine registers
duke@435 1450 #define Op_RegX Op_RegI
duke@435 1451 // For phase->intcon variants
duke@435 1452 #define MakeConX intcon
duke@435 1453 #define ConXNode ConINode
duke@435 1454 // For array index arithmetic
duke@435 1455 #define MulXNode MulINode
duke@435 1456 #define AndXNode AndINode
duke@435 1457 #define OrXNode OrINode
duke@435 1458 #define CmpXNode CmpINode
duke@435 1459 #define SubXNode SubINode
duke@435 1460 #define LShiftXNode LShiftINode
duke@435 1461 // For object size computation:
duke@435 1462 #define AddXNode AddINode
never@452 1463 #define RShiftXNode RShiftINode
duke@435 1464 // For card marks and hashcodes
duke@435 1465 #define URShiftXNode URShiftINode
kvn@855 1466 // UseOptoBiasInlining
kvn@855 1467 #define XorXNode XorINode
kvn@855 1468 #define StoreXConditionalNode StoreIConditionalNode
duke@435 1469 // Opcodes
duke@435 1470 #define Op_LShiftX Op_LShiftI
duke@435 1471 #define Op_AndX Op_AndI
duke@435 1472 #define Op_AddX Op_AddI
duke@435 1473 #define Op_SubX Op_SubI
kvn@1286 1474 #define Op_XorX Op_XorI
kvn@1286 1475 #define Op_URShiftX Op_URShiftI
duke@435 1476 // conversions
duke@435 1477 #define ConvI2X(x) (x)
duke@435 1478 #define ConvL2X(x) ConvL2I(x)
duke@435 1479 #define ConvX2I(x) (x)
duke@435 1480 #define ConvX2L(x) ConvI2L(x)
duke@435 1481
duke@435 1482 #endif
stefank@2314 1483
stefank@2314 1484 #endif // SHARE_VM_OPTO_TYPE_HPP

mercurial