1.1 --- a/src/share/vm/opto/type.hpp Tue Mar 25 12:54:21 2014 -0700 1.2 +++ b/src/share/vm/opto/type.hpp Tue Mar 25 17:07:36 2014 -0700 1.3 @@ -415,10 +415,15 @@ 1.4 bool is_autobox_cache = false); 1.5 1.6 // Speculative type. See TypeInstPtr 1.7 + virtual const TypeOopPtr* speculative() const { return NULL; } 1.8 virtual ciKlass* speculative_type() const { return NULL; } 1.9 const Type* maybe_remove_speculative(bool include_speculative) const; 1.10 virtual const Type* remove_speculative() const { return this; } 1.11 1.12 + virtual bool would_improve_type(ciKlass* exact_kls, int inline_depth) const { 1.13 + return exact_kls != NULL; 1.14 + } 1.15 + 1.16 private: 1.17 // support arrays 1.18 static const BasicType _basic_type[]; 1.19 @@ -489,6 +494,7 @@ 1.20 virtual const Type *filter_helper(const Type *kills, bool include_speculative) const; 1.21 1.22 public: 1.23 + typedef jint NativeType; 1.24 virtual bool eq( const Type *t ) const; 1.25 virtual int hash() const; // Type specific hashing 1.26 virtual bool singleton(void) const; // TRUE if type is a singleton 1.27 @@ -531,6 +537,9 @@ 1.28 static const TypeInt *POS1; 1.29 static const TypeInt *INT; 1.30 static const TypeInt *SYMINT; // symmetric range [-max_jint..max_jint] 1.31 + static const TypeInt *TYPE_DOMAIN; // alias for TypeInt::INT 1.32 + 1.33 + static const TypeInt *as_self(const Type *t) { return t->is_int(); } 1.34 #ifndef PRODUCT 1.35 virtual void dump2( Dict &d, uint depth, outputStream *st ) const; 1.36 #endif 1.37 @@ -546,6 +555,7 @@ 1.38 // Do not kill _widen bits. 1.39 virtual const Type *filter_helper(const Type *kills, bool include_speculative) const; 1.40 public: 1.41 + typedef jlong NativeType; 1.42 virtual bool eq( const Type *t ) const; 1.43 virtual int hash() const; // Type specific hashing 1.44 virtual bool singleton(void) const; // TRUE if type is a singleton 1.45 @@ -568,6 +578,7 @@ 1.46 1.47 virtual bool is_finite() const; // Has a finite value 1.48 1.49 + 1.50 virtual const Type *xmeet( const Type *t ) const; 1.51 virtual const Type *xdual() const; // Compute dual right now. 1.52 virtual const Type *widen( const Type *t, const Type* limit_type ) const; 1.53 @@ -580,6 +591,11 @@ 1.54 static const TypeLong *LONG; 1.55 static const TypeLong *INT; // 32-bit subrange [min_jint..max_jint] 1.56 static const TypeLong *UINT; // 32-bit unsigned [0..max_juint] 1.57 + static const TypeLong *TYPE_DOMAIN; // alias for TypeLong::LONG 1.58 + 1.59 + // static convenience methods. 1.60 + static const TypeLong *as_self(const Type *t) { return t->is_long(); } 1.61 + 1.62 #ifndef PRODUCT 1.63 virtual void dump2( Dict &d, uint, outputStream *st ) const;// Specialized per-Type dumping 1.64 #endif 1.65 @@ -834,7 +850,7 @@ 1.66 // Some kind of oop (Java pointer), either klass or instance or array. 1.67 class TypeOopPtr : public TypePtr { 1.68 protected: 1.69 - TypeOopPtr(TYPES t, PTR ptr, ciKlass* k, bool xk, ciObject* o, int offset, int instance_id, const TypeOopPtr* speculative); 1.70 + TypeOopPtr(TYPES t, PTR ptr, ciKlass* k, bool xk, ciObject* o, int offset, int instance_id, const TypeOopPtr* speculative, int inline_depth); 1.71 public: 1.72 virtual bool eq( const Type *t ) const; 1.73 virtual int hash() const; // Type specific hashing 1.74 @@ -845,6 +861,10 @@ 1.75 }; 1.76 protected: 1.77 1.78 + enum { 1.79 + InlineDepthBottom = INT_MAX, 1.80 + InlineDepthTop = -InlineDepthBottom 1.81 + }; 1.82 // Oop is NULL, unless this is a constant oop. 1.83 ciObject* _const_oop; // Constant oop 1.84 // If _klass is NULL, then so is _sig. This is an unloaded klass. 1.85 @@ -865,6 +885,11 @@ 1.86 // use it, then we have to emit a guard: this part of the type is 1.87 // not something we know but something we speculate about the type. 1.88 const TypeOopPtr* _speculative; 1.89 + // For speculative types, we record at what inlining depth the 1.90 + // profiling point that provided the data is. We want to favor 1.91 + // profile data coming from outer scopes which are likely better for 1.92 + // the current compilation. 1.93 + int _inline_depth; 1.94 1.95 static const TypeOopPtr* make_from_klass_common(ciKlass* klass, bool klass_change, bool try_for_exact); 1.96 1.97 @@ -880,6 +905,12 @@ 1.98 #ifndef PRODUCT 1.99 void dump_speculative(outputStream *st) const; 1.100 #endif 1.101 + // utility methods to work on the inline depth of the type 1.102 + int dual_inline_depth() const; 1.103 + int meet_inline_depth(int depth) const; 1.104 +#ifndef PRODUCT 1.105 + void dump_inline_depth(outputStream *st) const; 1.106 +#endif 1.107 1.108 // Do not allow interface-vs.-noninterface joins to collapse to top. 1.109 virtual const Type *filter_helper(const Type *kills, bool include_speculative) const; 1.110 @@ -910,7 +941,7 @@ 1.111 bool not_null_elements = false); 1.112 1.113 // Make a generic (unclassed) pointer to an oop. 1.114 - static const TypeOopPtr* make(PTR ptr, int offset, int instance_id, const TypeOopPtr* speculative); 1.115 + static const TypeOopPtr* make(PTR ptr, int offset, int instance_id, const TypeOopPtr* speculative = NULL, int inline_depth = InlineDepthBottom); 1.116 1.117 ciObject* const_oop() const { return _const_oop; } 1.118 virtual ciKlass* klass() const { return _klass; } 1.119 @@ -924,7 +955,7 @@ 1.120 bool is_known_instance() const { return _instance_id > 0; } 1.121 int instance_id() const { return _instance_id; } 1.122 bool is_known_instance_field() const { return is_known_instance() && _offset >= 0; } 1.123 - const TypeOopPtr* speculative() const { return _speculative; } 1.124 + virtual const TypeOopPtr* speculative() const { return _speculative; } 1.125 1.126 virtual intptr_t get_con() const; 1.127 1.128 @@ -957,18 +988,23 @@ 1.129 if (_speculative != NULL) { 1.130 const TypeOopPtr* speculative = _speculative->join(this)->is_oopptr(); 1.131 if (speculative->klass_is_exact()) { 1.132 - return speculative->klass(); 1.133 + return speculative->klass(); 1.134 } 1.135 } 1.136 return NULL; 1.137 } 1.138 + int inline_depth() const { 1.139 + return _inline_depth; 1.140 + } 1.141 + virtual const TypeOopPtr* with_inline_depth(int depth) const; 1.142 + virtual bool would_improve_type(ciKlass* exact_kls, int inline_depth) const; 1.143 }; 1.144 1.145 //------------------------------TypeInstPtr------------------------------------ 1.146 // Class of Java object pointers, pointing either to non-array Java instances 1.147 // or to a Klass* (including array klasses). 1.148 class TypeInstPtr : public TypeOopPtr { 1.149 - TypeInstPtr(PTR ptr, ciKlass* k, bool xk, ciObject* o, int offset, int instance_id, const TypeOopPtr* speculative); 1.150 + TypeInstPtr(PTR ptr, ciKlass* k, bool xk, ciObject* o, int offset, int instance_id, const TypeOopPtr* speculative, int inline_depth); 1.151 virtual bool eq( const Type *t ) const; 1.152 virtual int hash() const; // Type specific hashing 1.153 1.154 @@ -1004,7 +1040,7 @@ 1.155 } 1.156 1.157 // Make a pointer to an oop. 1.158 - static const TypeInstPtr *make(PTR ptr, ciKlass* k, bool xk, ciObject* o, int offset, int instance_id = InstanceBot, const TypeOopPtr* speculative = NULL); 1.159 + static const TypeInstPtr *make(PTR ptr, ciKlass* k, bool xk, ciObject* o, int offset, int instance_id = InstanceBot, const TypeOopPtr* speculative = NULL, int inline_depth = InlineDepthBottom); 1.160 1.161 /** Create constant type for a constant boxed value */ 1.162 const Type* get_const_boxed_value() const; 1.163 @@ -1023,6 +1059,7 @@ 1.164 virtual const TypePtr *add_offset( intptr_t offset ) const; 1.165 // Return same type without a speculative part 1.166 virtual const Type* remove_speculative() const; 1.167 + virtual const TypeOopPtr* with_inline_depth(int depth) const; 1.168 1.169 // the core of the computation of the meet of 2 types 1.170 virtual const Type *xmeet_helper(const Type *t) const; 1.171 @@ -1044,8 +1081,8 @@ 1.172 // Class of Java array pointers 1.173 class TypeAryPtr : public TypeOopPtr { 1.174 TypeAryPtr( PTR ptr, ciObject* o, const TypeAry *ary, ciKlass* k, bool xk, 1.175 - int offset, int instance_id, bool is_autobox_cache, const TypeOopPtr* speculative) 1.176 - : TypeOopPtr(AryPtr,ptr,k,xk,o,offset, instance_id, speculative), 1.177 + int offset, int instance_id, bool is_autobox_cache, const TypeOopPtr* speculative, int inline_depth) 1.178 + : TypeOopPtr(AryPtr,ptr,k,xk,o,offset, instance_id, speculative, inline_depth), 1.179 _ary(ary), 1.180 _is_autobox_cache(is_autobox_cache) 1.181 { 1.182 @@ -1083,9 +1120,9 @@ 1.183 1.184 bool is_autobox_cache() const { return _is_autobox_cache; } 1.185 1.186 - static const TypeAryPtr *make( PTR ptr, const TypeAry *ary, ciKlass* k, bool xk, int offset, int instance_id = InstanceBot, const TypeOopPtr* speculative = NULL); 1.187 + static const TypeAryPtr *make( PTR ptr, const TypeAry *ary, ciKlass* k, bool xk, int offset, int instance_id = InstanceBot, const TypeOopPtr* speculative = NULL, int inline_depth = InlineDepthBottom); 1.188 // Constant pointer to array 1.189 - static const TypeAryPtr *make( PTR ptr, ciObject* o, const TypeAry *ary, ciKlass* k, bool xk, int offset, int instance_id = InstanceBot, const TypeOopPtr* speculative = NULL, bool is_autobox_cache = false); 1.190 + static const TypeAryPtr *make( PTR ptr, ciObject* o, const TypeAry *ary, ciKlass* k, bool xk, int offset, int instance_id = InstanceBot, const TypeOopPtr* speculative = NULL, int inline_depth = InlineDepthBottom, bool is_autobox_cache= false); 1.191 1.192 // Return a 'ptr' version of this type 1.193 virtual const Type *cast_to_ptr_type(PTR ptr) const; 1.194 @@ -1101,6 +1138,7 @@ 1.195 virtual const TypePtr *add_offset( intptr_t offset ) const; 1.196 // Return same type without a speculative part 1.197 virtual const Type* remove_speculative() const; 1.198 + virtual const TypeOopPtr* with_inline_depth(int depth) const; 1.199 1.200 // the core of the computation of the meet of 2 types 1.201 virtual const Type *xmeet_helper(const Type *t) const; 1.202 @@ -1678,6 +1716,7 @@ 1.203 #define ConvL2X(x) (x) 1.204 #define ConvX2I(x) ConvL2I(x) 1.205 #define ConvX2L(x) (x) 1.206 +#define ConvX2UL(x) (x) 1.207 1.208 #else 1.209 1.210 @@ -1722,6 +1761,7 @@ 1.211 #define ConvL2X(x) ConvL2I(x) 1.212 #define ConvX2I(x) (x) 1.213 #define ConvX2L(x) ConvI2L(x) 1.214 +#define ConvX2UL(x) ConvI2UL(x) 1.215 1.216 #endif 1.217