1.1 --- a/src/share/vm/opto/type.hpp Thu Jul 03 11:01:32 2008 -0700 1.2 +++ b/src/share/vm/opto/type.hpp Fri Jul 11 01:14:44 2008 -0700 1.3 @@ -225,6 +225,12 @@ 1.4 virtual bool is_finite() const; // Has a finite value 1.5 virtual bool is_nan() const; // Is not a number (NaN) 1.6 1.7 + // Returns this ptr type or the equivalent ptr type for this compressed pointer. 1.8 + const TypePtr* make_ptr() const; 1.9 + // Returns this compressed pointer or the equivalent compressed version 1.10 + // of this pointer type. 1.11 + const TypeNarrowOop* make_narrowoop() const; 1.12 + 1.13 // Special test for register pressure heuristic 1.14 bool is_floatingpoint() const; // True if Float or Double base type 1.15 1.16 @@ -648,7 +654,8 @@ 1.17 virtual int hash() const; // Type specific hashing 1.18 virtual bool singleton(void) const; // TRUE if type is a singleton 1.19 enum { 1.20 - UNKNOWN_INSTANCE = 0 1.21 + InstanceTop = -1, // undefined instance 1.22 + InstanceBot = 0 // any possible instance 1.23 }; 1.24 protected: 1.25 1.26 @@ -661,14 +668,15 @@ 1.27 bool _klass_is_exact; 1.28 bool _is_ptr_to_narrowoop; 1.29 1.30 - int _instance_id; // if not UNKNOWN_INSTANCE, indicates that this is a particular instance 1.31 - // of this type which is distinct. This is the the node index of the 1.32 - // node creating this instance 1.33 + // If not InstanceTop or InstanceBot, indicates that this is 1.34 + // a particular instance of this type which is distinct. 1.35 + // This is the the node index of the allocation node creating this instance. 1.36 + int _instance_id; 1.37 1.38 static const TypeOopPtr* make_from_klass_common(ciKlass* klass, bool klass_change, bool try_for_exact); 1.39 1.40 - int dual_instance() const { return -_instance_id; } 1.41 - int meet_instance(int uid) const; 1.42 + int dual_instance_id() const; 1.43 + int meet_instance_id(int uid) const; 1.44 1.45 public: 1.46 // Creates a type given a klass. Correctly handles multi-dimensional arrays 1.47 @@ -701,9 +709,9 @@ 1.48 // compressed oop references. 1.49 bool is_ptr_to_narrowoop_nv() const { return _is_ptr_to_narrowoop; } 1.50 1.51 - bool is_instance() const { return _instance_id != UNKNOWN_INSTANCE; } 1.52 - uint instance_id() const { return _instance_id; } 1.53 - bool is_instance_field() const { return _instance_id != UNKNOWN_INSTANCE && _offset >= 0; } 1.54 + bool is_known_instance() const { return _instance_id > 0; } 1.55 + int instance_id() const { return _instance_id; } 1.56 + bool is_known_instance_field() const { return is_known_instance() && _offset >= 0; } 1.57 1.58 virtual intptr_t get_con() const; 1.59 1.60 @@ -711,16 +719,13 @@ 1.61 1.62 virtual const Type *cast_to_exactness(bool klass_is_exact) const; 1.63 1.64 - virtual const TypeOopPtr *cast_to_instance(int instance_id) const; 1.65 + virtual const TypeOopPtr *cast_to_instance_id(int instance_id) const; 1.66 1.67 // corresponding pointer to klass, for a given instance 1.68 const TypeKlassPtr* as_klass_type() const; 1.69 1.70 virtual const TypePtr *add_offset( int offset ) const; 1.71 1.72 - // returns the equivalent compressed version of this pointer type 1.73 - virtual const TypeNarrowOop* make_narrowoop() const; 1.74 - 1.75 virtual const Type *xmeet( const Type *t ) const; 1.76 virtual const Type *xdual() const; // Compute dual right now. 1.77 1.78 @@ -775,7 +780,7 @@ 1.79 } 1.80 1.81 // Make a pointer to an oop. 1.82 - static const TypeInstPtr *make(PTR ptr, ciKlass* k, bool xk, ciObject* o, int offset, int instance_id = 0 ); 1.83 + static const TypeInstPtr *make(PTR ptr, ciKlass* k, bool xk, ciObject* o, int offset, int instance_id = InstanceBot ); 1.84 1.85 // If this is a java.lang.Class constant, return the type for it or NULL. 1.86 // Pass to Type::get_const_type to turn it to a type, which will usually 1.87 @@ -786,7 +791,7 @@ 1.88 1.89 virtual const Type *cast_to_exactness(bool klass_is_exact) const; 1.90 1.91 - virtual const TypeOopPtr *cast_to_instance(int instance_id) const; 1.92 + virtual const TypeOopPtr *cast_to_instance_id(int instance_id) const; 1.93 1.94 virtual const TypePtr *add_offset( int offset ) const; 1.95 1.96 @@ -820,9 +825,9 @@ 1.97 const Type* elem() const { return _ary->_elem; } 1.98 const TypeInt* size() const { return _ary->_size; } 1.99 1.100 - static const TypeAryPtr *make( PTR ptr, const TypeAry *ary, ciKlass* k, bool xk, int offset, int instance_id = 0); 1.101 + static const TypeAryPtr *make( PTR ptr, const TypeAry *ary, ciKlass* k, bool xk, int offset, int instance_id = InstanceBot); 1.102 // Constant pointer to array 1.103 - static const TypeAryPtr *make( PTR ptr, ciObject* o, const TypeAry *ary, ciKlass* k, bool xk, int offset, int instance_id = 0); 1.104 + static const TypeAryPtr *make( PTR ptr, ciObject* o, const TypeAry *ary, ciKlass* k, bool xk, int offset, int instance_id = InstanceBot); 1.105 1.106 // Convenience 1.107 static const TypeAryPtr *make(ciObject* o); 1.108 @@ -832,7 +837,7 @@ 1.109 1.110 virtual const Type *cast_to_exactness(bool klass_is_exact) const; 1.111 1.112 - virtual const TypeOopPtr *cast_to_instance(int instance_id) const; 1.113 + virtual const TypeOopPtr *cast_to_instance_id(int instance_id) const; 1.114 1.115 virtual const TypeAryPtr* cast_to_size(const TypeInt* size) const; 1.116 1.117 @@ -911,7 +916,7 @@ 1.118 // between the normal and the compressed form. 1.119 class TypeNarrowOop : public Type { 1.120 protected: 1.121 - const TypePtr* _ooptype; 1.122 + const TypePtr* _ooptype; // Could be TypePtr::NULL_PTR 1.123 1.124 TypeNarrowOop( const TypePtr* ooptype): Type(NarrowOop), 1.125 _ooptype(ooptype) { 1.126 @@ -940,8 +945,8 @@ 1.127 return make(TypeOopPtr::make_from_constant(con)); 1.128 } 1.129 1.130 - // returns the equivalent oopptr type for this compressed pointer 1.131 - virtual const TypePtr *make_oopptr() const { 1.132 + // returns the equivalent ptr type for this compressed pointer 1.133 + const TypePtr *make_oopptr() const { 1.134 return _ooptype; 1.135 } 1.136 1.137 @@ -1128,6 +1133,16 @@ 1.138 return (TypeKlassPtr*)this; 1.139 } 1.140 1.141 +inline const TypePtr* Type::make_ptr() const { 1.142 + return (_base == NarrowOop) ? is_narrowoop()->make_oopptr() : 1.143 + (isa_ptr() ? is_ptr() : NULL); 1.144 +} 1.145 + 1.146 +inline const TypeNarrowOop* Type::make_narrowoop() const { 1.147 + return (_base == NarrowOop) ? is_narrowoop() : 1.148 + (isa_ptr() ? TypeNarrowOop::make(is_ptr()) : NULL); 1.149 +} 1.150 + 1.151 inline bool Type::is_floatingpoint() const { 1.152 if( (_base == FloatCon) || (_base == FloatBot) || 1.153 (_base == DoubleCon) || (_base == DoubleBot) )