comparison src/share/vm/opto/type.cpp @ 14909:4ca6dc0799b6

Backout jdk9 merge
author Gilles Duboscq <duboscq@ssw.jku.at>
date Tue, 01 Apr 2014 13:57:07 +0200
parents 484a359ff649
children 52b4284cb496
comparison
equal deleted inserted replaced
14908:8db6e76cb658 14909:4ca6dc0799b6
59 { Bad, T_NARROWOOP, "narrowoop:", false, Op_RegN, relocInfo::none }, // NarrowOop 59 { Bad, T_NARROWOOP, "narrowoop:", false, Op_RegN, relocInfo::none }, // NarrowOop
60 { Bad, T_NARROWKLASS,"narrowklass:", false, Op_RegN, relocInfo::none }, // NarrowKlass 60 { Bad, T_NARROWKLASS,"narrowklass:", false, Op_RegN, relocInfo::none }, // NarrowKlass
61 { Bad, T_ILLEGAL, "tuple:", false, Node::NotAMachineReg, relocInfo::none }, // Tuple 61 { Bad, T_ILLEGAL, "tuple:", false, Node::NotAMachineReg, relocInfo::none }, // Tuple
62 { Bad, T_ARRAY, "array:", false, Node::NotAMachineReg, relocInfo::none }, // Array 62 { Bad, T_ARRAY, "array:", false, Node::NotAMachineReg, relocInfo::none }, // Array
63 63
64 #ifdef SPARC 64 #ifndef SPARC
65 { Bad, T_ILLEGAL, "vectors:", false, Op_VecS, relocInfo::none }, // VectorS
66 { Bad, T_ILLEGAL, "vectord:", false, Op_VecD, relocInfo::none }, // VectorD
67 { Bad, T_ILLEGAL, "vectorx:", false, Op_VecX, relocInfo::none }, // VectorX
68 { Bad, T_ILLEGAL, "vectory:", false, Op_VecY, relocInfo::none }, // VectorY
69 #else
65 { Bad, T_ILLEGAL, "vectors:", false, 0, relocInfo::none }, // VectorS 70 { Bad, T_ILLEGAL, "vectors:", false, 0, relocInfo::none }, // VectorS
66 { Bad, T_ILLEGAL, "vectord:", false, Op_RegD, relocInfo::none }, // VectorD 71 { Bad, T_ILLEGAL, "vectord:", false, Op_RegD, relocInfo::none }, // VectorD
67 { Bad, T_ILLEGAL, "vectorx:", false, 0, relocInfo::none }, // VectorX 72 { Bad, T_ILLEGAL, "vectorx:", false, 0, relocInfo::none }, // VectorX
68 { Bad, T_ILLEGAL, "vectory:", false, 0, relocInfo::none }, // VectorY 73 { Bad, T_ILLEGAL, "vectory:", false, 0, relocInfo::none }, // VectorY
69 #elif defined(PPC64) 74 #endif // IA32 || AMD64
70 { Bad, T_ILLEGAL, "vectors:", false, 0, relocInfo::none }, // VectorS
71 { Bad, T_ILLEGAL, "vectord:", false, Op_RegL, relocInfo::none }, // VectorD
72 { Bad, T_ILLEGAL, "vectorx:", false, 0, relocInfo::none }, // VectorX
73 { Bad, T_ILLEGAL, "vectory:", false, 0, relocInfo::none }, // VectorY
74 #else // all other
75 { Bad, T_ILLEGAL, "vectors:", false, Op_VecS, relocInfo::none }, // VectorS
76 { Bad, T_ILLEGAL, "vectord:", false, Op_VecD, relocInfo::none }, // VectorD
77 { Bad, T_ILLEGAL, "vectorx:", false, Op_VecX, relocInfo::none }, // VectorX
78 { Bad, T_ILLEGAL, "vectory:", false, Op_VecY, relocInfo::none }, // VectorY
79 #endif
80 { Bad, T_ADDRESS, "anyptr:", false, Op_RegP, relocInfo::none }, // AnyPtr 75 { Bad, T_ADDRESS, "anyptr:", false, Op_RegP, relocInfo::none }, // AnyPtr
81 { Bad, T_ADDRESS, "rawptr:", false, Op_RegP, relocInfo::none }, // RawPtr 76 { Bad, T_ADDRESS, "rawptr:", false, Op_RegP, relocInfo::none }, // RawPtr
82 { Bad, T_OBJECT, "oop:", true, Op_RegP, relocInfo::oop_type }, // OopPtr 77 { Bad, T_OBJECT, "oop:", true, Op_RegP, relocInfo::oop_type }, // OopPtr
83 { Bad, T_OBJECT, "inst:", true, Op_RegP, relocInfo::oop_type }, // InstPtr 78 { Bad, T_OBJECT, "inst:", true, Op_RegP, relocInfo::oop_type }, // InstPtr
84 { Bad, T_OBJECT, "ary:", true, Op_RegP, relocInfo::oop_type }, // AryPtr 79 { Bad, T_OBJECT, "ary:", true, Op_RegP, relocInfo::oop_type }, // AryPtr
239 return 1; // Missed badly 234 return 1; // Missed badly
240 assert(t1 != t2 || t1->eq(t2), "eq must be reflexive"); 235 assert(t1 != t2 || t1->eq(t2), "eq must be reflexive");
241 return !t1->eq(t2); // Return ZERO if equal 236 return !t1->eq(t2); // Return ZERO if equal
242 } 237 }
243 238
244 const Type* Type::maybe_remove_speculative(bool include_speculative) const {
245 if (!include_speculative) {
246 return remove_speculative();
247 }
248 return this;
249 }
250
251 //------------------------------hash------------------------------------------- 239 //------------------------------hash-------------------------------------------
252 int Type::uhash( const Type *const t ) { 240 int Type::uhash( const Type *const t ) {
253 return t->hash(); 241 return t->hash();
254 } 242 }
255 243
304 TypeInt::SHORT = TypeInt::make(-32768,32767, WidenMin); // Java shorts 292 TypeInt::SHORT = TypeInt::make(-32768,32767, WidenMin); // Java shorts
305 TypeInt::POS = TypeInt::make(0,max_jint, WidenMin); // Non-neg values 293 TypeInt::POS = TypeInt::make(0,max_jint, WidenMin); // Non-neg values
306 TypeInt::POS1 = TypeInt::make(1,max_jint, WidenMin); // Positive values 294 TypeInt::POS1 = TypeInt::make(1,max_jint, WidenMin); // Positive values
307 TypeInt::INT = TypeInt::make(min_jint,max_jint, WidenMax); // 32-bit integers 295 TypeInt::INT = TypeInt::make(min_jint,max_jint, WidenMax); // 32-bit integers
308 TypeInt::SYMINT = TypeInt::make(-max_jint,max_jint,WidenMin); // symmetric range 296 TypeInt::SYMINT = TypeInt::make(-max_jint,max_jint,WidenMin); // symmetric range
309 TypeInt::TYPE_DOMAIN = TypeInt::INT;
310 // CmpL is overloaded both as the bytecode computation returning 297 // CmpL is overloaded both as the bytecode computation returning
311 // a trinary (-1,0,+1) integer result AND as an efficient long 298 // a trinary (-1,0,+1) integer result AND as an efficient long
312 // compare returning optimizer ideal-type flags. 299 // compare returning optimizer ideal-type flags.
313 assert( TypeInt::CC_LT == TypeInt::MINUS_1, "types must match for CmpL to work" ); 300 assert( TypeInt::CC_LT == TypeInt::MINUS_1, "types must match for CmpL to work" );
314 assert( TypeInt::CC_GT == TypeInt::ONE, "types must match for CmpL to work" ); 301 assert( TypeInt::CC_GT == TypeInt::ONE, "types must match for CmpL to work" );
321 TypeLong::ONE = TypeLong::make( 1); // 1 308 TypeLong::ONE = TypeLong::make( 1); // 1
322 TypeLong::POS = TypeLong::make(0,max_jlong, WidenMin); // Non-neg values 309 TypeLong::POS = TypeLong::make(0,max_jlong, WidenMin); // Non-neg values
323 TypeLong::LONG = TypeLong::make(min_jlong,max_jlong,WidenMax); // 64-bit integers 310 TypeLong::LONG = TypeLong::make(min_jlong,max_jlong,WidenMax); // 64-bit integers
324 TypeLong::INT = TypeLong::make((jlong)min_jint,(jlong)max_jint,WidenMin); 311 TypeLong::INT = TypeLong::make((jlong)min_jint,(jlong)max_jint,WidenMin);
325 TypeLong::UINT = TypeLong::make(0,(jlong)max_juint,WidenMin); 312 TypeLong::UINT = TypeLong::make(0,(jlong)max_juint,WidenMin);
326 TypeLong::TYPE_DOMAIN = TypeLong::LONG;
327 313
328 const Type **fboth =(const Type**)shared_type_arena->Amalloc_4(2*sizeof(Type*)); 314 const Type **fboth =(const Type**)shared_type_arena->Amalloc_4(2*sizeof(Type*));
329 fboth[0] = Type::CONTROL; 315 fboth[0] = Type::CONTROL;
330 fboth[1] = Type::CONTROL; 316 fboth[1] = Type::CONTROL;
331 TypeTuple::IFBOTH = TypeTuple::make( 2, fboth ); 317 TypeTuple::IFBOTH = TypeTuple::make( 2, fboth );
640 #endif 626 #endif
641 627
642 //------------------------------meet------------------------------------------- 628 //------------------------------meet-------------------------------------------
643 // Compute the MEET of two types. NOT virtual. It enforces that meet is 629 // Compute the MEET of two types. NOT virtual. It enforces that meet is
644 // commutative and the lattice is symmetric. 630 // commutative and the lattice is symmetric.
645 const Type *Type::meet_helper(const Type *t, bool include_speculative) const { 631 const Type *Type::meet( const Type *t ) const {
646 if (isa_narrowoop() && t->isa_narrowoop()) { 632 if (isa_narrowoop() && t->isa_narrowoop()) {
647 const Type* result = make_ptr()->meet_helper(t->make_ptr(), include_speculative); 633 const Type* result = make_ptr()->meet(t->make_ptr());
648 return result->make_narrowoop(); 634 return result->make_narrowoop();
649 } 635 }
650 if (isa_narrowklass() && t->isa_narrowklass()) { 636 if (isa_narrowklass() && t->isa_narrowklass()) {
651 const Type* result = make_ptr()->meet_helper(t->make_ptr(), include_speculative); 637 const Type* result = make_ptr()->meet(t->make_ptr());
652 return result->make_narrowklass(); 638 return result->make_narrowklass();
653 } 639 }
654 640
655 const Type *this_t = maybe_remove_speculative(include_speculative); 641 const Type *mt = xmeet(t);
656 t = t->maybe_remove_speculative(include_speculative);
657
658 const Type *mt = this_t->xmeet(t);
659 if (isa_narrowoop() || t->isa_narrowoop()) return mt; 642 if (isa_narrowoop() || t->isa_narrowoop()) return mt;
660 if (isa_narrowklass() || t->isa_narrowklass()) return mt; 643 if (isa_narrowklass() || t->isa_narrowklass()) return mt;
661 #ifdef ASSERT 644 #ifdef ASSERT
662 assert(mt == t->xmeet(this_t), "meet not commutative"); 645 assert( mt == t->xmeet(this), "meet not commutative" );
663 const Type* dual_join = mt->_dual; 646 const Type* dual_join = mt->_dual;
664 const Type *t2t = dual_join->xmeet(t->_dual); 647 const Type *t2t = dual_join->xmeet(t->_dual);
665 const Type *t2this = dual_join->xmeet(this_t->_dual); 648 const Type *t2this = dual_join->xmeet( _dual);
666 649
667 // Interface meet Oop is Not Symmetric: 650 // Interface meet Oop is Not Symmetric:
668 // Interface:AnyNull meet Oop:AnyNull == Interface:AnyNull 651 // Interface:AnyNull meet Oop:AnyNull == Interface:AnyNull
669 // Interface:NotNull meet Oop:NotNull == java/lang/Object:NotNull 652 // Interface:NotNull meet Oop:NotNull == java/lang/Object:NotNull
670 653
671 if( !interface_vs_oop(t) && (t2t != t->_dual || t2this != this_t->_dual) ) { 654 if( !interface_vs_oop(t) && (t2t != t->_dual || t2this != _dual) ) {
672 tty->print_cr("=== Meet Not Symmetric ==="); 655 tty->print_cr("=== Meet Not Symmetric ===");
673 tty->print("t = "); t->dump(); tty->cr(); 656 tty->print("t = "); t->dump(); tty->cr();
674 tty->print("this= "); this_t->dump(); tty->cr(); 657 tty->print("this= "); dump(); tty->cr();
675 tty->print("mt=(t meet this)= "); mt->dump(); tty->cr(); 658 tty->print("mt=(t meet this)= "); mt->dump(); tty->cr();
676 659
677 tty->print("t_dual= "); t->_dual->dump(); tty->cr(); 660 tty->print("t_dual= "); t->_dual->dump(); tty->cr();
678 tty->print("this_dual= "); this_t->_dual->dump(); tty->cr(); 661 tty->print("this_dual= "); _dual->dump(); tty->cr();
679 tty->print("mt_dual= "); mt->_dual->dump(); tty->cr(); 662 tty->print("mt_dual= "); mt->_dual->dump(); tty->cr();
680 663
681 tty->print("mt_dual meet t_dual= "); t2t ->dump(); tty->cr(); 664 tty->print("mt_dual meet t_dual= "); t2t ->dump(); tty->cr();
682 tty->print("mt_dual meet this_dual= "); t2this ->dump(); tty->cr(); 665 tty->print("mt_dual meet this_dual= "); t2this ->dump(); tty->cr();
683 666
684 fatal("meet not symmetric" ); 667 fatal("meet not symmetric" );
685 } 668 }
686 #endif 669 #endif
687 return mt; 670 return mt;
769 // The type is unchanged 752 // The type is unchanged
770 return this; 753 return this;
771 } 754 }
772 755
773 //-----------------------------filter------------------------------------------ 756 //-----------------------------filter------------------------------------------
774 const Type *Type::filter_helper(const Type *kills, bool include_speculative) const { 757 const Type *Type::filter( const Type *kills ) const {
775 const Type* ft = join_helper(kills, include_speculative); 758 const Type* ft = join(kills);
776 if (ft->empty()) 759 if (ft->empty())
777 return Type::TOP; // Canonical empty value 760 return Type::TOP; // Canonical empty value
778 return ft; 761 return ft;
779 } 762 }
780 763
1161 const TypeInt *TypeInt::SHORT; // Java shorts, -32768-32767 1144 const TypeInt *TypeInt::SHORT; // Java shorts, -32768-32767
1162 const TypeInt *TypeInt::POS; // Positive 32-bit integers or zero 1145 const TypeInt *TypeInt::POS; // Positive 32-bit integers or zero
1163 const TypeInt *TypeInt::POS1; // Positive 32-bit integers 1146 const TypeInt *TypeInt::POS1; // Positive 32-bit integers
1164 const TypeInt *TypeInt::INT; // 32-bit integers 1147 const TypeInt *TypeInt::INT; // 32-bit integers
1165 const TypeInt *TypeInt::SYMINT; // symmetric range [-max_jint..max_jint] 1148 const TypeInt *TypeInt::SYMINT; // symmetric range [-max_jint..max_jint]
1166 const TypeInt *TypeInt::TYPE_DOMAIN; // alias for TypeInt::INT
1167 1149
1168 //------------------------------TypeInt---------------------------------------- 1150 //------------------------------TypeInt----------------------------------------
1169 TypeInt::TypeInt( jint lo, jint hi, int w ) : Type(Int), _lo(lo), _hi(hi), _widen(w) { 1151 TypeInt::TypeInt( jint lo, jint hi, int w ) : Type(Int), _lo(lo), _hi(hi), _widen(w) {
1170 } 1152 }
1171 1153
1325 1307
1326 return this; 1308 return this;
1327 } 1309 }
1328 1310
1329 //-----------------------------filter------------------------------------------ 1311 //-----------------------------filter------------------------------------------
1330 const Type *TypeInt::filter_helper(const Type *kills, bool include_speculative) const { 1312 const Type *TypeInt::filter( const Type *kills ) const {
1331 const TypeInt* ft = join_helper(kills, include_speculative)->isa_int(); 1313 const TypeInt* ft = join(kills)->isa_int();
1332 if (ft == NULL || ft->empty()) 1314 if (ft == NULL || ft->empty())
1333 return Type::TOP; // Canonical empty value 1315 return Type::TOP; // Canonical empty value
1334 if (ft->_widen < this->_widen) { 1316 if (ft->_widen < this->_widen) {
1335 // Do not allow the value of kill->_widen to affect the outcome. 1317 // Do not allow the value of kill->_widen to affect the outcome.
1336 // The widen bits must be allowed to run freely through the graph. 1318 // The widen bits must be allowed to run freely through the graph.
1419 const TypeLong *TypeLong::ONE; // 1 1401 const TypeLong *TypeLong::ONE; // 1
1420 const TypeLong *TypeLong::POS; // >=0 1402 const TypeLong *TypeLong::POS; // >=0
1421 const TypeLong *TypeLong::LONG; // 64-bit integers 1403 const TypeLong *TypeLong::LONG; // 64-bit integers
1422 const TypeLong *TypeLong::INT; // 32-bit subrange 1404 const TypeLong *TypeLong::INT; // 32-bit subrange
1423 const TypeLong *TypeLong::UINT; // 32-bit unsigned subrange 1405 const TypeLong *TypeLong::UINT; // 32-bit unsigned subrange
1424 const TypeLong *TypeLong::TYPE_DOMAIN; // alias for TypeLong::LONG
1425 1406
1426 //------------------------------TypeLong--------------------------------------- 1407 //------------------------------TypeLong---------------------------------------
1427 TypeLong::TypeLong( jlong lo, jlong hi, int w ) : Type(Long), _lo(lo), _hi(hi), _widen(w) { 1408 TypeLong::TypeLong( jlong lo, jlong hi, int w ) : Type(Long), _lo(lo), _hi(hi), _widen(w) {
1428 } 1409 }
1429 1410
1587 1568
1588 return this; 1569 return this;
1589 } 1570 }
1590 1571
1591 //-----------------------------filter------------------------------------------ 1572 //-----------------------------filter------------------------------------------
1592 const Type *TypeLong::filter_helper(const Type *kills, bool include_speculative) const { 1573 const Type *TypeLong::filter( const Type *kills ) const {
1593 const TypeLong* ft = join_helper(kills, include_speculative)->isa_long(); 1574 const TypeLong* ft = join(kills)->isa_long();
1594 if (ft == NULL || ft->empty()) 1575 if (ft == NULL || ft->empty())
1595 return Type::TOP; // Canonical empty value 1576 return Type::TOP; // Canonical empty value
1596 if (ft->_widen < this->_widen) { 1577 if (ft->_widen < this->_widen) {
1597 // Do not allow the value of kill->_widen to affect the outcome. 1578 // Do not allow the value of kill->_widen to affect the outcome.
1598 // The widen bits must be allowed to run freely through the graph. 1579 // The widen bits must be allowed to run freely through the graph.
1743 const Type **field_array; 1724 const Type **field_array;
1744 if (recv != NULL) { 1725 if (recv != NULL) {
1745 total_fields++; 1726 total_fields++;
1746 field_array = fields(total_fields); 1727 field_array = fields(total_fields);
1747 // Use get_const_type here because it respects UseUniqueSubclasses: 1728 // Use get_const_type here because it respects UseUniqueSubclasses:
1748 field_array[pos++] = get_const_type(recv)->join_speculative(TypePtr::NOTNULL); 1729 field_array[pos++] = get_const_type(recv)->join(TypePtr::NOTNULL);
1749 } else { 1730 } else {
1750 field_array = fields(total_fields); 1731 field_array = fields(total_fields);
1751 } 1732 }
1752 1733
1753 int i = 0; 1734 int i = 0;
1933 default: // All else is a mistake 1914 default: // All else is a mistake
1934 typerr(t); 1915 typerr(t);
1935 1916
1936 case Array: { // Meeting 2 arrays? 1917 case Array: { // Meeting 2 arrays?
1937 const TypeAry *a = t->is_ary(); 1918 const TypeAry *a = t->is_ary();
1938 return TypeAry::make(_elem->meet_speculative(a->_elem), 1919 return TypeAry::make(_elem->meet(a->_elem),
1939 _size->xmeet(a->_size)->is_int(), 1920 _size->xmeet(a->_size)->is_int(),
1940 _stable & a->_stable); 1921 _stable & a->_stable);
1941 } 1922 }
1942 case Top: 1923 case Top:
1943 break; 1924 break;
1964 1945
1965 //------------------------------hash------------------------------------------- 1946 //------------------------------hash-------------------------------------------
1966 // Type-specific hashing function. 1947 // Type-specific hashing function.
1967 int TypeAry::hash(void) const { 1948 int TypeAry::hash(void) const {
1968 return (intptr_t)_elem + (intptr_t)_size + (_stable ? 43 : 0); 1949 return (intptr_t)_elem + (intptr_t)_size + (_stable ? 43 : 0);
1969 }
1970
1971 /**
1972 * Return same type without a speculative part in the element
1973 */
1974 const Type* TypeAry::remove_speculative() const {
1975 return make(_elem->remove_speculative(), _size, _stable);
1976 } 1950 }
1977 1951
1978 //----------------------interface_vs_oop--------------------------------------- 1952 //----------------------interface_vs_oop---------------------------------------
1979 #ifdef ASSERT 1953 #ifdef ASSERT
1980 bool TypeAry::interface_vs_oop(const Type *t) const { 1954 bool TypeAry::interface_vs_oop(const Type *t) const {
2059 assert(Matcher::vector_size_supported(elem_bt, length), "length in range"); 2033 assert(Matcher::vector_size_supported(elem_bt, length), "length in range");
2060 int size = length * type2aelembytes(elem_bt); 2034 int size = length * type2aelembytes(elem_bt);
2061 switch (Matcher::vector_ideal_reg(size)) { 2035 switch (Matcher::vector_ideal_reg(size)) {
2062 case Op_VecS: 2036 case Op_VecS:
2063 return (TypeVect*)(new TypeVectS(elem, length))->hashcons(); 2037 return (TypeVect*)(new TypeVectS(elem, length))->hashcons();
2064 case Op_RegL:
2065 case Op_VecD: 2038 case Op_VecD:
2066 case Op_RegD: 2039 case Op_RegD:
2067 return (TypeVect*)(new TypeVectD(elem, length))->hashcons(); 2040 return (TypeVect*)(new TypeVectD(elem, length))->hashcons();
2068 case Op_VecX: 2041 case Op_VecX:
2069 return (TypeVect*)(new TypeVectX(elem, length))->hashcons(); 2042 return (TypeVect*)(new TypeVectX(elem, length))->hashcons();
2461 //============================================================================= 2434 //=============================================================================
2462 // Convenience common pre-built type. 2435 // Convenience common pre-built type.
2463 const TypeOopPtr *TypeOopPtr::BOTTOM; 2436 const TypeOopPtr *TypeOopPtr::BOTTOM;
2464 2437
2465 //------------------------------TypeOopPtr------------------------------------- 2438 //------------------------------TypeOopPtr-------------------------------------
2466 TypeOopPtr::TypeOopPtr(TYPES t, PTR ptr, ciKlass* k, bool xk, ciObject* o, int offset, int instance_id, const TypeOopPtr* speculative, int inline_depth) 2439 TypeOopPtr::TypeOopPtr(TYPES t, PTR ptr, ciKlass* k, bool xk, ciObject* o, int offset, int instance_id, const TypeOopPtr* speculative)
2467 : TypePtr(t, ptr, offset), 2440 : TypePtr(t, ptr, offset),
2468 _const_oop(o), _klass(k), 2441 _const_oop(o), _klass(k),
2469 _klass_is_exact(xk), 2442 _klass_is_exact(xk),
2470 _is_ptr_to_narrowoop(false), 2443 _is_ptr_to_narrowoop(false),
2471 _is_ptr_to_narrowklass(false), 2444 _is_ptr_to_narrowklass(false),
2472 _is_ptr_to_boxed_value(false), 2445 _is_ptr_to_boxed_value(false),
2473 _instance_id(instance_id), 2446 _instance_id(instance_id),
2474 _speculative(speculative), 2447 _speculative(speculative) {
2475 _inline_depth(inline_depth){
2476 if (Compile::current()->eliminate_boxing() && (t == InstPtr) && 2448 if (Compile::current()->eliminate_boxing() && (t == InstPtr) &&
2477 (offset > 0) && xk && (k != 0) && k->is_instance_klass()) { 2449 (offset > 0) && xk && (k != 0) && k->is_instance_klass()) {
2478 _is_ptr_to_boxed_value = k->as_instance_klass()->is_boxed_value_offset(offset); 2450 _is_ptr_to_boxed_value = k->as_instance_klass()->is_boxed_value_offset(offset);
2479 } 2451 }
2480 #ifdef _LP64 2452 #ifdef _LP64
2537 #endif 2509 #endif
2538 } 2510 }
2539 2511
2540 //------------------------------make------------------------------------------- 2512 //------------------------------make-------------------------------------------
2541 const TypeOopPtr *TypeOopPtr::make(PTR ptr, 2513 const TypeOopPtr *TypeOopPtr::make(PTR ptr,
2542 int offset, int instance_id, const TypeOopPtr* speculative, int inline_depth) { 2514 int offset, int instance_id, const TypeOopPtr* speculative) {
2543 assert(ptr != Constant, "no constant generic pointers"); 2515 assert(ptr != Constant, "no constant generic pointers");
2544 ciKlass* k = Compile::current()->env()->Object_klass(); 2516 ciKlass* k = Compile::current()->env()->Object_klass();
2545 bool xk = false; 2517 bool xk = false;
2546 ciObject* o = NULL; 2518 ciObject* o = NULL;
2547 return (TypeOopPtr*)(new TypeOopPtr(OopPtr, ptr, k, xk, o, offset, instance_id, speculative, inline_depth))->hashcons(); 2519 return (TypeOopPtr*)(new TypeOopPtr(OopPtr, ptr, k, xk, o, offset, instance_id, speculative))->hashcons();
2548 } 2520 }
2549 2521
2550 2522
2551 //------------------------------cast_to_ptr_type------------------------------- 2523 //------------------------------cast_to_ptr_type-------------------------------
2552 const Type *TypeOopPtr::cast_to_ptr_type(PTR ptr) const { 2524 const Type *TypeOopPtr::cast_to_ptr_type(PTR ptr) const {
2553 assert(_base == OopPtr, "subclass must override cast_to_ptr_type"); 2525 assert(_base == OopPtr, "subclass must override cast_to_ptr_type");
2554 if( ptr == _ptr ) return this; 2526 if( ptr == _ptr ) return this;
2555 return make(ptr, _offset, _instance_id, _speculative, _inline_depth); 2527 return make(ptr, _offset, _instance_id, _speculative);
2556 } 2528 }
2557 2529
2558 //-----------------------------cast_to_instance_id---------------------------- 2530 //-----------------------------cast_to_instance_id----------------------------
2559 const TypeOopPtr *TypeOopPtr::cast_to_instance_id(int instance_id) const { 2531 const TypeOopPtr *TypeOopPtr::cast_to_instance_id(int instance_id) const {
2560 // There are no instances of a general oop. 2532 // There are no instances of a general oop.
2586 const Type* res = xmeet_helper(t); 2558 const Type* res = xmeet_helper(t);
2587 if (res->isa_oopptr() == NULL) { 2559 if (res->isa_oopptr() == NULL) {
2588 return res; 2560 return res;
2589 } 2561 }
2590 2562
2591 const TypeOopPtr* res_oopptr = res->is_oopptr(); 2563 if (res->isa_oopptr() != NULL) {
2592 if (res_oopptr->speculative() != NULL) {
2593 // type->speculative() == NULL means that speculation is no better 2564 // type->speculative() == NULL means that speculation is no better
2594 // than type, i.e. type->speculative() == type. So there are 2 2565 // than type, i.e. type->speculative() == type. So there are 2
2595 // ways to represent the fact that we have no useful speculative 2566 // ways to represent the fact that we have no useful speculative
2596 // data and we should use a single one to be able to test for 2567 // data and we should use a single one to be able to test for
2597 // equality between types. Check whether type->speculative() == 2568 // equality between types. Check whether type->speculative() ==
2598 // type and set speculative to NULL if it is the case. 2569 // type and set speculative to NULL if it is the case.
2570 const TypeOopPtr* res_oopptr = res->is_oopptr();
2599 if (res_oopptr->remove_speculative() == res_oopptr->speculative()) { 2571 if (res_oopptr->remove_speculative() == res_oopptr->speculative()) {
2600 return res_oopptr->remove_speculative(); 2572 return res_oopptr->remove_speculative();
2601 } 2573 }
2602 } 2574 }
2603 2575
2647 // else fall through: 2619 // else fall through:
2648 case TopPTR: 2620 case TopPTR:
2649 case AnyNull: { 2621 case AnyNull: {
2650 int instance_id = meet_instance_id(InstanceTop); 2622 int instance_id = meet_instance_id(InstanceTop);
2651 const TypeOopPtr* speculative = _speculative; 2623 const TypeOopPtr* speculative = _speculative;
2652 return make(ptr, offset, instance_id, speculative, _inline_depth); 2624 return make(ptr, offset, instance_id, speculative);
2653 } 2625 }
2654 case BotPTR: 2626 case BotPTR:
2655 case NotNull: 2627 case NotNull:
2656 return TypePtr::make(AnyPtr, ptr, offset); 2628 return TypePtr::make(AnyPtr, ptr, offset);
2657 default: typerr(t); 2629 default: typerr(t);
2659 } 2631 }
2660 2632
2661 case OopPtr: { // Meeting to other OopPtrs 2633 case OopPtr: { // Meeting to other OopPtrs
2662 const TypeOopPtr *tp = t->is_oopptr(); 2634 const TypeOopPtr *tp = t->is_oopptr();
2663 int instance_id = meet_instance_id(tp->instance_id()); 2635 int instance_id = meet_instance_id(tp->instance_id());
2664 const TypeOopPtr* speculative = xmeet_speculative(tp); 2636 const TypeOopPtr* speculative = meet_speculative(tp);
2665 int depth = meet_inline_depth(tp->inline_depth()); 2637 return make(meet_ptr(tp->ptr()), meet_offset(tp->offset()), instance_id, speculative);
2666 return make(meet_ptr(tp->ptr()), meet_offset(tp->offset()), instance_id, speculative, depth);
2667 } 2638 }
2668 2639
2669 case InstPtr: // For these, flip the call around to cut down 2640 case InstPtr: // For these, flip the call around to cut down
2670 case AryPtr: 2641 case AryPtr:
2671 return t->xmeet(this); // Call in reverse direction 2642 return t->xmeet(this); // Call in reverse direction
2678 //------------------------------xdual------------------------------------------ 2649 //------------------------------xdual------------------------------------------
2679 // Dual of a pure heap pointer. No relevant klass or oop information. 2650 // Dual of a pure heap pointer. No relevant klass or oop information.
2680 const Type *TypeOopPtr::xdual() const { 2651 const Type *TypeOopPtr::xdual() const {
2681 assert(klass() == Compile::current()->env()->Object_klass(), "no klasses here"); 2652 assert(klass() == Compile::current()->env()->Object_klass(), "no klasses here");
2682 assert(const_oop() == NULL, "no constants here"); 2653 assert(const_oop() == NULL, "no constants here");
2683 return new TypeOopPtr(_base, dual_ptr(), klass(), klass_is_exact(), const_oop(), dual_offset(), dual_instance_id(), dual_speculative(), dual_inline_depth()); 2654 return new TypeOopPtr(_base, dual_ptr(), klass(), klass_is_exact(), const_oop(), dual_offset(), dual_instance_id(), dual_speculative());
2684 } 2655 }
2685 2656
2686 //--------------------------make_from_klass_common----------------------------- 2657 //--------------------------make_from_klass_common-----------------------------
2687 // Computes the element-type given a klass. 2658 // Computes the element-type given a klass.
2688 const TypeOopPtr* TypeOopPtr::make_from_klass_common(ciKlass *klass, bool klass_change, bool try_for_exact) { 2659 const TypeOopPtr* TypeOopPtr::make_from_klass_common(ciKlass *klass, bool klass_change, bool try_for_exact) {
2769 if (require_constant) { 2740 if (require_constant) {
2770 if (!o->can_be_constant()) return NULL; 2741 if (!o->can_be_constant()) return NULL;
2771 } else if (!o->should_be_constant()) { 2742 } else if (!o->should_be_constant()) {
2772 return TypeAryPtr::make(TypePtr::NotNull, arr0, klass, true, 0); 2743 return TypeAryPtr::make(TypePtr::NotNull, arr0, klass, true, 0);
2773 } 2744 }
2774 const TypeAryPtr* arr = TypeAryPtr::make(TypePtr::Constant, o, arr0, klass, true, 0, InstanceBot, NULL, InlineDepthBottom, is_autobox_cache); 2745 const TypeAryPtr* arr = TypeAryPtr::make(TypePtr::Constant, o, arr0, klass, true, 0, InstanceBot, NULL, is_autobox_cache);
2775 return arr; 2746 return arr;
2776 } else if (klass->is_type_array_klass()) { 2747 } else if (klass->is_type_array_klass()) {
2777 // Element is an typeArray 2748 // Element is an typeArray
2778 const Type* etype = 2749 const Type* etype =
2779 (Type*)get_const_basic_type(klass->as_type_array_klass()->element_type()); 2750 (Type*)get_const_basic_type(klass->as_type_array_klass()->element_type());
2814 } 2785 }
2815 2786
2816 2787
2817 //-----------------------------filter------------------------------------------ 2788 //-----------------------------filter------------------------------------------
2818 // Do not allow interface-vs.-noninterface joins to collapse to top. 2789 // Do not allow interface-vs.-noninterface joins to collapse to top.
2819 const Type *TypeOopPtr::filter_helper(const Type *kills, bool include_speculative) const { 2790 const Type *TypeOopPtr::filter(const Type *kills) const {
2820 2791
2821 const Type* ft = join_helper(kills, include_speculative); 2792 const Type* ft = join(kills);
2822 const TypeInstPtr* ftip = ft->isa_instptr(); 2793 const TypeInstPtr* ftip = ft->isa_instptr();
2823 const TypeInstPtr* ktip = kills->isa_instptr(); 2794 const TypeInstPtr* ktip = kills->isa_instptr();
2824 2795
2825 if (ft->empty()) { 2796 if (ft->empty()) {
2826 // Check for evil case of 'this' being a class and 'kills' expecting an 2797 // Check for evil case of 'this' being a class and 'kills' expecting an
2858 // Structural equality check for Type representations 2829 // Structural equality check for Type representations
2859 bool TypeOopPtr::eq( const Type *t ) const { 2830 bool TypeOopPtr::eq( const Type *t ) const {
2860 const TypeOopPtr *a = (const TypeOopPtr*)t; 2831 const TypeOopPtr *a = (const TypeOopPtr*)t;
2861 if (_klass_is_exact != a->_klass_is_exact || 2832 if (_klass_is_exact != a->_klass_is_exact ||
2862 _instance_id != a->_instance_id || 2833 _instance_id != a->_instance_id ||
2863 !eq_speculative(a) || 2834 !eq_speculative(a)) return false;
2864 _inline_depth != a->_inline_depth) return false;
2865 ciObject* one = const_oop(); 2835 ciObject* one = const_oop();
2866 ciObject* two = a->const_oop(); 2836 ciObject* two = a->const_oop();
2867 if (one == NULL || two == NULL) { 2837 if (one == NULL || two == NULL) {
2868 return (one == two) && TypePtr::eq(t); 2838 return (one == two) && TypePtr::eq(t);
2869 } else { 2839 } else {
2877 return 2847 return
2878 (const_oop() ? const_oop()->hash() : 0) + 2848 (const_oop() ? const_oop()->hash() : 0) +
2879 _klass_is_exact + 2849 _klass_is_exact +
2880 _instance_id + 2850 _instance_id +
2881 hash_speculative() + 2851 hash_speculative() +
2882 _inline_depth +
2883 TypePtr::hash(); 2852 TypePtr::hash();
2884 } 2853 }
2885 2854
2886 //------------------------------dump2------------------------------------------ 2855 //------------------------------dump2------------------------------------------
2887 #ifndef PRODUCT 2856 #ifndef PRODUCT
2898 if (_instance_id == InstanceTop) 2867 if (_instance_id == InstanceTop)
2899 st->print(",iid=top"); 2868 st->print(",iid=top");
2900 else if (_instance_id != InstanceBot) 2869 else if (_instance_id != InstanceBot)
2901 st->print(",iid=%d",_instance_id); 2870 st->print(",iid=%d",_instance_id);
2902 2871
2903 dump_inline_depth(st);
2904 dump_speculative(st); 2872 dump_speculative(st);
2905 } 2873 }
2906 2874
2907 /** 2875 /**
2908 *dump the speculative part of the type 2876 *dump the speculative part of the type
2912 st->print(" (speculative="); 2880 st->print(" (speculative=");
2913 _speculative->dump_on(st); 2881 _speculative->dump_on(st);
2914 st->print(")"); 2882 st->print(")");
2915 } 2883 }
2916 } 2884 }
2917
2918 void TypeOopPtr::dump_inline_depth(outputStream *st) const {
2919 if (_inline_depth != InlineDepthBottom) {
2920 if (_inline_depth == InlineDepthTop) {
2921 st->print(" (inline_depth=InlineDepthTop)");
2922 } else {
2923 st->print(" (inline_depth=%d)", _inline_depth);
2924 }
2925 }
2926 }
2927 #endif 2885 #endif
2928 2886
2929 //------------------------------singleton-------------------------------------- 2887 //------------------------------singleton--------------------------------------
2930 // TRUE if Type is a singleton type, FALSE otherwise. Singletons are simple 2888 // TRUE if Type is a singleton type, FALSE otherwise. Singletons are simple
2931 // constants 2889 // constants
2935 return (_offset == 0) && !below_centerline(_ptr); 2893 return (_offset == 0) && !below_centerline(_ptr);
2936 } 2894 }
2937 2895
2938 //------------------------------add_offset------------------------------------- 2896 //------------------------------add_offset-------------------------------------
2939 const TypePtr *TypeOopPtr::add_offset(intptr_t offset) const { 2897 const TypePtr *TypeOopPtr::add_offset(intptr_t offset) const {
2940 return make(_ptr, xadd_offset(offset), _instance_id, add_offset_speculative(offset), _inline_depth); 2898 return make(_ptr, xadd_offset(offset), _instance_id, add_offset_speculative(offset));
2941 } 2899 }
2942 2900
2943 /** 2901 /**
2944 * Return same type without a speculative part 2902 * Return same type without a speculative part
2945 */ 2903 */
2946 const Type* TypeOopPtr::remove_speculative() const { 2904 const TypeOopPtr* TypeOopPtr::remove_speculative() const {
2947 if (_speculative == NULL) { 2905 return make(_ptr, _offset, _instance_id, NULL);
2948 return this;
2949 }
2950 assert(_inline_depth == InlineDepthTop || _inline_depth == InlineDepthBottom, "non speculative type shouldn't have inline depth");
2951 return make(_ptr, _offset, _instance_id, NULL, _inline_depth);
2952 }
2953
2954 /**
2955 * Return same type but with a different inline depth (used for speculation)
2956 *
2957 * @param depth depth to meet with
2958 */
2959 const TypeOopPtr* TypeOopPtr::with_inline_depth(int depth) const {
2960 if (!UseInlineDepthForSpeculativeTypes) {
2961 return this;
2962 }
2963 return make(_ptr, _offset, _instance_id, _speculative, depth);
2964 }
2965
2966 /**
2967 * Check whether new profiling would improve speculative type
2968 *
2969 * @param exact_kls class from profiling
2970 * @param inline_depth inlining depth of profile point
2971 *
2972 * @return true if type profile is valuable
2973 */
2974 bool TypeOopPtr::would_improve_type(ciKlass* exact_kls, int inline_depth) const {
2975 // no way to improve an already exact type
2976 if (klass_is_exact()) {
2977 return false;
2978 }
2979 // no profiling?
2980 if (exact_kls == NULL) {
2981 return false;
2982 }
2983 // no speculative type or non exact speculative type?
2984 if (speculative_type() == NULL) {
2985 return true;
2986 }
2987 // If the node already has an exact speculative type keep it,
2988 // unless it was provided by profiling that is at a deeper
2989 // inlining level. Profiling at a higher inlining depth is
2990 // expected to be less accurate.
2991 if (_speculative->inline_depth() == InlineDepthBottom) {
2992 return false;
2993 }
2994 assert(_speculative->inline_depth() != InlineDepthTop, "can't do the comparison");
2995 return inline_depth < _speculative->inline_depth();
2996 } 2906 }
2997 2907
2998 //------------------------------meet_instance_id-------------------------------- 2908 //------------------------------meet_instance_id--------------------------------
2999 int TypeOopPtr::meet_instance_id( int instance_id ) const { 2909 int TypeOopPtr::meet_instance_id( int instance_id ) const {
3000 // Either is 'TOP' instance? Return the other instance! 2910 // Either is 'TOP' instance? Return the other instance!
3015 /** 2925 /**
3016 * meet of the speculative parts of 2 types 2926 * meet of the speculative parts of 2 types
3017 * 2927 *
3018 * @param other type to meet with 2928 * @param other type to meet with
3019 */ 2929 */
3020 const TypeOopPtr* TypeOopPtr::xmeet_speculative(const TypeOopPtr* other) const { 2930 const TypeOopPtr* TypeOopPtr::meet_speculative(const TypeOopPtr* other) const {
3021 bool this_has_spec = (_speculative != NULL); 2931 bool this_has_spec = (_speculative != NULL);
3022 bool other_has_spec = (other->speculative() != NULL); 2932 bool other_has_spec = (other->speculative() != NULL);
3023 2933
3024 if (!this_has_spec && !other_has_spec) { 2934 if (!this_has_spec && !other_has_spec) {
3025 return NULL; 2935 return NULL;
3040 2950
3041 if (!other_has_spec) { 2951 if (!other_has_spec) {
3042 other_spec = other; 2952 other_spec = other;
3043 } 2953 }
3044 2954
3045 return this_spec->meet_speculative(other_spec)->is_oopptr(); 2955 return this_spec->meet(other_spec)->is_oopptr();
3046 } 2956 }
3047 2957
3048 /** 2958 /**
3049 * dual of the speculative part of the type 2959 * dual of the speculative part of the type
3050 */ 2960 */
3093 } 3003 }
3094 3004
3095 return _speculative->hash(); 3005 return _speculative->hash();
3096 } 3006 }
3097 3007
3098 /**
3099 * dual of the inline depth for this type (used for speculation)
3100 */
3101 int TypeOopPtr::dual_inline_depth() const {
3102 return -inline_depth();
3103 }
3104
3105 /**
3106 * meet of 2 inline depth (used for speculation)
3107 *
3108 * @param depth depth to meet with
3109 */
3110 int TypeOopPtr::meet_inline_depth(int depth) const {
3111 return MAX2(inline_depth(), depth);
3112 }
3113 3008
3114 //============================================================================= 3009 //=============================================================================
3115 // Convenience common pre-built types. 3010 // Convenience common pre-built types.
3116 const TypeInstPtr *TypeInstPtr::NOTNULL; 3011 const TypeInstPtr *TypeInstPtr::NOTNULL;
3117 const TypeInstPtr *TypeInstPtr::BOTTOM; 3012 const TypeInstPtr *TypeInstPtr::BOTTOM;
3118 const TypeInstPtr *TypeInstPtr::MIRROR; 3013 const TypeInstPtr *TypeInstPtr::MIRROR;
3119 const TypeInstPtr *TypeInstPtr::MARK; 3014 const TypeInstPtr *TypeInstPtr::MARK;
3120 const TypeInstPtr *TypeInstPtr::KLASS; 3015 const TypeInstPtr *TypeInstPtr::KLASS;
3121 3016
3122 //------------------------------TypeInstPtr------------------------------------- 3017 //------------------------------TypeInstPtr-------------------------------------
3123 TypeInstPtr::TypeInstPtr(PTR ptr, ciKlass* k, bool xk, ciObject* o, int off, int instance_id, const TypeOopPtr* speculative, int inline_depth) 3018 TypeInstPtr::TypeInstPtr(PTR ptr, ciKlass* k, bool xk, ciObject* o, int off, int instance_id, const TypeOopPtr* speculative)
3124 : TypeOopPtr(InstPtr, ptr, k, xk, o, off, instance_id, speculative, inline_depth), _name(k->name()) { 3019 : TypeOopPtr(InstPtr, ptr, k, xk, o, off, instance_id, speculative), _name(k->name()) {
3125 assert(k != NULL && 3020 assert(k != NULL &&
3126 (k->is_loaded() || o == NULL), 3021 (k->is_loaded() || o == NULL),
3127 "cannot have constants with non-loaded klass"); 3022 "cannot have constants with non-loaded klass");
3128 }; 3023 };
3129 3024
3132 ciKlass* k, 3027 ciKlass* k,
3133 bool xk, 3028 bool xk,
3134 ciObject* o, 3029 ciObject* o,
3135 int offset, 3030 int offset,
3136 int instance_id, 3031 int instance_id,
3137 const TypeOopPtr* speculative, 3032 const TypeOopPtr* speculative) {
3138 int inline_depth) {
3139 assert( !k->is_loaded() || k->is_instance_klass(), "Must be for instance"); 3033 assert( !k->is_loaded() || k->is_instance_klass(), "Must be for instance");
3140 // Either const_oop() is NULL or else ptr is Constant 3034 // Either const_oop() is NULL or else ptr is Constant
3141 assert( (!o && ptr != Constant) || (o && ptr == Constant), 3035 assert( (!o && ptr != Constant) || (o && ptr == Constant),
3142 "constant pointers must have a value supplied" ); 3036 "constant pointers must have a value supplied" );
3143 // Ptr is never Null 3037 // Ptr is never Null
3154 if (xk && ik->is_interface()) xk = false; // no exact interface 3048 if (xk && ik->is_interface()) xk = false; // no exact interface
3155 } 3049 }
3156 3050
3157 // Now hash this baby 3051 // Now hash this baby
3158 TypeInstPtr *result = 3052 TypeInstPtr *result =
3159 (TypeInstPtr*)(new TypeInstPtr(ptr, k, xk, o ,offset, instance_id, speculative, inline_depth))->hashcons(); 3053 (TypeInstPtr*)(new TypeInstPtr(ptr, k, xk, o ,offset, instance_id, speculative))->hashcons();
3160 3054
3161 return result; 3055 return result;
3162 } 3056 }
3163 3057
3164 /** 3058 /**
3187 //------------------------------cast_to_ptr_type------------------------------- 3081 //------------------------------cast_to_ptr_type-------------------------------
3188 const Type *TypeInstPtr::cast_to_ptr_type(PTR ptr) const { 3082 const Type *TypeInstPtr::cast_to_ptr_type(PTR ptr) const {
3189 if( ptr == _ptr ) return this; 3083 if( ptr == _ptr ) return this;
3190 // Reconstruct _sig info here since not a problem with later lazy 3084 // Reconstruct _sig info here since not a problem with later lazy
3191 // construction, _sig will show up on demand. 3085 // construction, _sig will show up on demand.
3192 return make(ptr, klass(), klass_is_exact(), const_oop(), _offset, _instance_id, _speculative, _inline_depth); 3086 return make(ptr, klass(), klass_is_exact(), const_oop(), _offset, _instance_id, _speculative);
3193 } 3087 }
3194 3088
3195 3089
3196 //-----------------------------cast_to_exactness------------------------------- 3090 //-----------------------------cast_to_exactness-------------------------------
3197 const Type *TypeInstPtr::cast_to_exactness(bool klass_is_exact) const { 3091 const Type *TypeInstPtr::cast_to_exactness(bool klass_is_exact) const {
3199 if (!UseExactTypes) return this; 3093 if (!UseExactTypes) return this;
3200 if (!_klass->is_loaded()) return this; 3094 if (!_klass->is_loaded()) return this;
3201 ciInstanceKlass* ik = _klass->as_instance_klass(); 3095 ciInstanceKlass* ik = _klass->as_instance_klass();
3202 if( (ik->is_final() || _const_oop) ) return this; // cannot clear xk 3096 if( (ik->is_final() || _const_oop) ) return this; // cannot clear xk
3203 if( ik->is_interface() ) return this; // cannot set xk 3097 if( ik->is_interface() ) return this; // cannot set xk
3204 return make(ptr(), klass(), klass_is_exact, const_oop(), _offset, _instance_id, _speculative, _inline_depth); 3098 return make(ptr(), klass(), klass_is_exact, const_oop(), _offset, _instance_id, _speculative);
3205 } 3099 }
3206 3100
3207 //-----------------------------cast_to_instance_id---------------------------- 3101 //-----------------------------cast_to_instance_id----------------------------
3208 const TypeOopPtr *TypeInstPtr::cast_to_instance_id(int instance_id) const { 3102 const TypeOopPtr *TypeInstPtr::cast_to_instance_id(int instance_id) const {
3209 if( instance_id == _instance_id ) return this; 3103 if( instance_id == _instance_id ) return this;
3210 return make(_ptr, klass(), _klass_is_exact, const_oop(), _offset, instance_id, _speculative, _inline_depth); 3104 return make(_ptr, klass(), _klass_is_exact, const_oop(), _offset, instance_id, _speculative);
3211 } 3105 }
3212 3106
3213 //------------------------------xmeet_unloaded--------------------------------- 3107 //------------------------------xmeet_unloaded---------------------------------
3214 // Compute the MEET of two InstPtrs when at least one is unloaded. 3108 // Compute the MEET of two InstPtrs when at least one is unloaded.
3215 // Assume classes are different since called after check for same name/class-loader 3109 // Assume classes are different since called after check for same name/class-loader
3216 const TypeInstPtr *TypeInstPtr::xmeet_unloaded(const TypeInstPtr *tinst) const { 3110 const TypeInstPtr *TypeInstPtr::xmeet_unloaded(const TypeInstPtr *tinst) const {
3217 int off = meet_offset(tinst->offset()); 3111 int off = meet_offset(tinst->offset());
3218 PTR ptr = meet_ptr(tinst->ptr()); 3112 PTR ptr = meet_ptr(tinst->ptr());
3219 int instance_id = meet_instance_id(tinst->instance_id()); 3113 int instance_id = meet_instance_id(tinst->instance_id());
3220 const TypeOopPtr* speculative = xmeet_speculative(tinst); 3114 const TypeOopPtr* speculative = meet_speculative(tinst);
3221 int depth = meet_inline_depth(tinst->inline_depth());
3222 3115
3223 const TypeInstPtr *loaded = is_loaded() ? this : tinst; 3116 const TypeInstPtr *loaded = is_loaded() ? this : tinst;
3224 const TypeInstPtr *unloaded = is_loaded() ? tinst : this; 3117 const TypeInstPtr *unloaded = is_loaded() ? tinst : this;
3225 if( loaded->klass()->equals(ciEnv::current()->Object_klass()) ) { 3118 if( loaded->klass()->equals(ciEnv::current()->Object_klass()) ) {
3226 // 3119 //
3237 // BOTTOM | ........................Object-BOTTOM ..................| 3130 // BOTTOM | ........................Object-BOTTOM ..................|
3238 // 3131 //
3239 assert(loaded->ptr() != TypePtr::Null, "insanity check"); 3132 assert(loaded->ptr() != TypePtr::Null, "insanity check");
3240 // 3133 //
3241 if( loaded->ptr() == TypePtr::TopPTR ) { return unloaded; } 3134 if( loaded->ptr() == TypePtr::TopPTR ) { return unloaded; }
3242 else if (loaded->ptr() == TypePtr::AnyNull) { return TypeInstPtr::make(ptr, unloaded->klass(), false, NULL, off, instance_id, speculative, depth); } 3135 else if (loaded->ptr() == TypePtr::AnyNull) { return TypeInstPtr::make(ptr, unloaded->klass(), false, NULL, off, instance_id, speculative); }
3243 else if (loaded->ptr() == TypePtr::BotPTR ) { return TypeInstPtr::BOTTOM; } 3136 else if (loaded->ptr() == TypePtr::BotPTR ) { return TypeInstPtr::BOTTOM; }
3244 else if (loaded->ptr() == TypePtr::Constant || loaded->ptr() == TypePtr::NotNull) { 3137 else if (loaded->ptr() == TypePtr::Constant || loaded->ptr() == TypePtr::NotNull) {
3245 if (unloaded->ptr() == TypePtr::BotPTR ) { return TypeInstPtr::BOTTOM; } 3138 if (unloaded->ptr() == TypePtr::BotPTR ) { return TypeInstPtr::BOTTOM; }
3246 else { return TypeInstPtr::NOTNULL; } 3139 else { return TypeInstPtr::NOTNULL; }
3247 } 3140 }
3293 case AryPtr: { // All arrays inherit from Object class 3186 case AryPtr: { // All arrays inherit from Object class
3294 const TypeAryPtr *tp = t->is_aryptr(); 3187 const TypeAryPtr *tp = t->is_aryptr();
3295 int offset = meet_offset(tp->offset()); 3188 int offset = meet_offset(tp->offset());
3296 PTR ptr = meet_ptr(tp->ptr()); 3189 PTR ptr = meet_ptr(tp->ptr());
3297 int instance_id = meet_instance_id(tp->instance_id()); 3190 int instance_id = meet_instance_id(tp->instance_id());
3298 const TypeOopPtr* speculative = xmeet_speculative(tp); 3191 const TypeOopPtr* speculative = meet_speculative(tp);
3299 int depth = meet_inline_depth(tp->inline_depth());
3300 switch (ptr) { 3192 switch (ptr) {
3301 case TopPTR: 3193 case TopPTR:
3302 case AnyNull: // Fall 'down' to dual of object klass 3194 case AnyNull: // Fall 'down' to dual of object klass
3303 // For instances when a subclass meets a superclass we fall 3195 // For instances when a subclass meets a superclass we fall
3304 // below the centerline when the superclass is exact. We need to 3196 // below the centerline when the superclass is exact. We need to
3305 // do the same here. 3197 // do the same here.
3306 if (klass()->equals(ciEnv::current()->Object_klass()) && !klass_is_exact()) { 3198 if (klass()->equals(ciEnv::current()->Object_klass()) && !klass_is_exact()) {
3307 return TypeAryPtr::make(ptr, tp->ary(), tp->klass(), tp->klass_is_exact(), offset, instance_id, speculative, depth); 3199 return TypeAryPtr::make(ptr, tp->ary(), tp->klass(), tp->klass_is_exact(), offset, instance_id, speculative);
3308 } else { 3200 } else {
3309 // cannot subclass, so the meet has to fall badly below the centerline 3201 // cannot subclass, so the meet has to fall badly below the centerline
3310 ptr = NotNull; 3202 ptr = NotNull;
3311 instance_id = InstanceBot; 3203 instance_id = InstanceBot;
3312 return TypeInstPtr::make( ptr, ciEnv::current()->Object_klass(), false, NULL, offset, instance_id, speculative, depth); 3204 return TypeInstPtr::make( ptr, ciEnv::current()->Object_klass(), false, NULL, offset, instance_id, speculative);
3313 } 3205 }
3314 case Constant: 3206 case Constant:
3315 case NotNull: 3207 case NotNull:
3316 case BotPTR: // Fall down to object klass 3208 case BotPTR: // Fall down to object klass
3317 // LCA is object_klass, but if we subclass from the top we can do better 3209 // LCA is object_klass, but if we subclass from the top we can do better
3322 // below the centerline when the superclass is exact. We need 3214 // below the centerline when the superclass is exact. We need
3323 // to do the same here. 3215 // to do the same here.
3324 if (klass()->equals(ciEnv::current()->Object_klass()) && !klass_is_exact()) { 3216 if (klass()->equals(ciEnv::current()->Object_klass()) && !klass_is_exact()) {
3325 // that is, tp's array type is a subtype of my klass 3217 // that is, tp's array type is a subtype of my klass
3326 return TypeAryPtr::make(ptr, (ptr == Constant ? tp->const_oop() : NULL), 3218 return TypeAryPtr::make(ptr, (ptr == Constant ? tp->const_oop() : NULL),
3327 tp->ary(), tp->klass(), tp->klass_is_exact(), offset, instance_id, speculative, depth); 3219 tp->ary(), tp->klass(), tp->klass_is_exact(), offset, instance_id, speculative);
3328 } 3220 }
3329 } 3221 }
3330 // The other case cannot happen, since I cannot be a subtype of an array. 3222 // The other case cannot happen, since I cannot be a subtype of an array.
3331 // The meet falls down to Object class below centerline. 3223 // The meet falls down to Object class below centerline.
3332 if( ptr == Constant ) 3224 if( ptr == Constant )
3333 ptr = NotNull; 3225 ptr = NotNull;
3334 instance_id = InstanceBot; 3226 instance_id = InstanceBot;
3335 return make(ptr, ciEnv::current()->Object_klass(), false, NULL, offset, instance_id, speculative, depth); 3227 return make(ptr, ciEnv::current()->Object_klass(), false, NULL, offset, instance_id, speculative);
3336 default: typerr(t); 3228 default: typerr(t);
3337 } 3229 }
3338 } 3230 }
3339 3231
3340 case OopPtr: { // Meeting to OopPtrs 3232 case OopPtr: { // Meeting to OopPtrs
3344 PTR ptr = meet_ptr(tp->ptr()); 3236 PTR ptr = meet_ptr(tp->ptr());
3345 switch (tp->ptr()) { 3237 switch (tp->ptr()) {
3346 case TopPTR: 3238 case TopPTR:
3347 case AnyNull: { 3239 case AnyNull: {
3348 int instance_id = meet_instance_id(InstanceTop); 3240 int instance_id = meet_instance_id(InstanceTop);
3349 const TypeOopPtr* speculative = xmeet_speculative(tp); 3241 const TypeOopPtr* speculative = meet_speculative(tp);
3350 int depth = meet_inline_depth(tp->inline_depth());
3351 return make(ptr, klass(), klass_is_exact(), 3242 return make(ptr, klass(), klass_is_exact(),
3352 (ptr == Constant ? const_oop() : NULL), offset, instance_id, speculative, depth); 3243 (ptr == Constant ? const_oop() : NULL), offset, instance_id, speculative);
3353 } 3244 }
3354 case NotNull: 3245 case NotNull:
3355 case BotPTR: { 3246 case BotPTR: {
3356 int instance_id = meet_instance_id(tp->instance_id()); 3247 int instance_id = meet_instance_id(tp->instance_id());
3357 const TypeOopPtr* speculative = xmeet_speculative(tp); 3248 const TypeOopPtr* speculative = meet_speculative(tp);
3358 int depth = meet_inline_depth(tp->inline_depth()); 3249 return TypeOopPtr::make(ptr, offset, instance_id, speculative);
3359 return TypeOopPtr::make(ptr, offset, instance_id, speculative, depth);
3360 } 3250 }
3361 default: typerr(t); 3251 default: typerr(t);
3362 } 3252 }
3363 } 3253 }
3364 3254
3374 case TopPTR: 3264 case TopPTR:
3375 case AnyNull: { 3265 case AnyNull: {
3376 int instance_id = meet_instance_id(InstanceTop); 3266 int instance_id = meet_instance_id(InstanceTop);
3377 const TypeOopPtr* speculative = _speculative; 3267 const TypeOopPtr* speculative = _speculative;
3378 return make(ptr, klass(), klass_is_exact(), 3268 return make(ptr, klass(), klass_is_exact(),
3379 (ptr == Constant ? const_oop() : NULL), offset, instance_id, speculative, _inline_depth); 3269 (ptr == Constant ? const_oop() : NULL), offset, instance_id, speculative);
3380 } 3270 }
3381 case NotNull: 3271 case NotNull:
3382 case BotPTR: 3272 case BotPTR:
3383 return TypePtr::make(AnyPtr, ptr, offset); 3273 return TypePtr::make(AnyPtr, ptr, offset);
3384 default: typerr(t); 3274 default: typerr(t);
3405 // Found an InstPtr sub-type vs self-InstPtr type 3295 // Found an InstPtr sub-type vs self-InstPtr type
3406 const TypeInstPtr *tinst = t->is_instptr(); 3296 const TypeInstPtr *tinst = t->is_instptr();
3407 int off = meet_offset( tinst->offset() ); 3297 int off = meet_offset( tinst->offset() );
3408 PTR ptr = meet_ptr( tinst->ptr() ); 3298 PTR ptr = meet_ptr( tinst->ptr() );
3409 int instance_id = meet_instance_id(tinst->instance_id()); 3299 int instance_id = meet_instance_id(tinst->instance_id());
3410 const TypeOopPtr* speculative = xmeet_speculative(tinst); 3300 const TypeOopPtr* speculative = meet_speculative(tinst);
3411 int depth = meet_inline_depth(tinst->inline_depth());
3412 3301
3413 // Check for easy case; klasses are equal (and perhaps not loaded!) 3302 // Check for easy case; klasses are equal (and perhaps not loaded!)
3414 // If we have constants, then we created oops so classes are loaded 3303 // If we have constants, then we created oops so classes are loaded
3415 // and we can handle the constants further down. This case handles 3304 // and we can handle the constants further down. This case handles
3416 // both-not-loaded or both-loaded classes 3305 // both-not-loaded or both-loaded classes
3417 if (ptr != Constant && klass()->equals(tinst->klass()) && klass_is_exact() == tinst->klass_is_exact()) { 3306 if (ptr != Constant && klass()->equals(tinst->klass()) && klass_is_exact() == tinst->klass_is_exact()) {
3418 return make(ptr, klass(), klass_is_exact(), NULL, off, instance_id, speculative, depth); 3307 return make(ptr, klass(), klass_is_exact(), NULL, off, instance_id, speculative);
3419 } 3308 }
3420 3309
3421 // Classes require inspection in the Java klass hierarchy. Must be loaded. 3310 // Classes require inspection in the Java klass hierarchy. Must be loaded.
3422 ciKlass* tinst_klass = tinst->klass(); 3311 ciKlass* tinst_klass = tinst->klass();
3423 ciKlass* this_klass = this->klass(); 3312 ciKlass* this_klass = this->klass();
3477 ciObject* o = NULL; // the Constant value, if any 3366 ciObject* o = NULL; // the Constant value, if any
3478 if (ptr == Constant) { 3367 if (ptr == Constant) {
3479 // Find out which constant. 3368 // Find out which constant.
3480 o = (this_klass == klass()) ? const_oop() : tinst->const_oop(); 3369 o = (this_klass == klass()) ? const_oop() : tinst->const_oop();
3481 } 3370 }
3482 return make(ptr, k, xk, o, off, instance_id, speculative, depth); 3371 return make(ptr, k, xk, o, off, instance_id, speculative);
3483 } 3372 }
3484 3373
3485 // Either oop vs oop or interface vs interface or interface vs Object 3374 // Either oop vs oop or interface vs interface or interface vs Object
3486 3375
3487 // !!! Here's how the symmetry requirement breaks down into invariants: 3376 // !!! Here's how the symmetry requirement breaks down into invariants:
3554 else if (above_centerline(tinst ->_ptr)) 3443 else if (above_centerline(tinst ->_ptr))
3555 o = this_oop; 3444 o = this_oop;
3556 else 3445 else
3557 ptr = NotNull; 3446 ptr = NotNull;
3558 } 3447 }
3559 return make(ptr, this_klass, this_xk, o, off, instance_id, speculative, depth); 3448 return make(ptr, this_klass, this_xk, o, off, instance_id, speculative);
3560 } // Else classes are not equal 3449 } // Else classes are not equal
3561 3450
3562 // Since klasses are different, we require a LCA in the Java 3451 // Since klasses are different, we require a LCA in the Java
3563 // class hierarchy - which means we have to fall to at least NotNull. 3452 // class hierarchy - which means we have to fall to at least NotNull.
3564 if( ptr == TopPTR || ptr == AnyNull || ptr == Constant ) 3453 if( ptr == TopPTR || ptr == AnyNull || ptr == Constant )
3565 ptr = NotNull; 3454 ptr = NotNull;
3566 instance_id = InstanceBot; 3455 instance_id = InstanceBot;
3567 3456
3568 // Now we find the LCA of Java classes 3457 // Now we find the LCA of Java classes
3569 ciKlass* k = this_klass->least_common_ancestor(tinst_klass); 3458 ciKlass* k = this_klass->least_common_ancestor(tinst_klass);
3570 return make(ptr, k, false, NULL, off, instance_id, speculative, depth); 3459 return make(ptr, k, false, NULL, off, instance_id, speculative);
3571 } // End of case InstPtr 3460 } // End of case InstPtr
3572 3461
3573 } // End of switch 3462 } // End of switch
3574 return this; // Return the double constant 3463 return this; // Return the double constant
3575 } 3464 }
3589 3478
3590 //------------------------------xdual------------------------------------------ 3479 //------------------------------xdual------------------------------------------
3591 // Dual: do NOT dual on klasses. This means I do NOT understand the Java 3480 // Dual: do NOT dual on klasses. This means I do NOT understand the Java
3592 // inheritance mechanism. 3481 // inheritance mechanism.
3593 const Type *TypeInstPtr::xdual() const { 3482 const Type *TypeInstPtr::xdual() const {
3594 return new TypeInstPtr(dual_ptr(), klass(), klass_is_exact(), const_oop(), dual_offset(), dual_instance_id(), dual_speculative(), dual_inline_depth()); 3483 return new TypeInstPtr(dual_ptr(), klass(), klass_is_exact(), const_oop(), dual_offset(), dual_instance_id(), dual_speculative());
3595 } 3484 }
3596 3485
3597 //------------------------------eq--------------------------------------------- 3486 //------------------------------eq---------------------------------------------
3598 // Structural equality check for Type representations 3487 // Structural equality check for Type representations
3599 bool TypeInstPtr::eq( const Type *t ) const { 3488 bool TypeInstPtr::eq( const Type *t ) const {
3646 if (_instance_id == InstanceTop) 3535 if (_instance_id == InstanceTop)
3647 st->print(",iid=top"); 3536 st->print(",iid=top");
3648 else if (_instance_id != InstanceBot) 3537 else if (_instance_id != InstanceBot)
3649 st->print(",iid=%d",_instance_id); 3538 st->print(",iid=%d",_instance_id);
3650 3539
3651 dump_inline_depth(st);
3652 dump_speculative(st); 3540 dump_speculative(st);
3653 } 3541 }
3654 #endif 3542 #endif
3655 3543
3656 //------------------------------add_offset------------------------------------- 3544 //------------------------------add_offset-------------------------------------
3657 const TypePtr *TypeInstPtr::add_offset(intptr_t offset) const { 3545 const TypePtr *TypeInstPtr::add_offset(intptr_t offset) const {
3658 return make(_ptr, klass(), klass_is_exact(), const_oop(), xadd_offset(offset), _instance_id, add_offset_speculative(offset)); 3546 return make(_ptr, klass(), klass_is_exact(), const_oop(), xadd_offset(offset), _instance_id, add_offset_speculative(offset));
3659 } 3547 }
3660 3548
3661 const Type *TypeInstPtr::remove_speculative() const { 3549 const TypeOopPtr *TypeInstPtr::remove_speculative() const {
3662 if (_speculative == NULL) { 3550 return make(_ptr, klass(), klass_is_exact(), const_oop(), _offset, _instance_id, NULL);
3663 return this;
3664 }
3665 assert(_inline_depth == InlineDepthTop || _inline_depth == InlineDepthBottom, "non speculative type shouldn't have inline depth");
3666 return make(_ptr, klass(), klass_is_exact(), const_oop(), _offset, _instance_id, NULL, _inline_depth);
3667 }
3668
3669 const TypeOopPtr *TypeInstPtr::with_inline_depth(int depth) const {
3670 if (!UseInlineDepthForSpeculativeTypes) {
3671 return this;
3672 }
3673 return make(_ptr, klass(), klass_is_exact(), const_oop(), _offset, _instance_id, _speculative, depth);
3674 } 3551 }
3675 3552
3676 //============================================================================= 3553 //=============================================================================
3677 // Convenience common pre-built types. 3554 // Convenience common pre-built types.
3678 const TypeAryPtr *TypeAryPtr::RANGE; 3555 const TypeAryPtr *TypeAryPtr::RANGE;
3685 const TypeAryPtr *TypeAryPtr::LONGS; 3562 const TypeAryPtr *TypeAryPtr::LONGS;
3686 const TypeAryPtr *TypeAryPtr::FLOATS; 3563 const TypeAryPtr *TypeAryPtr::FLOATS;
3687 const TypeAryPtr *TypeAryPtr::DOUBLES; 3564 const TypeAryPtr *TypeAryPtr::DOUBLES;
3688 3565
3689 //------------------------------make------------------------------------------- 3566 //------------------------------make-------------------------------------------
3690 const TypeAryPtr *TypeAryPtr::make(PTR ptr, const TypeAry *ary, ciKlass* k, bool xk, int offset, int instance_id, const TypeOopPtr* speculative, int inline_depth) { 3567 const TypeAryPtr *TypeAryPtr::make(PTR ptr, const TypeAry *ary, ciKlass* k, bool xk, int offset, int instance_id, const TypeOopPtr* speculative) {
3691 assert(!(k == NULL && ary->_elem->isa_int()), 3568 assert(!(k == NULL && ary->_elem->isa_int()),
3692 "integral arrays must be pre-equipped with a class"); 3569 "integral arrays must be pre-equipped with a class");
3693 if (!xk) xk = ary->ary_must_be_exact(); 3570 if (!xk) xk = ary->ary_must_be_exact();
3694 assert(instance_id <= 0 || xk || !UseExactTypes, "instances are always exactly typed"); 3571 assert(instance_id <= 0 || xk || !UseExactTypes, "instances are always exactly typed");
3695 if (!UseExactTypes) xk = (ptr == Constant); 3572 if (!UseExactTypes) xk = (ptr == Constant);
3696 return (TypeAryPtr*)(new TypeAryPtr(ptr, NULL, ary, k, xk, offset, instance_id, false, speculative, inline_depth))->hashcons(); 3573 return (TypeAryPtr*)(new TypeAryPtr(ptr, NULL, ary, k, xk, offset, instance_id, false, speculative))->hashcons();
3697 } 3574 }
3698 3575
3699 //------------------------------make------------------------------------------- 3576 //------------------------------make-------------------------------------------
3700 const TypeAryPtr *TypeAryPtr::make(PTR ptr, ciObject* o, const TypeAry *ary, ciKlass* k, bool xk, int offset, int instance_id, const TypeOopPtr* speculative, int inline_depth, bool is_autobox_cache) { 3577 const TypeAryPtr *TypeAryPtr::make(PTR ptr, ciObject* o, const TypeAry *ary, ciKlass* k, bool xk, int offset, int instance_id, const TypeOopPtr* speculative, bool is_autobox_cache) {
3701 assert(!(k == NULL && ary->_elem->isa_int()), 3578 assert(!(k == NULL && ary->_elem->isa_int()),
3702 "integral arrays must be pre-equipped with a class"); 3579 "integral arrays must be pre-equipped with a class");
3703 assert( (ptr==Constant && o) || (ptr!=Constant && !o), "" ); 3580 assert( (ptr==Constant && o) || (ptr!=Constant && !o), "" );
3704 if (!xk) xk = (o != NULL) || ary->ary_must_be_exact(); 3581 if (!xk) xk = (o != NULL) || ary->ary_must_be_exact();
3705 assert(instance_id <= 0 || xk || !UseExactTypes, "instances are always exactly typed"); 3582 assert(instance_id <= 0 || xk || !UseExactTypes, "instances are always exactly typed");
3706 if (!UseExactTypes) xk = (ptr == Constant); 3583 if (!UseExactTypes) xk = (ptr == Constant);
3707 return (TypeAryPtr*)(new TypeAryPtr(ptr, o, ary, k, xk, offset, instance_id, is_autobox_cache, speculative, inline_depth))->hashcons(); 3584 return (TypeAryPtr*)(new TypeAryPtr(ptr, o, ary, k, xk, offset, instance_id, is_autobox_cache, speculative))->hashcons();
3708 } 3585 }
3709 3586
3710 //------------------------------cast_to_ptr_type------------------------------- 3587 //------------------------------cast_to_ptr_type-------------------------------
3711 const Type *TypeAryPtr::cast_to_ptr_type(PTR ptr) const { 3588 const Type *TypeAryPtr::cast_to_ptr_type(PTR ptr) const {
3712 if( ptr == _ptr ) return this; 3589 if( ptr == _ptr ) return this;
3713 return make(ptr, const_oop(), _ary, klass(), klass_is_exact(), _offset, _instance_id, _speculative, _inline_depth); 3590 return make(ptr, const_oop(), _ary, klass(), klass_is_exact(), _offset, _instance_id, _speculative);
3714 } 3591 }
3715 3592
3716 3593
3717 //-----------------------------cast_to_exactness------------------------------- 3594 //-----------------------------cast_to_exactness-------------------------------
3718 const Type *TypeAryPtr::cast_to_exactness(bool klass_is_exact) const { 3595 const Type *TypeAryPtr::cast_to_exactness(bool klass_is_exact) const {
3719 if( klass_is_exact == _klass_is_exact ) return this; 3596 if( klass_is_exact == _klass_is_exact ) return this;
3720 if (!UseExactTypes) return this; 3597 if (!UseExactTypes) return this;
3721 if (_ary->ary_must_be_exact()) return this; // cannot clear xk 3598 if (_ary->ary_must_be_exact()) return this; // cannot clear xk
3722 return make(ptr(), const_oop(), _ary, klass(), klass_is_exact, _offset, _instance_id, _speculative, _inline_depth); 3599 return make(ptr(), const_oop(), _ary, klass(), klass_is_exact, _offset, _instance_id, _speculative);
3723 } 3600 }
3724 3601
3725 //-----------------------------cast_to_instance_id---------------------------- 3602 //-----------------------------cast_to_instance_id----------------------------
3726 const TypeOopPtr *TypeAryPtr::cast_to_instance_id(int instance_id) const { 3603 const TypeOopPtr *TypeAryPtr::cast_to_instance_id(int instance_id) const {
3727 if( instance_id == _instance_id ) return this; 3604 if( instance_id == _instance_id ) return this;
3728 return make(_ptr, const_oop(), _ary, klass(), _klass_is_exact, _offset, instance_id, _speculative, _inline_depth); 3605 return make(_ptr, const_oop(), _ary, klass(), _klass_is_exact, _offset, instance_id, _speculative);
3729 } 3606 }
3730 3607
3731 //-----------------------------narrow_size_type------------------------------- 3608 //-----------------------------narrow_size_type-------------------------------
3732 // Local cache for arrayOopDesc::max_array_length(etype), 3609 // Local cache for arrayOopDesc::max_array_length(etype),
3733 // which is kind of slow (and cached elsewhere by other users). 3610 // which is kind of slow (and cached elsewhere by other users).
3786 const TypeAryPtr* TypeAryPtr::cast_to_size(const TypeInt* new_size) const { 3663 const TypeAryPtr* TypeAryPtr::cast_to_size(const TypeInt* new_size) const {
3787 assert(new_size != NULL, ""); 3664 assert(new_size != NULL, "");
3788 new_size = narrow_size_type(new_size); 3665 new_size = narrow_size_type(new_size);
3789 if (new_size == size()) return this; 3666 if (new_size == size()) return this;
3790 const TypeAry* new_ary = TypeAry::make(elem(), new_size, is_stable()); 3667 const TypeAry* new_ary = TypeAry::make(elem(), new_size, is_stable());
3791 return make(ptr(), const_oop(), new_ary, klass(), klass_is_exact(), _offset, _instance_id, _speculative, _inline_depth); 3668 return make(ptr(), const_oop(), new_ary, klass(), klass_is_exact(), _offset, _instance_id, _speculative);
3792 } 3669 }
3793 3670
3794 3671
3795 //------------------------------cast_to_stable--------------------------------- 3672 //------------------------------cast_to_stable---------------------------------
3796 const TypeAryPtr* TypeAryPtr::cast_to_stable(bool stable, int stable_dimension) const { 3673 const TypeAryPtr* TypeAryPtr::cast_to_stable(bool stable, int stable_dimension) const {
3865 case OopPtr: { // Meeting to OopPtrs 3742 case OopPtr: { // Meeting to OopPtrs
3866 // Found a OopPtr type vs self-AryPtr type 3743 // Found a OopPtr type vs self-AryPtr type
3867 const TypeOopPtr *tp = t->is_oopptr(); 3744 const TypeOopPtr *tp = t->is_oopptr();
3868 int offset = meet_offset(tp->offset()); 3745 int offset = meet_offset(tp->offset());
3869 PTR ptr = meet_ptr(tp->ptr()); 3746 PTR ptr = meet_ptr(tp->ptr());
3870 int depth = meet_inline_depth(tp->inline_depth());
3871 switch (tp->ptr()) { 3747 switch (tp->ptr()) {
3872 case TopPTR: 3748 case TopPTR:
3873 case AnyNull: { 3749 case AnyNull: {
3874 int instance_id = meet_instance_id(InstanceTop); 3750 int instance_id = meet_instance_id(InstanceTop);
3875 const TypeOopPtr* speculative = xmeet_speculative(tp); 3751 const TypeOopPtr* speculative = meet_speculative(tp);
3876 return make(ptr, (ptr == Constant ? const_oop() : NULL), 3752 return make(ptr, (ptr == Constant ? const_oop() : NULL),
3877 _ary, _klass, _klass_is_exact, offset, instance_id, speculative, depth); 3753 _ary, _klass, _klass_is_exact, offset, instance_id, speculative);
3878 } 3754 }
3879 case BotPTR: 3755 case BotPTR:
3880 case NotNull: { 3756 case NotNull: {
3881 int instance_id = meet_instance_id(tp->instance_id()); 3757 int instance_id = meet_instance_id(tp->instance_id());
3882 const TypeOopPtr* speculative = xmeet_speculative(tp); 3758 const TypeOopPtr* speculative = meet_speculative(tp);
3883 return TypeOopPtr::make(ptr, offset, instance_id, speculative, depth); 3759 return TypeOopPtr::make(ptr, offset, instance_id, speculative);
3884 } 3760 }
3885 default: ShouldNotReachHere(); 3761 default: ShouldNotReachHere();
3886 } 3762 }
3887 } 3763 }
3888 3764
3902 // else fall through to AnyNull 3778 // else fall through to AnyNull
3903 case AnyNull: { 3779 case AnyNull: {
3904 int instance_id = meet_instance_id(InstanceTop); 3780 int instance_id = meet_instance_id(InstanceTop);
3905 const TypeOopPtr* speculative = _speculative; 3781 const TypeOopPtr* speculative = _speculative;
3906 return make(ptr, (ptr == Constant ? const_oop() : NULL), 3782 return make(ptr, (ptr == Constant ? const_oop() : NULL),
3907 _ary, _klass, _klass_is_exact, offset, instance_id, speculative, _inline_depth); 3783 _ary, _klass, _klass_is_exact, offset, instance_id, speculative);
3908 } 3784 }
3909 default: ShouldNotReachHere(); 3785 default: ShouldNotReachHere();
3910 } 3786 }
3911 } 3787 }
3912 3788
3915 case RawPtr: return TypePtr::BOTTOM; 3791 case RawPtr: return TypePtr::BOTTOM;
3916 3792
3917 case AryPtr: { // Meeting 2 references? 3793 case AryPtr: { // Meeting 2 references?
3918 const TypeAryPtr *tap = t->is_aryptr(); 3794 const TypeAryPtr *tap = t->is_aryptr();
3919 int off = meet_offset(tap->offset()); 3795 int off = meet_offset(tap->offset());
3920 const TypeAry *tary = _ary->meet_speculative(tap->_ary)->is_ary(); 3796 const TypeAry *tary = _ary->meet(tap->_ary)->is_ary();
3921 PTR ptr = meet_ptr(tap->ptr()); 3797 PTR ptr = meet_ptr(tap->ptr());
3922 int instance_id = meet_instance_id(tap->instance_id()); 3798 int instance_id = meet_instance_id(tap->instance_id());
3923 const TypeOopPtr* speculative = xmeet_speculative(tap); 3799 const TypeOopPtr* speculative = meet_speculative(tap);
3924 int depth = meet_inline_depth(tap->inline_depth());
3925 ciKlass* lazy_klass = NULL; 3800 ciKlass* lazy_klass = NULL;
3926 if (tary->_elem->isa_int()) { 3801 if (tary->_elem->isa_int()) {
3927 // Integral array element types have irrelevant lattice relations. 3802 // Integral array element types have irrelevant lattice relations.
3928 // It is the klass that determines array layout, not the element type. 3803 // It is the klass that determines array layout, not the element type.
3929 if (_klass == NULL) 3804 if (_klass == NULL)
3935 // This must fall to bottom, not (int[-128..65535])[int+]. 3810 // This must fall to bottom, not (int[-128..65535])[int+].
3936 instance_id = InstanceBot; 3811 instance_id = InstanceBot;
3937 tary = TypeAry::make(Type::BOTTOM, tary->_size, tary->_stable); 3812 tary = TypeAry::make(Type::BOTTOM, tary->_size, tary->_stable);
3938 } 3813 }
3939 } else // Non integral arrays. 3814 } else // Non integral arrays.
3940 // Must fall to bottom if exact klasses in upper lattice 3815 // Must fall to bottom if exact klasses in upper lattice
3941 // are not equal or super klass is exact. 3816 // are not equal or super klass is exact.
3942 if ((above_centerline(ptr) || ptr == Constant) && klass() != tap->klass() && 3817 if ( above_centerline(ptr) && klass() != tap->klass() &&
3943 // meet with top[] and bottom[] are processed further down: 3818 // meet with top[] and bottom[] are processed further down:
3944 tap->_klass != NULL && this->_klass != NULL && 3819 tap ->_klass != NULL && this->_klass != NULL &&
3945 // both are exact and not equal: 3820 // both are exact and not equal:
3946 ((tap->_klass_is_exact && this->_klass_is_exact) || 3821 ((tap ->_klass_is_exact && this->_klass_is_exact) ||
3947 // 'tap' is exact and super or unrelated: 3822 // 'tap' is exact and super or unrelated:
3948 (tap->_klass_is_exact && !tap->klass()->is_subtype_of(klass())) || 3823 (tap ->_klass_is_exact && !tap->klass()->is_subtype_of(klass())) ||
3949 // 'this' is exact and super or unrelated: 3824 // 'this' is exact and super or unrelated:
3950 (this->_klass_is_exact && !klass()->is_subtype_of(tap->klass())))) { 3825 (this->_klass_is_exact && !klass()->is_subtype_of(tap->klass())))) {
3951 tary = TypeAry::make(Type::BOTTOM, tary->_size, tary->_stable); 3826 tary = TypeAry::make(Type::BOTTOM, tary->_size, tary->_stable);
3952 return make(NotNull, NULL, tary, lazy_klass, false, off, InstanceBot); 3827 return make(NotNull, NULL, tary, lazy_klass, false, off, InstanceBot);
3953 } 3828 }
3954 3829
3955 bool xk = false; 3830 bool xk = false;
3960 if (below_centerline(this->_ptr)) { 3835 if (below_centerline(this->_ptr)) {
3961 xk = this->_klass_is_exact; 3836 xk = this->_klass_is_exact;
3962 } else { 3837 } else {
3963 xk = (tap->_klass_is_exact | this->_klass_is_exact); 3838 xk = (tap->_klass_is_exact | this->_klass_is_exact);
3964 } 3839 }
3965 return make(ptr, const_oop(), tary, lazy_klass, xk, off, instance_id, speculative, depth); 3840 return make(ptr, const_oop(), tary, lazy_klass, xk, off, instance_id, speculative);
3966 case Constant: { 3841 case Constant: {
3967 ciObject* o = const_oop(); 3842 ciObject* o = const_oop();
3968 if( _ptr == Constant ) { 3843 if( _ptr == Constant ) {
3969 if( tap->const_oop() != NULL && !o->equals(tap->const_oop()) ) { 3844 if( tap->const_oop() != NULL && !o->equals(tap->const_oop()) ) {
3970 xk = (klass() == tap->klass()); 3845 xk = (klass() == tap->klass());
3979 xk = true; 3854 xk = true;
3980 } else { 3855 } else {
3981 // Only precise for identical arrays 3856 // Only precise for identical arrays
3982 xk = this->_klass_is_exact && (klass() == tap->klass()); 3857 xk = this->_klass_is_exact && (klass() == tap->klass());
3983 } 3858 }
3984 return TypeAryPtr::make(ptr, o, tary, lazy_klass, xk, off, instance_id, speculative, depth); 3859 return TypeAryPtr::make(ptr, o, tary, lazy_klass, xk, off, instance_id, speculative);
3985 } 3860 }
3986 case NotNull: 3861 case NotNull:
3987 case BotPTR: 3862 case BotPTR:
3988 // Compute new klass on demand, do not use tap->_klass 3863 // Compute new klass on demand, do not use tap->_klass
3989 if (above_centerline(this->_ptr)) 3864 if (above_centerline(this->_ptr))
3990 xk = tap->_klass_is_exact; 3865 xk = tap->_klass_is_exact;
3991 else xk = (tap->_klass_is_exact & this->_klass_is_exact) && 3866 else xk = (tap->_klass_is_exact & this->_klass_is_exact) &&
3992 (klass() == tap->klass()); // Only precise for identical arrays 3867 (klass() == tap->klass()); // Only precise for identical arrays
3993 return TypeAryPtr::make(ptr, NULL, tary, lazy_klass, xk, off, instance_id, speculative, depth); 3868 return TypeAryPtr::make(ptr, NULL, tary, lazy_klass, xk, off, instance_id, speculative);
3994 default: ShouldNotReachHere(); 3869 default: ShouldNotReachHere();
3995 } 3870 }
3996 } 3871 }
3997 3872
3998 // All arrays inherit from Object class 3873 // All arrays inherit from Object class
3999 case InstPtr: { 3874 case InstPtr: {
4000 const TypeInstPtr *tp = t->is_instptr(); 3875 const TypeInstPtr *tp = t->is_instptr();
4001 int offset = meet_offset(tp->offset()); 3876 int offset = meet_offset(tp->offset());
4002 PTR ptr = meet_ptr(tp->ptr()); 3877 PTR ptr = meet_ptr(tp->ptr());
4003 int instance_id = meet_instance_id(tp->instance_id()); 3878 int instance_id = meet_instance_id(tp->instance_id());
4004 const TypeOopPtr* speculative = xmeet_speculative(tp); 3879 const TypeOopPtr* speculative = meet_speculative(tp);
4005 int depth = meet_inline_depth(tp->inline_depth());
4006 switch (ptr) { 3880 switch (ptr) {
4007 case TopPTR: 3881 case TopPTR:
4008 case AnyNull: // Fall 'down' to dual of object klass 3882 case AnyNull: // Fall 'down' to dual of object klass
4009 // For instances when a subclass meets a superclass we fall 3883 // For instances when a subclass meets a superclass we fall
4010 // below the centerline when the superclass is exact. We need to 3884 // below the centerline when the superclass is exact. We need to
4011 // do the same here. 3885 // do the same here.
4012 if (tp->klass()->equals(ciEnv::current()->Object_klass()) && !tp->klass_is_exact()) { 3886 if (tp->klass()->equals(ciEnv::current()->Object_klass()) && !tp->klass_is_exact()) {
4013 return TypeAryPtr::make(ptr, _ary, _klass, _klass_is_exact, offset, instance_id, speculative, depth); 3887 return TypeAryPtr::make(ptr, _ary, _klass, _klass_is_exact, offset, instance_id, speculative);
4014 } else { 3888 } else {
4015 // cannot subclass, so the meet has to fall badly below the centerline 3889 // cannot subclass, so the meet has to fall badly below the centerline
4016 ptr = NotNull; 3890 ptr = NotNull;
4017 instance_id = InstanceBot; 3891 instance_id = InstanceBot;
4018 return TypeInstPtr::make(ptr, ciEnv::current()->Object_klass(), false, NULL,offset, instance_id, speculative, depth); 3892 return TypeInstPtr::make(ptr, ciEnv::current()->Object_klass(), false, NULL,offset, instance_id, speculative);
4019 } 3893 }
4020 case Constant: 3894 case Constant:
4021 case NotNull: 3895 case NotNull:
4022 case BotPTR: // Fall down to object klass 3896 case BotPTR: // Fall down to object klass
4023 // LCA is object_klass, but if we subclass from the top we can do better 3897 // LCA is object_klass, but if we subclass from the top we can do better
4028 // below the centerline when the superclass is exact. We need 3902 // below the centerline when the superclass is exact. We need
4029 // to do the same here. 3903 // to do the same here.
4030 if (tp->klass()->equals(ciEnv::current()->Object_klass()) && !tp->klass_is_exact()) { 3904 if (tp->klass()->equals(ciEnv::current()->Object_klass()) && !tp->klass_is_exact()) {
4031 // that is, my array type is a subtype of 'tp' klass 3905 // that is, my array type is a subtype of 'tp' klass
4032 return make(ptr, (ptr == Constant ? const_oop() : NULL), 3906 return make(ptr, (ptr == Constant ? const_oop() : NULL),
4033 _ary, _klass, _klass_is_exact, offset, instance_id, speculative, depth); 3907 _ary, _klass, _klass_is_exact, offset, instance_id, speculative);
4034 } 3908 }
4035 } 3909 }
4036 // The other case cannot happen, since t cannot be a subtype of an array. 3910 // The other case cannot happen, since t cannot be a subtype of an array.
4037 // The meet falls down to Object class below centerline. 3911 // The meet falls down to Object class below centerline.
4038 if( ptr == Constant ) 3912 if( ptr == Constant )
4039 ptr = NotNull; 3913 ptr = NotNull;
4040 instance_id = InstanceBot; 3914 instance_id = InstanceBot;
4041 return TypeInstPtr::make(ptr, ciEnv::current()->Object_klass(), false, NULL,offset, instance_id, speculative, depth); 3915 return TypeInstPtr::make(ptr, ciEnv::current()->Object_klass(), false, NULL,offset, instance_id, speculative);
4042 default: typerr(t); 3916 default: typerr(t);
4043 } 3917 }
4044 } 3918 }
4045 } 3919 }
4046 return this; // Lint noise 3920 return this; // Lint noise
4047 } 3921 }
4048 3922
4049 //------------------------------xdual------------------------------------------ 3923 //------------------------------xdual------------------------------------------
4050 // Dual: compute field-by-field dual 3924 // Dual: compute field-by-field dual
4051 const Type *TypeAryPtr::xdual() const { 3925 const Type *TypeAryPtr::xdual() const {
4052 return new TypeAryPtr(dual_ptr(), _const_oop, _ary->dual()->is_ary(),_klass, _klass_is_exact, dual_offset(), dual_instance_id(), is_autobox_cache(), dual_speculative(), dual_inline_depth()); 3926 return new TypeAryPtr(dual_ptr(), _const_oop, _ary->dual()->is_ary(),_klass, _klass_is_exact, dual_offset(), dual_instance_id(), is_autobox_cache(), dual_speculative());
4053 } 3927 }
4054 3928
4055 //----------------------interface_vs_oop--------------------------------------- 3929 //----------------------interface_vs_oop---------------------------------------
4056 #ifdef ASSERT 3930 #ifdef ASSERT
4057 bool TypeAryPtr::interface_vs_oop(const Type *t) const { 3931 bool TypeAryPtr::interface_vs_oop(const Type *t) const {
4100 if (_instance_id == InstanceTop) 3974 if (_instance_id == InstanceTop)
4101 st->print(",iid=top"); 3975 st->print(",iid=top");
4102 else if (_instance_id != InstanceBot) 3976 else if (_instance_id != InstanceBot)
4103 st->print(",iid=%d",_instance_id); 3977 st->print(",iid=%d",_instance_id);
4104 3978
4105 dump_inline_depth(st);
4106 dump_speculative(st); 3979 dump_speculative(st);
4107 } 3980 }
4108 #endif 3981 #endif
4109 3982
4110 bool TypeAryPtr::empty(void) const { 3983 bool TypeAryPtr::empty(void) const {
4112 return TypeOopPtr::empty(); 3985 return TypeOopPtr::empty();
4113 } 3986 }
4114 3987
4115 //------------------------------add_offset------------------------------------- 3988 //------------------------------add_offset-------------------------------------
4116 const TypePtr *TypeAryPtr::add_offset(intptr_t offset) const { 3989 const TypePtr *TypeAryPtr::add_offset(intptr_t offset) const {
4117 return make(_ptr, _const_oop, _ary, _klass, _klass_is_exact, xadd_offset(offset), _instance_id, add_offset_speculative(offset), _inline_depth); 3990 return make(_ptr, _const_oop, _ary, _klass, _klass_is_exact, xadd_offset(offset), _instance_id, add_offset_speculative(offset));
4118 } 3991 }
4119 3992
4120 const Type *TypeAryPtr::remove_speculative() const { 3993 const TypeOopPtr *TypeAryPtr::remove_speculative() const {
4121 if (_speculative == NULL) { 3994 return make(_ptr, _const_oop, _ary, _klass, _klass_is_exact, _offset, _instance_id, NULL);
4122 return this;
4123 }
4124 assert(_inline_depth == InlineDepthTop || _inline_depth == InlineDepthBottom, "non speculative type shouldn't have inline depth");
4125 return make(_ptr, _const_oop, _ary->remove_speculative()->is_ary(), _klass, _klass_is_exact, _offset, _instance_id, NULL, _inline_depth);
4126 }
4127
4128 const TypeOopPtr *TypeAryPtr::with_inline_depth(int depth) const {
4129 if (!UseInlineDepthForSpeculativeTypes) {
4130 return this;
4131 }
4132 return make(_ptr, _const_oop, _ary->remove_speculative()->is_ary(), _klass, _klass_is_exact, _offset, _instance_id, _speculative, depth);
4133 } 3995 }
4134 3996
4135 //============================================================================= 3997 //=============================================================================
4136 3998
4137 //------------------------------hash------------------------------------------- 3999 //------------------------------hash-------------------------------------------
4167 const TypePtr* odual = _ptrtype->dual()->is_ptr(); 4029 const TypePtr* odual = _ptrtype->dual()->is_ptr();
4168 return make_same_narrowptr(odual); 4030 return make_same_narrowptr(odual);
4169 } 4031 }
4170 4032
4171 4033
4172 const Type *TypeNarrowPtr::filter_helper(const Type *kills, bool include_speculative) const { 4034 const Type *TypeNarrowPtr::filter( const Type *kills ) const {
4173 if (isa_same_narrowptr(kills)) { 4035 if (isa_same_narrowptr(kills)) {
4174 const Type* ft =_ptrtype->filter_helper(is_same_narrowptr(kills)->_ptrtype, include_speculative); 4036 const Type* ft =_ptrtype->filter(is_same_narrowptr(kills)->_ptrtype);
4175 if (ft->empty()) 4037 if (ft->empty())
4176 return Type::TOP; // Canonical empty value 4038 return Type::TOP; // Canonical empty value
4177 if (ft->isa_ptr()) { 4039 if (ft->isa_ptr()) {
4178 return make_hash_same_narrowptr(ft->isa_ptr()); 4040 return make_hash_same_narrowptr(ft->isa_ptr());
4179 } 4041 }
4180 return ft; 4042 return ft;
4181 } else if (kills->isa_ptr()) { 4043 } else if (kills->isa_ptr()) {
4182 const Type* ft = _ptrtype->join_helper(kills, include_speculative); 4044 const Type* ft = _ptrtype->join(kills);
4183 if (ft->empty()) 4045 if (ft->empty())
4184 return Type::TOP; // Canonical empty value 4046 return Type::TOP; // Canonical empty value
4185 return ft; 4047 return ft;
4186 } else { 4048 } else {
4187 return Type::TOP; 4049 return Type::TOP;
4307 return make( _ptr, _metadata, xadd_offset(offset)); 4169 return make( _ptr, _metadata, xadd_offset(offset));
4308 } 4170 }
4309 4171
4310 //-----------------------------filter------------------------------------------ 4172 //-----------------------------filter------------------------------------------
4311 // Do not allow interface-vs.-noninterface joins to collapse to top. 4173 // Do not allow interface-vs.-noninterface joins to collapse to top.
4312 const Type *TypeMetadataPtr::filter_helper(const Type *kills, bool include_speculative) const { 4174 const Type *TypeMetadataPtr::filter( const Type *kills ) const {
4313 const TypeMetadataPtr* ft = join_helper(kills, include_speculative)->isa_metadataptr(); 4175 const TypeMetadataPtr* ft = join(kills)->isa_metadataptr();
4314 if (ft == NULL || ft->empty()) 4176 if (ft == NULL || ft->empty())
4315 return Type::TOP; // Canonical empty value 4177 return Type::TOP; // Canonical empty value
4316 return ft; 4178 return ft;
4317 } 4179 }
4318 4180
4510 // TopPTR, Null, AnyNull, Constant are all singletons 4372 // TopPTR, Null, AnyNull, Constant are all singletons
4511 return (_offset == 0) && !below_centerline(_ptr); 4373 return (_offset == 0) && !below_centerline(_ptr);
4512 } 4374 }
4513 4375
4514 // Do not allow interface-vs.-noninterface joins to collapse to top. 4376 // Do not allow interface-vs.-noninterface joins to collapse to top.
4515 const Type *TypeKlassPtr::filter_helper(const Type *kills, bool include_speculative) const { 4377 const Type *TypeKlassPtr::filter(const Type *kills) const {
4516 // logic here mirrors the one from TypeOopPtr::filter. See comments 4378 // logic here mirrors the one from TypeOopPtr::filter. See comments
4517 // there. 4379 // there.
4518 const Type* ft = join_helper(kills, include_speculative); 4380 const Type* ft = join(kills);
4519 const TypeKlassPtr* ftkp = ft->isa_klassptr(); 4381 const TypeKlassPtr* ftkp = ft->isa_klassptr();
4520 const TypeKlassPtr* ktkp = kills->isa_klassptr(); 4382 const TypeKlassPtr* ktkp = kills->isa_klassptr();
4521 4383
4522 if (ft->empty()) { 4384 if (ft->empty()) {
4523 if (!empty() && ktkp != NULL && ktkp->klass()->is_loaded() && ktkp->klass()->is_interface()) 4385 if (!empty() && ktkp != NULL && ktkp->klass()->is_loaded() && ktkp->klass()->is_interface())