Mercurial > hg > graal-jvmci-8
comparison src/share/vm/opto/type.cpp @ 14422:2b8e28fdf503
Merge
author | kvn |
---|---|
date | Tue, 05 Nov 2013 17:38:04 -0800 |
parents | 6c2f07d1495f |
children | e045e1876610 15120a36272d |
comparison
equal
deleted
inserted
replaced
14421:3068270ba476 | 14422:2b8e28fdf503 |
---|---|
187 return Type::get_const_type(type); | 187 return Type::get_const_type(type); |
188 } | 188 } |
189 } | 189 } |
190 | 190 |
191 | 191 |
192 //-----------------------make_from_constant------------------------------------ | |
193 const Type* Type::make_from_constant(ciConstant constant, | |
194 bool require_constant, bool is_autobox_cache) { | |
195 switch (constant.basic_type()) { | |
196 case T_BOOLEAN: return TypeInt::make(constant.as_boolean()); | |
197 case T_CHAR: return TypeInt::make(constant.as_char()); | |
198 case T_BYTE: return TypeInt::make(constant.as_byte()); | |
199 case T_SHORT: return TypeInt::make(constant.as_short()); | |
200 case T_INT: return TypeInt::make(constant.as_int()); | |
201 case T_LONG: return TypeLong::make(constant.as_long()); | |
202 case T_FLOAT: return TypeF::make(constant.as_float()); | |
203 case T_DOUBLE: return TypeD::make(constant.as_double()); | |
204 case T_ARRAY: | |
205 case T_OBJECT: | |
206 { | |
207 // cases: | |
208 // can_be_constant = (oop not scavengable || ScavengeRootsInCode != 0) | |
209 // should_be_constant = (oop not scavengable || ScavengeRootsInCode >= 2) | |
210 // An oop is not scavengable if it is in the perm gen. | |
211 ciObject* oop_constant = constant.as_object(); | |
212 if (oop_constant->is_null_object()) { | |
213 return Type::get_zero_type(T_OBJECT); | |
214 } else if (require_constant || oop_constant->should_be_constant()) { | |
215 return TypeOopPtr::make_from_constant(oop_constant, require_constant, is_autobox_cache); | |
216 } | |
217 } | |
218 } | |
219 // Fall through to failure | |
220 return NULL; | |
221 } | |
222 | |
223 | |
192 //------------------------------make------------------------------------------- | 224 //------------------------------make------------------------------------------- |
193 // Create a simple Type, with default empty symbol sets. Then hashcons it | 225 // Create a simple Type, with default empty symbol sets. Then hashcons it |
194 // and look for an existing copy in the type dictionary. | 226 // and look for an existing copy in the type dictionary. |
195 const Type *Type::make( enum TYPES t ) { | 227 const Type *Type::make( enum TYPES t ) { |
196 return (new Type(t))->hashcons(); | 228 return (new Type(t))->hashcons(); |
324 TypeInstPtr::MIRROR = TypeInstPtr::make(TypePtr::NotNull, current->env()->Class_klass()); | 356 TypeInstPtr::MIRROR = TypeInstPtr::make(TypePtr::NotNull, current->env()->Class_klass()); |
325 TypeInstPtr::MARK = TypeInstPtr::make(TypePtr::BotPTR, current->env()->Object_klass(), | 357 TypeInstPtr::MARK = TypeInstPtr::make(TypePtr::BotPTR, current->env()->Object_klass(), |
326 false, 0, oopDesc::mark_offset_in_bytes()); | 358 false, 0, oopDesc::mark_offset_in_bytes()); |
327 TypeInstPtr::KLASS = TypeInstPtr::make(TypePtr::BotPTR, current->env()->Object_klass(), | 359 TypeInstPtr::KLASS = TypeInstPtr::make(TypePtr::BotPTR, current->env()->Object_klass(), |
328 false, 0, oopDesc::klass_offset_in_bytes()); | 360 false, 0, oopDesc::klass_offset_in_bytes()); |
329 TypeOopPtr::BOTTOM = TypeOopPtr::make(TypePtr::BotPTR, OffsetBot, TypeOopPtr::InstanceBot); | 361 TypeOopPtr::BOTTOM = TypeOopPtr::make(TypePtr::BotPTR, OffsetBot, TypeOopPtr::InstanceBot, NULL); |
330 | 362 |
331 TypeMetadataPtr::BOTTOM = TypeMetadataPtr::make(TypePtr::BotPTR, NULL, OffsetBot); | 363 TypeMetadataPtr::BOTTOM = TypeMetadataPtr::make(TypePtr::BotPTR, NULL, OffsetBot); |
332 | 364 |
333 TypeNarrowOop::NULL_PTR = TypeNarrowOop::make( TypePtr::NULL_PTR ); | 365 TypeNarrowOop::NULL_PTR = TypeNarrowOop::make( TypePtr::NULL_PTR ); |
334 TypeNarrowOop::BOTTOM = TypeNarrowOop::make( TypeInstPtr::BOTTOM ); | 366 TypeNarrowOop::BOTTOM = TypeNarrowOop::make( TypeInstPtr::BOTTOM ); |
395 | 427 |
396 const Type **longpair = TypeTuple::fields(2); | 428 const Type **longpair = TypeTuple::fields(2); |
397 longpair[0] = TypeLong::LONG; | 429 longpair[0] = TypeLong::LONG; |
398 longpair[1] = TypeLong::LONG; | 430 longpair[1] = TypeLong::LONG; |
399 TypeTuple::LONG_PAIR = TypeTuple::make(2, longpair); | 431 TypeTuple::LONG_PAIR = TypeTuple::make(2, longpair); |
432 | |
433 const Type **intccpair = TypeTuple::fields(2); | |
434 intccpair[0] = TypeInt::INT; | |
435 intccpair[1] = TypeInt::CC; | |
436 TypeTuple::INT_CC_PAIR = TypeTuple::make(2, intccpair); | |
437 | |
438 const Type **longccpair = TypeTuple::fields(2); | |
439 longccpair[0] = TypeLong::LONG; | |
440 longccpair[1] = TypeInt::CC; | |
441 TypeTuple::LONG_CC_PAIR = TypeTuple::make(2, longccpair); | |
400 | 442 |
401 _const_basic_type[T_NARROWOOP] = TypeNarrowOop::BOTTOM; | 443 _const_basic_type[T_NARROWOOP] = TypeNarrowOop::BOTTOM; |
402 _const_basic_type[T_NARROWKLASS] = Type::BOTTOM; | 444 _const_basic_type[T_NARROWKLASS] = Type::BOTTOM; |
403 _const_basic_type[T_BOOLEAN] = TypeInt::BOOL; | 445 _const_basic_type[T_BOOLEAN] = TypeInt::BOOL; |
404 _const_basic_type[T_CHAR] = TypeInt::CHAR; | 446 _const_basic_type[T_CHAR] = TypeInt::CHAR; |
538 return false; | 580 return false; |
539 } | 581 } |
540 | 582 |
541 //----------------------interface_vs_oop--------------------------------------- | 583 //----------------------interface_vs_oop--------------------------------------- |
542 #ifdef ASSERT | 584 #ifdef ASSERT |
543 bool Type::interface_vs_oop(const Type *t) const { | 585 bool Type::interface_vs_oop_helper(const Type *t) const { |
544 bool result = false; | 586 bool result = false; |
545 | 587 |
546 const TypePtr* this_ptr = this->make_ptr(); // In case it is narrow_oop | 588 const TypePtr* this_ptr = this->make_ptr(); // In case it is narrow_oop |
547 const TypePtr* t_ptr = t->make_ptr(); | 589 const TypePtr* t_ptr = t->make_ptr(); |
548 if( this_ptr == NULL || t_ptr == NULL ) | 590 if( this_ptr == NULL || t_ptr == NULL ) |
556 result = this_interface ^ t_interface; | 598 result = this_interface ^ t_interface; |
557 } | 599 } |
558 | 600 |
559 return result; | 601 return result; |
560 } | 602 } |
603 | |
604 bool Type::interface_vs_oop(const Type *t) const { | |
605 if (interface_vs_oop_helper(t)) { | |
606 return true; | |
607 } | |
608 // Now check the speculative parts as well | |
609 const TypeOopPtr* this_spec = isa_oopptr() != NULL ? isa_oopptr()->speculative() : NULL; | |
610 const TypeOopPtr* t_spec = t->isa_oopptr() != NULL ? t->isa_oopptr()->speculative() : NULL; | |
611 if (this_spec != NULL && t_spec != NULL) { | |
612 if (this_spec->interface_vs_oop_helper(t_spec)) { | |
613 return true; | |
614 } | |
615 return false; | |
616 } | |
617 if (this_spec != NULL && this_spec->interface_vs_oop_helper(t)) { | |
618 return true; | |
619 } | |
620 if (t_spec != NULL && interface_vs_oop_helper(t_spec)) { | |
621 return true; | |
622 } | |
623 return false; | |
624 } | |
625 | |
561 #endif | 626 #endif |
562 | 627 |
563 //------------------------------meet------------------------------------------- | 628 //------------------------------meet------------------------------------------- |
564 // 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 |
565 // commutative and the lattice is symmetric. | 630 // commutative and the lattice is symmetric. |
1612 const TypeTuple *TypeTuple::MEMBAR; | 1677 const TypeTuple *TypeTuple::MEMBAR; |
1613 const TypeTuple *TypeTuple::STORECONDITIONAL; | 1678 const TypeTuple *TypeTuple::STORECONDITIONAL; |
1614 const TypeTuple *TypeTuple::START_I2C; | 1679 const TypeTuple *TypeTuple::START_I2C; |
1615 const TypeTuple *TypeTuple::INT_PAIR; | 1680 const TypeTuple *TypeTuple::INT_PAIR; |
1616 const TypeTuple *TypeTuple::LONG_PAIR; | 1681 const TypeTuple *TypeTuple::LONG_PAIR; |
1682 const TypeTuple *TypeTuple::INT_CC_PAIR; | |
1683 const TypeTuple *TypeTuple::LONG_CC_PAIR; | |
1617 | 1684 |
1618 | 1685 |
1619 //------------------------------make------------------------------------------- | 1686 //------------------------------make------------------------------------------- |
1620 // Make a TypeTuple from the range of a method signature | 1687 // Make a TypeTuple from the range of a method signature |
1621 const TypeTuple *TypeTuple::make_range(ciSignature* sig) { | 1688 const TypeTuple *TypeTuple::make_range(ciSignature* sig) { |
1822 else | 1889 else |
1823 return size; | 1890 return size; |
1824 } | 1891 } |
1825 | 1892 |
1826 //------------------------------make------------------------------------------- | 1893 //------------------------------make------------------------------------------- |
1827 const TypeAry *TypeAry::make( const Type *elem, const TypeInt *size) { | 1894 const TypeAry* TypeAry::make(const Type* elem, const TypeInt* size, bool stable) { |
1828 if (UseCompressedOops && elem->isa_oopptr()) { | 1895 if (UseCompressedOops && elem->isa_oopptr()) { |
1829 elem = elem->make_narrowoop(); | 1896 elem = elem->make_narrowoop(); |
1830 } | 1897 } |
1831 size = normalize_array_size(size); | 1898 size = normalize_array_size(size); |
1832 return (TypeAry*)(new TypeAry(elem,size))->hashcons(); | 1899 return (TypeAry*)(new TypeAry(elem,size,stable))->hashcons(); |
1833 } | 1900 } |
1834 | 1901 |
1835 //------------------------------meet------------------------------------------- | 1902 //------------------------------meet------------------------------------------- |
1836 // Compute the MEET of two types. It returns a new Type object. | 1903 // Compute the MEET of two types. It returns a new Type object. |
1837 const Type *TypeAry::xmeet( const Type *t ) const { | 1904 const Type *TypeAry::xmeet( const Type *t ) const { |
1848 typerr(t); | 1915 typerr(t); |
1849 | 1916 |
1850 case Array: { // Meeting 2 arrays? | 1917 case Array: { // Meeting 2 arrays? |
1851 const TypeAry *a = t->is_ary(); | 1918 const TypeAry *a = t->is_ary(); |
1852 return TypeAry::make(_elem->meet(a->_elem), | 1919 return TypeAry::make(_elem->meet(a->_elem), |
1853 _size->xmeet(a->_size)->is_int()); | 1920 _size->xmeet(a->_size)->is_int(), |
1921 _stable & a->_stable); | |
1854 } | 1922 } |
1855 case Top: | 1923 case Top: |
1856 break; | 1924 break; |
1857 } | 1925 } |
1858 return this; // Return the double constant | 1926 return this; // Return the double constant |
1861 //------------------------------xdual------------------------------------------ | 1929 //------------------------------xdual------------------------------------------ |
1862 // Dual: compute field-by-field dual | 1930 // Dual: compute field-by-field dual |
1863 const Type *TypeAry::xdual() const { | 1931 const Type *TypeAry::xdual() const { |
1864 const TypeInt* size_dual = _size->dual()->is_int(); | 1932 const TypeInt* size_dual = _size->dual()->is_int(); |
1865 size_dual = normalize_array_size(size_dual); | 1933 size_dual = normalize_array_size(size_dual); |
1866 return new TypeAry( _elem->dual(), size_dual); | 1934 return new TypeAry(_elem->dual(), size_dual, !_stable); |
1867 } | 1935 } |
1868 | 1936 |
1869 //------------------------------eq--------------------------------------------- | 1937 //------------------------------eq--------------------------------------------- |
1870 // Structural equality check for Type representations | 1938 // Structural equality check for Type representations |
1871 bool TypeAry::eq( const Type *t ) const { | 1939 bool TypeAry::eq( const Type *t ) const { |
1872 const TypeAry *a = (const TypeAry*)t; | 1940 const TypeAry *a = (const TypeAry*)t; |
1873 return _elem == a->_elem && | 1941 return _elem == a->_elem && |
1942 _stable == a->_stable && | |
1874 _size == a->_size; | 1943 _size == a->_size; |
1875 } | 1944 } |
1876 | 1945 |
1877 //------------------------------hash------------------------------------------- | 1946 //------------------------------hash------------------------------------------- |
1878 // Type-specific hashing function. | 1947 // Type-specific hashing function. |
1879 int TypeAry::hash(void) const { | 1948 int TypeAry::hash(void) const { |
1880 return (intptr_t)_elem + (intptr_t)_size; | 1949 return (intptr_t)_elem + (intptr_t)_size + (_stable ? 43 : 0); |
1881 } | 1950 } |
1882 | 1951 |
1883 //----------------------interface_vs_oop--------------------------------------- | 1952 //----------------------interface_vs_oop--------------------------------------- |
1884 #ifdef ASSERT | 1953 #ifdef ASSERT |
1885 bool TypeAry::interface_vs_oop(const Type *t) const { | 1954 bool TypeAry::interface_vs_oop(const Type *t) const { |
1892 #endif | 1961 #endif |
1893 | 1962 |
1894 //------------------------------dump2------------------------------------------ | 1963 //------------------------------dump2------------------------------------------ |
1895 #ifndef PRODUCT | 1964 #ifndef PRODUCT |
1896 void TypeAry::dump2( Dict &d, uint depth, outputStream *st ) const { | 1965 void TypeAry::dump2( Dict &d, uint depth, outputStream *st ) const { |
1966 if (_stable) st->print("stable:"); | |
1897 _elem->dump2(d, depth, st); | 1967 _elem->dump2(d, depth, st); |
1898 st->print("["); | 1968 st->print("["); |
1899 _size->dump2(d, depth, st); | 1969 _size->dump2(d, depth, st); |
1900 st->print("]"); | 1970 st->print("]"); |
1901 } | 1971 } |
2364 //============================================================================= | 2434 //============================================================================= |
2365 // Convenience common pre-built type. | 2435 // Convenience common pre-built type. |
2366 const TypeOopPtr *TypeOopPtr::BOTTOM; | 2436 const TypeOopPtr *TypeOopPtr::BOTTOM; |
2367 | 2437 |
2368 //------------------------------TypeOopPtr------------------------------------- | 2438 //------------------------------TypeOopPtr------------------------------------- |
2369 TypeOopPtr::TypeOopPtr( TYPES t, PTR ptr, ciKlass* k, bool xk, ciObject* o, int offset, int instance_id ) | 2439 TypeOopPtr::TypeOopPtr(TYPES t, PTR ptr, ciKlass* k, bool xk, ciObject* o, int offset, int instance_id, const TypeOopPtr* speculative) |
2370 : TypePtr(t, ptr, offset), | 2440 : TypePtr(t, ptr, offset), |
2371 _const_oop(o), _klass(k), | 2441 _const_oop(o), _klass(k), |
2372 _klass_is_exact(xk), | 2442 _klass_is_exact(xk), |
2373 _is_ptr_to_narrowoop(false), | 2443 _is_ptr_to_narrowoop(false), |
2374 _is_ptr_to_narrowklass(false), | 2444 _is_ptr_to_narrowklass(false), |
2375 _is_ptr_to_boxed_value(false), | 2445 _is_ptr_to_boxed_value(false), |
2376 _instance_id(instance_id) { | 2446 _instance_id(instance_id), |
2447 _speculative(speculative) { | |
2377 if (Compile::current()->eliminate_boxing() && (t == InstPtr) && | 2448 if (Compile::current()->eliminate_boxing() && (t == InstPtr) && |
2378 (offset > 0) && xk && (k != 0) && k->is_instance_klass()) { | 2449 (offset > 0) && xk && (k != 0) && k->is_instance_klass()) { |
2379 _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); |
2380 } | 2451 } |
2381 #ifdef _LP64 | 2452 #ifdef _LP64 |
2382 if (_offset != 0) { | 2453 if (_offset != 0) { |
2383 if (_offset == oopDesc::klass_offset_in_bytes()) { | 2454 if (_offset == oopDesc::klass_offset_in_bytes()) { |
2384 _is_ptr_to_narrowklass = UseCompressedKlassPointers; | 2455 _is_ptr_to_narrowklass = UseCompressedClassPointers; |
2385 } else if (klass() == NULL) { | 2456 } else if (klass() == NULL) { |
2386 // Array with unknown body type | 2457 // Array with unknown body type |
2387 assert(this->isa_aryptr(), "only arrays without klass"); | 2458 assert(this->isa_aryptr(), "only arrays without klass"); |
2388 _is_ptr_to_narrowoop = UseCompressedOops; | 2459 _is_ptr_to_narrowoop = UseCompressedOops; |
2389 } else if (this->isa_aryptr()) { | 2460 } else if (this->isa_aryptr()) { |
2438 #endif | 2509 #endif |
2439 } | 2510 } |
2440 | 2511 |
2441 //------------------------------make------------------------------------------- | 2512 //------------------------------make------------------------------------------- |
2442 const TypeOopPtr *TypeOopPtr::make(PTR ptr, | 2513 const TypeOopPtr *TypeOopPtr::make(PTR ptr, |
2443 int offset, int instance_id) { | 2514 int offset, int instance_id, const TypeOopPtr* speculative) { |
2444 assert(ptr != Constant, "no constant generic pointers"); | 2515 assert(ptr != Constant, "no constant generic pointers"); |
2445 ciKlass* k = Compile::current()->env()->Object_klass(); | 2516 ciKlass* k = Compile::current()->env()->Object_klass(); |
2446 bool xk = false; | 2517 bool xk = false; |
2447 ciObject* o = NULL; | 2518 ciObject* o = NULL; |
2448 return (TypeOopPtr*)(new TypeOopPtr(OopPtr, ptr, k, xk, o, offset, instance_id))->hashcons(); | 2519 return (TypeOopPtr*)(new TypeOopPtr(OopPtr, ptr, k, xk, o, offset, instance_id, speculative))->hashcons(); |
2449 } | 2520 } |
2450 | 2521 |
2451 | 2522 |
2452 //------------------------------cast_to_ptr_type------------------------------- | 2523 //------------------------------cast_to_ptr_type------------------------------- |
2453 const Type *TypeOopPtr::cast_to_ptr_type(PTR ptr) const { | 2524 const Type *TypeOopPtr::cast_to_ptr_type(PTR ptr) const { |
2454 assert(_base == OopPtr, "subclass must override cast_to_ptr_type"); | 2525 assert(_base == OopPtr, "subclass must override cast_to_ptr_type"); |
2455 if( ptr == _ptr ) return this; | 2526 if( ptr == _ptr ) return this; |
2456 return make(ptr, _offset, _instance_id); | 2527 return make(ptr, _offset, _instance_id, _speculative); |
2457 } | 2528 } |
2458 | 2529 |
2459 //-----------------------------cast_to_instance_id---------------------------- | 2530 //-----------------------------cast_to_instance_id---------------------------- |
2460 const TypeOopPtr *TypeOopPtr::cast_to_instance_id(int instance_id) const { | 2531 const TypeOopPtr *TypeOopPtr::cast_to_instance_id(int instance_id) const { |
2461 // There are no instances of a general oop. | 2532 // There are no instances of a general oop. |
2481 return TypeKlassPtr::OBJECT; | 2552 return TypeKlassPtr::OBJECT; |
2482 else | 2553 else |
2483 return TypeKlassPtr::make(xk? Constant: NotNull, k, 0); | 2554 return TypeKlassPtr::make(xk? Constant: NotNull, k, 0); |
2484 } | 2555 } |
2485 | 2556 |
2557 const Type *TypeOopPtr::xmeet(const Type *t) const { | |
2558 const Type* res = xmeet_helper(t); | |
2559 if (res->isa_oopptr() == NULL) { | |
2560 return res; | |
2561 } | |
2562 | |
2563 if (res->isa_oopptr() != NULL) { | |
2564 // type->speculative() == NULL means that speculation is no better | |
2565 // than type, i.e. type->speculative() == type. So there are 2 | |
2566 // ways to represent the fact that we have no useful speculative | |
2567 // data and we should use a single one to be able to test for | |
2568 // equality between types. Check whether type->speculative() == | |
2569 // type and set speculative to NULL if it is the case. | |
2570 const TypeOopPtr* res_oopptr = res->is_oopptr(); | |
2571 if (res_oopptr->remove_speculative() == res_oopptr->speculative()) { | |
2572 return res_oopptr->remove_speculative(); | |
2573 } | |
2574 } | |
2575 | |
2576 return res; | |
2577 } | |
2486 | 2578 |
2487 //------------------------------meet------------------------------------------- | 2579 //------------------------------meet------------------------------------------- |
2488 // Compute the MEET of two types. It returns a new Type object. | 2580 // Compute the MEET of two types. It returns a new Type object. |
2489 const Type *TypeOopPtr::xmeet( const Type *t ) const { | 2581 const Type *TypeOopPtr::xmeet_helper(const Type *t) const { |
2490 // Perform a fast test for common case; meeting the same types together. | 2582 // Perform a fast test for common case; meeting the same types together. |
2491 if( this == t ) return this; // Meeting same type-rep? | 2583 if( this == t ) return this; // Meeting same type-rep? |
2492 | 2584 |
2493 // Current "this->_base" is OopPtr | 2585 // Current "this->_base" is OopPtr |
2494 switch (t->base()) { // switch on original type | 2586 switch (t->base()) { // switch on original type |
2526 if (ptr == Null) return TypePtr::make(AnyPtr, ptr, offset); | 2618 if (ptr == Null) return TypePtr::make(AnyPtr, ptr, offset); |
2527 // else fall through: | 2619 // else fall through: |
2528 case TopPTR: | 2620 case TopPTR: |
2529 case AnyNull: { | 2621 case AnyNull: { |
2530 int instance_id = meet_instance_id(InstanceTop); | 2622 int instance_id = meet_instance_id(InstanceTop); |
2531 return make(ptr, offset, instance_id); | 2623 const TypeOopPtr* speculative = _speculative; |
2624 return make(ptr, offset, instance_id, speculative); | |
2532 } | 2625 } |
2533 case BotPTR: | 2626 case BotPTR: |
2534 case NotNull: | 2627 case NotNull: |
2535 return TypePtr::make(AnyPtr, ptr, offset); | 2628 return TypePtr::make(AnyPtr, ptr, offset); |
2536 default: typerr(t); | 2629 default: typerr(t); |
2538 } | 2631 } |
2539 | 2632 |
2540 case OopPtr: { // Meeting to other OopPtrs | 2633 case OopPtr: { // Meeting to other OopPtrs |
2541 const TypeOopPtr *tp = t->is_oopptr(); | 2634 const TypeOopPtr *tp = t->is_oopptr(); |
2542 int instance_id = meet_instance_id(tp->instance_id()); | 2635 int instance_id = meet_instance_id(tp->instance_id()); |
2543 return make( meet_ptr(tp->ptr()), meet_offset(tp->offset()), instance_id ); | 2636 const TypeOopPtr* speculative = meet_speculative(tp); |
2637 return make(meet_ptr(tp->ptr()), meet_offset(tp->offset()), instance_id, speculative); | |
2544 } | 2638 } |
2545 | 2639 |
2546 case InstPtr: // For these, flip the call around to cut down | 2640 case InstPtr: // For these, flip the call around to cut down |
2547 case AryPtr: | 2641 case AryPtr: |
2548 return t->xmeet(this); // Call in reverse direction | 2642 return t->xmeet(this); // Call in reverse direction |
2555 //------------------------------xdual------------------------------------------ | 2649 //------------------------------xdual------------------------------------------ |
2556 // 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. |
2557 const Type *TypeOopPtr::xdual() const { | 2651 const Type *TypeOopPtr::xdual() const { |
2558 assert(klass() == Compile::current()->env()->Object_klass(), "no klasses here"); | 2652 assert(klass() == Compile::current()->env()->Object_klass(), "no klasses here"); |
2559 assert(const_oop() == NULL, "no constants here"); | 2653 assert(const_oop() == NULL, "no constants here"); |
2560 return new TypeOopPtr(_base, dual_ptr(), klass(), klass_is_exact(), const_oop(), dual_offset(), dual_instance_id() ); | 2654 return new TypeOopPtr(_base, dual_ptr(), klass(), klass_is_exact(), const_oop(), dual_offset(), dual_instance_id(), dual_speculative()); |
2561 } | 2655 } |
2562 | 2656 |
2563 //--------------------------make_from_klass_common----------------------------- | 2657 //--------------------------make_from_klass_common----------------------------- |
2564 // Computes the element-type given a klass. | 2658 // Computes the element-type given a klass. |
2565 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) { |
2646 if (require_constant) { | 2740 if (require_constant) { |
2647 if (!o->can_be_constant()) return NULL; | 2741 if (!o->can_be_constant()) return NULL; |
2648 } else if (!o->should_be_constant()) { | 2742 } else if (!o->should_be_constant()) { |
2649 return TypeAryPtr::make(TypePtr::NotNull, arr0, klass, true, 0); | 2743 return TypeAryPtr::make(TypePtr::NotNull, arr0, klass, true, 0); |
2650 } | 2744 } |
2651 const TypeAryPtr* arr = TypeAryPtr::make(TypePtr::Constant, o, arr0, klass, true, 0, InstanceBot, is_autobox_cache); | 2745 const TypeAryPtr* arr = TypeAryPtr::make(TypePtr::Constant, o, arr0, klass, true, 0, InstanceBot, NULL, is_autobox_cache); |
2652 return arr; | 2746 return arr; |
2653 } else if (klass->is_type_array_klass()) { | 2747 } else if (klass->is_type_array_klass()) { |
2654 // Element is an typeArray | 2748 // Element is an typeArray |
2655 const Type* etype = | 2749 const Type* etype = |
2656 (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()); |
2691 } | 2785 } |
2692 | 2786 |
2693 | 2787 |
2694 //-----------------------------filter------------------------------------------ | 2788 //-----------------------------filter------------------------------------------ |
2695 // Do not allow interface-vs.-noninterface joins to collapse to top. | 2789 // Do not allow interface-vs.-noninterface joins to collapse to top. |
2696 const Type *TypeOopPtr::filter( const Type *kills ) const { | 2790 const Type *TypeOopPtr::filter(const Type *kills) const { |
2697 | 2791 |
2698 const Type* ft = join(kills); | 2792 const Type* ft = join(kills); |
2699 const TypeInstPtr* ftip = ft->isa_instptr(); | 2793 const TypeInstPtr* ftip = ft->isa_instptr(); |
2700 const TypeInstPtr* ktip = kills->isa_instptr(); | 2794 const TypeInstPtr* ktip = kills->isa_instptr(); |
2701 const TypeKlassPtr* ftkp = ft->isa_klassptr(); | |
2702 const TypeKlassPtr* ktkp = kills->isa_klassptr(); | |
2703 | 2795 |
2704 if (ft->empty()) { | 2796 if (ft->empty()) { |
2705 // 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 |
2706 // interface. This can happen because the bytecodes do not contain | 2798 // interface. This can happen because the bytecodes do not contain |
2707 // enough type info to distinguish a Java-level interface variable | 2799 // enough type info to distinguish a Java-level interface variable |
2711 // be 'I' or 'j/l/O'. Thus we'll pick 'j/l/O'. If this then flows | 2803 // be 'I' or 'j/l/O'. Thus we'll pick 'j/l/O'. If this then flows |
2712 // into a Phi which "knows" it's an Interface type we'll have to | 2804 // into a Phi which "knows" it's an Interface type we'll have to |
2713 // uplift the type. | 2805 // uplift the type. |
2714 if (!empty() && ktip != NULL && ktip->is_loaded() && ktip->klass()->is_interface()) | 2806 if (!empty() && ktip != NULL && ktip->is_loaded() && ktip->klass()->is_interface()) |
2715 return kills; // Uplift to interface | 2807 return kills; // Uplift to interface |
2716 if (!empty() && ktkp != NULL && ktkp->klass()->is_loaded() && ktkp->klass()->is_interface()) | |
2717 return kills; // Uplift to interface | |
2718 | 2808 |
2719 return Type::TOP; // Canonical empty value | 2809 return Type::TOP; // Canonical empty value |
2720 } | 2810 } |
2721 | 2811 |
2722 // If we have an interface-typed Phi or cast and we narrow to a class type, | 2812 // If we have an interface-typed Phi or cast and we narrow to a class type, |
2729 ktip->is_loaded() && !ktip->klass()->is_interface()) { | 2819 ktip->is_loaded() && !ktip->klass()->is_interface()) { |
2730 // Happens in a CTW of rt.jar, 320-341, no extra flags | 2820 // Happens in a CTW of rt.jar, 320-341, no extra flags |
2731 assert(!ftip->klass_is_exact(), "interface could not be exact"); | 2821 assert(!ftip->klass_is_exact(), "interface could not be exact"); |
2732 return ktip->cast_to_ptr_type(ftip->ptr()); | 2822 return ktip->cast_to_ptr_type(ftip->ptr()); |
2733 } | 2823 } |
2734 // Interface klass type could be exact in opposite to interface type, | |
2735 // return it here instead of incorrect Constant ptr J/L/Object (6894807). | |
2736 if (ftkp != NULL && ktkp != NULL && | |
2737 ftkp->is_loaded() && ftkp->klass()->is_interface() && | |
2738 !ftkp->klass_is_exact() && // Keep exact interface klass | |
2739 ktkp->is_loaded() && !ktkp->klass()->is_interface()) { | |
2740 return ktkp->cast_to_ptr_type(ftkp->ptr()); | |
2741 } | |
2742 | 2824 |
2743 return ft; | 2825 return ft; |
2744 } | 2826 } |
2745 | 2827 |
2746 //------------------------------eq--------------------------------------------- | 2828 //------------------------------eq--------------------------------------------- |
2747 // Structural equality check for Type representations | 2829 // Structural equality check for Type representations |
2748 bool TypeOopPtr::eq( const Type *t ) const { | 2830 bool TypeOopPtr::eq( const Type *t ) const { |
2749 const TypeOopPtr *a = (const TypeOopPtr*)t; | 2831 const TypeOopPtr *a = (const TypeOopPtr*)t; |
2750 if (_klass_is_exact != a->_klass_is_exact || | 2832 if (_klass_is_exact != a->_klass_is_exact || |
2751 _instance_id != a->_instance_id) return false; | 2833 _instance_id != a->_instance_id || |
2834 !eq_speculative(a)) return false; | |
2752 ciObject* one = const_oop(); | 2835 ciObject* one = const_oop(); |
2753 ciObject* two = a->const_oop(); | 2836 ciObject* two = a->const_oop(); |
2754 if (one == NULL || two == NULL) { | 2837 if (one == NULL || two == NULL) { |
2755 return (one == two) && TypePtr::eq(t); | 2838 return (one == two) && TypePtr::eq(t); |
2756 } else { | 2839 } else { |
2763 int TypeOopPtr::hash(void) const { | 2846 int TypeOopPtr::hash(void) const { |
2764 return | 2847 return |
2765 (const_oop() ? const_oop()->hash() : 0) + | 2848 (const_oop() ? const_oop()->hash() : 0) + |
2766 _klass_is_exact + | 2849 _klass_is_exact + |
2767 _instance_id + | 2850 _instance_id + |
2851 hash_speculative() + | |
2768 TypePtr::hash(); | 2852 TypePtr::hash(); |
2769 } | 2853 } |
2770 | 2854 |
2771 //------------------------------dump2------------------------------------------ | 2855 //------------------------------dump2------------------------------------------ |
2772 #ifndef PRODUCT | 2856 #ifndef PRODUCT |
2782 } | 2866 } |
2783 if (_instance_id == InstanceTop) | 2867 if (_instance_id == InstanceTop) |
2784 st->print(",iid=top"); | 2868 st->print(",iid=top"); |
2785 else if (_instance_id != InstanceBot) | 2869 else if (_instance_id != InstanceBot) |
2786 st->print(",iid=%d",_instance_id); | 2870 st->print(",iid=%d",_instance_id); |
2871 | |
2872 dump_speculative(st); | |
2873 } | |
2874 | |
2875 /** | |
2876 *dump the speculative part of the type | |
2877 */ | |
2878 void TypeOopPtr::dump_speculative(outputStream *st) const { | |
2879 if (_speculative != NULL) { | |
2880 st->print(" (speculative="); | |
2881 _speculative->dump_on(st); | |
2882 st->print(")"); | |
2883 } | |
2787 } | 2884 } |
2788 #endif | 2885 #endif |
2789 | 2886 |
2790 //------------------------------singleton-------------------------------------- | 2887 //------------------------------singleton-------------------------------------- |
2791 // 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 |
2795 // TopPTR, Null, AnyNull, Constant are all singletons | 2892 // TopPTR, Null, AnyNull, Constant are all singletons |
2796 return (_offset == 0) && !below_centerline(_ptr); | 2893 return (_offset == 0) && !below_centerline(_ptr); |
2797 } | 2894 } |
2798 | 2895 |
2799 //------------------------------add_offset------------------------------------- | 2896 //------------------------------add_offset------------------------------------- |
2800 const TypePtr *TypeOopPtr::add_offset( intptr_t offset ) const { | 2897 const TypePtr *TypeOopPtr::add_offset(intptr_t offset) const { |
2801 return make( _ptr, xadd_offset(offset), _instance_id); | 2898 return make(_ptr, xadd_offset(offset), _instance_id, add_offset_speculative(offset)); |
2899 } | |
2900 | |
2901 /** | |
2902 * Return same type without a speculative part | |
2903 */ | |
2904 const TypeOopPtr* TypeOopPtr::remove_speculative() const { | |
2905 return make(_ptr, _offset, _instance_id, NULL); | |
2802 } | 2906 } |
2803 | 2907 |
2804 //------------------------------meet_instance_id-------------------------------- | 2908 //------------------------------meet_instance_id-------------------------------- |
2805 int TypeOopPtr::meet_instance_id( int instance_id ) const { | 2909 int TypeOopPtr::meet_instance_id( int instance_id ) const { |
2806 // Either is 'TOP' instance? Return the other instance! | 2910 // Either is 'TOP' instance? Return the other instance! |
2816 if( _instance_id == InstanceTop ) return InstanceBot; // Map TOP into BOTTOM | 2920 if( _instance_id == InstanceTop ) return InstanceBot; // Map TOP into BOTTOM |
2817 if( _instance_id == InstanceBot ) return InstanceTop; // Map BOTTOM into TOP | 2921 if( _instance_id == InstanceBot ) return InstanceTop; // Map BOTTOM into TOP |
2818 return _instance_id; // Map everything else into self | 2922 return _instance_id; // Map everything else into self |
2819 } | 2923 } |
2820 | 2924 |
2925 /** | |
2926 * meet of the speculative parts of 2 types | |
2927 * | |
2928 * @param other type to meet with | |
2929 */ | |
2930 const TypeOopPtr* TypeOopPtr::meet_speculative(const TypeOopPtr* other) const { | |
2931 bool this_has_spec = (_speculative != NULL); | |
2932 bool other_has_spec = (other->speculative() != NULL); | |
2933 | |
2934 if (!this_has_spec && !other_has_spec) { | |
2935 return NULL; | |
2936 } | |
2937 | |
2938 // If we are at a point where control flow meets and one branch has | |
2939 // a speculative type and the other has not, we meet the speculative | |
2940 // type of one branch with the actual type of the other. If the | |
2941 // actual type is exact and the speculative is as well, then the | |
2942 // result is a speculative type which is exact and we can continue | |
2943 // speculation further. | |
2944 const TypeOopPtr* this_spec = _speculative; | |
2945 const TypeOopPtr* other_spec = other->speculative(); | |
2946 | |
2947 if (!this_has_spec) { | |
2948 this_spec = this; | |
2949 } | |
2950 | |
2951 if (!other_has_spec) { | |
2952 other_spec = other; | |
2953 } | |
2954 | |
2955 return this_spec->meet(other_spec)->is_oopptr(); | |
2956 } | |
2957 | |
2958 /** | |
2959 * dual of the speculative part of the type | |
2960 */ | |
2961 const TypeOopPtr* TypeOopPtr::dual_speculative() const { | |
2962 if (_speculative == NULL) { | |
2963 return NULL; | |
2964 } | |
2965 return _speculative->dual()->is_oopptr(); | |
2966 } | |
2967 | |
2968 /** | |
2969 * add offset to the speculative part of the type | |
2970 * | |
2971 * @param offset offset to add | |
2972 */ | |
2973 const TypeOopPtr* TypeOopPtr::add_offset_speculative(intptr_t offset) const { | |
2974 if (_speculative == NULL) { | |
2975 return NULL; | |
2976 } | |
2977 return _speculative->add_offset(offset)->is_oopptr(); | |
2978 } | |
2979 | |
2980 /** | |
2981 * Are the speculative parts of 2 types equal? | |
2982 * | |
2983 * @param other type to compare this one to | |
2984 */ | |
2985 bool TypeOopPtr::eq_speculative(const TypeOopPtr* other) const { | |
2986 if (_speculative == NULL || other->speculative() == NULL) { | |
2987 return _speculative == other->speculative(); | |
2988 } | |
2989 | |
2990 if (_speculative->base() != other->speculative()->base()) { | |
2991 return false; | |
2992 } | |
2993 | |
2994 return _speculative->eq(other->speculative()); | |
2995 } | |
2996 | |
2997 /** | |
2998 * Hash of the speculative part of the type | |
2999 */ | |
3000 int TypeOopPtr::hash_speculative() const { | |
3001 if (_speculative == NULL) { | |
3002 return 0; | |
3003 } | |
3004 | |
3005 return _speculative->hash(); | |
3006 } | |
3007 | |
2821 | 3008 |
2822 //============================================================================= | 3009 //============================================================================= |
2823 // Convenience common pre-built types. | 3010 // Convenience common pre-built types. |
2824 const TypeInstPtr *TypeInstPtr::NOTNULL; | 3011 const TypeInstPtr *TypeInstPtr::NOTNULL; |
2825 const TypeInstPtr *TypeInstPtr::BOTTOM; | 3012 const TypeInstPtr *TypeInstPtr::BOTTOM; |
2826 const TypeInstPtr *TypeInstPtr::MIRROR; | 3013 const TypeInstPtr *TypeInstPtr::MIRROR; |
2827 const TypeInstPtr *TypeInstPtr::MARK; | 3014 const TypeInstPtr *TypeInstPtr::MARK; |
2828 const TypeInstPtr *TypeInstPtr::KLASS; | 3015 const TypeInstPtr *TypeInstPtr::KLASS; |
2829 | 3016 |
2830 //------------------------------TypeInstPtr------------------------------------- | 3017 //------------------------------TypeInstPtr------------------------------------- |
2831 TypeInstPtr::TypeInstPtr(PTR ptr, ciKlass* k, bool xk, ciObject* o, int off, int instance_id) | 3018 TypeInstPtr::TypeInstPtr(PTR ptr, ciKlass* k, bool xk, ciObject* o, int off, int instance_id, const TypeOopPtr* speculative) |
2832 : TypeOopPtr(InstPtr, ptr, k, xk, o, off, instance_id), _name(k->name()) { | 3019 : TypeOopPtr(InstPtr, ptr, k, xk, o, off, instance_id, speculative), _name(k->name()) { |
2833 assert(k != NULL && | 3020 assert(k != NULL && |
2834 (k->is_loaded() || o == NULL), | 3021 (k->is_loaded() || o == NULL), |
2835 "cannot have constants with non-loaded klass"); | 3022 "cannot have constants with non-loaded klass"); |
2836 }; | 3023 }; |
2837 | 3024 |
2839 const TypeInstPtr *TypeInstPtr::make(PTR ptr, | 3026 const TypeInstPtr *TypeInstPtr::make(PTR ptr, |
2840 ciKlass* k, | 3027 ciKlass* k, |
2841 bool xk, | 3028 bool xk, |
2842 ciObject* o, | 3029 ciObject* o, |
2843 int offset, | 3030 int offset, |
2844 int instance_id) { | 3031 int instance_id, |
3032 const TypeOopPtr* speculative) { | |
2845 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"); |
2846 // Either const_oop() is NULL or else ptr is Constant | 3034 // Either const_oop() is NULL or else ptr is Constant |
2847 assert( (!o && ptr != Constant) || (o && ptr == Constant), | 3035 assert( (!o && ptr != Constant) || (o && ptr == Constant), |
2848 "constant pointers must have a value supplied" ); | 3036 "constant pointers must have a value supplied" ); |
2849 // Ptr is never Null | 3037 // Ptr is never Null |
2860 if (xk && ik->is_interface()) xk = false; // no exact interface | 3048 if (xk && ik->is_interface()) xk = false; // no exact interface |
2861 } | 3049 } |
2862 | 3050 |
2863 // Now hash this baby | 3051 // Now hash this baby |
2864 TypeInstPtr *result = | 3052 TypeInstPtr *result = |
2865 (TypeInstPtr*)(new TypeInstPtr(ptr, k, xk, o ,offset, instance_id))->hashcons(); | 3053 (TypeInstPtr*)(new TypeInstPtr(ptr, k, xk, o ,offset, instance_id, speculative))->hashcons(); |
2866 | 3054 |
2867 return result; | 3055 return result; |
2868 } | 3056 } |
2869 | 3057 |
2870 /** | 3058 /** |
2893 //------------------------------cast_to_ptr_type------------------------------- | 3081 //------------------------------cast_to_ptr_type------------------------------- |
2894 const Type *TypeInstPtr::cast_to_ptr_type(PTR ptr) const { | 3082 const Type *TypeInstPtr::cast_to_ptr_type(PTR ptr) const { |
2895 if( ptr == _ptr ) return this; | 3083 if( ptr == _ptr ) return this; |
2896 // Reconstruct _sig info here since not a problem with later lazy | 3084 // Reconstruct _sig info here since not a problem with later lazy |
2897 // construction, _sig will show up on demand. | 3085 // construction, _sig will show up on demand. |
2898 return make(ptr, klass(), klass_is_exact(), const_oop(), _offset, _instance_id); | 3086 return make(ptr, klass(), klass_is_exact(), const_oop(), _offset, _instance_id, _speculative); |
2899 } | 3087 } |
2900 | 3088 |
2901 | 3089 |
2902 //-----------------------------cast_to_exactness------------------------------- | 3090 //-----------------------------cast_to_exactness------------------------------- |
2903 const Type *TypeInstPtr::cast_to_exactness(bool klass_is_exact) const { | 3091 const Type *TypeInstPtr::cast_to_exactness(bool klass_is_exact) const { |
2905 if (!UseExactTypes) return this; | 3093 if (!UseExactTypes) return this; |
2906 if (!_klass->is_loaded()) return this; | 3094 if (!_klass->is_loaded()) return this; |
2907 ciInstanceKlass* ik = _klass->as_instance_klass(); | 3095 ciInstanceKlass* ik = _klass->as_instance_klass(); |
2908 if( (ik->is_final() || _const_oop) ) return this; // cannot clear xk | 3096 if( (ik->is_final() || _const_oop) ) return this; // cannot clear xk |
2909 if( ik->is_interface() ) return this; // cannot set xk | 3097 if( ik->is_interface() ) return this; // cannot set xk |
2910 return make(ptr(), klass(), klass_is_exact, const_oop(), _offset, _instance_id); | 3098 return make(ptr(), klass(), klass_is_exact, const_oop(), _offset, _instance_id, _speculative); |
2911 } | 3099 } |
2912 | 3100 |
2913 //-----------------------------cast_to_instance_id---------------------------- | 3101 //-----------------------------cast_to_instance_id---------------------------- |
2914 const TypeOopPtr *TypeInstPtr::cast_to_instance_id(int instance_id) const { | 3102 const TypeOopPtr *TypeInstPtr::cast_to_instance_id(int instance_id) const { |
2915 if( instance_id == _instance_id ) return this; | 3103 if( instance_id == _instance_id ) return this; |
2916 return make(_ptr, klass(), _klass_is_exact, const_oop(), _offset, instance_id); | 3104 return make(_ptr, klass(), _klass_is_exact, const_oop(), _offset, instance_id, _speculative); |
2917 } | 3105 } |
2918 | 3106 |
2919 //------------------------------xmeet_unloaded--------------------------------- | 3107 //------------------------------xmeet_unloaded--------------------------------- |
2920 // 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. |
2921 // 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 |
2922 const TypeInstPtr *TypeInstPtr::xmeet_unloaded(const TypeInstPtr *tinst) const { | 3110 const TypeInstPtr *TypeInstPtr::xmeet_unloaded(const TypeInstPtr *tinst) const { |
2923 int off = meet_offset(tinst->offset()); | 3111 int off = meet_offset(tinst->offset()); |
2924 PTR ptr = meet_ptr(tinst->ptr()); | 3112 PTR ptr = meet_ptr(tinst->ptr()); |
2925 int instance_id = meet_instance_id(tinst->instance_id()); | 3113 int instance_id = meet_instance_id(tinst->instance_id()); |
3114 const TypeOopPtr* speculative = meet_speculative(tinst); | |
2926 | 3115 |
2927 const TypeInstPtr *loaded = is_loaded() ? this : tinst; | 3116 const TypeInstPtr *loaded = is_loaded() ? this : tinst; |
2928 const TypeInstPtr *unloaded = is_loaded() ? tinst : this; | 3117 const TypeInstPtr *unloaded = is_loaded() ? tinst : this; |
2929 if( loaded->klass()->equals(ciEnv::current()->Object_klass()) ) { | 3118 if( loaded->klass()->equals(ciEnv::current()->Object_klass()) ) { |
2930 // | 3119 // |
2941 // BOTTOM | ........................Object-BOTTOM ..................| | 3130 // BOTTOM | ........................Object-BOTTOM ..................| |
2942 // | 3131 // |
2943 assert(loaded->ptr() != TypePtr::Null, "insanity check"); | 3132 assert(loaded->ptr() != TypePtr::Null, "insanity check"); |
2944 // | 3133 // |
2945 if( loaded->ptr() == TypePtr::TopPTR ) { return unloaded; } | 3134 if( loaded->ptr() == TypePtr::TopPTR ) { return unloaded; } |
2946 else if (loaded->ptr() == TypePtr::AnyNull) { return TypeInstPtr::make( ptr, unloaded->klass(), false, NULL, off, instance_id ); } | 3135 else if (loaded->ptr() == TypePtr::AnyNull) { return TypeInstPtr::make(ptr, unloaded->klass(), false, NULL, off, instance_id, speculative); } |
2947 else if (loaded->ptr() == TypePtr::BotPTR ) { return TypeInstPtr::BOTTOM; } | 3136 else if (loaded->ptr() == TypePtr::BotPTR ) { return TypeInstPtr::BOTTOM; } |
2948 else if (loaded->ptr() == TypePtr::Constant || loaded->ptr() == TypePtr::NotNull) { | 3137 else if (loaded->ptr() == TypePtr::Constant || loaded->ptr() == TypePtr::NotNull) { |
2949 if (unloaded->ptr() == TypePtr::BotPTR ) { return TypeInstPtr::BOTTOM; } | 3138 if (unloaded->ptr() == TypePtr::BotPTR ) { return TypeInstPtr::BOTTOM; } |
2950 else { return TypeInstPtr::NOTNULL; } | 3139 else { return TypeInstPtr::NOTNULL; } |
2951 } | 3140 } |
2963 } | 3152 } |
2964 | 3153 |
2965 | 3154 |
2966 //------------------------------meet------------------------------------------- | 3155 //------------------------------meet------------------------------------------- |
2967 // Compute the MEET of two types. It returns a new Type object. | 3156 // Compute the MEET of two types. It returns a new Type object. |
2968 const Type *TypeInstPtr::xmeet( const Type *t ) const { | 3157 const Type *TypeInstPtr::xmeet_helper(const Type *t) const { |
2969 // Perform a fast test for common case; meeting the same types together. | 3158 // Perform a fast test for common case; meeting the same types together. |
2970 if( this == t ) return this; // Meeting same type-rep? | 3159 if( this == t ) return this; // Meeting same type-rep? |
2971 | 3160 |
2972 // Current "this->_base" is Pointer | 3161 // Current "this->_base" is Pointer |
2973 switch (t->base()) { // switch on original type | 3162 switch (t->base()) { // switch on original type |
2997 case AryPtr: { // All arrays inherit from Object class | 3186 case AryPtr: { // All arrays inherit from Object class |
2998 const TypeAryPtr *tp = t->is_aryptr(); | 3187 const TypeAryPtr *tp = t->is_aryptr(); |
2999 int offset = meet_offset(tp->offset()); | 3188 int offset = meet_offset(tp->offset()); |
3000 PTR ptr = meet_ptr(tp->ptr()); | 3189 PTR ptr = meet_ptr(tp->ptr()); |
3001 int instance_id = meet_instance_id(tp->instance_id()); | 3190 int instance_id = meet_instance_id(tp->instance_id()); |
3191 const TypeOopPtr* speculative = meet_speculative(tp); | |
3002 switch (ptr) { | 3192 switch (ptr) { |
3003 case TopPTR: | 3193 case TopPTR: |
3004 case AnyNull: // Fall 'down' to dual of object klass | 3194 case AnyNull: // Fall 'down' to dual of object klass |
3005 if (klass()->equals(ciEnv::current()->Object_klass())) { | 3195 // For instances when a subclass meets a superclass we fall |
3006 return TypeAryPtr::make(ptr, tp->ary(), tp->klass(), tp->klass_is_exact(), offset, instance_id); | 3196 // below the centerline when the superclass is exact. We need to |
3197 // do the same here. | |
3198 if (klass()->equals(ciEnv::current()->Object_klass()) && !klass_is_exact()) { | |
3199 return TypeAryPtr::make(ptr, tp->ary(), tp->klass(), tp->klass_is_exact(), offset, instance_id, speculative); | |
3007 } else { | 3200 } else { |
3008 // 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 |
3009 ptr = NotNull; | 3202 ptr = NotNull; |
3010 instance_id = InstanceBot; | 3203 instance_id = InstanceBot; |
3011 return TypeInstPtr::make( ptr, ciEnv::current()->Object_klass(), false, NULL, offset, instance_id); | 3204 return TypeInstPtr::make( ptr, ciEnv::current()->Object_klass(), false, NULL, offset, instance_id, speculative); |
3012 } | 3205 } |
3013 case Constant: | 3206 case Constant: |
3014 case NotNull: | 3207 case NotNull: |
3015 case BotPTR: // Fall down to object klass | 3208 case BotPTR: // Fall down to object klass |
3016 // 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 |
3017 if( above_centerline(_ptr) ) { // if( _ptr == TopPTR || _ptr == AnyNull ) | 3210 if( above_centerline(_ptr) ) { // if( _ptr == TopPTR || _ptr == AnyNull ) |
3018 // If 'this' (InstPtr) is above the centerline and it is Object class | 3211 // If 'this' (InstPtr) is above the centerline and it is Object class |
3019 // then we can subclass in the Java class hierarchy. | 3212 // then we can subclass in the Java class hierarchy. |
3020 if (klass()->equals(ciEnv::current()->Object_klass())) { | 3213 // For instances when a subclass meets a superclass we fall |
3214 // below the centerline when the superclass is exact. We need | |
3215 // to do the same here. | |
3216 if (klass()->equals(ciEnv::current()->Object_klass()) && !klass_is_exact()) { | |
3021 // 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 |
3022 return TypeAryPtr::make(ptr, (ptr == Constant ? tp->const_oop() : NULL), | 3218 return TypeAryPtr::make(ptr, (ptr == Constant ? tp->const_oop() : NULL), |
3023 tp->ary(), tp->klass(), tp->klass_is_exact(), offset, instance_id); | 3219 tp->ary(), tp->klass(), tp->klass_is_exact(), offset, instance_id, speculative); |
3024 } | 3220 } |
3025 } | 3221 } |
3026 // 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. |
3027 // The meet falls down to Object class below centerline. | 3223 // The meet falls down to Object class below centerline. |
3028 if( ptr == Constant ) | 3224 if( ptr == Constant ) |
3029 ptr = NotNull; | 3225 ptr = NotNull; |
3030 instance_id = InstanceBot; | 3226 instance_id = InstanceBot; |
3031 return make( ptr, ciEnv::current()->Object_klass(), false, NULL, offset, instance_id ); | 3227 return make(ptr, ciEnv::current()->Object_klass(), false, NULL, offset, instance_id, speculative); |
3032 default: typerr(t); | 3228 default: typerr(t); |
3033 } | 3229 } |
3034 } | 3230 } |
3035 | 3231 |
3036 case OopPtr: { // Meeting to OopPtrs | 3232 case OopPtr: { // Meeting to OopPtrs |
3040 PTR ptr = meet_ptr(tp->ptr()); | 3236 PTR ptr = meet_ptr(tp->ptr()); |
3041 switch (tp->ptr()) { | 3237 switch (tp->ptr()) { |
3042 case TopPTR: | 3238 case TopPTR: |
3043 case AnyNull: { | 3239 case AnyNull: { |
3044 int instance_id = meet_instance_id(InstanceTop); | 3240 int instance_id = meet_instance_id(InstanceTop); |
3241 const TypeOopPtr* speculative = meet_speculative(tp); | |
3045 return make(ptr, klass(), klass_is_exact(), | 3242 return make(ptr, klass(), klass_is_exact(), |
3046 (ptr == Constant ? const_oop() : NULL), offset, instance_id); | 3243 (ptr == Constant ? const_oop() : NULL), offset, instance_id, speculative); |
3047 } | 3244 } |
3048 case NotNull: | 3245 case NotNull: |
3049 case BotPTR: { | 3246 case BotPTR: { |
3050 int instance_id = meet_instance_id(tp->instance_id()); | 3247 int instance_id = meet_instance_id(tp->instance_id()); |
3051 return TypeOopPtr::make(ptr, offset, instance_id); | 3248 const TypeOopPtr* speculative = meet_speculative(tp); |
3249 return TypeOopPtr::make(ptr, offset, instance_id, speculative); | |
3052 } | 3250 } |
3053 default: typerr(t); | 3251 default: typerr(t); |
3054 } | 3252 } |
3055 } | 3253 } |
3056 | 3254 |
3059 const TypePtr *tp = t->is_ptr(); | 3257 const TypePtr *tp = t->is_ptr(); |
3060 int offset = meet_offset(tp->offset()); | 3258 int offset = meet_offset(tp->offset()); |
3061 PTR ptr = meet_ptr(tp->ptr()); | 3259 PTR ptr = meet_ptr(tp->ptr()); |
3062 switch (tp->ptr()) { | 3260 switch (tp->ptr()) { |
3063 case Null: | 3261 case Null: |
3064 if( ptr == Null ) return TypePtr::make( AnyPtr, ptr, offset ); | 3262 if( ptr == Null ) return TypePtr::make(AnyPtr, ptr, offset); |
3065 // else fall through to AnyNull | 3263 // else fall through to AnyNull |
3066 case TopPTR: | 3264 case TopPTR: |
3067 case AnyNull: { | 3265 case AnyNull: { |
3068 int instance_id = meet_instance_id(InstanceTop); | 3266 int instance_id = meet_instance_id(InstanceTop); |
3069 return make( ptr, klass(), klass_is_exact(), | 3267 const TypeOopPtr* speculative = _speculative; |
3070 (ptr == Constant ? const_oop() : NULL), offset, instance_id); | 3268 return make(ptr, klass(), klass_is_exact(), |
3269 (ptr == Constant ? const_oop() : NULL), offset, instance_id, speculative); | |
3071 } | 3270 } |
3072 case NotNull: | 3271 case NotNull: |
3073 case BotPTR: | 3272 case BotPTR: |
3074 return TypePtr::make( AnyPtr, ptr, offset ); | 3273 return TypePtr::make(AnyPtr, ptr, offset); |
3075 default: typerr(t); | 3274 default: typerr(t); |
3076 } | 3275 } |
3077 } | 3276 } |
3078 | 3277 |
3079 /* | 3278 /* |
3096 // Found an InstPtr sub-type vs self-InstPtr type | 3295 // Found an InstPtr sub-type vs self-InstPtr type |
3097 const TypeInstPtr *tinst = t->is_instptr(); | 3296 const TypeInstPtr *tinst = t->is_instptr(); |
3098 int off = meet_offset( tinst->offset() ); | 3297 int off = meet_offset( tinst->offset() ); |
3099 PTR ptr = meet_ptr( tinst->ptr() ); | 3298 PTR ptr = meet_ptr( tinst->ptr() ); |
3100 int instance_id = meet_instance_id(tinst->instance_id()); | 3299 int instance_id = meet_instance_id(tinst->instance_id()); |
3300 const TypeOopPtr* speculative = meet_speculative(tinst); | |
3101 | 3301 |
3102 // Check for easy case; klasses are equal (and perhaps not loaded!) | 3302 // Check for easy case; klasses are equal (and perhaps not loaded!) |
3103 // 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 |
3104 // and we can handle the constants further down. This case handles | 3304 // and we can handle the constants further down. This case handles |
3105 // both-not-loaded or both-loaded classes | 3305 // both-not-loaded or both-loaded classes |
3106 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()) { |
3107 return make( ptr, klass(), klass_is_exact(), NULL, off, instance_id ); | 3307 return make(ptr, klass(), klass_is_exact(), NULL, off, instance_id, speculative); |
3108 } | 3308 } |
3109 | 3309 |
3110 // Classes require inspection in the Java klass hierarchy. Must be loaded. | 3310 // Classes require inspection in the Java klass hierarchy. Must be loaded. |
3111 ciKlass* tinst_klass = tinst->klass(); | 3311 ciKlass* tinst_klass = tinst->klass(); |
3112 ciKlass* this_klass = this->klass(); | 3312 ciKlass* this_klass = this->klass(); |
3124 #endif | 3324 #endif |
3125 return unloaded_meet; | 3325 return unloaded_meet; |
3126 } | 3326 } |
3127 | 3327 |
3128 // Handle mixing oops and interfaces first. | 3328 // Handle mixing oops and interfaces first. |
3129 if( this_klass->is_interface() && !tinst_klass->is_interface() ) { | 3329 if( this_klass->is_interface() && !(tinst_klass->is_interface() || |
3330 tinst_klass == ciEnv::current()->Object_klass())) { | |
3130 ciKlass *tmp = tinst_klass; // Swap interface around | 3331 ciKlass *tmp = tinst_klass; // Swap interface around |
3131 tinst_klass = this_klass; | 3332 tinst_klass = this_klass; |
3132 this_klass = tmp; | 3333 this_klass = tmp; |
3133 bool tmp2 = tinst_xk; | 3334 bool tmp2 = tinst_xk; |
3134 tinst_xk = this_xk; | 3335 tinst_xk = this_xk; |
3165 ciObject* o = NULL; // the Constant value, if any | 3366 ciObject* o = NULL; // the Constant value, if any |
3166 if (ptr == Constant) { | 3367 if (ptr == Constant) { |
3167 // Find out which constant. | 3368 // Find out which constant. |
3168 o = (this_klass == klass()) ? const_oop() : tinst->const_oop(); | 3369 o = (this_klass == klass()) ? const_oop() : tinst->const_oop(); |
3169 } | 3370 } |
3170 return make( ptr, k, xk, o, off, instance_id ); | 3371 return make(ptr, k, xk, o, off, instance_id, speculative); |
3171 } | 3372 } |
3172 | 3373 |
3173 // 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 |
3174 | 3375 |
3175 // !!! Here's how the symmetry requirement breaks down into invariants: | 3376 // !!! Here's how the symmetry requirement breaks down into invariants: |
3242 else if (above_centerline(tinst ->_ptr)) | 3443 else if (above_centerline(tinst ->_ptr)) |
3243 o = this_oop; | 3444 o = this_oop; |
3244 else | 3445 else |
3245 ptr = NotNull; | 3446 ptr = NotNull; |
3246 } | 3447 } |
3247 return make( ptr, this_klass, this_xk, o, off, instance_id ); | 3448 return make(ptr, this_klass, this_xk, o, off, instance_id, speculative); |
3248 } // Else classes are not equal | 3449 } // Else classes are not equal |
3249 | 3450 |
3250 // Since klasses are different, we require a LCA in the Java | 3451 // Since klasses are different, we require a LCA in the Java |
3251 // 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. |
3252 if( ptr == TopPTR || ptr == AnyNull || ptr == Constant ) | 3453 if( ptr == TopPTR || ptr == AnyNull || ptr == Constant ) |
3253 ptr = NotNull; | 3454 ptr = NotNull; |
3254 instance_id = InstanceBot; | 3455 instance_id = InstanceBot; |
3255 | 3456 |
3256 // Now we find the LCA of Java classes | 3457 // Now we find the LCA of Java classes |
3257 ciKlass* k = this_klass->least_common_ancestor(tinst_klass); | 3458 ciKlass* k = this_klass->least_common_ancestor(tinst_klass); |
3258 return make( ptr, k, false, NULL, off, instance_id ); | 3459 return make(ptr, k, false, NULL, off, instance_id, speculative); |
3259 } // End of case InstPtr | 3460 } // End of case InstPtr |
3260 | 3461 |
3261 } // End of switch | 3462 } // End of switch |
3262 return this; // Return the double constant | 3463 return this; // Return the double constant |
3263 } | 3464 } |
3277 | 3478 |
3278 //------------------------------xdual------------------------------------------ | 3479 //------------------------------xdual------------------------------------------ |
3279 // 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 |
3280 // inheritance mechanism. | 3481 // inheritance mechanism. |
3281 const Type *TypeInstPtr::xdual() const { | 3482 const Type *TypeInstPtr::xdual() const { |
3282 return new TypeInstPtr( dual_ptr(), klass(), klass_is_exact(), const_oop(), dual_offset(), dual_instance_id() ); | 3483 return new TypeInstPtr(dual_ptr(), klass(), klass_is_exact(), const_oop(), dual_offset(), dual_instance_id(), dual_speculative()); |
3283 } | 3484 } |
3284 | 3485 |
3285 //------------------------------eq--------------------------------------------- | 3486 //------------------------------eq--------------------------------------------- |
3286 // Structural equality check for Type representations | 3487 // Structural equality check for Type representations |
3287 bool TypeInstPtr::eq( const Type *t ) const { | 3488 bool TypeInstPtr::eq( const Type *t ) const { |
3333 st->print(" *"); | 3534 st->print(" *"); |
3334 if (_instance_id == InstanceTop) | 3535 if (_instance_id == InstanceTop) |
3335 st->print(",iid=top"); | 3536 st->print(",iid=top"); |
3336 else if (_instance_id != InstanceBot) | 3537 else if (_instance_id != InstanceBot) |
3337 st->print(",iid=%d",_instance_id); | 3538 st->print(",iid=%d",_instance_id); |
3539 | |
3540 dump_speculative(st); | |
3338 } | 3541 } |
3339 #endif | 3542 #endif |
3340 | 3543 |
3341 //------------------------------add_offset------------------------------------- | 3544 //------------------------------add_offset------------------------------------- |
3342 const TypePtr *TypeInstPtr::add_offset( intptr_t offset ) const { | 3545 const TypePtr *TypeInstPtr::add_offset(intptr_t offset) const { |
3343 return make( _ptr, klass(), klass_is_exact(), const_oop(), xadd_offset(offset), _instance_id ); | 3546 return make(_ptr, klass(), klass_is_exact(), const_oop(), xadd_offset(offset), _instance_id, add_offset_speculative(offset)); |
3547 } | |
3548 | |
3549 const TypeOopPtr *TypeInstPtr::remove_speculative() const { | |
3550 return make(_ptr, klass(), klass_is_exact(), const_oop(), _offset, _instance_id, NULL); | |
3344 } | 3551 } |
3345 | 3552 |
3346 //============================================================================= | 3553 //============================================================================= |
3347 // Convenience common pre-built types. | 3554 // Convenience common pre-built types. |
3348 const TypeAryPtr *TypeAryPtr::RANGE; | 3555 const TypeAryPtr *TypeAryPtr::RANGE; |
3355 const TypeAryPtr *TypeAryPtr::LONGS; | 3562 const TypeAryPtr *TypeAryPtr::LONGS; |
3356 const TypeAryPtr *TypeAryPtr::FLOATS; | 3563 const TypeAryPtr *TypeAryPtr::FLOATS; |
3357 const TypeAryPtr *TypeAryPtr::DOUBLES; | 3564 const TypeAryPtr *TypeAryPtr::DOUBLES; |
3358 | 3565 |
3359 //------------------------------make------------------------------------------- | 3566 //------------------------------make------------------------------------------- |
3360 const TypeAryPtr *TypeAryPtr::make( PTR ptr, const TypeAry *ary, ciKlass* k, bool xk, int offset, int instance_id ) { | 3567 const TypeAryPtr *TypeAryPtr::make(PTR ptr, const TypeAry *ary, ciKlass* k, bool xk, int offset, int instance_id, const TypeOopPtr* speculative) { |
3361 assert(!(k == NULL && ary->_elem->isa_int()), | 3568 assert(!(k == NULL && ary->_elem->isa_int()), |
3362 "integral arrays must be pre-equipped with a class"); | 3569 "integral arrays must be pre-equipped with a class"); |
3363 if (!xk) xk = ary->ary_must_be_exact(); | 3570 if (!xk) xk = ary->ary_must_be_exact(); |
3364 assert(instance_id <= 0 || xk || !UseExactTypes, "instances are always exactly typed"); | 3571 assert(instance_id <= 0 || xk || !UseExactTypes, "instances are always exactly typed"); |
3365 if (!UseExactTypes) xk = (ptr == Constant); | 3572 if (!UseExactTypes) xk = (ptr == Constant); |
3366 return (TypeAryPtr*)(new TypeAryPtr(ptr, NULL, ary, k, xk, offset, instance_id, false))->hashcons(); | 3573 return (TypeAryPtr*)(new TypeAryPtr(ptr, NULL, ary, k, xk, offset, instance_id, false, speculative))->hashcons(); |
3367 } | 3574 } |
3368 | 3575 |
3369 //------------------------------make------------------------------------------- | 3576 //------------------------------make------------------------------------------- |
3370 const TypeAryPtr *TypeAryPtr::make( PTR ptr, ciObject* o, const TypeAry *ary, ciKlass* k, bool xk, int offset, int instance_id, 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) { |
3371 assert(!(k == NULL && ary->_elem->isa_int()), | 3578 assert(!(k == NULL && ary->_elem->isa_int()), |
3372 "integral arrays must be pre-equipped with a class"); | 3579 "integral arrays must be pre-equipped with a class"); |
3373 assert( (ptr==Constant && o) || (ptr!=Constant && !o), "" ); | 3580 assert( (ptr==Constant && o) || (ptr!=Constant && !o), "" ); |
3374 if (!xk) xk = (o != NULL) || ary->ary_must_be_exact(); | 3581 if (!xk) xk = (o != NULL) || ary->ary_must_be_exact(); |
3375 assert(instance_id <= 0 || xk || !UseExactTypes, "instances are always exactly typed"); | 3582 assert(instance_id <= 0 || xk || !UseExactTypes, "instances are always exactly typed"); |
3376 if (!UseExactTypes) xk = (ptr == Constant); | 3583 if (!UseExactTypes) xk = (ptr == Constant); |
3377 return (TypeAryPtr*)(new TypeAryPtr(ptr, o, ary, k, xk, offset, instance_id, is_autobox_cache))->hashcons(); | 3584 return (TypeAryPtr*)(new TypeAryPtr(ptr, o, ary, k, xk, offset, instance_id, is_autobox_cache, speculative))->hashcons(); |
3378 } | 3585 } |
3379 | 3586 |
3380 //------------------------------cast_to_ptr_type------------------------------- | 3587 //------------------------------cast_to_ptr_type------------------------------- |
3381 const Type *TypeAryPtr::cast_to_ptr_type(PTR ptr) const { | 3588 const Type *TypeAryPtr::cast_to_ptr_type(PTR ptr) const { |
3382 if( ptr == _ptr ) return this; | 3589 if( ptr == _ptr ) return this; |
3383 return make(ptr, const_oop(), _ary, klass(), klass_is_exact(), _offset, _instance_id); | 3590 return make(ptr, const_oop(), _ary, klass(), klass_is_exact(), _offset, _instance_id, _speculative); |
3384 } | 3591 } |
3385 | 3592 |
3386 | 3593 |
3387 //-----------------------------cast_to_exactness------------------------------- | 3594 //-----------------------------cast_to_exactness------------------------------- |
3388 const Type *TypeAryPtr::cast_to_exactness(bool klass_is_exact) const { | 3595 const Type *TypeAryPtr::cast_to_exactness(bool klass_is_exact) const { |
3389 if( klass_is_exact == _klass_is_exact ) return this; | 3596 if( klass_is_exact == _klass_is_exact ) return this; |
3390 if (!UseExactTypes) return this; | 3597 if (!UseExactTypes) return this; |
3391 if (_ary->ary_must_be_exact()) return this; // cannot clear xk | 3598 if (_ary->ary_must_be_exact()) return this; // cannot clear xk |
3392 return make(ptr(), const_oop(), _ary, klass(), klass_is_exact, _offset, _instance_id); | 3599 return make(ptr(), const_oop(), _ary, klass(), klass_is_exact, _offset, _instance_id, _speculative); |
3393 } | 3600 } |
3394 | 3601 |
3395 //-----------------------------cast_to_instance_id---------------------------- | 3602 //-----------------------------cast_to_instance_id---------------------------- |
3396 const TypeOopPtr *TypeAryPtr::cast_to_instance_id(int instance_id) const { | 3603 const TypeOopPtr *TypeAryPtr::cast_to_instance_id(int instance_id) const { |
3397 if( instance_id == _instance_id ) return this; | 3604 if( instance_id == _instance_id ) return this; |
3398 return make(_ptr, const_oop(), _ary, klass(), _klass_is_exact, _offset, instance_id); | 3605 return make(_ptr, const_oop(), _ary, klass(), _klass_is_exact, _offset, instance_id, _speculative); |
3399 } | 3606 } |
3400 | 3607 |
3401 //-----------------------------narrow_size_type------------------------------- | 3608 //-----------------------------narrow_size_type------------------------------- |
3402 // Local cache for arrayOopDesc::max_array_length(etype), | 3609 // Local cache for arrayOopDesc::max_array_length(etype), |
3403 // which is kind of slow (and cached elsewhere by other users). | 3610 // which is kind of slow (and cached elsewhere by other users). |
3455 //-------------------------------cast_to_size---------------------------------- | 3662 //-------------------------------cast_to_size---------------------------------- |
3456 const TypeAryPtr* TypeAryPtr::cast_to_size(const TypeInt* new_size) const { | 3663 const TypeAryPtr* TypeAryPtr::cast_to_size(const TypeInt* new_size) const { |
3457 assert(new_size != NULL, ""); | 3664 assert(new_size != NULL, ""); |
3458 new_size = narrow_size_type(new_size); | 3665 new_size = narrow_size_type(new_size); |
3459 if (new_size == size()) return this; | 3666 if (new_size == size()) return this; |
3460 const TypeAry* new_ary = TypeAry::make(elem(), new_size); | 3667 const TypeAry* new_ary = TypeAry::make(elem(), new_size, is_stable()); |
3668 return make(ptr(), const_oop(), new_ary, klass(), klass_is_exact(), _offset, _instance_id, _speculative); | |
3669 } | |
3670 | |
3671 | |
3672 //------------------------------cast_to_stable--------------------------------- | |
3673 const TypeAryPtr* TypeAryPtr::cast_to_stable(bool stable, int stable_dimension) const { | |
3674 if (stable_dimension <= 0 || (stable_dimension == 1 && stable == this->is_stable())) | |
3675 return this; | |
3676 | |
3677 const Type* elem = this->elem(); | |
3678 const TypePtr* elem_ptr = elem->make_ptr(); | |
3679 | |
3680 if (stable_dimension > 1 && elem_ptr != NULL && elem_ptr->isa_aryptr()) { | |
3681 // If this is widened from a narrow oop, TypeAry::make will re-narrow it. | |
3682 elem = elem_ptr = elem_ptr->is_aryptr()->cast_to_stable(stable, stable_dimension - 1); | |
3683 } | |
3684 | |
3685 const TypeAry* new_ary = TypeAry::make(elem, size(), stable); | |
3686 | |
3461 return make(ptr(), const_oop(), new_ary, klass(), klass_is_exact(), _offset, _instance_id); | 3687 return make(ptr(), const_oop(), new_ary, klass(), klass_is_exact(), _offset, _instance_id); |
3462 } | 3688 } |
3463 | 3689 |
3690 //-----------------------------stable_dimension-------------------------------- | |
3691 int TypeAryPtr::stable_dimension() const { | |
3692 if (!is_stable()) return 0; | |
3693 int dim = 1; | |
3694 const TypePtr* elem_ptr = elem()->make_ptr(); | |
3695 if (elem_ptr != NULL && elem_ptr->isa_aryptr()) | |
3696 dim += elem_ptr->is_aryptr()->stable_dimension(); | |
3697 return dim; | |
3698 } | |
3464 | 3699 |
3465 //------------------------------eq--------------------------------------------- | 3700 //------------------------------eq--------------------------------------------- |
3466 // Structural equality check for Type representations | 3701 // Structural equality check for Type representations |
3467 bool TypeAryPtr::eq( const Type *t ) const { | 3702 bool TypeAryPtr::eq( const Type *t ) const { |
3468 const TypeAryPtr *p = t->is_aryptr(); | 3703 const TypeAryPtr *p = t->is_aryptr(); |
3477 return (intptr_t)_ary + TypeOopPtr::hash(); | 3712 return (intptr_t)_ary + TypeOopPtr::hash(); |
3478 } | 3713 } |
3479 | 3714 |
3480 //------------------------------meet------------------------------------------- | 3715 //------------------------------meet------------------------------------------- |
3481 // Compute the MEET of two types. It returns a new Type object. | 3716 // Compute the MEET of two types. It returns a new Type object. |
3482 const Type *TypeAryPtr::xmeet( const Type *t ) const { | 3717 const Type *TypeAryPtr::xmeet_helper(const Type *t) const { |
3483 // Perform a fast test for common case; meeting the same types together. | 3718 // Perform a fast test for common case; meeting the same types together. |
3484 if( this == t ) return this; // Meeting same type-rep? | 3719 if( this == t ) return this; // Meeting same type-rep? |
3485 // Current "this->_base" is Pointer | 3720 // Current "this->_base" is Pointer |
3486 switch (t->base()) { // switch on original type | 3721 switch (t->base()) { // switch on original type |
3487 | 3722 |
3511 PTR ptr = meet_ptr(tp->ptr()); | 3746 PTR ptr = meet_ptr(tp->ptr()); |
3512 switch (tp->ptr()) { | 3747 switch (tp->ptr()) { |
3513 case TopPTR: | 3748 case TopPTR: |
3514 case AnyNull: { | 3749 case AnyNull: { |
3515 int instance_id = meet_instance_id(InstanceTop); | 3750 int instance_id = meet_instance_id(InstanceTop); |
3751 const TypeOopPtr* speculative = meet_speculative(tp); | |
3516 return make(ptr, (ptr == Constant ? const_oop() : NULL), | 3752 return make(ptr, (ptr == Constant ? const_oop() : NULL), |
3517 _ary, _klass, _klass_is_exact, offset, instance_id); | 3753 _ary, _klass, _klass_is_exact, offset, instance_id, speculative); |
3518 } | 3754 } |
3519 case BotPTR: | 3755 case BotPTR: |
3520 case NotNull: { | 3756 case NotNull: { |
3521 int instance_id = meet_instance_id(tp->instance_id()); | 3757 int instance_id = meet_instance_id(tp->instance_id()); |
3522 return TypeOopPtr::make(ptr, offset, instance_id); | 3758 const TypeOopPtr* speculative = meet_speculative(tp); |
3759 return TypeOopPtr::make(ptr, offset, instance_id, speculative); | |
3523 } | 3760 } |
3524 default: ShouldNotReachHere(); | 3761 default: ShouldNotReachHere(); |
3525 } | 3762 } |
3526 } | 3763 } |
3527 | 3764 |
3539 case Null: | 3776 case Null: |
3540 if( ptr == Null ) return TypePtr::make(AnyPtr, ptr, offset); | 3777 if( ptr == Null ) return TypePtr::make(AnyPtr, ptr, offset); |
3541 // else fall through to AnyNull | 3778 // else fall through to AnyNull |
3542 case AnyNull: { | 3779 case AnyNull: { |
3543 int instance_id = meet_instance_id(InstanceTop); | 3780 int instance_id = meet_instance_id(InstanceTop); |
3544 return make( ptr, (ptr == Constant ? const_oop() : NULL), | 3781 const TypeOopPtr* speculative = _speculative; |
3545 _ary, _klass, _klass_is_exact, offset, instance_id); | 3782 return make(ptr, (ptr == Constant ? const_oop() : NULL), |
3783 _ary, _klass, _klass_is_exact, offset, instance_id, speculative); | |
3546 } | 3784 } |
3547 default: ShouldNotReachHere(); | 3785 default: ShouldNotReachHere(); |
3548 } | 3786 } |
3549 } | 3787 } |
3550 | 3788 |
3556 const TypeAryPtr *tap = t->is_aryptr(); | 3794 const TypeAryPtr *tap = t->is_aryptr(); |
3557 int off = meet_offset(tap->offset()); | 3795 int off = meet_offset(tap->offset()); |
3558 const TypeAry *tary = _ary->meet(tap->_ary)->is_ary(); | 3796 const TypeAry *tary = _ary->meet(tap->_ary)->is_ary(); |
3559 PTR ptr = meet_ptr(tap->ptr()); | 3797 PTR ptr = meet_ptr(tap->ptr()); |
3560 int instance_id = meet_instance_id(tap->instance_id()); | 3798 int instance_id = meet_instance_id(tap->instance_id()); |
3799 const TypeOopPtr* speculative = meet_speculative(tap); | |
3561 ciKlass* lazy_klass = NULL; | 3800 ciKlass* lazy_klass = NULL; |
3562 if (tary->_elem->isa_int()) { | 3801 if (tary->_elem->isa_int()) { |
3563 // Integral array element types have irrelevant lattice relations. | 3802 // Integral array element types have irrelevant lattice relations. |
3564 // 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. |
3565 if (_klass == NULL) | 3804 if (_klass == NULL) |
3568 lazy_klass = _klass; | 3807 lazy_klass = _klass; |
3569 } else { | 3808 } else { |
3570 // Something like byte[int+] meets char[int+]. | 3809 // Something like byte[int+] meets char[int+]. |
3571 // This must fall to bottom, not (int[-128..65535])[int+]. | 3810 // This must fall to bottom, not (int[-128..65535])[int+]. |
3572 instance_id = InstanceBot; | 3811 instance_id = InstanceBot; |
3573 tary = TypeAry::make(Type::BOTTOM, tary->_size); | 3812 tary = TypeAry::make(Type::BOTTOM, tary->_size, tary->_stable); |
3574 } | 3813 } |
3575 } else // Non integral arrays. | 3814 } else // Non integral arrays. |
3576 // Must fall to bottom if exact klasses in upper lattice | 3815 // Must fall to bottom if exact klasses in upper lattice |
3577 // are not equal or super klass is exact. | 3816 // are not equal or super klass is exact. |
3578 if ( above_centerline(ptr) && klass() != tap->klass() && | 3817 if ( above_centerline(ptr) && klass() != tap->klass() && |
3582 ((tap ->_klass_is_exact && this->_klass_is_exact) || | 3821 ((tap ->_klass_is_exact && this->_klass_is_exact) || |
3583 // 'tap' is exact and super or unrelated: | 3822 // 'tap' is exact and super or unrelated: |
3584 (tap ->_klass_is_exact && !tap->klass()->is_subtype_of(klass())) || | 3823 (tap ->_klass_is_exact && !tap->klass()->is_subtype_of(klass())) || |
3585 // 'this' is exact and super or unrelated: | 3824 // 'this' is exact and super or unrelated: |
3586 (this->_klass_is_exact && !klass()->is_subtype_of(tap->klass())))) { | 3825 (this->_klass_is_exact && !klass()->is_subtype_of(tap->klass())))) { |
3587 tary = TypeAry::make(Type::BOTTOM, tary->_size); | 3826 tary = TypeAry::make(Type::BOTTOM, tary->_size, tary->_stable); |
3588 return make( NotNull, NULL, tary, lazy_klass, false, off, InstanceBot ); | 3827 return make(NotNull, NULL, tary, lazy_klass, false, off, InstanceBot); |
3589 } | 3828 } |
3590 | 3829 |
3591 bool xk = false; | 3830 bool xk = false; |
3592 switch (tap->ptr()) { | 3831 switch (tap->ptr()) { |
3593 case AnyNull: | 3832 case AnyNull: |
3594 case TopPTR: | 3833 case TopPTR: |
3595 // Compute new klass on demand, do not use tap->_klass | 3834 // Compute new klass on demand, do not use tap->_klass |
3596 xk = (tap->_klass_is_exact | this->_klass_is_exact); | 3835 if (below_centerline(this->_ptr)) { |
3597 return make( ptr, const_oop(), tary, lazy_klass, xk, off, instance_id ); | 3836 xk = this->_klass_is_exact; |
3837 } else { | |
3838 xk = (tap->_klass_is_exact | this->_klass_is_exact); | |
3839 } | |
3840 return make(ptr, const_oop(), tary, lazy_klass, xk, off, instance_id, speculative); | |
3598 case Constant: { | 3841 case Constant: { |
3599 ciObject* o = const_oop(); | 3842 ciObject* o = const_oop(); |
3600 if( _ptr == Constant ) { | 3843 if( _ptr == Constant ) { |
3601 if( tap->const_oop() != NULL && !o->equals(tap->const_oop()) ) { | 3844 if( tap->const_oop() != NULL && !o->equals(tap->const_oop()) ) { |
3602 xk = (klass() == tap->klass()); | 3845 xk = (klass() == tap->klass()); |
3604 o = NULL; | 3847 o = NULL; |
3605 instance_id = InstanceBot; | 3848 instance_id = InstanceBot; |
3606 } else { | 3849 } else { |
3607 xk = true; | 3850 xk = true; |
3608 } | 3851 } |
3609 } else if( above_centerline(_ptr) ) { | 3852 } else if(above_centerline(_ptr)) { |
3610 o = tap->const_oop(); | 3853 o = tap->const_oop(); |
3611 xk = true; | 3854 xk = true; |
3612 } else { | 3855 } else { |
3613 // Only precise for identical arrays | 3856 // Only precise for identical arrays |
3614 xk = this->_klass_is_exact && (klass() == tap->klass()); | 3857 xk = this->_klass_is_exact && (klass() == tap->klass()); |
3615 } | 3858 } |
3616 return TypeAryPtr::make( ptr, o, tary, lazy_klass, xk, off, instance_id ); | 3859 return TypeAryPtr::make(ptr, o, tary, lazy_klass, xk, off, instance_id, speculative); |
3617 } | 3860 } |
3618 case NotNull: | 3861 case NotNull: |
3619 case BotPTR: | 3862 case BotPTR: |
3620 // Compute new klass on demand, do not use tap->_klass | 3863 // Compute new klass on demand, do not use tap->_klass |
3621 if (above_centerline(this->_ptr)) | 3864 if (above_centerline(this->_ptr)) |
3622 xk = tap->_klass_is_exact; | 3865 xk = tap->_klass_is_exact; |
3623 else if (above_centerline(tap->_ptr)) | |
3624 xk = this->_klass_is_exact; | |
3625 else xk = (tap->_klass_is_exact & this->_klass_is_exact) && | 3866 else xk = (tap->_klass_is_exact & this->_klass_is_exact) && |
3626 (klass() == tap->klass()); // Only precise for identical arrays | 3867 (klass() == tap->klass()); // Only precise for identical arrays |
3627 return TypeAryPtr::make( ptr, NULL, tary, lazy_klass, xk, off, instance_id ); | 3868 return TypeAryPtr::make(ptr, NULL, tary, lazy_klass, xk, off, instance_id, speculative); |
3628 default: ShouldNotReachHere(); | 3869 default: ShouldNotReachHere(); |
3629 } | 3870 } |
3630 } | 3871 } |
3631 | 3872 |
3632 // All arrays inherit from Object class | 3873 // All arrays inherit from Object class |
3633 case InstPtr: { | 3874 case InstPtr: { |
3634 const TypeInstPtr *tp = t->is_instptr(); | 3875 const TypeInstPtr *tp = t->is_instptr(); |
3635 int offset = meet_offset(tp->offset()); | 3876 int offset = meet_offset(tp->offset()); |
3636 PTR ptr = meet_ptr(tp->ptr()); | 3877 PTR ptr = meet_ptr(tp->ptr()); |
3637 int instance_id = meet_instance_id(tp->instance_id()); | 3878 int instance_id = meet_instance_id(tp->instance_id()); |
3879 const TypeOopPtr* speculative = meet_speculative(tp); | |
3638 switch (ptr) { | 3880 switch (ptr) { |
3639 case TopPTR: | 3881 case TopPTR: |
3640 case AnyNull: // Fall 'down' to dual of object klass | 3882 case AnyNull: // Fall 'down' to dual of object klass |
3641 if( tp->klass()->equals(ciEnv::current()->Object_klass()) ) { | 3883 // For instances when a subclass meets a superclass we fall |
3642 return TypeAryPtr::make( ptr, _ary, _klass, _klass_is_exact, offset, instance_id ); | 3884 // below the centerline when the superclass is exact. We need to |
3885 // do the same here. | |
3886 if (tp->klass()->equals(ciEnv::current()->Object_klass()) && !tp->klass_is_exact()) { | |
3887 return TypeAryPtr::make(ptr, _ary, _klass, _klass_is_exact, offset, instance_id, speculative); | |
3643 } else { | 3888 } else { |
3644 // 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 |
3645 ptr = NotNull; | 3890 ptr = NotNull; |
3646 instance_id = InstanceBot; | 3891 instance_id = InstanceBot; |
3647 return TypeInstPtr::make( ptr, ciEnv::current()->Object_klass(), false, NULL,offset, instance_id); | 3892 return TypeInstPtr::make(ptr, ciEnv::current()->Object_klass(), false, NULL,offset, instance_id, speculative); |
3648 } | 3893 } |
3649 case Constant: | 3894 case Constant: |
3650 case NotNull: | 3895 case NotNull: |
3651 case BotPTR: // Fall down to object klass | 3896 case BotPTR: // Fall down to object klass |
3652 // 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 |
3653 if (above_centerline(tp->ptr())) { | 3898 if (above_centerline(tp->ptr())) { |
3654 // If 'tp' is above the centerline and it is Object class | 3899 // If 'tp' is above the centerline and it is Object class |
3655 // then we can subclass in the Java class hierarchy. | 3900 // then we can subclass in the Java class hierarchy. |
3656 if( tp->klass()->equals(ciEnv::current()->Object_klass()) ) { | 3901 // For instances when a subclass meets a superclass we fall |
3902 // below the centerline when the superclass is exact. We need | |
3903 // to do the same here. | |
3904 if (tp->klass()->equals(ciEnv::current()->Object_klass()) && !tp->klass_is_exact()) { | |
3657 // that is, my array type is a subtype of 'tp' klass | 3905 // that is, my array type is a subtype of 'tp' klass |
3658 return make( ptr, (ptr == Constant ? const_oop() : NULL), | 3906 return make(ptr, (ptr == Constant ? const_oop() : NULL), |
3659 _ary, _klass, _klass_is_exact, offset, instance_id ); | 3907 _ary, _klass, _klass_is_exact, offset, instance_id, speculative); |
3660 } | 3908 } |
3661 } | 3909 } |
3662 // 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. |
3663 // The meet falls down to Object class below centerline. | 3911 // The meet falls down to Object class below centerline. |
3664 if( ptr == Constant ) | 3912 if( ptr == Constant ) |
3665 ptr = NotNull; | 3913 ptr = NotNull; |
3666 instance_id = InstanceBot; | 3914 instance_id = InstanceBot; |
3667 return TypeInstPtr::make( ptr, ciEnv::current()->Object_klass(), false, NULL,offset, instance_id); | 3915 return TypeInstPtr::make(ptr, ciEnv::current()->Object_klass(), false, NULL,offset, instance_id, speculative); |
3668 default: typerr(t); | 3916 default: typerr(t); |
3669 } | 3917 } |
3670 } | 3918 } |
3671 } | 3919 } |
3672 return this; // Lint noise | 3920 return this; // Lint noise |
3673 } | 3921 } |
3674 | 3922 |
3675 //------------------------------xdual------------------------------------------ | 3923 //------------------------------xdual------------------------------------------ |
3676 // Dual: compute field-by-field dual | 3924 // Dual: compute field-by-field dual |
3677 const Type *TypeAryPtr::xdual() const { | 3925 const Type *TypeAryPtr::xdual() const { |
3678 return new TypeAryPtr( dual_ptr(), _const_oop, _ary->dual()->is_ary(),_klass, _klass_is_exact, dual_offset(), dual_instance_id(), is_autobox_cache() ); | 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()); |
3679 } | 3927 } |
3680 | 3928 |
3681 //----------------------interface_vs_oop--------------------------------------- | 3929 //----------------------interface_vs_oop--------------------------------------- |
3682 #ifdef ASSERT | 3930 #ifdef ASSERT |
3683 bool TypeAryPtr::interface_vs_oop(const Type *t) const { | 3931 bool TypeAryPtr::interface_vs_oop(const Type *t) const { |
3725 st->print(" *"); | 3973 st->print(" *"); |
3726 if (_instance_id == InstanceTop) | 3974 if (_instance_id == InstanceTop) |
3727 st->print(",iid=top"); | 3975 st->print(",iid=top"); |
3728 else if (_instance_id != InstanceBot) | 3976 else if (_instance_id != InstanceBot) |
3729 st->print(",iid=%d",_instance_id); | 3977 st->print(",iid=%d",_instance_id); |
3978 | |
3979 dump_speculative(st); | |
3730 } | 3980 } |
3731 #endif | 3981 #endif |
3732 | 3982 |
3733 bool TypeAryPtr::empty(void) const { | 3983 bool TypeAryPtr::empty(void) const { |
3734 if (_ary->empty()) return true; | 3984 if (_ary->empty()) return true; |
3735 return TypeOopPtr::empty(); | 3985 return TypeOopPtr::empty(); |
3736 } | 3986 } |
3737 | 3987 |
3738 //------------------------------add_offset------------------------------------- | 3988 //------------------------------add_offset------------------------------------- |
3739 const TypePtr *TypeAryPtr::add_offset( intptr_t offset ) const { | 3989 const TypePtr *TypeAryPtr::add_offset(intptr_t offset) const { |
3740 return make( _ptr, _const_oop, _ary, _klass, _klass_is_exact, xadd_offset(offset), _instance_id ); | 3990 return make(_ptr, _const_oop, _ary, _klass, _klass_is_exact, xadd_offset(offset), _instance_id, add_offset_speculative(offset)); |
3741 } | 3991 } |
3742 | 3992 |
3993 const TypeOopPtr *TypeAryPtr::remove_speculative() const { | |
3994 return make(_ptr, _const_oop, _ary, _klass, _klass_is_exact, _offset, _instance_id, NULL); | |
3995 } | |
3743 | 3996 |
3744 //============================================================================= | 3997 //============================================================================= |
3745 | 3998 |
3746 //------------------------------hash------------------------------------------- | 3999 //------------------------------hash------------------------------------------- |
3747 // Type-specific hashing function. | 4000 // Type-specific hashing function. |
4116 // constants | 4369 // constants |
4117 bool TypeKlassPtr::singleton(void) const { | 4370 bool TypeKlassPtr::singleton(void) const { |
4118 // detune optimizer to not generate constant klass + constant offset as a constant! | 4371 // detune optimizer to not generate constant klass + constant offset as a constant! |
4119 // TopPTR, Null, AnyNull, Constant are all singletons | 4372 // TopPTR, Null, AnyNull, Constant are all singletons |
4120 return (_offset == 0) && !below_centerline(_ptr); | 4373 return (_offset == 0) && !below_centerline(_ptr); |
4374 } | |
4375 | |
4376 // Do not allow interface-vs.-noninterface joins to collapse to top. | |
4377 const Type *TypeKlassPtr::filter(const Type *kills) const { | |
4378 // logic here mirrors the one from TypeOopPtr::filter. See comments | |
4379 // there. | |
4380 const Type* ft = join(kills); | |
4381 const TypeKlassPtr* ftkp = ft->isa_klassptr(); | |
4382 const TypeKlassPtr* ktkp = kills->isa_klassptr(); | |
4383 | |
4384 if (ft->empty()) { | |
4385 if (!empty() && ktkp != NULL && ktkp->klass()->is_loaded() && ktkp->klass()->is_interface()) | |
4386 return kills; // Uplift to interface | |
4387 | |
4388 return Type::TOP; // Canonical empty value | |
4389 } | |
4390 | |
4391 // Interface klass type could be exact in opposite to interface type, | |
4392 // return it here instead of incorrect Constant ptr J/L/Object (6894807). | |
4393 if (ftkp != NULL && ktkp != NULL && | |
4394 ftkp->is_loaded() && ftkp->klass()->is_interface() && | |
4395 !ftkp->klass_is_exact() && // Keep exact interface klass | |
4396 ktkp->is_loaded() && !ktkp->klass()->is_interface()) { | |
4397 return ktkp->cast_to_ptr_type(ftkp->ptr()); | |
4398 } | |
4399 | |
4400 return ft; | |
4121 } | 4401 } |
4122 | 4402 |
4123 //----------------------compute_klass------------------------------------------ | 4403 //----------------------compute_klass------------------------------------------ |
4124 // Compute the defining klass for this class | 4404 // Compute the defining klass for this class |
4125 ciKlass* TypeAryPtr::compute_klass(DEBUG_ONLY(bool verify)) const { | 4405 ciKlass* TypeAryPtr::compute_klass(DEBUG_ONLY(bool verify)) const { |