src/share/vm/opto/type.hpp

Wed, 27 Apr 2016 01:25:04 +0800

author
aoqi
date
Wed, 27 Apr 2016 01:25:04 +0800
changeset 0
f90c822e73f8
child 6876
710a3c8b516e
permissions
-rw-r--r--

Initial load
http://hg.openjdk.java.net/jdk8u/jdk8u/hotspot/
changeset: 6782:28b50d07f6f8
tag: jdk8u25-b17

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

mercurial