hotspot/src/share/vm/opto/type.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File hotspot-comp Cdiff hotspot/src/share/vm/opto/type.cpp

hotspot/src/share/vm/opto/type.cpp

Print this page
rev 5143 : imported patch webrev.01

*** 187,196 **** --- 187,228 ---- return Type::get_const_type(type); } } + //-----------------------make_from_constant------------------------------------ + const Type* Type::make_from_constant(ciConstant constant, + bool require_constant, bool is_autobox_cache) { + switch (constant.basic_type()) { + case T_BOOLEAN: return TypeInt::make(constant.as_boolean()); + case T_CHAR: return TypeInt::make(constant.as_char()); + case T_BYTE: return TypeInt::make(constant.as_byte()); + case T_SHORT: return TypeInt::make(constant.as_short()); + case T_INT: return TypeInt::make(constant.as_int()); + case T_LONG: return TypeLong::make(constant.as_long()); + case T_FLOAT: return TypeF::make(constant.as_float()); + case T_DOUBLE: return TypeD::make(constant.as_double()); + case T_ARRAY: + case T_OBJECT: + { + // cases: + // can_be_constant = (oop not scavengable || ScavengeRootsInCode != 0) + // should_be_constant = (oop not scavengable || ScavengeRootsInCode >= 2) + // An oop is not scavengable if it is in the perm gen. + ciObject* oop_constant = constant.as_object(); + if (oop_constant->is_null_object()) { + return Type::get_zero_type(T_OBJECT); + } else if (require_constant || oop_constant->should_be_constant()) { + return TypeOopPtr::make_from_constant(oop_constant, require_constant, is_autobox_cache); + } + } + } + // Fall through to failure + return NULL; + } + + //------------------------------make------------------------------------------- // Create a simple Type, with default empty symbol sets. Then hashcons it // and look for an existing copy in the type dictionary. const Type *Type::make( enum TYPES t ) { return (new Type(t))->hashcons();
*** 1822,1837 **** else return size; } //------------------------------make------------------------------------------- ! const TypeAry *TypeAry::make( const Type *elem, const TypeInt *size) { if (UseCompressedOops && elem->isa_oopptr()) { elem = elem->make_narrowoop(); } size = normalize_array_size(size); ! return (TypeAry*)(new TypeAry(elem,size))->hashcons(); } //------------------------------meet------------------------------------------- // Compute the MEET of two types. It returns a new Type object. const Type *TypeAry::xmeet( const Type *t ) const { --- 1854,1869 ---- else return size; } //------------------------------make------------------------------------------- ! const TypeAry* TypeAry::make(const Type* elem, const TypeInt* size, bool stable) { if (UseCompressedOops && elem->isa_oopptr()) { elem = elem->make_narrowoop(); } size = normalize_array_size(size); ! return (TypeAry*)(new TypeAry(elem,size,stable))->hashcons(); } //------------------------------meet------------------------------------------- // Compute the MEET of two types. It returns a new Type object. const Type *TypeAry::xmeet( const Type *t ) const {
*** 1848,1858 **** typerr(t); case Array: { // Meeting 2 arrays? const TypeAry *a = t->is_ary(); return TypeAry::make(_elem->meet(a->_elem), ! _size->xmeet(a->_size)->is_int()); } case Top: break; } return this; // Return the double constant --- 1880,1891 ---- typerr(t); case Array: { // Meeting 2 arrays? const TypeAry *a = t->is_ary(); return TypeAry::make(_elem->meet(a->_elem), ! _size->xmeet(a->_size)->is_int(), ! _stable & a->_stable); } case Top: break; } return this; // Return the double constant
*** 1861,1885 **** //------------------------------xdual------------------------------------------ // Dual: compute field-by-field dual const Type *TypeAry::xdual() const { const TypeInt* size_dual = _size->dual()->is_int(); size_dual = normalize_array_size(size_dual); ! return new TypeAry( _elem->dual(), size_dual); } //------------------------------eq--------------------------------------------- // Structural equality check for Type representations bool TypeAry::eq( const Type *t ) const { const TypeAry *a = (const TypeAry*)t; return _elem == a->_elem && _size == a->_size; } //------------------------------hash------------------------------------------- // Type-specific hashing function. int TypeAry::hash(void) const { ! return (intptr_t)_elem + (intptr_t)_size; } //----------------------interface_vs_oop--------------------------------------- #ifdef ASSERT bool TypeAry::interface_vs_oop(const Type *t) const { --- 1894,1919 ---- //------------------------------xdual------------------------------------------ // Dual: compute field-by-field dual const Type *TypeAry::xdual() const { const TypeInt* size_dual = _size->dual()->is_int(); size_dual = normalize_array_size(size_dual); ! return new TypeAry(_elem->dual(), size_dual, !_stable); } //------------------------------eq--------------------------------------------- // Structural equality check for Type representations bool TypeAry::eq( const Type *t ) const { const TypeAry *a = (const TypeAry*)t; return _elem == a->_elem && + _stable == a->_stable && _size == a->_size; } //------------------------------hash------------------------------------------- // Type-specific hashing function. int TypeAry::hash(void) const { ! return (intptr_t)_elem + (intptr_t)_size + (_stable ? 43 : 0); } //----------------------interface_vs_oop--------------------------------------- #ifdef ASSERT bool TypeAry::interface_vs_oop(const Type *t) const {
*** 1892,1901 **** --- 1926,1936 ---- #endif //------------------------------dump2------------------------------------------ #ifndef PRODUCT void TypeAry::dump2( Dict &d, uint depth, outputStream *st ) const { + if (_stable) st->print("stable:"); _elem->dump2(d, depth, st); st->print("["); _size->dump2(d, depth, st); st->print("]"); }
*** 3455,3468 **** //-------------------------------cast_to_size---------------------------------- const TypeAryPtr* TypeAryPtr::cast_to_size(const TypeInt* new_size) const { assert(new_size != NULL, ""); new_size = narrow_size_type(new_size); if (new_size == size()) return this; ! const TypeAry* new_ary = TypeAry::make(elem(), new_size); return make(ptr(), const_oop(), new_ary, klass(), klass_is_exact(), _offset, _instance_id); } //------------------------------eq--------------------------------------------- // Structural equality check for Type representations bool TypeAryPtr::eq( const Type *t ) const { const TypeAryPtr *p = t->is_aryptr(); --- 3490,3531 ---- //-------------------------------cast_to_size---------------------------------- const TypeAryPtr* TypeAryPtr::cast_to_size(const TypeInt* new_size) const { assert(new_size != NULL, ""); new_size = narrow_size_type(new_size); if (new_size == size()) return this; ! const TypeAry* new_ary = TypeAry::make(elem(), new_size, is_stable()); ! return make(ptr(), const_oop(), new_ary, klass(), klass_is_exact(), _offset, _instance_id); ! } ! ! ! //------------------------------cast_to_stable--------------------------------- ! const TypeAryPtr* TypeAryPtr::cast_to_stable(bool stable, int stable_dimension) const { ! if (stable_dimension <= 0 || (stable_dimension == 1 && stable == this->is_stable())) ! return this; ! ! const Type* elem = this->elem(); ! const TypePtr* elem_ptr = elem->make_ptr(); ! ! if (stable_dimension > 1 && elem_ptr != NULL && elem_ptr->isa_aryptr()) { ! // If this is widened from a narrow oop, TypeAry::make will re-narrow it. ! elem = elem_ptr = elem_ptr->is_aryptr()->cast_to_stable(stable, stable_dimension - 1); ! } ! ! const TypeAry* new_ary = TypeAry::make(elem, size(), stable); ! return make(ptr(), const_oop(), new_ary, klass(), klass_is_exact(), _offset, _instance_id); } + //-----------------------------stable_dimension-------------------------------- + int TypeAryPtr::stable_dimension() const { + if (!is_stable()) return 0; + int dim = 1; + const TypePtr* elem_ptr = elem()->make_ptr(); + if (elem_ptr != NULL && elem_ptr->isa_aryptr()) + dim += elem_ptr->is_aryptr()->stable_dimension(); + return dim; + } //------------------------------eq--------------------------------------------- // Structural equality check for Type representations bool TypeAryPtr::eq( const Type *t ) const { const TypeAryPtr *p = t->is_aryptr();
*** 3568,3578 **** lazy_klass = _klass; } else { // Something like byte[int+] meets char[int+]. // This must fall to bottom, not (int[-128..65535])[int+]. instance_id = InstanceBot; ! tary = TypeAry::make(Type::BOTTOM, tary->_size); } } else // Non integral arrays. // Must fall to bottom if exact klasses in upper lattice // are not equal or super klass is exact. if ( above_centerline(ptr) && klass() != tap->klass() && --- 3631,3641 ---- lazy_klass = _klass; } else { // Something like byte[int+] meets char[int+]. // This must fall to bottom, not (int[-128..65535])[int+]. instance_id = InstanceBot; ! tary = TypeAry::make(Type::BOTTOM, tary->_size, tary->_stable); } } else // Non integral arrays. // Must fall to bottom if exact klasses in upper lattice // are not equal or super klass is exact. if ( above_centerline(ptr) && klass() != tap->klass() &&
*** 3582,3592 **** ((tap ->_klass_is_exact && this->_klass_is_exact) || // 'tap' is exact and super or unrelated: (tap ->_klass_is_exact && !tap->klass()->is_subtype_of(klass())) || // 'this' is exact and super or unrelated: (this->_klass_is_exact && !klass()->is_subtype_of(tap->klass())))) { ! tary = TypeAry::make(Type::BOTTOM, tary->_size); return make( NotNull, NULL, tary, lazy_klass, false, off, InstanceBot ); } bool xk = false; switch (tap->ptr()) { --- 3645,3655 ---- ((tap ->_klass_is_exact && this->_klass_is_exact) || // 'tap' is exact and super or unrelated: (tap ->_klass_is_exact && !tap->klass()->is_subtype_of(klass())) || // 'this' is exact and super or unrelated: (this->_klass_is_exact && !klass()->is_subtype_of(tap->klass())))) { ! tary = TypeAry::make(Type::BOTTOM, tary->_size, tary->_stable); return make( NotNull, NULL, tary, lazy_klass, false, off, InstanceBot ); } bool xk = false; switch (tap->ptr()) {
hotspot/src/share/vm/opto/type.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File