src/share/vm/opto/type.hpp

Tue, 15 Sep 2009 21:53:47 -0700

author
jrose
date
Tue, 15 Sep 2009 21:53:47 -0700
changeset 1424
148e5441d916
parent 1393
c7e94e8fff43
child 1427
6a8ccac44f41
permissions
-rw-r--r--

6863023: need non-perm oops in code cache for JSR 292
Summary: Make a special root-list for those few nmethods which might contain non-perm oops.
Reviewed-by: twisti, kvn, never, jmasa, ysr

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

mercurial