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(PhaseGVN* 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;
945 }
|
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(PhaseGVN* 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 && ((const Node*)l->phi() == this)) { // Trip counted loop!
908 // protect against init_trip() or limit() returning NULL
909 if (l->can_be_counted_loop(phase)) {
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 } else if (l->in(LoopNode::LoopBackControl) != NULL &&
928 in(LoopNode::EntryControl) != NULL &&
929 phase->type(l->in(LoopNode::LoopBackControl)) == Type::TOP) {
930 // During CCP, if we saturate the type of a counted loop's Phi
931 // before the special code for counted loop above has a chance
932 // to run (that is as long as the type of the backedge's control
933 // is top), we might end up with non monotonic types
934 return phase->type(in(LoopNode::EntryControl));
935 }
936 }
937
938 // Until we have harmony between classes and interfaces in the type
939 // lattice, we must tread carefully around phis which implicitly
940 // convert the one to the other.
941 const TypePtr* ttp = _type->make_ptr();
942 const TypeInstPtr* ttip = (ttp != NULL) ? ttp->isa_instptr() : NULL;
943 const TypeKlassPtr* ttkp = (ttp != NULL) ? ttp->isa_klassptr() : NULL;
944 bool is_intf = false;
945 if (ttip != NULL) {
946 ciKlass* k = ttip->klass();
947 if (k->is_loaded() && k->is_interface())
948 is_intf = true;
949 }
950 if (ttkp != NULL) {
951 ciKlass* k = ttkp->klass();
952 if (k->is_loaded() && k->is_interface())
953 is_intf = true;
954 }
|