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