src/share/vm/opto/cfgnode.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File hotspot Sdiff src/share/vm/opto

src/share/vm/opto/cfgnode.cpp

Print this page
rev 9743 : 8139771: Eliminating CastPP nodes at Phis when they all come from a unique input may cause crash
Summary: Lost dependency when CastPP at Phis are eliminate
Reviewed-by:
rev 9744 : reviews
rev 9746 : fix


 886     VectorSet visited(Thread::current()->resource_area());
 887     verify_adr_type(visited, _adr_type);
 888   }
 889 }
 890 #endif
 891 
 892 
 893 //------------------------------Value------------------------------------------
 894 // Compute the type of the PhiNode
 895 const Type *PhiNode::Value( PhaseTransform *phase ) const {
 896   Node *r = in(0);              // RegionNode
 897   if( !r )                      // Copy or dead
 898     return in(1) ? phase->type(in(1)) : Type::TOP;
 899 
 900   // Note: During parsing, phis are often transformed before their regions.
 901   // This means we have to use type_or_null to defend against untyped regions.
 902   if( phase->type_or_null(r) == Type::TOP )  // Dead code?
 903     return Type::TOP;
 904 
 905   // Check for trip-counted loop.  If so, be smarter.
 906   CountedLoopNode *l = r->is_CountedLoop() ? r->as_CountedLoop() : NULL;
 907   if( l && l->can_be_counted_loop(phase) &&
 908       ((const Node*)l->phi() == this) ) { // Trip counted loop!
 909     // protect against init_trip() or limit() returning NULL
 910     const Node *init   = l->init_trip();
 911     const Node *limit  = l->limit();
 912     if( init != NULL && limit != NULL && l->stride_is_con() ) {
 913       const TypeInt *lo = init ->bottom_type()->isa_int();
 914       const TypeInt *hi = limit->bottom_type()->isa_int();
 915       if( lo && hi ) {            // Dying loops might have TOP here
 916         int stride = l->stride_con();
 917         if( stride < 0 ) {          // Down-counter loop
 918           const TypeInt *tmp = lo; lo = hi; hi = tmp;
 919           stride = -stride;




 920         }
 921         if( lo->_hi < hi->_lo )     // Reversed endpoints are well defined :-(
 922           return TypeInt::make(lo->_lo,hi->_hi,3);
 923       }
 924     }
 925   }
 926 
 927   // Until we have harmony between classes and interfaces in the type
 928   // lattice, we must tread carefully around phis which implicitly
 929   // convert the one to the other.
 930   const TypePtr* ttp = _type->make_ptr();
 931   const TypeInstPtr* ttip = (ttp != NULL) ? ttp->isa_instptr() : NULL;
 932   const TypeKlassPtr* ttkp = (ttp != NULL) ? ttp->isa_klassptr() : NULL;
 933   bool is_intf = false;
 934   if (ttip != NULL) {
 935     ciKlass* k = ttip->klass();
 936     if (k->is_loaded() && k->is_interface())
 937       is_intf = true;
 938   }
 939   if (ttkp != NULL) {
 940     ciKlass* k = ttkp->klass();
 941     if (k->is_loaded() && k->is_interface())
 942       is_intf = true;




 886     VectorSet visited(Thread::current()->resource_area());
 887     verify_adr_type(visited, _adr_type);
 888   }
 889 }
 890 #endif
 891 
 892 
 893 //------------------------------Value------------------------------------------
 894 // Compute the type of the PhiNode
 895 const Type *PhiNode::Value( PhaseTransform *phase ) const {
 896   Node *r = in(0);              // RegionNode
 897   if( !r )                      // Copy or dead
 898     return in(1) ? phase->type(in(1)) : Type::TOP;
 899 
 900   // Note: During parsing, phis are often transformed before their regions.
 901   // This means we have to use type_or_null to defend against untyped regions.
 902   if( phase->type_or_null(r) == Type::TOP )  // Dead code?
 903     return Type::TOP;
 904 
 905   // Check for trip-counted loop.  If so, be smarter.
 906   CountedLoopNode* l = r->is_CountedLoop() ? r->as_CountedLoop() : NULL;
 907   if (l && l->can_be_counted_loop(phase) &&
 908       ((const Node*)l->phi() == this)) { // Trip counted loop!
 909     // protect against init_trip() or limit() returning NULL
 910     const Node *init   = l->init_trip();
 911     const Node *limit  = l->limit();
 912     const Node* stride = l->stride();
 913     if (init != NULL && limit != NULL && stride != NULL) {
 914       const TypeInt* lo = phase->type(init)->isa_int();
 915       const TypeInt* hi = phase->type(limit)->isa_int();
 916       const TypeInt* stride_t = phase->type(stride)->isa_int();
 917       if (lo != NULL && hi != NULL && stride_t != NULL) { // Dying loops might have TOP here
 918         assert(stride_t->_hi >= stride_t->_lo, "bad stride type");
 919         if (stride_t->_hi < 0) {          // Down-counter loop
 920           swap(lo, hi);
 921           return TypeInt::make(MIN2(lo->_lo, hi->_lo) , hi->_hi, 3);
 922         } else if (stride_t->_lo >= 0) {
 923           return TypeInt::make(lo->_lo, MAX2(lo->_hi, hi->_hi), 3);
 924         }


 925       }
 926     }
 927   }
 928 
 929   // Until we have harmony between classes and interfaces in the type
 930   // lattice, we must tread carefully around phis which implicitly
 931   // convert the one to the other.
 932   const TypePtr* ttp = _type->make_ptr();
 933   const TypeInstPtr* ttip = (ttp != NULL) ? ttp->isa_instptr() : NULL;
 934   const TypeKlassPtr* ttkp = (ttp != NULL) ? ttp->isa_klassptr() : NULL;
 935   bool is_intf = false;
 936   if (ttip != NULL) {
 937     ciKlass* k = ttip->klass();
 938     if (k->is_loaded() && k->is_interface())
 939       is_intf = true;
 940   }
 941   if (ttkp != NULL) {
 942     ciKlass* k = ttkp->klass();
 943     if (k->is_loaded() && k->is_interface())
 944       is_intf = true;


src/share/vm/opto/cfgnode.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File