1.1 --- a/src/share/vm/opto/type.hpp Mon Oct 08 17:04:00 2012 -0700 1.2 +++ b/src/share/vm/opto/type.hpp Tue Oct 09 10:11:38 2012 +0200 1.3 @@ -48,7 +48,9 @@ 1.4 class TypeF; 1.5 class TypeInt; 1.6 class TypeLong; 1.7 -class TypeNarrowOop; 1.8 +class TypeNarrowPtr; 1.9 +class TypeNarrowOop; 1.10 +class TypeNarrowKlass; 1.11 class TypeAry; 1.12 class TypeTuple; 1.13 class TypeVect; 1.14 @@ -81,6 +83,7 @@ 1.15 Long, // Long integer range (lo-hi) 1.16 Half, // Placeholder half of doubleword 1.17 NarrowOop, // Compressed oop pointer 1.18 + NarrowKlass, // Compressed klass pointer 1.19 1.20 Tuple, // Method signature or object layout 1.21 Array, // Array types 1.22 @@ -229,6 +232,7 @@ 1.23 // Returns true if this pointer points at memory which contains a 1.24 // compressed oop references. 1.25 bool is_ptr_to_narrowoop() const; 1.26 + bool is_ptr_to_narrowklass() const; 1.27 1.28 // Convenience access 1.29 float getf() const; 1.30 @@ -252,6 +256,8 @@ 1.31 const TypeRawPtr *is_rawptr() const; // Asserts is rawptr 1.32 const TypeNarrowOop *is_narrowoop() const; // Java-style GC'd pointer 1.33 const TypeNarrowOop *isa_narrowoop() const; // Returns NULL if not oop ptr type 1.34 + const TypeNarrowKlass *is_narrowklass() const; // compressed klass pointer 1.35 + const TypeNarrowKlass *isa_narrowklass() const;// Returns NULL if not oop ptr type 1.36 const TypeOopPtr *isa_oopptr() const; // Returns NULL if not oop ptr type 1.37 const TypeOopPtr *is_oopptr() const; // Java-style GC'd pointer 1.38 const TypeInstPtr *isa_instptr() const; // Returns NULL if not InstPtr 1.39 @@ -278,6 +284,10 @@ 1.40 // of this pointer type. 1.41 const TypeNarrowOop* make_narrowoop() const; 1.42 1.43 + // Returns this compressed klass pointer or the equivalent 1.44 + // compressed version of this pointer type. 1.45 + const TypeNarrowKlass* make_narrowklass() const; 1.46 + 1.47 // Special test for register pressure heuristic 1.48 bool is_floatingpoint() const; // True if Float or Double base type 1.49 1.50 @@ -670,7 +680,7 @@ 1.51 // Otherwise the _base will indicate which subset of pointers is affected, 1.52 // and the class will be inherited from. 1.53 class TypePtr : public Type { 1.54 - friend class TypeNarrowOop; 1.55 + friend class TypeNarrowPtr; 1.56 public: 1.57 enum PTR { TopPTR, AnyNull, Constant, Null, NotNull, BotPTR, lastPTR }; 1.58 protected: 1.59 @@ -781,6 +791,7 @@ 1.60 // Does the type exclude subclasses of the klass? (Inexact == polymorphic.) 1.61 bool _klass_is_exact; 1.62 bool _is_ptr_to_narrowoop; 1.63 + bool _is_ptr_to_narrowklass; 1.64 1.65 // If not InstanceTop or InstanceBot, indicates that this is 1.66 // a particular instance of this type which is distinct. 1.67 @@ -825,6 +836,7 @@ 1.68 // Returns true if this pointer points at memory which contains a 1.69 // compressed oop references. 1.70 bool is_ptr_to_narrowoop_nv() const { return _is_ptr_to_narrowoop; } 1.71 + bool is_ptr_to_narrowklass_nv() const { return _is_ptr_to_narrowklass; } 1.72 1.73 bool is_known_instance() const { return _instance_id > 0; } 1.74 int instance_id() const { return _instance_id; } 1.75 @@ -1122,22 +1134,21 @@ 1.76 #endif 1.77 }; 1.78 1.79 -//------------------------------TypeNarrowOop---------------------------------- 1.80 -// A compressed reference to some kind of Oop. This type wraps around 1.81 -// a preexisting TypeOopPtr and forwards most of it's operations to 1.82 -// the underlying type. It's only real purpose is to track the 1.83 -// oopness of the compressed oop value when we expose the conversion 1.84 -// between the normal and the compressed form. 1.85 -class TypeNarrowOop : public Type { 1.86 +class TypeNarrowPtr : public Type { 1.87 protected: 1.88 const TypePtr* _ptrtype; // Could be TypePtr::NULL_PTR 1.89 1.90 - TypeNarrowOop( const TypePtr* ptrtype): Type(NarrowOop), 1.91 - _ptrtype(ptrtype) { 1.92 + TypeNarrowPtr(TYPES t, const TypePtr* ptrtype): _ptrtype(ptrtype), 1.93 + Type(t) { 1.94 assert(ptrtype->offset() == 0 || 1.95 ptrtype->offset() == OffsetBot || 1.96 ptrtype->offset() == OffsetTop, "no real offsets"); 1.97 } 1.98 + 1.99 + virtual const TypeNarrowPtr *isa_same_narrowptr(const Type *t) const = 0; 1.100 + virtual const TypeNarrowPtr *is_same_narrowptr(const Type *t) const = 0; 1.101 + virtual const TypeNarrowPtr *make_same_narrowptr(const TypePtr *t) const = 0; 1.102 + virtual const TypeNarrowPtr *make_hash_same_narrowptr(const TypePtr *t) const = 0; 1.103 public: 1.104 virtual bool eq( const Type *t ) const; 1.105 virtual int hash() const; // Type specific hashing 1.106 @@ -1153,19 +1164,89 @@ 1.107 1.108 virtual bool empty(void) const; // TRUE if type is vacuous 1.109 1.110 + // returns the equivalent ptr type for this compressed pointer 1.111 + const TypePtr *get_ptrtype() const { 1.112 + return _ptrtype; 1.113 + } 1.114 + 1.115 +#ifndef PRODUCT 1.116 + virtual void dump2( Dict &d, uint depth, outputStream *st ) const; 1.117 +#endif 1.118 +}; 1.119 + 1.120 +//------------------------------TypeNarrowOop---------------------------------- 1.121 +// A compressed reference to some kind of Oop. This type wraps around 1.122 +// a preexisting TypeOopPtr and forwards most of it's operations to 1.123 +// the underlying type. It's only real purpose is to track the 1.124 +// oopness of the compressed oop value when we expose the conversion 1.125 +// between the normal and the compressed form. 1.126 +class TypeNarrowOop : public TypeNarrowPtr { 1.127 +protected: 1.128 + TypeNarrowOop( const TypePtr* ptrtype): TypeNarrowPtr(NarrowOop, ptrtype) { 1.129 + } 1.130 + 1.131 + virtual const TypeNarrowPtr *isa_same_narrowptr(const Type *t) const { 1.132 + return t->isa_narrowoop(); 1.133 + } 1.134 + 1.135 + virtual const TypeNarrowPtr *is_same_narrowptr(const Type *t) const { 1.136 + return t->is_narrowoop(); 1.137 + } 1.138 + 1.139 + virtual const TypeNarrowPtr *make_same_narrowptr(const TypePtr *t) const { 1.140 + return new TypeNarrowOop(t); 1.141 + } 1.142 + 1.143 + virtual const TypeNarrowPtr *make_hash_same_narrowptr(const TypePtr *t) const { 1.144 + return (const TypeNarrowPtr*)((new TypeNarrowOop(t))->hashcons()); 1.145 + } 1.146 + 1.147 +public: 1.148 + 1.149 static const TypeNarrowOop *make( const TypePtr* type); 1.150 1.151 static const TypeNarrowOop* make_from_constant(ciObject* con, bool require_constant = false) { 1.152 return make(TypeOopPtr::make_from_constant(con, require_constant)); 1.153 } 1.154 1.155 - // returns the equivalent ptr type for this compressed pointer 1.156 - const TypePtr *get_ptrtype() const { 1.157 - return _ptrtype; 1.158 + static const TypeNarrowOop *BOTTOM; 1.159 + static const TypeNarrowOop *NULL_PTR; 1.160 + 1.161 +#ifndef PRODUCT 1.162 + virtual void dump2( Dict &d, uint depth, outputStream *st ) const; 1.163 +#endif 1.164 +}; 1.165 + 1.166 +//------------------------------TypeNarrowKlass---------------------------------- 1.167 +// A compressed reference to klass pointer. This type wraps around a 1.168 +// preexisting TypeKlassPtr and forwards most of it's operations to 1.169 +// the underlying type. 1.170 +class TypeNarrowKlass : public TypeNarrowPtr { 1.171 +protected: 1.172 + TypeNarrowKlass( const TypePtr* ptrtype): TypeNarrowPtr(NarrowKlass, ptrtype) { 1.173 } 1.174 1.175 - static const TypeNarrowOop *BOTTOM; 1.176 - static const TypeNarrowOop *NULL_PTR; 1.177 + virtual const TypeNarrowPtr *isa_same_narrowptr(const Type *t) const { 1.178 + return t->isa_narrowklass(); 1.179 + } 1.180 + 1.181 + virtual const TypeNarrowPtr *is_same_narrowptr(const Type *t) const { 1.182 + return t->is_narrowklass(); 1.183 + } 1.184 + 1.185 + virtual const TypeNarrowPtr *make_same_narrowptr(const TypePtr *t) const { 1.186 + return new TypeNarrowKlass(t); 1.187 + } 1.188 + 1.189 + virtual const TypeNarrowPtr *make_hash_same_narrowptr(const TypePtr *t) const { 1.190 + return (const TypeNarrowPtr*)((new TypeNarrowKlass(t))->hashcons()); 1.191 + } 1.192 + 1.193 +public: 1.194 + static const TypeNarrowKlass *make( const TypePtr* type); 1.195 + 1.196 + // static const TypeNarrowKlass *BOTTOM; 1.197 + static const TypeNarrowKlass *NULL_PTR; 1.198 1.199 #ifndef PRODUCT 1.200 virtual void dump2( Dict &d, uint depth, outputStream *st ) const; 1.201 @@ -1221,6 +1302,14 @@ 1.202 #endif 1.203 } 1.204 1.205 +inline bool Type::is_ptr_to_narrowklass() const { 1.206 +#ifdef _LP64 1.207 + return (isa_oopptr() != NULL && is_oopptr()->is_ptr_to_narrowklass_nv()); 1.208 +#else 1.209 + return false; 1.210 +#endif 1.211 +} 1.212 + 1.213 inline float Type::getf() const { 1.214 assert( _base == FloatCon, "Not a FloatCon" ); 1.215 return ((TypeF*)this)->_f; 1.216 @@ -1346,6 +1435,15 @@ 1.217 return (_base == NarrowOop) ? (TypeNarrowOop*)this : NULL; 1.218 } 1.219 1.220 +inline const TypeNarrowKlass *Type::is_narrowklass() const { 1.221 + assert(_base == NarrowKlass, "Not a narrow oop" ) ; 1.222 + return (TypeNarrowKlass*)this; 1.223 +} 1.224 + 1.225 +inline const TypeNarrowKlass *Type::isa_narrowklass() const { 1.226 + return (_base == NarrowKlass) ? (TypeNarrowKlass*)this : NULL; 1.227 +} 1.228 + 1.229 inline const TypeMetadataPtr *Type::is_metadataptr() const { 1.230 // MetadataPtr is the first and CPCachePtr the last 1.231 assert(_base == MetadataPtr, "Not a metadata pointer" ) ; 1.232 @@ -1367,7 +1465,8 @@ 1.233 1.234 inline const TypePtr* Type::make_ptr() const { 1.235 return (_base == NarrowOop) ? is_narrowoop()->get_ptrtype() : 1.236 - (isa_ptr() ? is_ptr() : NULL); 1.237 + ((_base == NarrowKlass) ? is_narrowklass()->get_ptrtype() : 1.238 + (isa_ptr() ? is_ptr() : NULL)); 1.239 } 1.240 1.241 inline const TypeOopPtr* Type::make_oopptr() const { 1.242 @@ -1379,6 +1478,11 @@ 1.243 (isa_ptr() ? TypeNarrowOop::make(is_ptr()) : NULL); 1.244 } 1.245 1.246 +inline const TypeNarrowKlass* Type::make_narrowklass() const { 1.247 + return (_base == NarrowKlass) ? is_narrowklass() : 1.248 + (isa_ptr() ? TypeNarrowKlass::make(is_ptr()) : NULL); 1.249 +} 1.250 + 1.251 inline bool Type::is_floatingpoint() const { 1.252 if( (_base == FloatCon) || (_base == FloatBot) || 1.253 (_base == DoubleCon) || (_base == DoubleBot) )