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