src/share/vm/opto/type.hpp

Fri, 18 Oct 2013 10:41:56 +0200

author
rbackman
date
Fri, 18 Oct 2013 10:41:56 +0200
changeset 5997
59e8ad757e19
parent 5991
b2ee5dc63353
child 6043
6c2f07d1495f
permissions
-rw-r--r--

8026844: Various Math functions needs intrinsification
Reviewed-by: kvn, twisti

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

mercurial