860 } 861 } 862 } 863 864 // Known constants can be compared exactly 865 // Null can be distinguished from any NotNull pointers 866 // Unknown inputs makes an unknown result 867 if( r0->singleton() ) { 868 intptr_t bits0 = r0->get_con(); 869 if( r1->singleton() ) 870 return bits0 == r1->get_con() ? TypeInt::CC_EQ : TypeInt::CC_GT; 871 return ( r1->_ptr == TypePtr::NotNull && bits0==0 ) ? TypeInt::CC_GT : TypeInt::CC; 872 } else if( r1->singleton() ) { 873 intptr_t bits1 = r1->get_con(); 874 return ( r0->_ptr == TypePtr::NotNull && bits1==0 ) ? TypeInt::CC_GT : TypeInt::CC; 875 } else 876 return TypeInt::CC; 877 } 878 879 static inline Node* isa_java_mirror_load(PhaseGVN* phase, Node* n) { 880 // Return the klass node for 881 // LoadP(AddP(foo:Klass, #java_mirror)) 882 // or NULL if not matching. 883 if (n->Opcode() != Op_LoadP) return NULL; 884 885 const TypeInstPtr* tp = phase->type(n)->isa_instptr(); 886 if (!tp || tp->klass() != phase->C->env()->Class_klass()) return NULL; 887 888 Node* adr = n->in(MemNode::Address); 889 intptr_t off = 0; 890 Node* k = AddPNode::Ideal_base_and_offset(adr, phase, off); 891 if (k == NULL) return NULL; 892 const TypeKlassPtr* tkp = phase->type(k)->isa_klassptr(); 893 if (!tkp || off != in_bytes(Klass::java_mirror_offset())) return NULL; 894 895 // We've found the klass node of a Java mirror load. 896 return k; 897 } 898 899 static inline Node* isa_const_java_mirror(PhaseGVN* phase, Node* n) { 900 // for ConP(Foo.class) return ConP(Foo.klass) 901 // otherwise return NULL 902 if (!n->is_Con()) return NULL; 903 904 const TypeInstPtr* tp = phase->type(n)->isa_instptr(); 905 if (!tp) return NULL; 906 907 ciType* mirror_type = tp->java_mirror_type(); 908 // TypeInstPtr::java_mirror_type() returns non-NULL for compile- | 860 } 861 } 862 } 863 864 // Known constants can be compared exactly 865 // Null can be distinguished from any NotNull pointers 866 // Unknown inputs makes an unknown result 867 if( r0->singleton() ) { 868 intptr_t bits0 = r0->get_con(); 869 if( r1->singleton() ) 870 return bits0 == r1->get_con() ? TypeInt::CC_EQ : TypeInt::CC_GT; 871 return ( r1->_ptr == TypePtr::NotNull && bits0==0 ) ? TypeInt::CC_GT : TypeInt::CC; 872 } else if( r1->singleton() ) { 873 intptr_t bits1 = r1->get_con(); 874 return ( r0->_ptr == TypePtr::NotNull && bits1==0 ) ? TypeInt::CC_GT : TypeInt::CC; 875 } else 876 return TypeInt::CC; 877 } 878 879 static inline Node* isa_java_mirror_load(PhaseGVN* phase, Node* n) { 880 // Return the klass node for (indirect load from OopHandle) 881 // LoadP(LoadP(AddP(foo:Klass, #java_mirror))) 882 // or NULL if not matching. 883 if (n->Opcode() != Op_LoadP) return NULL; 884 885 const TypeInstPtr* tp = phase->type(n)->isa_instptr(); 886 if (!tp || tp->klass() != phase->C->env()->Class_klass()) return NULL; 887 888 Node* adr = n->in(MemNode::Address); 889 // First load from OopHandle 890 if (adr->Opcode() != Op_LoadP || !phase->type(adr)->isa_rawptr()) return NULL; 891 adr = adr->in(MemNode::Address); 892 893 intptr_t off = 0; 894 Node* k = AddPNode::Ideal_base_and_offset(adr, phase, off); 895 if (k == NULL) return NULL; 896 const TypeKlassPtr* tkp = phase->type(k)->isa_klassptr(); 897 if (!tkp || off != in_bytes(Klass::java_mirror_offset())) return NULL; 898 899 // We've found the klass node of a Java mirror load. 900 return k; 901 } 902 903 static inline Node* isa_const_java_mirror(PhaseGVN* phase, Node* n) { 904 // for ConP(Foo.class) return ConP(Foo.klass) 905 // otherwise return NULL 906 if (!n->is_Con()) return NULL; 907 908 const TypeInstPtr* tp = phase->type(n)->isa_instptr(); 909 if (!tp) return NULL; 910 911 ciType* mirror_type = tp->java_mirror_type(); 912 // TypeInstPtr::java_mirror_type() returns non-NULL for compile- |