1.1 --- a/src/share/vm/opto/subnode.cpp Fri Apr 11 09:56:35 2008 -0400 1.2 +++ b/src/share/vm/opto/subnode.cpp Sun Apr 13 17:43:42 2008 -0400 1.3 @@ -736,6 +736,75 @@ 1.4 } 1.5 1.6 //============================================================================= 1.7 +//------------------------------sub-------------------------------------------- 1.8 +// Simplify an CmpN (compare 2 pointers) node, based on local information. 1.9 +// If both inputs are constants, compare them. 1.10 +const Type *CmpNNode::sub( const Type *t1, const Type *t2 ) const { 1.11 + const TypePtr *r0 = t1->is_narrowoop()->make_oopptr(); // Handy access 1.12 + const TypePtr *r1 = t2->is_narrowoop()->make_oopptr(); 1.13 + 1.14 + // Undefined inputs makes for an undefined result 1.15 + if( TypePtr::above_centerline(r0->_ptr) || 1.16 + TypePtr::above_centerline(r1->_ptr) ) 1.17 + return Type::TOP; 1.18 + 1.19 + if (r0 == r1 && r0->singleton()) { 1.20 + // Equal pointer constants (klasses, nulls, etc.) 1.21 + return TypeInt::CC_EQ; 1.22 + } 1.23 + 1.24 + // See if it is 2 unrelated classes. 1.25 + const TypeOopPtr* p0 = r0->isa_oopptr(); 1.26 + const TypeOopPtr* p1 = r1->isa_oopptr(); 1.27 + if (p0 && p1) { 1.28 + ciKlass* klass0 = p0->klass(); 1.29 + bool xklass0 = p0->klass_is_exact(); 1.30 + ciKlass* klass1 = p1->klass(); 1.31 + bool xklass1 = p1->klass_is_exact(); 1.32 + int kps = (p0->isa_klassptr()?1:0) + (p1->isa_klassptr()?1:0); 1.33 + if (klass0 && klass1 && 1.34 + kps != 1 && // both or neither are klass pointers 1.35 + !klass0->is_interface() && // do not trust interfaces 1.36 + !klass1->is_interface()) { 1.37 + // See if neither subclasses the other, or if the class on top 1.38 + // is precise. In either of these cases, the compare must fail. 1.39 + if (klass0->equals(klass1) || // if types are unequal but klasses are 1.40 + !klass0->is_java_klass() || // types not part of Java language? 1.41 + !klass1->is_java_klass()) { // types not part of Java language? 1.42 + // Do nothing; we know nothing for imprecise types 1.43 + } else if (klass0->is_subtype_of(klass1)) { 1.44 + // If klass1's type is PRECISE, then we can fail. 1.45 + if (xklass1) return TypeInt::CC_GT; 1.46 + } else if (klass1->is_subtype_of(klass0)) { 1.47 + // If klass0's type is PRECISE, then we can fail. 1.48 + if (xklass0) return TypeInt::CC_GT; 1.49 + } else { // Neither subtypes the other 1.50 + return TypeInt::CC_GT; // ...so always fail 1.51 + } 1.52 + } 1.53 + } 1.54 + 1.55 + // Known constants can be compared exactly 1.56 + // Null can be distinguished from any NotNull pointers 1.57 + // Unknown inputs makes an unknown result 1.58 + if( r0->singleton() ) { 1.59 + intptr_t bits0 = r0->get_con(); 1.60 + if( r1->singleton() ) 1.61 + return bits0 == r1->get_con() ? TypeInt::CC_EQ : TypeInt::CC_GT; 1.62 + return ( r1->_ptr == TypePtr::NotNull && bits0==0 ) ? TypeInt::CC_GT : TypeInt::CC; 1.63 + } else if( r1->singleton() ) { 1.64 + intptr_t bits1 = r1->get_con(); 1.65 + return ( r0->_ptr == TypePtr::NotNull && bits1==0 ) ? TypeInt::CC_GT : TypeInt::CC; 1.66 + } else 1.67 + return TypeInt::CC; 1.68 +} 1.69 + 1.70 +//------------------------------Ideal------------------------------------------ 1.71 +Node *CmpNNode::Ideal( PhaseGVN *phase, bool can_reshape ) { 1.72 + return NULL; 1.73 +} 1.74 + 1.75 +//============================================================================= 1.76 //------------------------------Value------------------------------------------ 1.77 // Simplify an CmpF (compare 2 floats ) node, based on local information. 1.78 // If both inputs are constants, compare them.