src/share/vm/opto/subnode.cpp

Print this page
rev 4505 : 8014189: JVM crash with SEGV in ConnectionGraph::record_for_escape_analysis()
Summary: Add NULL checks and asserts for Type::make_ptr() returned value.
Reviewed-by: kvn


 848     if (!ik->is_final()) {
 849       phase->C->dependencies()->assert_leaf_type(ik);
 850     }
 851   }
 852 
 853   // Bypass the dependent load, and compare directly
 854   this->set_req(1,ldk2);
 855 
 856   return this;
 857 }
 858 
 859 //=============================================================================
 860 //------------------------------sub--------------------------------------------
 861 // Simplify an CmpN (compare 2 pointers) node, based on local information.
 862 // If both inputs are constants, compare them.
 863 const Type *CmpNNode::sub( const Type *t1, const Type *t2 ) const {
 864   const TypePtr *r0 = t1->make_ptr(); // Handy access
 865   const TypePtr *r1 = t2->make_ptr();
 866 
 867   // Undefined inputs makes for an undefined result
 868   if( TypePtr::above_centerline(r0->_ptr) ||
 869       TypePtr::above_centerline(r1->_ptr) )

 870     return Type::TOP;
 871 
 872   if (r0 == r1 && r0->singleton()) {
 873     // Equal pointer constants (klasses, nulls, etc.)
 874     return TypeInt::CC_EQ;
 875   }
 876 
 877   // See if it is 2 unrelated classes.
 878   const TypeOopPtr* p0 = r0->isa_oopptr();
 879   const TypeOopPtr* p1 = r1->isa_oopptr();
 880   if (p0 && p1) {
 881     ciKlass* klass0 = p0->klass();
 882     bool    xklass0 = p0->klass_is_exact();
 883     ciKlass* klass1 = p1->klass();
 884     bool    xklass1 = p1->klass_is_exact();
 885     int kps = (p0->isa_klassptr()?1:0) + (p1->isa_klassptr()?1:0);
 886     if (klass0 && klass1 &&
 887         kps != 1 &&             // both or neither are klass pointers
 888         !klass0->is_interface() && // do not trust interfaces
 889         !klass1->is_interface()) {
 890       bool unrelated_classes = false;
 891       // See if neither subclasses the other, or if the class on top




 848     if (!ik->is_final()) {
 849       phase->C->dependencies()->assert_leaf_type(ik);
 850     }
 851   }
 852 
 853   // Bypass the dependent load, and compare directly
 854   this->set_req(1,ldk2);
 855 
 856   return this;
 857 }
 858 
 859 //=============================================================================
 860 //------------------------------sub--------------------------------------------
 861 // Simplify an CmpN (compare 2 pointers) node, based on local information.
 862 // If both inputs are constants, compare them.
 863 const Type *CmpNNode::sub( const Type *t1, const Type *t2 ) const {
 864   const TypePtr *r0 = t1->make_ptr(); // Handy access
 865   const TypePtr *r1 = t2->make_ptr();
 866 
 867   // Undefined inputs makes for an undefined result
 868   if ((r0 == NULL) || (r1 == NULL) ||
 869       TypePtr::above_centerline(r0->_ptr) ||
 870       TypePtr::above_centerline(r1->_ptr)) {
 871     return Type::TOP;
 872   }
 873   if (r0 == r1 && r0->singleton()) {
 874     // Equal pointer constants (klasses, nulls, etc.)
 875     return TypeInt::CC_EQ;
 876   }
 877 
 878   // See if it is 2 unrelated classes.
 879   const TypeOopPtr* p0 = r0->isa_oopptr();
 880   const TypeOopPtr* p1 = r1->isa_oopptr();
 881   if (p0 && p1) {
 882     ciKlass* klass0 = p0->klass();
 883     bool    xklass0 = p0->klass_is_exact();
 884     ciKlass* klass1 = p1->klass();
 885     bool    xklass1 = p1->klass_is_exact();
 886     int kps = (p0->isa_klassptr()?1:0) + (p1->isa_klassptr()?1:0);
 887     if (klass0 && klass1 &&
 888         kps != 1 &&             // both or neither are klass pointers
 889         !klass0->is_interface() && // do not trust interfaces
 890         !klass1->is_interface()) {
 891       bool unrelated_classes = false;
 892       // See if neither subclasses the other, or if the class on top