841 if( init != NULL && limit != NULL && l->stride_is_con() ) {
842 const TypeInt *lo = init ->bottom_type()->isa_int();
843 const TypeInt *hi = limit->bottom_type()->isa_int();
844 if( lo && hi ) { // Dying loops might have TOP here
845 int stride = l->stride_con();
846 if( stride < 0 ) { // Down-counter loop
847 const TypeInt *tmp = lo; lo = hi; hi = tmp;
848 stride = -stride;
849 }
850 if( lo->_hi < hi->_lo ) // Reversed endpoints are well defined :-(
851 return TypeInt::make(lo->_lo,hi->_hi,3);
852 }
853 }
854 }
855
856 // Until we have harmony between classes and interfaces in the type
857 // lattice, we must tread carefully around phis which implicitly
858 // convert the one to the other.
859 const TypePtr* ttp = _type->make_ptr();
860 const TypeInstPtr* ttip = (ttp != NULL) ? ttp->isa_instptr() : NULL;
861 bool is_intf = false;
862 if (ttip != NULL) {
863 ciKlass* k = ttip->klass();
864 if (k->is_loaded() && k->is_interface())
865 is_intf = true;
866 }
867
868 // Default case: merge all inputs
869 const Type *t = Type::TOP; // Merged type starting value
870 for (uint i = 1; i < req(); ++i) {// For all paths in
871 // Reachable control path?
872 if (r->in(i) && phase->type(r->in(i)) == Type::CONTROL) {
873 const Type* ti = phase->type(in(i));
874 // We assume that each input of an interface-valued Phi is a true
875 // subtype of that interface. This might not be true of the meet
876 // of all the input types. The lattice is not distributive in
877 // such cases. Ward off asserts in type.cpp by refusing to do
878 // meets between interfaces and proper classes.
879 const TypePtr* tip = ti->make_ptr();
880 const TypeInstPtr* tiip = (tip != NULL) ? tip->isa_instptr() : NULL;
881 if (tiip) {
882 bool ti_is_intf = false;
883 ciKlass* k = tiip->klass();
884 if (k->is_loaded() && k->is_interface())
885 ti_is_intf = true;
886 if (is_intf != ti_is_intf)
904 // It is not possible to see Type::BOTTOM values as phi inputs,
905 // because the ciTypeFlow pre-pass produces verifier-quality types.
906 const Type* ft = t->filter(_type); // Worst case type
907
908 #ifdef ASSERT
909 // The following logic has been moved into TypeOopPtr::filter.
910 const Type* jt = t->join(_type);
911 if( jt->empty() ) { // Emptied out???
912
913 // Check for evil case of 't' being a class and '_type' expecting an
914 // interface. This can happen because the bytecodes do not contain
915 // enough type info to distinguish a Java-level interface variable
916 // from a Java-level object variable. If we meet 2 classes which
917 // both implement interface I, but their meet is at 'j/l/O' which
918 // doesn't implement I, we have no way to tell if the result should
919 // be 'I' or 'j/l/O'. Thus we'll pick 'j/l/O'. If this then flows
920 // into a Phi which "knows" it's an Interface type we'll have to
921 // uplift the type.
922 if( !t->empty() && ttip && ttip->is_loaded() && ttip->klass()->is_interface() )
923 { assert(ft == _type, ""); } // Uplift to interface
924 // Otherwise it's something stupid like non-overlapping int ranges
925 // found on dying counted loops.
926 else
927 { assert(ft == Type::TOP, ""); } // Canonical empty value
928 }
929
930 else {
931
932 // If we have an interface-typed Phi and we narrow to a class type, the join
933 // should report back the class. However, if we have a J/L/Object
934 // class-typed Phi and an interface flows in, it's possible that the meet &
935 // join report an interface back out. This isn't possible but happens
936 // because the type system doesn't interact well with interfaces.
937 const TypePtr *jtp = jt->make_ptr();
938 const TypeInstPtr *jtip = (jtp != NULL) ? jtp->isa_instptr() : NULL;
939 if( jtip && ttip ) {
940 if( jtip->is_loaded() && jtip->klass()->is_interface() &&
941 ttip->is_loaded() && !ttip->klass()->is_interface() ) {
942 // Happens in a CTW of rt.jar, 320-341, no extra flags
943 assert(ft == ttip->cast_to_ptr_type(jtip->ptr()) ||
944 ft->isa_narrowoop() && ft->make_ptr() == ttip->cast_to_ptr_type(jtip->ptr()), "");
945 jt = ft;
946 }
947 }
948 if (jt != ft && jt->base() == ft->base()) {
949 if (jt->isa_int() &&
950 jt->is_int()->_lo == ft->is_int()->_lo &&
951 jt->is_int()->_hi == ft->is_int()->_hi)
952 jt = ft;
953 if (jt->isa_long() &&
954 jt->is_long()->_lo == ft->is_long()->_lo &&
955 jt->is_long()->_hi == ft->is_long()->_hi)
956 jt = ft;
957 }
958 if (jt != ft) {
959 tty->print("merge type: "); t->dump(); tty->cr();
960 tty->print("kill type: "); _type->dump(); tty->cr();
961 tty->print("join type: "); jt->dump(); tty->cr();
962 tty->print("filter type: "); ft->dump(); tty->cr();
963 }
964 assert(jt == ft, "");
965 }
966 #endif //ASSERT
|
841 if( init != NULL && limit != NULL && l->stride_is_con() ) {
842 const TypeInt *lo = init ->bottom_type()->isa_int();
843 const TypeInt *hi = limit->bottom_type()->isa_int();
844 if( lo && hi ) { // Dying loops might have TOP here
845 int stride = l->stride_con();
846 if( stride < 0 ) { // Down-counter loop
847 const TypeInt *tmp = lo; lo = hi; hi = tmp;
848 stride = -stride;
849 }
850 if( lo->_hi < hi->_lo ) // Reversed endpoints are well defined :-(
851 return TypeInt::make(lo->_lo,hi->_hi,3);
852 }
853 }
854 }
855
856 // Until we have harmony between classes and interfaces in the type
857 // lattice, we must tread carefully around phis which implicitly
858 // convert the one to the other.
859 const TypePtr* ttp = _type->make_ptr();
860 const TypeInstPtr* ttip = (ttp != NULL) ? ttp->isa_instptr() : NULL;
861 const TypeKlassPtr* ttkp = (ttp != NULL) ? ttp->isa_klassptr() : NULL;
862 bool is_intf = false;
863 if (ttip != NULL) {
864 ciKlass* k = ttip->klass();
865 if (k->is_loaded() && k->is_interface())
866 is_intf = true;
867 }
868 if (ttkp != NULL) {
869 ciKlass* k = ttkp->klass();
870 if (k->is_loaded() && k->is_interface())
871 is_intf = true;
872 }
873
874 // Default case: merge all inputs
875 const Type *t = Type::TOP; // Merged type starting value
876 for (uint i = 1; i < req(); ++i) {// For all paths in
877 // Reachable control path?
878 if (r->in(i) && phase->type(r->in(i)) == Type::CONTROL) {
879 const Type* ti = phase->type(in(i));
880 // We assume that each input of an interface-valued Phi is a true
881 // subtype of that interface. This might not be true of the meet
882 // of all the input types. The lattice is not distributive in
883 // such cases. Ward off asserts in type.cpp by refusing to do
884 // meets between interfaces and proper classes.
885 const TypePtr* tip = ti->make_ptr();
886 const TypeInstPtr* tiip = (tip != NULL) ? tip->isa_instptr() : NULL;
887 if (tiip) {
888 bool ti_is_intf = false;
889 ciKlass* k = tiip->klass();
890 if (k->is_loaded() && k->is_interface())
891 ti_is_intf = true;
892 if (is_intf != ti_is_intf)
910 // It is not possible to see Type::BOTTOM values as phi inputs,
911 // because the ciTypeFlow pre-pass produces verifier-quality types.
912 const Type* ft = t->filter(_type); // Worst case type
913
914 #ifdef ASSERT
915 // The following logic has been moved into TypeOopPtr::filter.
916 const Type* jt = t->join(_type);
917 if( jt->empty() ) { // Emptied out???
918
919 // Check for evil case of 't' being a class and '_type' expecting an
920 // interface. This can happen because the bytecodes do not contain
921 // enough type info to distinguish a Java-level interface variable
922 // from a Java-level object variable. If we meet 2 classes which
923 // both implement interface I, but their meet is at 'j/l/O' which
924 // doesn't implement I, we have no way to tell if the result should
925 // be 'I' or 'j/l/O'. Thus we'll pick 'j/l/O'. If this then flows
926 // into a Phi which "knows" it's an Interface type we'll have to
927 // uplift the type.
928 if( !t->empty() && ttip && ttip->is_loaded() && ttip->klass()->is_interface() )
929 { assert(ft == _type, ""); } // Uplift to interface
930 else if( !t->empty() && ttkp && ttkp->is_loaded() && ttkp->klass()->is_interface() )
931 { assert(ft == _type, ""); } // Uplift to interface
932 // Otherwise it's something stupid like non-overlapping int ranges
933 // found on dying counted loops.
934 else
935 { assert(ft == Type::TOP, ""); } // Canonical empty value
936 }
937
938 else {
939
940 // If we have an interface-typed Phi and we narrow to a class type, the join
941 // should report back the class. However, if we have a J/L/Object
942 // class-typed Phi and an interface flows in, it's possible that the meet &
943 // join report an interface back out. This isn't possible but happens
944 // because the type system doesn't interact well with interfaces.
945 const TypePtr *jtp = jt->make_ptr();
946 const TypeInstPtr *jtip = (jtp != NULL) ? jtp->isa_instptr() : NULL;
947 const TypeKlassPtr *jtkp = (jtp != NULL) ? jtp->isa_klassptr() : NULL;
948 if( jtip && ttip ) {
949 if( jtip->is_loaded() && jtip->klass()->is_interface() &&
950 ttip->is_loaded() && !ttip->klass()->is_interface() ) {
951 // Happens in a CTW of rt.jar, 320-341, no extra flags
952 assert(ft == ttip->cast_to_ptr_type(jtip->ptr()) ||
953 ft->isa_narrowoop() && ft->make_ptr() == ttip->cast_to_ptr_type(jtip->ptr()), "");
954 jt = ft;
955 }
956 }
957 if( jtkp && ttkp ) {
958 if( jtkp->is_loaded() && jtkp->klass()->is_interface() &&
959 ttkp->is_loaded() && !ttkp->klass()->is_interface() ) {
960 assert(ft == ttkp->cast_to_ptr_type(jtkp->ptr()) ||
961 ft->isa_narrowoop() && ft->make_ptr() == ttkp->cast_to_ptr_type(jtkp->ptr()), "");
962 jt = ft;
963 }
964 }
965 if (jt != ft && jt->base() == ft->base()) {
966 if (jt->isa_int() &&
967 jt->is_int()->_lo == ft->is_int()->_lo &&
968 jt->is_int()->_hi == ft->is_int()->_hi)
969 jt = ft;
970 if (jt->isa_long() &&
971 jt->is_long()->_lo == ft->is_long()->_lo &&
972 jt->is_long()->_hi == ft->is_long()->_hi)
973 jt = ft;
974 }
975 if (jt != ft) {
976 tty->print("merge type: "); t->dump(); tty->cr();
977 tty->print("kill type: "); _type->dump(); tty->cr();
978 tty->print("join type: "); jt->dump(); tty->cr();
979 tty->print("filter type: "); ft->dump(); tty->cr();
980 }
981 assert(jt == ft, "");
982 }
983 #endif //ASSERT
|