src/share/vm/opto/type.hpp

Thu, 24 May 2018 19:26:50 +0800

author
aoqi
date
Thu, 24 May 2018 19:26:50 +0800
changeset 8862
fd13a567f179
parent 8856
ac27a9c85bea
child 9041
95a08233f46c
permissions
-rw-r--r--

#7046 C2 supports long branch
Contributed-by: fujie

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
shshahma@8656 212 bool 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
shshahma@8656 216 bool 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
shshahma@8422 370 // For two instance arrays of same dimension, return the base element types.
shshahma@8422 371 // Otherwise or if the arrays have different dimensions, return NULL.
shshahma@8422 372 static void get_arrays_base_elements(const Type *a1, const Type *a2,
shshahma@8422 373 const TypeInstPtr **e1, const TypeInstPtr **e2);
shshahma@8422 374
aoqi@0 375 // Mapping to the array element's basic type.
aoqi@0 376 BasicType array_element_basic_type() const;
aoqi@0 377
aoqi@0 378 // Create standard type for a ciType:
aoqi@0 379 static const Type* get_const_type(ciType* type);
aoqi@0 380
aoqi@0 381 // Create standard zero value:
aoqi@0 382 static const Type* get_zero_type(BasicType type) {
aoqi@0 383 assert((uint)type <= T_CONFLICT && _zero_type[type] != NULL, "bad type");
aoqi@0 384 return _zero_type[type];
aoqi@0 385 }
aoqi@0 386
aoqi@0 387 // Report if this is a zero value (not top).
aoqi@0 388 bool is_zero_type() const {
aoqi@0 389 BasicType type = basic_type();
aoqi@0 390 if (type == T_VOID || type >= T_CONFLICT)
aoqi@0 391 return false;
aoqi@0 392 else
aoqi@0 393 return (this == _zero_type[type]);
aoqi@0 394 }
aoqi@0 395
aoqi@0 396 // Convenience common pre-built types.
aoqi@0 397 static const Type *ABIO;
aoqi@0 398 static const Type *BOTTOM;
aoqi@0 399 static const Type *CONTROL;
aoqi@0 400 static const Type *DOUBLE;
aoqi@0 401 static const Type *FLOAT;
aoqi@0 402 static const Type *HALF;
aoqi@0 403 static const Type *MEMORY;
aoqi@0 404 static const Type *MULTI;
aoqi@0 405 static const Type *RETURN_ADDRESS;
aoqi@0 406 static const Type *TOP;
aoqi@0 407
aoqi@0 408 // Mapping from compiler type to VM BasicType
aoqi@0 409 BasicType basic_type() const { return _type_info[_base].basic_type; }
aoqi@0 410 int ideal_reg() const { return _type_info[_base].ideal_reg; }
aoqi@0 411 const char* msg() const { return _type_info[_base].msg; }
aoqi@0 412 bool isa_oop_ptr() const { return _type_info[_base].isa_oop; }
aoqi@0 413 relocInfo::relocType reloc() const { return _type_info[_base].reloc; }
aoqi@0 414
aoqi@0 415 // Mapping from CI type system to compiler type:
aoqi@0 416 static const Type* get_typeflow_type(ciType* type);
aoqi@0 417
aoqi@0 418 static const Type* make_from_constant(ciConstant constant,
aoqi@0 419 bool require_constant = false,
aoqi@0 420 bool is_autobox_cache = false);
aoqi@0 421
aoqi@0 422 // Speculative type. See TypeInstPtr
aoqi@0 423 virtual const TypeOopPtr* speculative() const { return NULL; }
aoqi@0 424 virtual ciKlass* speculative_type() const { return NULL; }
aoqi@0 425 const Type* maybe_remove_speculative(bool include_speculative) const;
aoqi@0 426 virtual const Type* remove_speculative() const { return this; }
aoqi@0 427
aoqi@0 428 virtual bool would_improve_type(ciKlass* exact_kls, int inline_depth) const {
aoqi@0 429 return exact_kls != NULL;
aoqi@0 430 }
aoqi@0 431
aoqi@0 432 private:
aoqi@0 433 // support arrays
aoqi@0 434 static const BasicType _basic_type[];
aoqi@0 435 static const Type* _zero_type[T_CONFLICT+1];
aoqi@0 436 static const Type* _const_basic_type[T_CONFLICT+1];
aoqi@0 437 };
aoqi@0 438
aoqi@0 439 //------------------------------TypeF------------------------------------------
aoqi@0 440 // Class of Float-Constant Types.
aoqi@0 441 class TypeF : public Type {
aoqi@0 442 TypeF( float f ) : Type(FloatCon), _f(f) {};
aoqi@0 443 public:
aoqi@0 444 virtual bool eq( const Type *t ) const;
aoqi@0 445 virtual int hash() const; // Type specific hashing
aoqi@0 446 virtual bool singleton(void) const; // TRUE if type is a singleton
aoqi@0 447 virtual bool empty(void) const; // TRUE if type is vacuous
aoqi@0 448 public:
aoqi@0 449 const float _f; // Float constant
aoqi@0 450
aoqi@0 451 static const TypeF *make(float f);
aoqi@0 452
aoqi@0 453 virtual bool is_finite() const; // Has a finite value
aoqi@0 454 virtual bool is_nan() const; // Is not a number (NaN)
aoqi@0 455
aoqi@0 456 virtual const Type *xmeet( const Type *t ) const;
aoqi@0 457 virtual const Type *xdual() const; // Compute dual right now.
aoqi@0 458 // Convenience common pre-built types.
aoqi@0 459 static const TypeF *ZERO; // positive zero only
aoqi@0 460 static const TypeF *ONE;
aoqi@0 461 #ifndef PRODUCT
aoqi@0 462 virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
aoqi@0 463 #endif
aoqi@0 464 };
aoqi@0 465
aoqi@0 466 //------------------------------TypeD------------------------------------------
aoqi@0 467 // Class of Double-Constant Types.
aoqi@0 468 class TypeD : public Type {
aoqi@0 469 TypeD( double d ) : Type(DoubleCon), _d(d) {};
aoqi@0 470 public:
aoqi@0 471 virtual bool eq( const Type *t ) const;
aoqi@0 472 virtual int hash() const; // Type specific hashing
aoqi@0 473 virtual bool singleton(void) const; // TRUE if type is a singleton
aoqi@0 474 virtual bool empty(void) const; // TRUE if type is vacuous
aoqi@0 475 public:
aoqi@0 476 const double _d; // Double constant
aoqi@0 477
aoqi@0 478 static const TypeD *make(double d);
aoqi@0 479
aoqi@0 480 virtual bool is_finite() const; // Has a finite value
aoqi@0 481 virtual bool is_nan() const; // Is not a number (NaN)
aoqi@0 482
aoqi@0 483 virtual const Type *xmeet( const Type *t ) const;
aoqi@0 484 virtual const Type *xdual() const; // Compute dual right now.
aoqi@0 485 // Convenience common pre-built types.
aoqi@0 486 static const TypeD *ZERO; // positive zero only
aoqi@0 487 static const TypeD *ONE;
aoqi@0 488 #ifndef PRODUCT
aoqi@0 489 virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
aoqi@0 490 #endif
aoqi@0 491 };
aoqi@0 492
aoqi@0 493 //------------------------------TypeInt----------------------------------------
aoqi@0 494 // Class of integer ranges, the set of integers between a lower bound and an
aoqi@0 495 // upper bound, inclusive.
aoqi@0 496 class TypeInt : public Type {
aoqi@0 497 TypeInt( jint lo, jint hi, int w );
aoqi@0 498 protected:
aoqi@0 499 virtual const Type *filter_helper(const Type *kills, bool include_speculative) const;
aoqi@0 500
aoqi@0 501 public:
aoqi@0 502 typedef jint NativeType;
aoqi@0 503 virtual bool eq( const Type *t ) const;
aoqi@0 504 virtual int hash() const; // Type specific hashing
aoqi@0 505 virtual bool singleton(void) const; // TRUE if type is a singleton
aoqi@0 506 virtual bool empty(void) const; // TRUE if type is vacuous
aoqi@0 507 const jint _lo, _hi; // Lower bound, upper bound
aoqi@0 508 const short _widen; // Limit on times we widen this sucker
aoqi@0 509
aoqi@0 510 static const TypeInt *make(jint lo);
aoqi@0 511 // must always specify w
aoqi@0 512 static const TypeInt *make(jint lo, jint hi, int w);
aoqi@0 513
aoqi@0 514 // Check for single integer
aoqi@0 515 int is_con() const { return _lo==_hi; }
aoqi@0 516 bool is_con(int i) const { return is_con() && _lo == i; }
aoqi@0 517 jint get_con() const { assert( is_con(), "" ); return _lo; }
aoqi@0 518
aoqi@0 519 virtual bool is_finite() const; // Has a finite value
aoqi@0 520
aoqi@0 521 virtual const Type *xmeet( const Type *t ) const;
aoqi@0 522 virtual const Type *xdual() const; // Compute dual right now.
aoqi@0 523 virtual const Type *widen( const Type *t, const Type* limit_type ) const;
aoqi@0 524 virtual const Type *narrow( const Type *t ) const;
aoqi@0 525 // Do not kill _widen bits.
aoqi@0 526 // Convenience common pre-built types.
aoqi@0 527 static const TypeInt *MINUS_1;
aoqi@0 528 static const TypeInt *ZERO;
aoqi@0 529 static const TypeInt *ONE;
aoqi@0 530 static const TypeInt *BOOL;
aoqi@0 531 static const TypeInt *CC;
aoqi@0 532 static const TypeInt *CC_LT; // [-1] == MINUS_1
aoqi@0 533 static const TypeInt *CC_GT; // [1] == ONE
aoqi@0 534 static const TypeInt *CC_EQ; // [0] == ZERO
aoqi@0 535 static const TypeInt *CC_LE; // [-1,0]
aoqi@0 536 static const TypeInt *CC_GE; // [0,1] == BOOL (!)
aoqi@0 537 static const TypeInt *BYTE;
aoqi@0 538 static const TypeInt *UBYTE;
aoqi@0 539 static const TypeInt *CHAR;
aoqi@0 540 static const TypeInt *SHORT;
aoqi@0 541 static const TypeInt *POS;
aoqi@0 542 static const TypeInt *POS1;
aoqi@0 543 static const TypeInt *INT;
aoqi@0 544 static const TypeInt *SYMINT; // symmetric range [-max_jint..max_jint]
aoqi@0 545 static const TypeInt *TYPE_DOMAIN; // alias for TypeInt::INT
aoqi@0 546
aoqi@0 547 static const TypeInt *as_self(const Type *t) { return t->is_int(); }
aoqi@0 548 #ifndef PRODUCT
aoqi@0 549 virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
aoqi@0 550 #endif
aoqi@0 551 };
aoqi@0 552
aoqi@0 553
aoqi@0 554 //------------------------------TypeLong---------------------------------------
aoqi@0 555 // Class of long integer ranges, the set of integers between a lower bound and
aoqi@0 556 // an upper bound, inclusive.
aoqi@0 557 class TypeLong : public Type {
aoqi@0 558 TypeLong( jlong lo, jlong hi, int w );
aoqi@0 559 protected:
aoqi@0 560 // Do not kill _widen bits.
aoqi@0 561 virtual const Type *filter_helper(const Type *kills, bool include_speculative) const;
aoqi@0 562 public:
aoqi@0 563 typedef jlong NativeType;
aoqi@0 564 virtual bool eq( const Type *t ) const;
aoqi@0 565 virtual int hash() const; // Type specific hashing
aoqi@0 566 virtual bool singleton(void) const; // TRUE if type is a singleton
aoqi@0 567 virtual bool empty(void) const; // TRUE if type is vacuous
aoqi@0 568 public:
aoqi@0 569 const jlong _lo, _hi; // Lower bound, upper bound
aoqi@0 570 const short _widen; // Limit on times we widen this sucker
aoqi@0 571
aoqi@0 572 static const TypeLong *make(jlong lo);
aoqi@0 573 // must always specify w
aoqi@0 574 static const TypeLong *make(jlong lo, jlong hi, int w);
aoqi@0 575
aoqi@0 576 // Check for single integer
aoqi@0 577 int is_con() const { return _lo==_hi; }
aoqi@0 578 bool is_con(int i) const { return is_con() && _lo == i; }
aoqi@0 579 jlong get_con() const { assert( is_con(), "" ); return _lo; }
aoqi@0 580
aoqi@0 581 // Check for positive 32-bit value.
aoqi@0 582 int is_positive_int() const { return _lo >= 0 && _hi <= (jlong)max_jint; }
aoqi@0 583
aoqi@0 584 virtual bool is_finite() const; // Has a finite value
aoqi@0 585
aoqi@0 586
aoqi@0 587 virtual const Type *xmeet( const Type *t ) const;
aoqi@0 588 virtual const Type *xdual() const; // Compute dual right now.
aoqi@0 589 virtual const Type *widen( const Type *t, const Type* limit_type ) const;
aoqi@0 590 virtual const Type *narrow( const Type *t ) const;
aoqi@0 591 // Convenience common pre-built types.
aoqi@0 592 static const TypeLong *MINUS_1;
aoqi@0 593 static const TypeLong *ZERO;
aoqi@0 594 static const TypeLong *ONE;
aoqi@0 595 static const TypeLong *POS;
aoqi@0 596 static const TypeLong *LONG;
aoqi@0 597 static const TypeLong *INT; // 32-bit subrange [min_jint..max_jint]
aoqi@0 598 static const TypeLong *UINT; // 32-bit unsigned [0..max_juint]
aoqi@0 599 static const TypeLong *TYPE_DOMAIN; // alias for TypeLong::LONG
aoqi@0 600
aoqi@0 601 // static convenience methods.
aoqi@0 602 static const TypeLong *as_self(const Type *t) { return t->is_long(); }
aoqi@0 603
aoqi@0 604 #ifndef PRODUCT
aoqi@0 605 virtual void dump2( Dict &d, uint, outputStream *st ) const;// Specialized per-Type dumping
aoqi@0 606 #endif
aoqi@0 607 };
aoqi@0 608
aoqi@0 609 //------------------------------TypeTuple--------------------------------------
aoqi@0 610 // Class of Tuple Types, essentially type collections for function signatures
aoqi@0 611 // and class layouts. It happens to also be a fast cache for the HotSpot
aoqi@0 612 // signature types.
aoqi@0 613 class TypeTuple : public Type {
aoqi@0 614 TypeTuple( uint cnt, const Type **fields ) : Type(Tuple), _cnt(cnt), _fields(fields) { }
aoqi@0 615 public:
aoqi@0 616 virtual bool eq( const Type *t ) const;
aoqi@0 617 virtual int hash() const; // Type specific hashing
aoqi@0 618 virtual bool singleton(void) const; // TRUE if type is a singleton
aoqi@0 619 virtual bool empty(void) const; // TRUE if type is vacuous
aoqi@0 620
aoqi@0 621 public:
aoqi@0 622 const uint _cnt; // Count of fields
aoqi@0 623 const Type ** const _fields; // Array of field types
aoqi@0 624
aoqi@0 625 // Accessors:
aoqi@0 626 uint cnt() const { return _cnt; }
aoqi@0 627 const Type* field_at(uint i) const {
aoqi@0 628 assert(i < _cnt, "oob");
aoqi@0 629 return _fields[i];
aoqi@0 630 }
aoqi@0 631 void set_field_at(uint i, const Type* t) {
aoqi@0 632 assert(i < _cnt, "oob");
aoqi@0 633 _fields[i] = t;
aoqi@0 634 }
aoqi@0 635
aoqi@0 636 static const TypeTuple *make( uint cnt, const Type **fields );
aoqi@0 637 static const TypeTuple *make_range(ciSignature *sig);
aoqi@0 638 static const TypeTuple *make_domain(ciInstanceKlass* recv, ciSignature *sig);
aoqi@0 639
aoqi@0 640 // Subroutine call type with space allocated for argument types
aoqi@0 641 static const Type **fields( uint arg_cnt );
aoqi@0 642
aoqi@0 643 virtual const Type *xmeet( const Type *t ) const;
aoqi@0 644 virtual const Type *xdual() const; // Compute dual right now.
aoqi@0 645 // Convenience common pre-built types.
aoqi@0 646 static const TypeTuple *IFBOTH;
aoqi@0 647 static const TypeTuple *IFFALSE;
aoqi@0 648 static const TypeTuple *IFTRUE;
aoqi@0 649 static const TypeTuple *IFNEITHER;
aoqi@0 650 static const TypeTuple *LOOPBODY;
aoqi@0 651 static const TypeTuple *MEMBAR;
aoqi@0 652 static const TypeTuple *STORECONDITIONAL;
aoqi@0 653 static const TypeTuple *START_I2C;
aoqi@0 654 static const TypeTuple *INT_PAIR;
aoqi@0 655 static const TypeTuple *LONG_PAIR;
aoqi@0 656 static const TypeTuple *INT_CC_PAIR;
aoqi@0 657 static const TypeTuple *LONG_CC_PAIR;
aoqi@0 658 #ifndef PRODUCT
aoqi@0 659 virtual void dump2( Dict &d, uint, outputStream *st ) const; // Specialized per-Type dumping
aoqi@0 660 #endif
aoqi@0 661 };
aoqi@0 662
aoqi@0 663 //------------------------------TypeAry----------------------------------------
aoqi@0 664 // Class of Array Types
aoqi@0 665 class TypeAry : public Type {
aoqi@0 666 TypeAry(const Type* elem, const TypeInt* size, bool stable) : Type(Array),
aoqi@0 667 _elem(elem), _size(size), _stable(stable) {}
aoqi@0 668 public:
aoqi@0 669 virtual bool eq( const Type *t ) const;
aoqi@0 670 virtual int hash() const; // Type specific hashing
aoqi@0 671 virtual bool singleton(void) const; // TRUE if type is a singleton
aoqi@0 672 virtual bool empty(void) const; // TRUE if type is vacuous
aoqi@0 673
aoqi@0 674 private:
aoqi@0 675 const Type *_elem; // Element type of array
aoqi@0 676 const TypeInt *_size; // Elements in array
aoqi@0 677 const bool _stable; // Are elements @Stable?
aoqi@0 678 friend class TypeAryPtr;
aoqi@0 679
aoqi@0 680 public:
aoqi@0 681 static const TypeAry* make(const Type* elem, const TypeInt* size, bool stable = false);
aoqi@0 682
aoqi@0 683 virtual const Type *xmeet( const Type *t ) const;
aoqi@0 684 virtual const Type *xdual() const; // Compute dual right now.
aoqi@0 685 bool ary_must_be_exact() const; // true if arrays of such are never generic
aoqi@0 686 virtual const Type* remove_speculative() const;
aoqi@0 687 #ifdef ASSERT
aoqi@0 688 // One type is interface, the other is oop
aoqi@0 689 virtual bool interface_vs_oop(const Type *t) const;
aoqi@0 690 #endif
aoqi@0 691 #ifndef PRODUCT
aoqi@0 692 virtual void dump2( Dict &d, uint, outputStream *st ) const; // Specialized per-Type dumping
aoqi@0 693 #endif
aoqi@0 694 };
aoqi@0 695
aoqi@0 696 //------------------------------TypeVect---------------------------------------
aoqi@0 697 // Class of Vector Types
aoqi@0 698 class TypeVect : public Type {
aoqi@0 699 const Type* _elem; // Vector's element type
aoqi@0 700 const uint _length; // Elements in vector (power of 2)
aoqi@0 701
aoqi@0 702 protected:
aoqi@0 703 TypeVect(TYPES t, const Type* elem, uint length) : Type(t),
aoqi@0 704 _elem(elem), _length(length) {}
aoqi@0 705
aoqi@0 706 public:
aoqi@0 707 const Type* element_type() const { return _elem; }
aoqi@0 708 BasicType element_basic_type() const { return _elem->array_element_basic_type(); }
aoqi@0 709 uint length() const { return _length; }
aoqi@0 710 uint length_in_bytes() const {
aoqi@0 711 return _length * type2aelembytes(element_basic_type());
aoqi@0 712 }
aoqi@0 713
aoqi@0 714 virtual bool eq(const Type *t) const;
aoqi@0 715 virtual int hash() const; // Type specific hashing
aoqi@0 716 virtual bool singleton(void) const; // TRUE if type is a singleton
aoqi@0 717 virtual bool empty(void) const; // TRUE if type is vacuous
aoqi@0 718
aoqi@0 719 static const TypeVect *make(const BasicType elem_bt, uint length) {
aoqi@0 720 // Use bottom primitive type.
aoqi@0 721 return make(get_const_basic_type(elem_bt), length);
aoqi@0 722 }
aoqi@0 723 // Used directly by Replicate nodes to construct singleton vector.
aoqi@0 724 static const TypeVect *make(const Type* elem, uint length);
aoqi@0 725
aoqi@0 726 virtual const Type *xmeet( const Type *t) const;
aoqi@0 727 virtual const Type *xdual() const; // Compute dual right now.
aoqi@0 728
aoqi@0 729 static const TypeVect *VECTS;
aoqi@0 730 static const TypeVect *VECTD;
aoqi@0 731 static const TypeVect *VECTX;
aoqi@0 732 static const TypeVect *VECTY;
aoqi@0 733
aoqi@0 734 #ifndef PRODUCT
aoqi@0 735 virtual void dump2(Dict &d, uint, outputStream *st) const; // Specialized per-Type dumping
aoqi@0 736 #endif
aoqi@0 737 };
aoqi@0 738
aoqi@0 739 class TypeVectS : public TypeVect {
aoqi@0 740 friend class TypeVect;
aoqi@0 741 TypeVectS(const Type* elem, uint length) : TypeVect(VectorS, elem, length) {}
aoqi@0 742 };
aoqi@0 743
aoqi@0 744 class TypeVectD : public TypeVect {
aoqi@0 745 friend class TypeVect;
aoqi@0 746 TypeVectD(const Type* elem, uint length) : TypeVect(VectorD, elem, length) {}
aoqi@0 747 };
aoqi@0 748
aoqi@0 749 class TypeVectX : public TypeVect {
aoqi@0 750 friend class TypeVect;
aoqi@0 751 TypeVectX(const Type* elem, uint length) : TypeVect(VectorX, elem, length) {}
aoqi@0 752 };
aoqi@0 753
aoqi@0 754 class TypeVectY : public TypeVect {
aoqi@0 755 friend class TypeVect;
aoqi@0 756 TypeVectY(const Type* elem, uint length) : TypeVect(VectorY, elem, length) {}
aoqi@0 757 };
aoqi@0 758
aoqi@0 759 //------------------------------TypePtr----------------------------------------
aoqi@0 760 // Class of machine Pointer Types: raw data, instances or arrays.
aoqi@0 761 // If the _base enum is AnyPtr, then this refers to all of the above.
aoqi@0 762 // Otherwise the _base will indicate which subset of pointers is affected,
aoqi@0 763 // and the class will be inherited from.
aoqi@0 764 class TypePtr : public Type {
aoqi@0 765 friend class TypeNarrowPtr;
aoqi@0 766 public:
aoqi@0 767 enum PTR { TopPTR, AnyNull, Constant, Null, NotNull, BotPTR, lastPTR };
aoqi@0 768 protected:
aoqi@0 769 TypePtr( TYPES t, PTR ptr, int offset ) : Type(t), _ptr(ptr), _offset(offset) {}
aoqi@0 770 virtual bool eq( const Type *t ) const;
aoqi@0 771 virtual int hash() const; // Type specific hashing
aoqi@0 772 static const PTR ptr_meet[lastPTR][lastPTR];
aoqi@0 773 static const PTR ptr_dual[lastPTR];
aoqi@0 774 static const char * const ptr_msg[lastPTR];
aoqi@0 775
aoqi@0 776 public:
aoqi@0 777 const int _offset; // Offset into oop, with TOP & BOT
aoqi@0 778 const PTR _ptr; // Pointer equivalence class
aoqi@0 779
aoqi@0 780 const int offset() const { return _offset; }
aoqi@0 781 const PTR ptr() const { return _ptr; }
aoqi@0 782
aoqi@0 783 static const TypePtr *make( TYPES t, PTR ptr, int offset );
aoqi@0 784
aoqi@0 785 // Return a 'ptr' version of this type
aoqi@0 786 virtual const Type *cast_to_ptr_type(PTR ptr) const;
aoqi@0 787
aoqi@0 788 virtual intptr_t get_con() const;
aoqi@0 789
aoqi@0 790 int xadd_offset( intptr_t offset ) const;
aoqi@0 791 virtual const TypePtr *add_offset( intptr_t offset ) const;
aoqi@0 792
aoqi@0 793 virtual bool singleton(void) const; // TRUE if type is a singleton
aoqi@0 794 virtual bool empty(void) const; // TRUE if type is vacuous
aoqi@0 795 virtual const Type *xmeet( const Type *t ) const;
aoqi@0 796 int meet_offset( int offset ) const;
aoqi@0 797 int dual_offset( ) const;
aoqi@0 798 virtual const Type *xdual() const; // Compute dual right now.
aoqi@0 799
aoqi@0 800 // meet, dual and join over pointer equivalence sets
aoqi@0 801 PTR meet_ptr( const PTR in_ptr ) const { return ptr_meet[in_ptr][ptr()]; }
aoqi@0 802 PTR dual_ptr() const { return ptr_dual[ptr()]; }
aoqi@0 803
aoqi@0 804 // This is textually confusing unless one recalls that
aoqi@0 805 // join(t) == dual()->meet(t->dual())->dual().
aoqi@0 806 PTR join_ptr( const PTR in_ptr ) const {
aoqi@0 807 return ptr_dual[ ptr_meet[ ptr_dual[in_ptr] ] [ dual_ptr() ] ];
aoqi@0 808 }
aoqi@0 809
aoqi@0 810 // Tests for relation to centerline of type lattice:
aoqi@0 811 static bool above_centerline(PTR ptr) { return (ptr <= AnyNull); }
aoqi@0 812 static bool below_centerline(PTR ptr) { return (ptr >= NotNull); }
aoqi@0 813 // Convenience common pre-built types.
aoqi@0 814 static const TypePtr *NULL_PTR;
aoqi@0 815 static const TypePtr *NOTNULL;
aoqi@0 816 static const TypePtr *BOTTOM;
aoqi@0 817 #ifndef PRODUCT
aoqi@0 818 virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
aoqi@0 819 #endif
aoqi@0 820 };
aoqi@0 821
aoqi@0 822 //------------------------------TypeRawPtr-------------------------------------
aoqi@0 823 // Class of raw pointers, pointers to things other than Oops. Examples
aoqi@0 824 // include the stack pointer, top of heap, card-marking area, handles, etc.
aoqi@0 825 class TypeRawPtr : public TypePtr {
aoqi@0 826 protected:
aoqi@0 827 TypeRawPtr( PTR ptr, address bits ) : TypePtr(RawPtr,ptr,0), _bits(bits){}
aoqi@0 828 public:
aoqi@0 829 virtual bool eq( const Type *t ) const;
aoqi@0 830 virtual int hash() const; // Type specific hashing
aoqi@0 831
aoqi@0 832 const address _bits; // Constant value, if applicable
aoqi@0 833
aoqi@0 834 static const TypeRawPtr *make( PTR ptr );
aoqi@0 835 static const TypeRawPtr *make( address bits );
aoqi@0 836
aoqi@0 837 // Return a 'ptr' version of this type
aoqi@0 838 virtual const Type *cast_to_ptr_type(PTR ptr) const;
aoqi@0 839
aoqi@0 840 virtual intptr_t get_con() const;
aoqi@0 841
aoqi@0 842 virtual const TypePtr *add_offset( intptr_t offset ) const;
aoqi@0 843
aoqi@0 844 virtual const Type *xmeet( const Type *t ) const;
aoqi@0 845 virtual const Type *xdual() const; // Compute dual right now.
aoqi@0 846 // Convenience common pre-built types.
aoqi@0 847 static const TypeRawPtr *BOTTOM;
aoqi@0 848 static const TypeRawPtr *NOTNULL;
aoqi@0 849 #ifndef PRODUCT
aoqi@0 850 virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
aoqi@0 851 #endif
aoqi@0 852 };
aoqi@0 853
aoqi@0 854 //------------------------------TypeOopPtr-------------------------------------
aoqi@0 855 // Some kind of oop (Java pointer), either klass or instance or array.
aoqi@0 856 class TypeOopPtr : public TypePtr {
aoqi@0 857 protected:
aoqi@0 858 TypeOopPtr(TYPES t, PTR ptr, ciKlass* k, bool xk, ciObject* o, int offset, int instance_id, const TypeOopPtr* speculative, int inline_depth);
aoqi@0 859 public:
aoqi@0 860 virtual bool eq( const Type *t ) const;
aoqi@0 861 virtual int hash() const; // Type specific hashing
aoqi@0 862 virtual bool singleton(void) const; // TRUE if type is a singleton
aoqi@0 863 enum {
aoqi@0 864 InstanceTop = -1, // undefined instance
aoqi@0 865 InstanceBot = 0 // any possible instance
aoqi@0 866 };
aoqi@0 867 protected:
aoqi@0 868
aoqi@0 869 enum {
aoqi@0 870 InlineDepthBottom = INT_MAX,
aoqi@0 871 InlineDepthTop = -InlineDepthBottom
aoqi@0 872 };
aoqi@0 873 // Oop is NULL, unless this is a constant oop.
aoqi@0 874 ciObject* _const_oop; // Constant oop
aoqi@0 875 // If _klass is NULL, then so is _sig. This is an unloaded klass.
aoqi@0 876 ciKlass* _klass; // Klass object
aoqi@0 877 // Does the type exclude subclasses of the klass? (Inexact == polymorphic.)
aoqi@0 878 bool _klass_is_exact;
aoqi@0 879 bool _is_ptr_to_narrowoop;
aoqi@0 880 bool _is_ptr_to_narrowklass;
aoqi@0 881 bool _is_ptr_to_boxed_value;
aoqi@0 882
aoqi@0 883 // If not InstanceTop or InstanceBot, indicates that this is
aoqi@0 884 // a particular instance of this type which is distinct.
poonam@8646 885 // This is the node index of the allocation node creating this instance.
aoqi@0 886 int _instance_id;
aoqi@0 887
aoqi@0 888 // Extra type information profiling gave us. We propagate it the
aoqi@0 889 // same way the rest of the type info is propagated. If we want to
aoqi@0 890 // use it, then we have to emit a guard: this part of the type is
aoqi@0 891 // not something we know but something we speculate about the type.
aoqi@0 892 const TypeOopPtr* _speculative;
aoqi@0 893 // For speculative types, we record at what inlining depth the
aoqi@0 894 // profiling point that provided the data is. We want to favor
aoqi@0 895 // profile data coming from outer scopes which are likely better for
aoqi@0 896 // the current compilation.
aoqi@0 897 int _inline_depth;
aoqi@0 898
aoqi@0 899 static const TypeOopPtr* make_from_klass_common(ciKlass* klass, bool klass_change, bool try_for_exact);
aoqi@0 900
aoqi@0 901 int dual_instance_id() const;
aoqi@0 902 int meet_instance_id(int uid) const;
aoqi@0 903
aoqi@0 904 // utility methods to work on the speculative part of the type
aoqi@0 905 const TypeOopPtr* dual_speculative() const;
aoqi@0 906 const TypeOopPtr* xmeet_speculative(const TypeOopPtr* other) const;
aoqi@0 907 bool eq_speculative(const TypeOopPtr* other) const;
aoqi@0 908 int hash_speculative() const;
aoqi@0 909 const TypeOopPtr* add_offset_speculative(intptr_t offset) const;
aoqi@0 910 #ifndef PRODUCT
aoqi@0 911 void dump_speculative(outputStream *st) const;
aoqi@0 912 #endif
aoqi@0 913 // utility methods to work on the inline depth of the type
aoqi@0 914 int dual_inline_depth() const;
aoqi@0 915 int meet_inline_depth(int depth) const;
aoqi@0 916 #ifndef PRODUCT
aoqi@0 917 void dump_inline_depth(outputStream *st) const;
aoqi@0 918 #endif
aoqi@0 919
aoqi@0 920 // Do not allow interface-vs.-noninterface joins to collapse to top.
aoqi@0 921 virtual const Type *filter_helper(const Type *kills, bool include_speculative) const;
aoqi@0 922
aoqi@0 923 public:
aoqi@0 924 // Creates a type given a klass. Correctly handles multi-dimensional arrays
aoqi@0 925 // Respects UseUniqueSubclasses.
aoqi@0 926 // If the klass is final, the resulting type will be exact.
aoqi@0 927 static const TypeOopPtr* make_from_klass(ciKlass* klass) {
aoqi@0 928 return make_from_klass_common(klass, true, false);
aoqi@0 929 }
aoqi@0 930 // Same as before, but will produce an exact type, even if
aoqi@0 931 // the klass is not final, as long as it has exactly one implementation.
aoqi@0 932 static const TypeOopPtr* make_from_klass_unique(ciKlass* klass) {
aoqi@0 933 return make_from_klass_common(klass, true, true);
aoqi@0 934 }
aoqi@0 935 // Same as before, but does not respects UseUniqueSubclasses.
aoqi@0 936 // Use this only for creating array element types.
aoqi@0 937 static const TypeOopPtr* make_from_klass_raw(ciKlass* klass) {
aoqi@0 938 return make_from_klass_common(klass, false, false);
aoqi@0 939 }
aoqi@0 940 // Creates a singleton type given an object.
aoqi@0 941 // If the object cannot be rendered as a constant,
aoqi@0 942 // may return a non-singleton type.
aoqi@0 943 // If require_constant, produce a NULL if a singleton is not possible.
aoqi@0 944 static const TypeOopPtr* make_from_constant(ciObject* o,
aoqi@0 945 bool require_constant = false,
aoqi@0 946 bool not_null_elements = false);
aoqi@0 947
aoqi@0 948 // Make a generic (unclassed) pointer to an oop.
aoqi@0 949 static const TypeOopPtr* make(PTR ptr, int offset, int instance_id, const TypeOopPtr* speculative = NULL, int inline_depth = InlineDepthBottom);
aoqi@0 950
aoqi@0 951 ciObject* const_oop() const { return _const_oop; }
aoqi@0 952 virtual ciKlass* klass() const { return _klass; }
aoqi@0 953 bool klass_is_exact() const { return _klass_is_exact; }
aoqi@0 954
aoqi@0 955 // Returns true if this pointer points at memory which contains a
aoqi@0 956 // compressed oop references.
aoqi@0 957 bool is_ptr_to_narrowoop_nv() const { return _is_ptr_to_narrowoop; }
aoqi@0 958 bool is_ptr_to_narrowklass_nv() const { return _is_ptr_to_narrowklass; }
aoqi@0 959 bool is_ptr_to_boxed_value() const { return _is_ptr_to_boxed_value; }
aoqi@0 960 bool is_known_instance() const { return _instance_id > 0; }
aoqi@0 961 int instance_id() const { return _instance_id; }
aoqi@0 962 bool is_known_instance_field() const { return is_known_instance() && _offset >= 0; }
aoqi@0 963 virtual const TypeOopPtr* speculative() const { return _speculative; }
aoqi@0 964
aoqi@0 965 virtual intptr_t get_con() const;
aoqi@0 966
aoqi@0 967 virtual const Type *cast_to_ptr_type(PTR ptr) const;
aoqi@0 968
aoqi@0 969 virtual const Type *cast_to_exactness(bool klass_is_exact) const;
aoqi@0 970
aoqi@0 971 virtual const TypeOopPtr *cast_to_instance_id(int instance_id) const;
aoqi@0 972
aoqi@0 973 // corresponding pointer to klass, for a given instance
aoqi@0 974 const TypeKlassPtr* as_klass_type() const;
aoqi@0 975
aoqi@0 976 virtual const TypePtr *add_offset( intptr_t offset ) const;
aoqi@0 977 // Return same type without a speculative part
aoqi@0 978 virtual const Type* remove_speculative() const;
aoqi@0 979
aoqi@0 980 virtual const Type *xmeet(const Type *t) const;
aoqi@0 981 virtual const Type *xdual() const; // Compute dual right now.
aoqi@0 982 // the core of the computation of the meet for TypeOopPtr and for its subclasses
aoqi@0 983 virtual const Type *xmeet_helper(const Type *t) const;
aoqi@0 984
aoqi@0 985 // Convenience common pre-built type.
aoqi@0 986 static const TypeOopPtr *BOTTOM;
aoqi@0 987 #ifndef PRODUCT
aoqi@0 988 virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
aoqi@0 989 #endif
aoqi@0 990
aoqi@0 991 // Return the speculative type if any
aoqi@0 992 ciKlass* speculative_type() const {
aoqi@0 993 if (_speculative != NULL) {
aoqi@0 994 const TypeOopPtr* speculative = _speculative->join(this)->is_oopptr();
aoqi@0 995 if (speculative->klass_is_exact()) {
aoqi@0 996 return speculative->klass();
aoqi@0 997 }
aoqi@0 998 }
aoqi@0 999 return NULL;
aoqi@0 1000 }
aoqi@0 1001 int inline_depth() const {
aoqi@0 1002 return _inline_depth;
aoqi@0 1003 }
aoqi@0 1004 virtual const TypeOopPtr* with_inline_depth(int depth) const;
aoqi@0 1005 virtual bool would_improve_type(ciKlass* exact_kls, int inline_depth) const;
aoqi@0 1006 };
aoqi@0 1007
aoqi@0 1008 //------------------------------TypeInstPtr------------------------------------
aoqi@0 1009 // Class of Java object pointers, pointing either to non-array Java instances
aoqi@0 1010 // or to a Klass* (including array klasses).
aoqi@0 1011 class TypeInstPtr : public TypeOopPtr {
aoqi@0 1012 TypeInstPtr(PTR ptr, ciKlass* k, bool xk, ciObject* o, int offset, int instance_id, const TypeOopPtr* speculative, int inline_depth);
aoqi@0 1013 virtual bool eq( const Type *t ) const;
aoqi@0 1014 virtual int hash() const; // Type specific hashing
aoqi@0 1015
aoqi@0 1016 ciSymbol* _name; // class name
aoqi@0 1017
aoqi@0 1018 public:
aoqi@0 1019 ciSymbol* name() const { return _name; }
aoqi@0 1020
aoqi@0 1021 bool is_loaded() const { return _klass->is_loaded(); }
aoqi@0 1022
aoqi@0 1023 // Make a pointer to a constant oop.
aoqi@0 1024 static const TypeInstPtr *make(ciObject* o) {
aoqi@0 1025 return make(TypePtr::Constant, o->klass(), true, o, 0, InstanceBot);
aoqi@0 1026 }
aoqi@0 1027 // Make a pointer to a constant oop with offset.
aoqi@0 1028 static const TypeInstPtr *make(ciObject* o, int offset) {
aoqi@0 1029 return make(TypePtr::Constant, o->klass(), true, o, offset, InstanceBot);
aoqi@0 1030 }
aoqi@0 1031
aoqi@0 1032 // Make a pointer to some value of type klass.
aoqi@0 1033 static const TypeInstPtr *make(PTR ptr, ciKlass* klass) {
aoqi@0 1034 return make(ptr, klass, false, NULL, 0, InstanceBot);
aoqi@0 1035 }
aoqi@0 1036
aoqi@0 1037 // Make a pointer to some non-polymorphic value of exactly type klass.
aoqi@0 1038 static const TypeInstPtr *make_exact(PTR ptr, ciKlass* klass) {
aoqi@0 1039 return make(ptr, klass, true, NULL, 0, InstanceBot);
aoqi@0 1040 }
aoqi@0 1041
aoqi@0 1042 // Make a pointer to some value of type klass with offset.
aoqi@0 1043 static const TypeInstPtr *make(PTR ptr, ciKlass* klass, int offset) {
aoqi@0 1044 return make(ptr, klass, false, NULL, offset, InstanceBot);
aoqi@0 1045 }
aoqi@0 1046
aoqi@0 1047 // Make a pointer to an oop.
aoqi@0 1048 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 1049
aoqi@0 1050 /** Create constant type for a constant boxed value */
aoqi@0 1051 const Type* get_const_boxed_value() const;
aoqi@0 1052
aoqi@0 1053 // If this is a java.lang.Class constant, return the type for it or NULL.
aoqi@0 1054 // Pass to Type::get_const_type to turn it to a type, which will usually
aoqi@0 1055 // be a TypeInstPtr, but may also be a TypeInt::INT for int.class, etc.
aoqi@0 1056 ciType* java_mirror_type() const;
aoqi@0 1057
aoqi@0 1058 virtual const Type *cast_to_ptr_type(PTR ptr) const;
aoqi@0 1059
aoqi@0 1060 virtual const Type *cast_to_exactness(bool klass_is_exact) const;
aoqi@0 1061
aoqi@0 1062 virtual const TypeOopPtr *cast_to_instance_id(int instance_id) const;
aoqi@0 1063
aoqi@0 1064 virtual const TypePtr *add_offset( intptr_t offset ) const;
aoqi@0 1065 // Return same type without a speculative part
aoqi@0 1066 virtual const Type* remove_speculative() const;
aoqi@0 1067 virtual const TypeOopPtr* with_inline_depth(int depth) const;
aoqi@0 1068
aoqi@0 1069 // the core of the computation of the meet of 2 types
aoqi@0 1070 virtual const Type *xmeet_helper(const Type *t) const;
aoqi@0 1071 virtual const TypeInstPtr *xmeet_unloaded( const TypeInstPtr *t ) const;
aoqi@0 1072 virtual const Type *xdual() const; // Compute dual right now.
aoqi@0 1073
aoqi@0 1074 // Convenience common pre-built types.
aoqi@0 1075 static const TypeInstPtr *NOTNULL;
aoqi@0 1076 static const TypeInstPtr *BOTTOM;
aoqi@0 1077 static const TypeInstPtr *MIRROR;
aoqi@0 1078 static const TypeInstPtr *MARK;
aoqi@0 1079 static const TypeInstPtr *KLASS;
aoqi@0 1080 #ifndef PRODUCT
aoqi@0 1081 virtual void dump2( Dict &d, uint depth, outputStream *st ) const; // Specialized per-Type dumping
aoqi@0 1082 #endif
aoqi@0 1083 };
aoqi@0 1084
aoqi@0 1085 //------------------------------TypeAryPtr-------------------------------------
aoqi@0 1086 // Class of Java array pointers
aoqi@0 1087 class TypeAryPtr : public TypeOopPtr {
aoqi@0 1088 TypeAryPtr( PTR ptr, ciObject* o, const TypeAry *ary, ciKlass* k, bool xk,
aoqi@0 1089 int offset, int instance_id, bool is_autobox_cache, const TypeOopPtr* speculative, int inline_depth)
aoqi@0 1090 : TypeOopPtr(AryPtr,ptr,k,xk,o,offset, instance_id, speculative, inline_depth),
aoqi@0 1091 _ary(ary),
aoqi@0 1092 _is_autobox_cache(is_autobox_cache)
aoqi@0 1093 {
aoqi@0 1094 #ifdef ASSERT
aoqi@0 1095 if (k != NULL) {
aoqi@0 1096 // Verify that specified klass and TypeAryPtr::klass() follow the same rules.
aoqi@0 1097 ciKlass* ck = compute_klass(true);
aoqi@0 1098 if (k != ck) {
aoqi@0 1099 this->dump(); tty->cr();
aoqi@0 1100 tty->print(" k: ");
aoqi@0 1101 k->print(); tty->cr();
aoqi@0 1102 tty->print("ck: ");
aoqi@0 1103 if (ck != NULL) ck->print();
aoqi@0 1104 else tty->print("<NULL>");
aoqi@0 1105 tty->cr();
aoqi@0 1106 assert(false, "unexpected TypeAryPtr::_klass");
aoqi@0 1107 }
aoqi@0 1108 }
aoqi@0 1109 #endif
aoqi@0 1110 }
aoqi@0 1111 virtual bool eq( const Type *t ) const;
aoqi@0 1112 virtual int hash() const; // Type specific hashing
aoqi@0 1113 const TypeAry *_ary; // Array we point into
aoqi@0 1114 const bool _is_autobox_cache;
aoqi@0 1115
aoqi@0 1116 ciKlass* compute_klass(DEBUG_ONLY(bool verify = false)) const;
aoqi@0 1117
aoqi@0 1118 public:
aoqi@0 1119 // Accessors
aoqi@0 1120 ciKlass* klass() const;
aoqi@0 1121 const TypeAry* ary() const { return _ary; }
aoqi@0 1122 const Type* elem() const { return _ary->_elem; }
aoqi@0 1123 const TypeInt* size() const { return _ary->_size; }
aoqi@0 1124 bool is_stable() const { return _ary->_stable; }
aoqi@0 1125
aoqi@0 1126 bool is_autobox_cache() const { return _is_autobox_cache; }
aoqi@0 1127
aoqi@0 1128 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 1129 // Constant pointer to array
aoqi@0 1130 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 1131
aoqi@0 1132 // Return a 'ptr' version of this type
aoqi@0 1133 virtual const Type *cast_to_ptr_type(PTR ptr) const;
aoqi@0 1134
aoqi@0 1135 virtual const Type *cast_to_exactness(bool klass_is_exact) const;
aoqi@0 1136
aoqi@0 1137 virtual const TypeOopPtr *cast_to_instance_id(int instance_id) const;
aoqi@0 1138
aoqi@0 1139 virtual const TypeAryPtr* cast_to_size(const TypeInt* size) const;
aoqi@0 1140 virtual const TypeInt* narrow_size_type(const TypeInt* size) const;
aoqi@0 1141
aoqi@0 1142 virtual bool empty(void) const; // TRUE if type is vacuous
aoqi@0 1143 virtual const TypePtr *add_offset( intptr_t offset ) const;
aoqi@0 1144 // Return same type without a speculative part
aoqi@0 1145 virtual const Type* remove_speculative() const;
aoqi@0 1146 virtual const TypeOopPtr* with_inline_depth(int depth) const;
aoqi@0 1147
aoqi@0 1148 // the core of the computation of the meet of 2 types
aoqi@0 1149 virtual const Type *xmeet_helper(const Type *t) const;
aoqi@0 1150 virtual const Type *xdual() const; // Compute dual right now.
aoqi@0 1151
aoqi@0 1152 const TypeAryPtr* cast_to_stable(bool stable, int stable_dimension = 1) const;
aoqi@0 1153 int stable_dimension() const;
aoqi@0 1154
aoqi@0 1155 // Convenience common pre-built types.
aoqi@0 1156 static const TypeAryPtr *RANGE;
aoqi@0 1157 static const TypeAryPtr *OOPS;
aoqi@0 1158 static const TypeAryPtr *NARROWOOPS;
aoqi@0 1159 static const TypeAryPtr *BYTES;
aoqi@0 1160 static const TypeAryPtr *SHORTS;
aoqi@0 1161 static const TypeAryPtr *CHARS;
aoqi@0 1162 static const TypeAryPtr *INTS;
aoqi@0 1163 static const TypeAryPtr *LONGS;
aoqi@0 1164 static const TypeAryPtr *FLOATS;
aoqi@0 1165 static const TypeAryPtr *DOUBLES;
aoqi@0 1166 // selects one of the above:
aoqi@0 1167 static const TypeAryPtr *get_array_body_type(BasicType elem) {
aoqi@0 1168 assert((uint)elem <= T_CONFLICT && _array_body_type[elem] != NULL, "bad elem type");
aoqi@0 1169 return _array_body_type[elem];
aoqi@0 1170 }
aoqi@0 1171 static const TypeAryPtr *_array_body_type[T_CONFLICT+1];
aoqi@0 1172 // sharpen the type of an int which is used as an array size
aoqi@0 1173 #ifdef ASSERT
aoqi@0 1174 // One type is interface, the other is oop
aoqi@0 1175 virtual bool interface_vs_oop(const Type *t) const;
aoqi@0 1176 #endif
aoqi@0 1177 #ifndef PRODUCT
aoqi@0 1178 virtual void dump2( Dict &d, uint depth, outputStream *st ) const; // Specialized per-Type dumping
aoqi@0 1179 #endif
aoqi@0 1180 };
aoqi@0 1181
aoqi@0 1182 //------------------------------TypeMetadataPtr-------------------------------------
aoqi@0 1183 // Some kind of metadata, either Method*, MethodData* or CPCacheOop
aoqi@0 1184 class TypeMetadataPtr : public TypePtr {
aoqi@0 1185 protected:
aoqi@0 1186 TypeMetadataPtr(PTR ptr, ciMetadata* metadata, int offset);
aoqi@0 1187 // Do not allow interface-vs.-noninterface joins to collapse to top.
aoqi@0 1188 virtual const Type *filter_helper(const Type *kills, bool include_speculative) const;
aoqi@0 1189 public:
aoqi@0 1190 virtual bool eq( const Type *t ) const;
aoqi@0 1191 virtual int hash() const; // Type specific hashing
aoqi@0 1192 virtual bool singleton(void) const; // TRUE if type is a singleton
aoqi@0 1193
aoqi@0 1194 private:
aoqi@0 1195 ciMetadata* _metadata;
aoqi@0 1196
aoqi@0 1197 public:
aoqi@0 1198 static const TypeMetadataPtr* make(PTR ptr, ciMetadata* m, int offset);
aoqi@0 1199
aoqi@0 1200 static const TypeMetadataPtr* make(ciMethod* m);
aoqi@0 1201 static const TypeMetadataPtr* make(ciMethodData* m);
aoqi@0 1202
aoqi@0 1203 ciMetadata* metadata() const { return _metadata; }
aoqi@0 1204
aoqi@0 1205 virtual const Type *cast_to_ptr_type(PTR ptr) const;
aoqi@0 1206
aoqi@0 1207 virtual const TypePtr *add_offset( intptr_t offset ) const;
aoqi@0 1208
aoqi@0 1209 virtual const Type *xmeet( const Type *t ) const;
aoqi@0 1210 virtual const Type *xdual() const; // Compute dual right now.
aoqi@0 1211
aoqi@0 1212 virtual intptr_t get_con() const;
aoqi@0 1213
aoqi@0 1214 // Convenience common pre-built types.
aoqi@0 1215 static const TypeMetadataPtr *BOTTOM;
aoqi@0 1216
aoqi@0 1217 #ifndef PRODUCT
aoqi@0 1218 virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
aoqi@0 1219 #endif
aoqi@0 1220 };
aoqi@0 1221
aoqi@0 1222 //------------------------------TypeKlassPtr-----------------------------------
aoqi@0 1223 // Class of Java Klass pointers
aoqi@0 1224 class TypeKlassPtr : public TypePtr {
aoqi@0 1225 TypeKlassPtr( PTR ptr, ciKlass* klass, int offset );
aoqi@0 1226
aoqi@0 1227 protected:
aoqi@0 1228 virtual const Type *filter_helper(const Type *kills, bool include_speculative) const;
aoqi@0 1229 public:
aoqi@0 1230 virtual bool eq( const Type *t ) const;
aoqi@0 1231 virtual int hash() const; // Type specific hashing
aoqi@0 1232 virtual bool singleton(void) const; // TRUE if type is a singleton
aoqi@0 1233 private:
aoqi@0 1234
aoqi@0 1235 static const TypeKlassPtr* make_from_klass_common(ciKlass* klass, bool klass_change, bool try_for_exact);
aoqi@0 1236
aoqi@0 1237 ciKlass* _klass;
aoqi@0 1238
aoqi@0 1239 // Does the type exclude subclasses of the klass? (Inexact == polymorphic.)
aoqi@0 1240 bool _klass_is_exact;
aoqi@0 1241
aoqi@0 1242 public:
aoqi@0 1243 ciSymbol* name() const { return klass()->name(); }
aoqi@0 1244
aoqi@0 1245 ciKlass* klass() const { return _klass; }
aoqi@0 1246 bool klass_is_exact() const { return _klass_is_exact; }
aoqi@0 1247
aoqi@0 1248 bool is_loaded() const { return klass()->is_loaded(); }
aoqi@0 1249
aoqi@0 1250 // Creates a type given a klass. Correctly handles multi-dimensional arrays
aoqi@0 1251 // Respects UseUniqueSubclasses.
aoqi@0 1252 // If the klass is final, the resulting type will be exact.
aoqi@0 1253 static const TypeKlassPtr* make_from_klass(ciKlass* klass) {
aoqi@0 1254 return make_from_klass_common(klass, true, false);
aoqi@0 1255 }
aoqi@0 1256 // Same as before, but will produce an exact type, even if
aoqi@0 1257 // the klass is not final, as long as it has exactly one implementation.
aoqi@0 1258 static const TypeKlassPtr* make_from_klass_unique(ciKlass* klass) {
aoqi@0 1259 return make_from_klass_common(klass, true, true);
aoqi@0 1260 }
aoqi@0 1261 // Same as before, but does not respects UseUniqueSubclasses.
aoqi@0 1262 // Use this only for creating array element types.
aoqi@0 1263 static const TypeKlassPtr* make_from_klass_raw(ciKlass* klass) {
aoqi@0 1264 return make_from_klass_common(klass, false, false);
aoqi@0 1265 }
aoqi@0 1266
aoqi@0 1267 // Make a generic (unclassed) pointer to metadata.
aoqi@0 1268 static const TypeKlassPtr* make(PTR ptr, int offset);
aoqi@0 1269
aoqi@0 1270 // ptr to klass 'k'
aoqi@0 1271 static const TypeKlassPtr *make( ciKlass* k ) { return make( TypePtr::Constant, k, 0); }
aoqi@0 1272 // ptr to klass 'k' with offset
aoqi@0 1273 static const TypeKlassPtr *make( ciKlass* k, int offset ) { return make( TypePtr::Constant, k, offset); }
aoqi@0 1274 // ptr to klass 'k' or sub-klass
aoqi@0 1275 static const TypeKlassPtr *make( PTR ptr, ciKlass* k, int offset);
aoqi@0 1276
aoqi@0 1277 virtual const Type *cast_to_ptr_type(PTR ptr) const;
aoqi@0 1278
aoqi@0 1279 virtual const Type *cast_to_exactness(bool klass_is_exact) const;
aoqi@0 1280
aoqi@0 1281 // corresponding pointer to instance, for a given class
aoqi@0 1282 const TypeOopPtr* as_instance_type() const;
aoqi@0 1283
aoqi@0 1284 virtual const TypePtr *add_offset( intptr_t offset ) const;
aoqi@0 1285 virtual const Type *xmeet( const Type *t ) const;
aoqi@0 1286 virtual const Type *xdual() const; // Compute dual right now.
aoqi@0 1287
aoqi@0 1288 virtual intptr_t get_con() const;
aoqi@0 1289
aoqi@0 1290 // Convenience common pre-built types.
aoqi@0 1291 static const TypeKlassPtr* OBJECT; // Not-null object klass or below
aoqi@0 1292 static const TypeKlassPtr* OBJECT_OR_NULL; // Maybe-null version of same
aoqi@0 1293 #ifndef PRODUCT
aoqi@0 1294 virtual void dump2( Dict &d, uint depth, outputStream *st ) const; // Specialized per-Type dumping
aoqi@0 1295 #endif
aoqi@0 1296 };
aoqi@0 1297
aoqi@0 1298 class TypeNarrowPtr : public Type {
aoqi@0 1299 protected:
aoqi@0 1300 const TypePtr* _ptrtype; // Could be TypePtr::NULL_PTR
aoqi@0 1301
aoqi@0 1302 TypeNarrowPtr(TYPES t, const TypePtr* ptrtype): _ptrtype(ptrtype),
aoqi@0 1303 Type(t) {
aoqi@0 1304 assert(ptrtype->offset() == 0 ||
aoqi@0 1305 ptrtype->offset() == OffsetBot ||
aoqi@0 1306 ptrtype->offset() == OffsetTop, "no real offsets");
aoqi@0 1307 }
aoqi@0 1308
aoqi@0 1309 virtual const TypeNarrowPtr *isa_same_narrowptr(const Type *t) const = 0;
aoqi@0 1310 virtual const TypeNarrowPtr *is_same_narrowptr(const Type *t) const = 0;
aoqi@0 1311 virtual const TypeNarrowPtr *make_same_narrowptr(const TypePtr *t) const = 0;
aoqi@0 1312 virtual const TypeNarrowPtr *make_hash_same_narrowptr(const TypePtr *t) const = 0;
aoqi@0 1313 // Do not allow interface-vs.-noninterface joins to collapse to top.
aoqi@0 1314 virtual const Type *filter_helper(const Type *kills, bool include_speculative) const;
aoqi@0 1315 public:
aoqi@0 1316 virtual bool eq( const Type *t ) const;
aoqi@0 1317 virtual int hash() const; // Type specific hashing
aoqi@0 1318 virtual bool singleton(void) const; // TRUE if type is a singleton
aoqi@0 1319
aoqi@0 1320 virtual const Type *xmeet( const Type *t ) const;
aoqi@0 1321 virtual const Type *xdual() const; // Compute dual right now.
aoqi@0 1322
aoqi@0 1323 virtual intptr_t get_con() const;
aoqi@0 1324
aoqi@0 1325 virtual bool empty(void) const; // TRUE if type is vacuous
aoqi@0 1326
aoqi@0 1327 // returns the equivalent ptr type for this compressed pointer
aoqi@0 1328 const TypePtr *get_ptrtype() const {
aoqi@0 1329 return _ptrtype;
aoqi@0 1330 }
aoqi@0 1331
aoqi@0 1332 #ifndef PRODUCT
aoqi@0 1333 virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
aoqi@0 1334 #endif
aoqi@0 1335 };
aoqi@0 1336
aoqi@0 1337 //------------------------------TypeNarrowOop----------------------------------
aoqi@0 1338 // A compressed reference to some kind of Oop. This type wraps around
aoqi@0 1339 // a preexisting TypeOopPtr and forwards most of it's operations to
aoqi@0 1340 // the underlying type. It's only real purpose is to track the
aoqi@0 1341 // oopness of the compressed oop value when we expose the conversion
aoqi@0 1342 // between the normal and the compressed form.
aoqi@0 1343 class TypeNarrowOop : public TypeNarrowPtr {
aoqi@0 1344 protected:
aoqi@0 1345 TypeNarrowOop( const TypePtr* ptrtype): TypeNarrowPtr(NarrowOop, ptrtype) {
aoqi@0 1346 }
aoqi@0 1347
aoqi@0 1348 virtual const TypeNarrowPtr *isa_same_narrowptr(const Type *t) const {
aoqi@0 1349 return t->isa_narrowoop();
aoqi@0 1350 }
aoqi@0 1351
aoqi@0 1352 virtual const TypeNarrowPtr *is_same_narrowptr(const Type *t) const {
aoqi@0 1353 return t->is_narrowoop();
aoqi@0 1354 }
aoqi@0 1355
aoqi@0 1356 virtual const TypeNarrowPtr *make_same_narrowptr(const TypePtr *t) const {
aoqi@0 1357 return new TypeNarrowOop(t);
aoqi@0 1358 }
aoqi@0 1359
aoqi@0 1360 virtual const TypeNarrowPtr *make_hash_same_narrowptr(const TypePtr *t) const {
aoqi@0 1361 return (const TypeNarrowPtr*)((new TypeNarrowOop(t))->hashcons());
aoqi@0 1362 }
aoqi@0 1363
aoqi@0 1364 public:
aoqi@0 1365
aoqi@0 1366 static const TypeNarrowOop *make( const TypePtr* type);
aoqi@0 1367
aoqi@0 1368 static const TypeNarrowOop* make_from_constant(ciObject* con, bool require_constant = false) {
aoqi@0 1369 return make(TypeOopPtr::make_from_constant(con, require_constant));
aoqi@0 1370 }
aoqi@0 1371
aoqi@0 1372 static const TypeNarrowOop *BOTTOM;
aoqi@0 1373 static const TypeNarrowOop *NULL_PTR;
aoqi@0 1374
aoqi@0 1375 virtual const Type* remove_speculative() const {
aoqi@0 1376 return make(_ptrtype->remove_speculative()->is_ptr());
aoqi@0 1377 }
aoqi@0 1378
aoqi@0 1379 #ifndef PRODUCT
aoqi@0 1380 virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
aoqi@0 1381 #endif
aoqi@0 1382 };
aoqi@0 1383
aoqi@0 1384 //------------------------------TypeNarrowKlass----------------------------------
aoqi@0 1385 // A compressed reference to klass pointer. This type wraps around a
aoqi@0 1386 // preexisting TypeKlassPtr and forwards most of it's operations to
aoqi@0 1387 // the underlying type.
aoqi@0 1388 class TypeNarrowKlass : public TypeNarrowPtr {
aoqi@0 1389 protected:
aoqi@0 1390 TypeNarrowKlass( const TypePtr* ptrtype): TypeNarrowPtr(NarrowKlass, ptrtype) {
aoqi@0 1391 }
aoqi@0 1392
aoqi@0 1393 virtual const TypeNarrowPtr *isa_same_narrowptr(const Type *t) const {
aoqi@0 1394 return t->isa_narrowklass();
aoqi@0 1395 }
aoqi@0 1396
aoqi@0 1397 virtual const TypeNarrowPtr *is_same_narrowptr(const Type *t) const {
aoqi@0 1398 return t->is_narrowklass();
aoqi@0 1399 }
aoqi@0 1400
aoqi@0 1401 virtual const TypeNarrowPtr *make_same_narrowptr(const TypePtr *t) const {
aoqi@0 1402 return new TypeNarrowKlass(t);
aoqi@0 1403 }
aoqi@0 1404
aoqi@0 1405 virtual const TypeNarrowPtr *make_hash_same_narrowptr(const TypePtr *t) const {
aoqi@0 1406 return (const TypeNarrowPtr*)((new TypeNarrowKlass(t))->hashcons());
aoqi@0 1407 }
aoqi@0 1408
aoqi@0 1409 public:
aoqi@0 1410 static const TypeNarrowKlass *make( const TypePtr* type);
aoqi@0 1411
aoqi@0 1412 // static const TypeNarrowKlass *BOTTOM;
aoqi@0 1413 static const TypeNarrowKlass *NULL_PTR;
aoqi@0 1414
aoqi@0 1415 #ifndef PRODUCT
aoqi@0 1416 virtual void dump2( Dict &d, uint depth, outputStream *st ) const;
aoqi@0 1417 #endif
aoqi@0 1418 };
aoqi@0 1419
aoqi@0 1420 //------------------------------TypeFunc---------------------------------------
aoqi@0 1421 // Class of Array Types
aoqi@0 1422 class TypeFunc : public Type {
aoqi@0 1423 TypeFunc( const TypeTuple *domain, const TypeTuple *range ) : Type(Function), _domain(domain), _range(range) {}
aoqi@0 1424 virtual bool eq( const Type *t ) const;
aoqi@0 1425 virtual int hash() const; // Type specific hashing
aoqi@0 1426 virtual bool singleton(void) const; // TRUE if type is a singleton
aoqi@0 1427 virtual bool empty(void) const; // TRUE if type is vacuous
aoqi@0 1428 public:
aoqi@0 1429 // Constants are shared among ADLC and VM
aoqi@0 1430 enum { Control = AdlcVMDeps::Control,
aoqi@0 1431 I_O = AdlcVMDeps::I_O,
aoqi@0 1432 Memory = AdlcVMDeps::Memory,
aoqi@0 1433 FramePtr = AdlcVMDeps::FramePtr,
aoqi@0 1434 ReturnAdr = AdlcVMDeps::ReturnAdr,
aoqi@0 1435 Parms = AdlcVMDeps::Parms
aoqi@0 1436 };
aoqi@0 1437
aoqi@0 1438 const TypeTuple* const _domain; // Domain of inputs
aoqi@0 1439 const TypeTuple* const _range; // Range of results
aoqi@0 1440
aoqi@0 1441 // Accessors:
aoqi@0 1442 const TypeTuple* domain() const { return _domain; }
aoqi@0 1443 const TypeTuple* range() const { return _range; }
aoqi@0 1444
aoqi@0 1445 static const TypeFunc *make(ciMethod* method);
aoqi@0 1446 static const TypeFunc *make(ciSignature signature, const Type* extra);
aoqi@0 1447 static const TypeFunc *make(const TypeTuple* domain, const TypeTuple* range);
aoqi@0 1448
aoqi@0 1449 virtual const Type *xmeet( const Type *t ) const;
aoqi@0 1450 virtual const Type *xdual() const; // Compute dual right now.
aoqi@0 1451
aoqi@0 1452 BasicType return_type() const;
aoqi@0 1453
aoqi@0 1454 #ifndef PRODUCT
aoqi@0 1455 virtual void dump2( Dict &d, uint depth, outputStream *st ) const; // Specialized per-Type dumping
aoqi@0 1456 #endif
aoqi@0 1457 // Convenience common pre-built types.
aoqi@0 1458 };
aoqi@0 1459
aoqi@0 1460 //------------------------------accessors--------------------------------------
aoqi@0 1461 inline bool Type::is_ptr_to_narrowoop() const {
aoqi@0 1462 #ifdef _LP64
aoqi@0 1463 return (isa_oopptr() != NULL && is_oopptr()->is_ptr_to_narrowoop_nv());
aoqi@0 1464 #else
aoqi@0 1465 return false;
aoqi@0 1466 #endif
aoqi@0 1467 }
aoqi@0 1468
aoqi@0 1469 inline bool Type::is_ptr_to_narrowklass() const {
aoqi@0 1470 #ifdef _LP64
aoqi@0 1471 return (isa_oopptr() != NULL && is_oopptr()->is_ptr_to_narrowklass_nv());
aoqi@0 1472 #else
aoqi@0 1473 return false;
aoqi@0 1474 #endif
aoqi@0 1475 }
aoqi@0 1476
aoqi@0 1477 inline float Type::getf() const {
aoqi@0 1478 assert( _base == FloatCon, "Not a FloatCon" );
aoqi@0 1479 return ((TypeF*)this)->_f;
aoqi@0 1480 }
aoqi@0 1481
aoqi@0 1482 inline double Type::getd() const {
aoqi@0 1483 assert( _base == DoubleCon, "Not a DoubleCon" );
aoqi@0 1484 return ((TypeD*)this)->_d;
aoqi@0 1485 }
aoqi@0 1486
aoqi@0 1487 inline const TypeInt *Type::is_int() const {
aoqi@0 1488 assert( _base == Int, "Not an Int" );
aoqi@0 1489 return (TypeInt*)this;
aoqi@0 1490 }
aoqi@0 1491
aoqi@0 1492 inline const TypeInt *Type::isa_int() const {
aoqi@0 1493 return ( _base == Int ? (TypeInt*)this : NULL);
aoqi@0 1494 }
aoqi@0 1495
aoqi@0 1496 inline const TypeLong *Type::is_long() const {
aoqi@0 1497 assert( _base == Long, "Not a Long" );
aoqi@0 1498 return (TypeLong*)this;
aoqi@0 1499 }
aoqi@0 1500
aoqi@0 1501 inline const TypeLong *Type::isa_long() const {
aoqi@0 1502 return ( _base == Long ? (TypeLong*)this : NULL);
aoqi@0 1503 }
aoqi@0 1504
aoqi@0 1505 inline const TypeF *Type::isa_float() const {
aoqi@0 1506 return ((_base == FloatTop ||
aoqi@0 1507 _base == FloatCon ||
aoqi@0 1508 _base == FloatBot) ? (TypeF*)this : NULL);
aoqi@0 1509 }
aoqi@0 1510
aoqi@0 1511 inline const TypeF *Type::is_float_constant() const {
aoqi@0 1512 assert( _base == FloatCon, "Not a Float" );
aoqi@0 1513 return (TypeF*)this;
aoqi@0 1514 }
aoqi@0 1515
aoqi@0 1516 inline const TypeF *Type::isa_float_constant() const {
aoqi@0 1517 return ( _base == FloatCon ? (TypeF*)this : NULL);
aoqi@0 1518 }
aoqi@0 1519
aoqi@0 1520 inline const TypeD *Type::isa_double() const {
aoqi@0 1521 return ((_base == DoubleTop ||
aoqi@0 1522 _base == DoubleCon ||
aoqi@0 1523 _base == DoubleBot) ? (TypeD*)this : NULL);
aoqi@0 1524 }
aoqi@0 1525
aoqi@0 1526 inline const TypeD *Type::is_double_constant() const {
aoqi@0 1527 assert( _base == DoubleCon, "Not a Double" );
aoqi@0 1528 return (TypeD*)this;
aoqi@0 1529 }
aoqi@0 1530
aoqi@0 1531 inline const TypeD *Type::isa_double_constant() const {
aoqi@0 1532 return ( _base == DoubleCon ? (TypeD*)this : NULL);
aoqi@0 1533 }
aoqi@0 1534
aoqi@0 1535 inline const TypeTuple *Type::is_tuple() const {
aoqi@0 1536 assert( _base == Tuple, "Not a Tuple" );
aoqi@0 1537 return (TypeTuple*)this;
aoqi@0 1538 }
aoqi@0 1539
aoqi@0 1540 inline const TypeAry *Type::is_ary() const {
aoqi@0 1541 assert( _base == Array , "Not an Array" );
aoqi@0 1542 return (TypeAry*)this;
aoqi@0 1543 }
aoqi@0 1544
aoqi@0 1545 inline const TypeVect *Type::is_vect() const {
aoqi@0 1546 assert( _base >= VectorS && _base <= VectorY, "Not a Vector" );
aoqi@0 1547 return (TypeVect*)this;
aoqi@0 1548 }
aoqi@0 1549
aoqi@0 1550 inline const TypeVect *Type::isa_vect() const {
aoqi@0 1551 return (_base >= VectorS && _base <= VectorY) ? (TypeVect*)this : NULL;
aoqi@0 1552 }
aoqi@0 1553
aoqi@0 1554 inline const TypePtr *Type::is_ptr() const {
aoqi@0 1555 // AnyPtr is the first Ptr and KlassPtr the last, with no non-ptrs between.
aoqi@0 1556 assert(_base >= AnyPtr && _base <= KlassPtr, "Not a pointer");
aoqi@0 1557 return (TypePtr*)this;
aoqi@0 1558 }
aoqi@0 1559
aoqi@0 1560 inline const TypePtr *Type::isa_ptr() const {
aoqi@0 1561 // AnyPtr is the first Ptr and KlassPtr the last, with no non-ptrs between.
aoqi@0 1562 return (_base >= AnyPtr && _base <= KlassPtr) ? (TypePtr*)this : NULL;
aoqi@0 1563 }
aoqi@0 1564
aoqi@0 1565 inline const TypeOopPtr *Type::is_oopptr() const {
aoqi@0 1566 // OopPtr is the first and KlassPtr the last, with no non-oops between.
aoqi@0 1567 assert(_base >= OopPtr && _base <= AryPtr, "Not a Java pointer" ) ;
aoqi@0 1568 return (TypeOopPtr*)this;
aoqi@0 1569 }
aoqi@0 1570
aoqi@0 1571 inline const TypeOopPtr *Type::isa_oopptr() const {
aoqi@0 1572 // OopPtr is the first and KlassPtr the last, with no non-oops between.
aoqi@0 1573 return (_base >= OopPtr && _base <= AryPtr) ? (TypeOopPtr*)this : NULL;
aoqi@0 1574 }
aoqi@0 1575
aoqi@0 1576 inline const TypeRawPtr *Type::isa_rawptr() const {
aoqi@0 1577 return (_base == RawPtr) ? (TypeRawPtr*)this : NULL;
aoqi@0 1578 }
aoqi@0 1579
aoqi@0 1580 inline const TypeRawPtr *Type::is_rawptr() const {
aoqi@0 1581 assert( _base == RawPtr, "Not a raw pointer" );
aoqi@0 1582 return (TypeRawPtr*)this;
aoqi@0 1583 }
aoqi@0 1584
aoqi@0 1585 inline const TypeInstPtr *Type::isa_instptr() const {
aoqi@0 1586 return (_base == InstPtr) ? (TypeInstPtr*)this : NULL;
aoqi@0 1587 }
aoqi@0 1588
aoqi@0 1589 inline const TypeInstPtr *Type::is_instptr() const {
aoqi@0 1590 assert( _base == InstPtr, "Not an object pointer" );
aoqi@0 1591 return (TypeInstPtr*)this;
aoqi@0 1592 }
aoqi@0 1593
aoqi@0 1594 inline const TypeAryPtr *Type::isa_aryptr() const {
aoqi@0 1595 return (_base == AryPtr) ? (TypeAryPtr*)this : NULL;
aoqi@0 1596 }
aoqi@0 1597
aoqi@0 1598 inline const TypeAryPtr *Type::is_aryptr() const {
aoqi@0 1599 assert( _base == AryPtr, "Not an array pointer" );
aoqi@0 1600 return (TypeAryPtr*)this;
aoqi@0 1601 }
aoqi@0 1602
aoqi@0 1603 inline const TypeNarrowOop *Type::is_narrowoop() const {
aoqi@0 1604 // OopPtr is the first and KlassPtr the last, with no non-oops between.
aoqi@0 1605 assert(_base == NarrowOop, "Not a narrow oop" ) ;
aoqi@0 1606 return (TypeNarrowOop*)this;
aoqi@0 1607 }
aoqi@0 1608
aoqi@0 1609 inline const TypeNarrowOop *Type::isa_narrowoop() const {
aoqi@0 1610 // OopPtr is the first and KlassPtr the last, with no non-oops between.
aoqi@0 1611 return (_base == NarrowOop) ? (TypeNarrowOop*)this : NULL;
aoqi@0 1612 }
aoqi@0 1613
aoqi@0 1614 inline const TypeNarrowKlass *Type::is_narrowklass() const {
aoqi@0 1615 assert(_base == NarrowKlass, "Not a narrow oop" ) ;
aoqi@0 1616 return (TypeNarrowKlass*)this;
aoqi@0 1617 }
aoqi@0 1618
aoqi@0 1619 inline const TypeNarrowKlass *Type::isa_narrowklass() const {
aoqi@0 1620 return (_base == NarrowKlass) ? (TypeNarrowKlass*)this : NULL;
aoqi@0 1621 }
aoqi@0 1622
aoqi@0 1623 inline const TypeMetadataPtr *Type::is_metadataptr() const {
aoqi@0 1624 // MetadataPtr is the first and CPCachePtr the last
aoqi@0 1625 assert(_base == MetadataPtr, "Not a metadata pointer" ) ;
aoqi@0 1626 return (TypeMetadataPtr*)this;
aoqi@0 1627 }
aoqi@0 1628
aoqi@0 1629 inline const TypeMetadataPtr *Type::isa_metadataptr() const {
aoqi@0 1630 return (_base == MetadataPtr) ? (TypeMetadataPtr*)this : NULL;
aoqi@0 1631 }
aoqi@0 1632
aoqi@0 1633 inline const TypeKlassPtr *Type::isa_klassptr() const {
aoqi@0 1634 return (_base == KlassPtr) ? (TypeKlassPtr*)this : NULL;
aoqi@0 1635 }
aoqi@0 1636
aoqi@0 1637 inline const TypeKlassPtr *Type::is_klassptr() const {
aoqi@0 1638 assert( _base == KlassPtr, "Not a klass pointer" );
aoqi@0 1639 return (TypeKlassPtr*)this;
aoqi@0 1640 }
aoqi@0 1641
aoqi@0 1642 inline const TypePtr* Type::make_ptr() const {
aoqi@0 1643 return (_base == NarrowOop) ? is_narrowoop()->get_ptrtype() :
aoqi@0 1644 ((_base == NarrowKlass) ? is_narrowklass()->get_ptrtype() :
aoqi@0 1645 (isa_ptr() ? is_ptr() : NULL));
aoqi@0 1646 }
aoqi@0 1647
aoqi@0 1648 inline const TypeOopPtr* Type::make_oopptr() const {
aoqi@0 1649 return (_base == NarrowOop) ? is_narrowoop()->get_ptrtype()->is_oopptr() : is_oopptr();
aoqi@0 1650 }
aoqi@0 1651
aoqi@0 1652 inline const TypeNarrowOop* Type::make_narrowoop() const {
aoqi@0 1653 return (_base == NarrowOop) ? is_narrowoop() :
aoqi@0 1654 (isa_ptr() ? TypeNarrowOop::make(is_ptr()) : NULL);
aoqi@0 1655 }
aoqi@0 1656
aoqi@0 1657 inline const TypeNarrowKlass* Type::make_narrowklass() const {
aoqi@0 1658 return (_base == NarrowKlass) ? is_narrowklass() :
aoqi@0 1659 (isa_ptr() ? TypeNarrowKlass::make(is_ptr()) : NULL);
aoqi@0 1660 }
aoqi@0 1661
aoqi@0 1662 inline bool Type::is_floatingpoint() const {
aoqi@0 1663 if( (_base == FloatCon) || (_base == FloatBot) ||
aoqi@0 1664 (_base == DoubleCon) || (_base == DoubleBot) )
aoqi@0 1665 return true;
aoqi@0 1666 return false;
aoqi@0 1667 }
aoqi@0 1668
aoqi@0 1669 inline bool Type::is_ptr_to_boxing_obj() const {
aoqi@0 1670 const TypeInstPtr* tp = isa_instptr();
aoqi@0 1671 return (tp != NULL) && (tp->offset() == 0) &&
aoqi@0 1672 tp->klass()->is_instance_klass() &&
aoqi@0 1673 tp->klass()->as_instance_klass()->is_box_klass();
aoqi@0 1674 }
aoqi@0 1675
aoqi@0 1676
aoqi@0 1677 // ===============================================================
aoqi@0 1678 // Things that need to be 64-bits in the 64-bit build but
aoqi@0 1679 // 32-bits in the 32-bit build. Done this way to get full
aoqi@0 1680 // optimization AND strong typing.
aoqi@0 1681 #ifdef _LP64
aoqi@0 1682
aoqi@0 1683 // For type queries and asserts
aoqi@0 1684 #define is_intptr_t is_long
aoqi@0 1685 #define isa_intptr_t isa_long
aoqi@0 1686 #define find_intptr_t_type find_long_type
aoqi@0 1687 #define find_intptr_t_con find_long_con
aoqi@0 1688 #define TypeX TypeLong
aoqi@0 1689 #define Type_X Type::Long
aoqi@0 1690 #define TypeX_X TypeLong::LONG
aoqi@0 1691 #define TypeX_ZERO TypeLong::ZERO
aoqi@0 1692 // For 'ideal_reg' machine registers
aoqi@0 1693 #define Op_RegX Op_RegL
aoqi@0 1694 // For phase->intcon variants
aoqi@0 1695 #define MakeConX longcon
aoqi@0 1696 #define ConXNode ConLNode
aoqi@0 1697 // For array index arithmetic
aoqi@0 1698 #define MulXNode MulLNode
aoqi@0 1699 #define AndXNode AndLNode
aoqi@0 1700 #define OrXNode OrLNode
aoqi@0 1701 #define CmpXNode CmpLNode
aoqi@0 1702 #define SubXNode SubLNode
aoqi@0 1703 #define LShiftXNode LShiftLNode
aoqi@0 1704 // For object size computation:
aoqi@0 1705 #define AddXNode AddLNode
aoqi@0 1706 #define RShiftXNode RShiftLNode
aoqi@0 1707 // For card marks and hashcodes
aoqi@0 1708 #define URShiftXNode URShiftLNode
aoqi@0 1709 // UseOptoBiasInlining
aoqi@0 1710 #define XorXNode XorLNode
aoqi@0 1711 #define StoreXConditionalNode StoreLConditionalNode
aoqi@0 1712 // Opcodes
aoqi@0 1713 #define Op_LShiftX Op_LShiftL
aoqi@0 1714 #define Op_AndX Op_AndL
aoqi@0 1715 #define Op_AddX Op_AddL
aoqi@0 1716 #define Op_SubX Op_SubL
aoqi@0 1717 #define Op_XorX Op_XorL
aoqi@0 1718 #define Op_URShiftX Op_URShiftL
aoqi@0 1719 // conversions
aoqi@0 1720 #define ConvI2X(x) ConvI2L(x)
aoqi@0 1721 #define ConvL2X(x) (x)
aoqi@0 1722 #define ConvX2I(x) ConvL2I(x)
aoqi@0 1723 #define ConvX2L(x) (x)
aoqi@0 1724 #define ConvX2UL(x) (x)
aoqi@0 1725
aoqi@0 1726 #else
aoqi@0 1727
aoqi@0 1728 // For type queries and asserts
aoqi@0 1729 #define is_intptr_t is_int
aoqi@0 1730 #define isa_intptr_t isa_int
aoqi@0 1731 #define find_intptr_t_type find_int_type
aoqi@0 1732 #define find_intptr_t_con find_int_con
aoqi@0 1733 #define TypeX TypeInt
aoqi@0 1734 #define Type_X Type::Int
aoqi@0 1735 #define TypeX_X TypeInt::INT
aoqi@0 1736 #define TypeX_ZERO TypeInt::ZERO
aoqi@0 1737 // For 'ideal_reg' machine registers
aoqi@0 1738 #define Op_RegX Op_RegI
aoqi@0 1739 // For phase->intcon variants
aoqi@0 1740 #define MakeConX intcon
aoqi@0 1741 #define ConXNode ConINode
aoqi@0 1742 // For array index arithmetic
aoqi@0 1743 #define MulXNode MulINode
aoqi@0 1744 #define AndXNode AndINode
aoqi@0 1745 #define OrXNode OrINode
aoqi@0 1746 #define CmpXNode CmpINode
aoqi@0 1747 #define SubXNode SubINode
aoqi@0 1748 #define LShiftXNode LShiftINode
aoqi@0 1749 // For object size computation:
aoqi@0 1750 #define AddXNode AddINode
aoqi@0 1751 #define RShiftXNode RShiftINode
aoqi@0 1752 // For card marks and hashcodes
aoqi@0 1753 #define URShiftXNode URShiftINode
aoqi@0 1754 // UseOptoBiasInlining
aoqi@0 1755 #define XorXNode XorINode
aoqi@0 1756 #define StoreXConditionalNode StoreIConditionalNode
aoqi@0 1757 // Opcodes
aoqi@0 1758 #define Op_LShiftX Op_LShiftI
aoqi@0 1759 #define Op_AndX Op_AndI
aoqi@0 1760 #define Op_AddX Op_AddI
aoqi@0 1761 #define Op_SubX Op_SubI
aoqi@0 1762 #define Op_XorX Op_XorI
aoqi@0 1763 #define Op_URShiftX Op_URShiftI
aoqi@0 1764 // conversions
aoqi@0 1765 #define ConvI2X(x) (x)
aoqi@0 1766 #define ConvL2X(x) ConvL2I(x)
aoqi@0 1767 #define ConvX2I(x) (x)
aoqi@0 1768 #define ConvX2L(x) ConvI2L(x)
aoqi@0 1769 #define ConvX2UL(x) ConvI2UL(x)
aoqi@0 1770
aoqi@0 1771 #endif
aoqi@0 1772
aoqi@0 1773 #endif // SHARE_VM_OPTO_TYPE_HPP

mercurial