< prev index next >

src/hotspot/share/opto/type.cpp

Print this page




2092 
2093 //------------------------------meet-------------------------------------------
2094 // Compute the MEET of two types.  It returns a new Type object.
2095 const Type *TypeAry::xmeet( const Type *t ) const {
2096   // Perform a fast test for common case; meeting the same types together.
2097   if( this == t ) return this;  // Meeting same type-rep?
2098 
2099   // Current "this->_base" is Ary
2100   switch (t->base()) {          // switch on original type
2101 
2102   case Bottom:                  // Ye Olde Default
2103     return t;
2104 
2105   default:                      // All else is a mistake
2106     typerr(t);
2107 
2108   case Array: {                 // Meeting 2 arrays?
2109     const TypeAry *a = t->is_ary();
2110     return TypeAry::make(_elem->meet_speculative(a->_elem),
2111                          _size->xmeet(a->_size)->is_int(),
2112                          _stable && a->_stable);
2113   }
2114   case Top:
2115     break;
2116   }
2117   return this;                  // Return the double constant
2118 }
2119 
2120 //------------------------------xdual------------------------------------------
2121 // Dual: compute field-by-field dual
2122 const Type *TypeAry::xdual() const {
2123   const TypeInt* size_dual = _size->dual()->is_int();
2124   size_dual = normalize_array_size(size_dual);
2125   return new TypeAry(_elem->dual(), size_dual, !_stable);
2126 }
2127 
2128 //------------------------------eq---------------------------------------------
2129 // Structural equality check for Type representations
2130 bool TypeAry::eq( const Type *t ) const {
2131   const TypeAry *a = (const TypeAry*)t;
2132   return _elem == a->_elem &&


3862     // Now, reorder the above list; observe that both-down+subtype is also
3863     // "fall hard"; "fall hard" becomes the default case:
3864     // If we split one up & one down AND they subtype, take the down man.
3865     // If both are up and they subtype, take the subtype class.
3866 
3867     // If both are down and they subtype, "fall hard".
3868     // If both are down and they do NOT subtype, "fall hard".
3869     // If both are up and they do NOT subtype, "fall hard".
3870     // If we split one up & one down AND they do NOT subtype, "fall hard".
3871 
3872     // If a proper subtype is exact, and we return it, we return it exactly.
3873     // If a proper supertype is exact, there can be no subtyping relationship!
3874     // If both types are equal to the subtype, exactness is and-ed below the
3875     // centerline and or-ed above it.  (N.B. Constants are always exact.)
3876 
3877     // Check for subtyping:
3878     ciKlass *subtype = NULL;
3879     bool subtype_exact = false;
3880     if( tinst_klass->equals(this_klass) ) {
3881       subtype = this_klass;
3882       subtype_exact = below_centerline(ptr) ? (this_xk && tinst_xk) : (this_xk || tinst_xk);
3883     } else if( !tinst_xk && this_klass->is_subtype_of( tinst_klass ) ) {
3884       subtype = this_klass;     // Pick subtyping class
3885       subtype_exact = this_xk;
3886     } else if( !this_xk && tinst_klass->is_subtype_of( this_klass ) ) {
3887       subtype = tinst_klass;    // Pick subtyping class
3888       subtype_exact = tinst_xk;
3889     }
3890 
3891     if( subtype ) {
3892       if( above_centerline(ptr) ) { // both are up?
3893         this_klass = tinst_klass = subtype;
3894         this_xk = tinst_xk = subtype_exact;
3895       } else if( above_centerline(this ->_ptr) && !above_centerline(tinst->_ptr) ) {
3896         this_klass = tinst_klass; // tinst is down; keep down man
3897         this_xk = tinst_xk;
3898       } else if( above_centerline(tinst->_ptr) && !above_centerline(this ->_ptr) ) {
3899         tinst_klass = this_klass; // this is down; keep down man
3900         tinst_xk = this_xk;
3901       } else {
3902         this_xk = subtype_exact;  // either they are equal, or we'll do an LCA


4344           // both are exact and not equal:
4345           ((tap->_klass_is_exact && this->_klass_is_exact) ||
4346            // 'tap'  is exact and super or unrelated:
4347            (tap->_klass_is_exact && !tap->klass()->is_subtype_of(klass())) ||
4348            // 'this' is exact and super or unrelated:
4349            (this->_klass_is_exact && !klass()->is_subtype_of(tap->klass())))) {
4350       if (above_centerline(ptr)) {
4351         tary = TypeAry::make(Type::BOTTOM, tary->_size, tary->_stable);
4352       }
4353       return make(NotNull, NULL, tary, lazy_klass, false, off, InstanceBot, speculative, depth);
4354     }
4355 
4356     bool xk = false;
4357     switch (tap->ptr()) {
4358     case AnyNull:
4359     case TopPTR:
4360       // Compute new klass on demand, do not use tap->_klass
4361       if (below_centerline(this->_ptr)) {
4362         xk = this->_klass_is_exact;
4363       } else {
4364         xk = (tap->_klass_is_exact || this->_klass_is_exact);
4365       }
4366       return make(ptr, const_oop(), tary, lazy_klass, xk, off, instance_id, speculative, depth);
4367     case Constant: {
4368       ciObject* o = const_oop();
4369       if( _ptr == Constant ) {
4370         if( tap->const_oop() != NULL && !o->equals(tap->const_oop()) ) {
4371           xk = (klass() == tap->klass());
4372           ptr = NotNull;
4373           o = NULL;
4374           instance_id = InstanceBot;
4375         } else {
4376           xk = true;
4377         }
4378       } else if(above_centerline(_ptr)) {
4379         o = tap->const_oop();
4380         xk = true;
4381       } else {
4382         // Only precise for identical arrays
4383         xk = this->_klass_is_exact && (klass() == tap->klass());
4384       }




2092 
2093 //------------------------------meet-------------------------------------------
2094 // Compute the MEET of two types.  It returns a new Type object.
2095 const Type *TypeAry::xmeet( const Type *t ) const {
2096   // Perform a fast test for common case; meeting the same types together.
2097   if( this == t ) return this;  // Meeting same type-rep?
2098 
2099   // Current "this->_base" is Ary
2100   switch (t->base()) {          // switch on original type
2101 
2102   case Bottom:                  // Ye Olde Default
2103     return t;
2104 
2105   default:                      // All else is a mistake
2106     typerr(t);
2107 
2108   case Array: {                 // Meeting 2 arrays?
2109     const TypeAry *a = t->is_ary();
2110     return TypeAry::make(_elem->meet_speculative(a->_elem),
2111                          _size->xmeet(a->_size)->is_int(),
2112                          _stable & a->_stable);
2113   }
2114   case Top:
2115     break;
2116   }
2117   return this;                  // Return the double constant
2118 }
2119 
2120 //------------------------------xdual------------------------------------------
2121 // Dual: compute field-by-field dual
2122 const Type *TypeAry::xdual() const {
2123   const TypeInt* size_dual = _size->dual()->is_int();
2124   size_dual = normalize_array_size(size_dual);
2125   return new TypeAry(_elem->dual(), size_dual, !_stable);
2126 }
2127 
2128 //------------------------------eq---------------------------------------------
2129 // Structural equality check for Type representations
2130 bool TypeAry::eq( const Type *t ) const {
2131   const TypeAry *a = (const TypeAry*)t;
2132   return _elem == a->_elem &&


3862     // Now, reorder the above list; observe that both-down+subtype is also
3863     // "fall hard"; "fall hard" becomes the default case:
3864     // If we split one up & one down AND they subtype, take the down man.
3865     // If both are up and they subtype, take the subtype class.
3866 
3867     // If both are down and they subtype, "fall hard".
3868     // If both are down and they do NOT subtype, "fall hard".
3869     // If both are up and they do NOT subtype, "fall hard".
3870     // If we split one up & one down AND they do NOT subtype, "fall hard".
3871 
3872     // If a proper subtype is exact, and we return it, we return it exactly.
3873     // If a proper supertype is exact, there can be no subtyping relationship!
3874     // If both types are equal to the subtype, exactness is and-ed below the
3875     // centerline and or-ed above it.  (N.B. Constants are always exact.)
3876 
3877     // Check for subtyping:
3878     ciKlass *subtype = NULL;
3879     bool subtype_exact = false;
3880     if( tinst_klass->equals(this_klass) ) {
3881       subtype = this_klass;
3882       subtype_exact = below_centerline(ptr) ? (this_xk & tinst_xk) : (this_xk | tinst_xk);
3883     } else if( !tinst_xk && this_klass->is_subtype_of( tinst_klass ) ) {
3884       subtype = this_klass;     // Pick subtyping class
3885       subtype_exact = this_xk;
3886     } else if( !this_xk && tinst_klass->is_subtype_of( this_klass ) ) {
3887       subtype = tinst_klass;    // Pick subtyping class
3888       subtype_exact = tinst_xk;
3889     }
3890 
3891     if( subtype ) {
3892       if( above_centerline(ptr) ) { // both are up?
3893         this_klass = tinst_klass = subtype;
3894         this_xk = tinst_xk = subtype_exact;
3895       } else if( above_centerline(this ->_ptr) && !above_centerline(tinst->_ptr) ) {
3896         this_klass = tinst_klass; // tinst is down; keep down man
3897         this_xk = tinst_xk;
3898       } else if( above_centerline(tinst->_ptr) && !above_centerline(this ->_ptr) ) {
3899         tinst_klass = this_klass; // this is down; keep down man
3900         tinst_xk = this_xk;
3901       } else {
3902         this_xk = subtype_exact;  // either they are equal, or we'll do an LCA


4344           // both are exact and not equal:
4345           ((tap->_klass_is_exact && this->_klass_is_exact) ||
4346            // 'tap'  is exact and super or unrelated:
4347            (tap->_klass_is_exact && !tap->klass()->is_subtype_of(klass())) ||
4348            // 'this' is exact and super or unrelated:
4349            (this->_klass_is_exact && !klass()->is_subtype_of(tap->klass())))) {
4350       if (above_centerline(ptr)) {
4351         tary = TypeAry::make(Type::BOTTOM, tary->_size, tary->_stable);
4352       }
4353       return make(NotNull, NULL, tary, lazy_klass, false, off, InstanceBot, speculative, depth);
4354     }
4355 
4356     bool xk = false;
4357     switch (tap->ptr()) {
4358     case AnyNull:
4359     case TopPTR:
4360       // Compute new klass on demand, do not use tap->_klass
4361       if (below_centerline(this->_ptr)) {
4362         xk = this->_klass_is_exact;
4363       } else {
4364         xk = (tap->_klass_is_exact | this->_klass_is_exact);
4365       }
4366       return make(ptr, const_oop(), tary, lazy_klass, xk, off, instance_id, speculative, depth);
4367     case Constant: {
4368       ciObject* o = const_oop();
4369       if( _ptr == Constant ) {
4370         if( tap->const_oop() != NULL && !o->equals(tap->const_oop()) ) {
4371           xk = (klass() == tap->klass());
4372           ptr = NotNull;
4373           o = NULL;
4374           instance_id = InstanceBot;
4375         } else {
4376           xk = true;
4377         }
4378       } else if(above_centerline(_ptr)) {
4379         o = tap->const_oop();
4380         xk = true;
4381       } else {
4382         // Only precise for identical arrays
4383         xk = this->_klass_is_exact && (klass() == tap->klass());
4384       }


< prev index next >