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