< prev index next >

src/share/vm/opto/cfgnode.cpp

Print this page
rev 9165 : 8141551: C2 can not handle returns with inccompatible interface arrays


 967   }
 968 
 969   // The worst-case type (from ciTypeFlow) should be consistent with "t".
 970   // That is, we expect that "t->higher_equal(_type)" holds true.
 971   // There are various exceptions:
 972   // - Inputs which are phis might in fact be widened unnecessarily.
 973   //   For example, an input might be a widened int while the phi is a short.
 974   // - Inputs might be BotPtrs but this phi is dependent on a null check,
 975   //   and postCCP has removed the cast which encodes the result of the check.
 976   // - The type of this phi is an interface, and the inputs are classes.
 977   // - Value calls on inputs might produce fuzzy results.
 978   //   (Occurrences of this case suggest improvements to Value methods.)
 979   //
 980   // It is not possible to see Type::BOTTOM values as phi inputs,
 981   // because the ciTypeFlow pre-pass produces verifier-quality types.
 982   const Type* ft = t->filter_speculative(_type);  // Worst case type
 983 
 984 #ifdef ASSERT
 985   // The following logic has been moved into TypeOopPtr::filter.
 986   const Type* jt = t->join_speculative(_type);
 987   if( jt->empty() ) {           // Emptied out???
 988 
 989     // Check for evil case of 't' being a class and '_type' expecting an
 990     // interface.  This can happen because the bytecodes do not contain
 991     // enough type info to distinguish a Java-level interface variable
 992     // from a Java-level object variable.  If we meet 2 classes which
 993     // both implement interface I, but their meet is at 'j/l/O' which
 994     // doesn't implement I, we have no way to tell if the result should
 995     // be 'I' or 'j/l/O'.  Thus we'll pick 'j/l/O'.  If this then flows
 996     // into a Phi which "knows" it's an Interface type we'll have to
 997     // uplift the type.
 998     if( !t->empty() && ttip && ttip->is_loaded() && ttip->klass()->is_interface() )
 999       { assert(ft == _type, ""); } // Uplift to interface
1000     else if( !t->empty() && ttkp && ttkp->is_loaded() && ttkp->klass()->is_interface() )
1001       { assert(ft == _type, ""); } // Uplift to interface





















1002     // Otherwise it's something stupid like non-overlapping int ranges
1003     // found on dying counted loops.
1004     else
1005       { assert(ft == Type::TOP, ""); } // Canonical empty value





1006   }
1007 
1008   else {
1009 
1010     // If we have an interface-typed Phi and we narrow to a class type, the join
1011     // should report back the class.  However, if we have a J/L/Object
1012     // class-typed Phi and an interface flows in, it's possible that the meet &
1013     // join report an interface back out.  This isn't possible but happens
1014     // because the type system doesn't interact well with interfaces.
1015     const TypePtr *jtp = jt->make_ptr();
1016     const TypeInstPtr *jtip = (jtp != NULL) ? jtp->isa_instptr() : NULL;
1017     const TypeKlassPtr *jtkp = (jtp != NULL) ? jtp->isa_klassptr() : NULL;
1018     if( jtip && ttip ) {
1019       if( jtip->is_loaded() &&  jtip->klass()->is_interface() &&
1020           ttip->is_loaded() && !ttip->klass()->is_interface() ) {
1021         assert(ft == ttip->cast_to_ptr_type(jtip->ptr()) ||
1022                ft->isa_narrowoop() && ft->make_ptr() == ttip->cast_to_ptr_type(jtip->ptr()), "");
1023         jt = ft;
1024       }
1025     }




 967   }
 968 
 969   // The worst-case type (from ciTypeFlow) should be consistent with "t".
 970   // That is, we expect that "t->higher_equal(_type)" holds true.
 971   // There are various exceptions:
 972   // - Inputs which are phis might in fact be widened unnecessarily.
 973   //   For example, an input might be a widened int while the phi is a short.
 974   // - Inputs might be BotPtrs but this phi is dependent on a null check,
 975   //   and postCCP has removed the cast which encodes the result of the check.
 976   // - The type of this phi is an interface, and the inputs are classes.
 977   // - Value calls on inputs might produce fuzzy results.
 978   //   (Occurrences of this case suggest improvements to Value methods.)
 979   //
 980   // It is not possible to see Type::BOTTOM values as phi inputs,
 981   // because the ciTypeFlow pre-pass produces verifier-quality types.
 982   const Type* ft = t->filter_speculative(_type);  // Worst case type
 983 
 984 #ifdef ASSERT
 985   // The following logic has been moved into TypeOopPtr::filter.
 986   const Type* jt = t->join_speculative(_type);
 987   if (jt->empty()) {           // Emptied out???
 988 
 989     // Check for evil case of 't' being a class and '_type' expecting an
 990     // interface.  This can happen because the bytecodes do not contain
 991     // enough type info to distinguish a Java-level interface variable
 992     // from a Java-level object variable.  If we meet 2 classes which
 993     // both implement interface I, but their meet is at 'j/l/O' which
 994     // doesn't implement I, we have no way to tell if the result should
 995     // be 'I' or 'j/l/O'.  Thus we'll pick 'j/l/O'.  If this then flows
 996     // into a Phi which "knows" it's an Interface type we'll have to
 997     // uplift the type.
 998     if (!t->empty() && ttip && ttip->is_loaded() && ttip->klass()->is_interface()) {
 999       assert(ft == _type, ""); // Uplift to interface
1000     }
1001     else if (!t->empty() && ttkp && ttkp->is_loaded() && ttkp->klass()->is_interface()) {
1002       assert(ft == _type, ""); // Uplift to interface
1003     }
1004     else {
1005       // We also have to handle 'evil cases' of interface- vs. class-arrays
1006       const TypeAryPtr* ftap = jt->isa_aryptr();
1007       const TypeAryPtr* ktap = _type->isa_aryptr();
1008       if (!t->empty() && ftap != NULL && ktap != NULL) {
1009         // Handle multidimensional arrays
1010         const TypePtr* ftp = ftap->elem()->make_ptr();
1011         const TypePtr* ktp = ktap->elem()->make_ptr();
1012         while (ftp && ftp->isa_aryptr() && ktp && ktp->isa_aryptr()) {
1013           ftap = ftp->is_aryptr();
1014           ktap = ktp->is_aryptr();
1015           ftp = ftap->elem()->make_ptr();
1016           ktp = ktap->elem()->make_ptr();
1017         }
1018         const TypeInstPtr* ktip = ktp ? ktp->isa_instptr() : NULL;
1019         if (ktip != NULL && ktip->is_loaded() && ktip->klass()->is_interface()) {
1020           assert(ft == _type, ""); // Uplift to array of interface
1021         }
1022         else {
1023           // Otherwise it's something stupid like non-overlapping int ranges
1024           // found on dying counted loops.
1025           assert(ft == Type::TOP, ""); // Canonical empty value
1026         }
1027       }
1028       else {
1029         assert(ft == Type::TOP, ""); // Canonical empty value
1030       }
1031     }
1032   }
1033 
1034   else {
1035 
1036     // If we have an interface-typed Phi and we narrow to a class type, the join
1037     // should report back the class.  However, if we have a J/L/Object
1038     // class-typed Phi and an interface flows in, it's possible that the meet &
1039     // join report an interface back out.  This isn't possible but happens
1040     // because the type system doesn't interact well with interfaces.
1041     const TypePtr *jtp = jt->make_ptr();
1042     const TypeInstPtr *jtip = (jtp != NULL) ? jtp->isa_instptr() : NULL;
1043     const TypeKlassPtr *jtkp = (jtp != NULL) ? jtp->isa_klassptr() : NULL;
1044     if( jtip && ttip ) {
1045       if( jtip->is_loaded() &&  jtip->klass()->is_interface() &&
1046           ttip->is_loaded() && !ttip->klass()->is_interface() ) {
1047         assert(ft == ttip->cast_to_ptr_type(jtip->ptr()) ||
1048                ft->isa_narrowoop() && ft->make_ptr() == ttip->cast_to_ptr_type(jtip->ptr()), "");
1049         jt = ft;
1050       }
1051     }


< prev index next >