1.1 --- a/src/share/vm/opto/subnode.cpp Mon Aug 18 23:17:51 2008 -0700 1.2 +++ b/src/share/vm/opto/subnode.cpp Tue Aug 19 07:25:02 2008 -0700 1.3 @@ -633,20 +633,31 @@ 1.4 kps != 1 && // both or neither are klass pointers 1.5 !klass0->is_interface() && // do not trust interfaces 1.6 !klass1->is_interface()) { 1.7 + bool unrelated_classes = false; 1.8 // See if neither subclasses the other, or if the class on top 1.9 - // is precise. In either of these cases, the compare must fail. 1.10 + // is precise. In either of these cases, the compare is known 1.11 + // to fail if at least one of the pointers is provably not null. 1.12 if (klass0->equals(klass1) || // if types are unequal but klasses are 1.13 !klass0->is_java_klass() || // types not part of Java language? 1.14 !klass1->is_java_klass()) { // types not part of Java language? 1.15 // Do nothing; we know nothing for imprecise types 1.16 } else if (klass0->is_subtype_of(klass1)) { 1.17 - // If klass1's type is PRECISE, then we can fail. 1.18 - if (xklass1) return TypeInt::CC_GT; 1.19 + // If klass1's type is PRECISE, then classes are unrelated. 1.20 + unrelated_classes = xklass1; 1.21 } else if (klass1->is_subtype_of(klass0)) { 1.22 - // If klass0's type is PRECISE, then we can fail. 1.23 - if (xklass0) return TypeInt::CC_GT; 1.24 + // If klass0's type is PRECISE, then classes are unrelated. 1.25 + unrelated_classes = xklass0; 1.26 } else { // Neither subtypes the other 1.27 - return TypeInt::CC_GT; // ...so always fail 1.28 + unrelated_classes = true; 1.29 + } 1.30 + if (unrelated_classes) { 1.31 + // The oops classes are known to be unrelated. If the joined PTRs of 1.32 + // two oops is not Null and not Bottom, then we are sure that one 1.33 + // of the two oops is non-null, and the comparison will always fail. 1.34 + TypePtr::PTR jp = r0->join_ptr(r1->_ptr); 1.35 + if (jp != TypePtr::Null && jp != TypePtr::BotPTR) { 1.36 + return TypeInt::CC_GT; 1.37 + } 1.38 } 1.39 } 1.40 } 1.41 @@ -777,20 +788,31 @@ 1.42 kps != 1 && // both or neither are klass pointers 1.43 !klass0->is_interface() && // do not trust interfaces 1.44 !klass1->is_interface()) { 1.45 + bool unrelated_classes = false; 1.46 // See if neither subclasses the other, or if the class on top 1.47 - // is precise. In either of these cases, the compare must fail. 1.48 + // is precise. In either of these cases, the compare is known 1.49 + // to fail if at least one of the pointers is provably not null. 1.50 if (klass0->equals(klass1) || // if types are unequal but klasses are 1.51 !klass0->is_java_klass() || // types not part of Java language? 1.52 !klass1->is_java_klass()) { // types not part of Java language? 1.53 // Do nothing; we know nothing for imprecise types 1.54 } else if (klass0->is_subtype_of(klass1)) { 1.55 - // If klass1's type is PRECISE, then we can fail. 1.56 - if (xklass1) return TypeInt::CC_GT; 1.57 + // If klass1's type is PRECISE, then classes are unrelated. 1.58 + unrelated_classes = xklass1; 1.59 } else if (klass1->is_subtype_of(klass0)) { 1.60 - // If klass0's type is PRECISE, then we can fail. 1.61 - if (xklass0) return TypeInt::CC_GT; 1.62 + // If klass0's type is PRECISE, then classes are unrelated. 1.63 + unrelated_classes = xklass0; 1.64 } else { // Neither subtypes the other 1.65 - return TypeInt::CC_GT; // ...so always fail 1.66 + unrelated_classes = true; 1.67 + } 1.68 + if (unrelated_classes) { 1.69 + // The oops classes are known to be unrelated. If the joined PTRs of 1.70 + // two oops is not Null and not Bottom, then we are sure that one 1.71 + // of the two oops is non-null, and the comparison will always fail. 1.72 + TypePtr::PTR jp = r0->join_ptr(r1->_ptr); 1.73 + if (jp != TypePtr::Null && jp != TypePtr::BotPTR) { 1.74 + return TypeInt::CC_GT; 1.75 + } 1.76 } 1.77 } 1.78 }