src/share/vm/opto/subnode.cpp

changeset 731
ce93a51457ae
parent 728
c3e045194476
child 835
cc80376deb0c
equal deleted inserted replaced
730:ea18057223c4 731:ce93a51457ae
631 int kps = (p0->isa_klassptr()?1:0) + (p1->isa_klassptr()?1:0); 631 int kps = (p0->isa_klassptr()?1:0) + (p1->isa_klassptr()?1:0);
632 if (klass0 && klass1 && 632 if (klass0 && klass1 &&
633 kps != 1 && // both or neither are klass pointers 633 kps != 1 && // both or neither are klass pointers
634 !klass0->is_interface() && // do not trust interfaces 634 !klass0->is_interface() && // do not trust interfaces
635 !klass1->is_interface()) { 635 !klass1->is_interface()) {
636 bool unrelated_classes = false;
636 // See if neither subclasses the other, or if the class on top 637 // See if neither subclasses the other, or if the class on top
637 // is precise. In either of these cases, the compare must fail. 638 // is precise. In either of these cases, the compare is known
639 // to fail if at least one of the pointers is provably not null.
638 if (klass0->equals(klass1) || // if types are unequal but klasses are 640 if (klass0->equals(klass1) || // if types are unequal but klasses are
639 !klass0->is_java_klass() || // types not part of Java language? 641 !klass0->is_java_klass() || // types not part of Java language?
640 !klass1->is_java_klass()) { // types not part of Java language? 642 !klass1->is_java_klass()) { // types not part of Java language?
641 // Do nothing; we know nothing for imprecise types 643 // Do nothing; we know nothing for imprecise types
642 } else if (klass0->is_subtype_of(klass1)) { 644 } else if (klass0->is_subtype_of(klass1)) {
643 // If klass1's type is PRECISE, then we can fail. 645 // If klass1's type is PRECISE, then classes are unrelated.
644 if (xklass1) return TypeInt::CC_GT; 646 unrelated_classes = xklass1;
645 } else if (klass1->is_subtype_of(klass0)) { 647 } else if (klass1->is_subtype_of(klass0)) {
646 // If klass0's type is PRECISE, then we can fail. 648 // If klass0's type is PRECISE, then classes are unrelated.
647 if (xklass0) return TypeInt::CC_GT; 649 unrelated_classes = xklass0;
648 } else { // Neither subtypes the other 650 } else { // Neither subtypes the other
649 return TypeInt::CC_GT; // ...so always fail 651 unrelated_classes = true;
652 }
653 if (unrelated_classes) {
654 // The oops classes are known to be unrelated. If the joined PTRs of
655 // two oops is not Null and not Bottom, then we are sure that one
656 // of the two oops is non-null, and the comparison will always fail.
657 TypePtr::PTR jp = r0->join_ptr(r1->_ptr);
658 if (jp != TypePtr::Null && jp != TypePtr::BotPTR) {
659 return TypeInt::CC_GT;
660 }
650 } 661 }
651 } 662 }
652 } 663 }
653 664
654 // Known constants can be compared exactly 665 // Known constants can be compared exactly
775 int kps = (p0->isa_klassptr()?1:0) + (p1->isa_klassptr()?1:0); 786 int kps = (p0->isa_klassptr()?1:0) + (p1->isa_klassptr()?1:0);
776 if (klass0 && klass1 && 787 if (klass0 && klass1 &&
777 kps != 1 && // both or neither are klass pointers 788 kps != 1 && // both or neither are klass pointers
778 !klass0->is_interface() && // do not trust interfaces 789 !klass0->is_interface() && // do not trust interfaces
779 !klass1->is_interface()) { 790 !klass1->is_interface()) {
791 bool unrelated_classes = false;
780 // See if neither subclasses the other, or if the class on top 792 // See if neither subclasses the other, or if the class on top
781 // is precise. In either of these cases, the compare must fail. 793 // is precise. In either of these cases, the compare is known
794 // to fail if at least one of the pointers is provably not null.
782 if (klass0->equals(klass1) || // if types are unequal but klasses are 795 if (klass0->equals(klass1) || // if types are unequal but klasses are
783 !klass0->is_java_klass() || // types not part of Java language? 796 !klass0->is_java_klass() || // types not part of Java language?
784 !klass1->is_java_klass()) { // types not part of Java language? 797 !klass1->is_java_klass()) { // types not part of Java language?
785 // Do nothing; we know nothing for imprecise types 798 // Do nothing; we know nothing for imprecise types
786 } else if (klass0->is_subtype_of(klass1)) { 799 } else if (klass0->is_subtype_of(klass1)) {
787 // If klass1's type is PRECISE, then we can fail. 800 // If klass1's type is PRECISE, then classes are unrelated.
788 if (xklass1) return TypeInt::CC_GT; 801 unrelated_classes = xklass1;
789 } else if (klass1->is_subtype_of(klass0)) { 802 } else if (klass1->is_subtype_of(klass0)) {
790 // If klass0's type is PRECISE, then we can fail. 803 // If klass0's type is PRECISE, then classes are unrelated.
791 if (xklass0) return TypeInt::CC_GT; 804 unrelated_classes = xklass0;
792 } else { // Neither subtypes the other 805 } else { // Neither subtypes the other
793 return TypeInt::CC_GT; // ...so always fail 806 unrelated_classes = true;
807 }
808 if (unrelated_classes) {
809 // The oops classes are known to be unrelated. If the joined PTRs of
810 // two oops is not Null and not Bottom, then we are sure that one
811 // of the two oops is non-null, and the comparison will always fail.
812 TypePtr::PTR jp = r0->join_ptr(r1->_ptr);
813 if (jp != TypePtr::Null && jp != TypePtr::BotPTR) {
814 return TypeInt::CC_GT;
815 }
794 } 816 }
795 } 817 }
796 } 818 }
797 819
798 // Known constants can be compared exactly 820 // Known constants can be compared exactly

mercurial