Mercurial > hg > graal-compiler
annotate src/share/vm/opto/type.cpp @ 1751:2528b5bd749c
6980262: Memory leak when exception is thrown in static initializer
Summary: Use resource memory instead of c-heap for the exception message
Reviewed-by: phh, jmasa
author | kamg |
---|---|
date | Fri, 27 Aug 2010 15:05:28 -0400 |
parents | d678e3277048 |
children | 14b92b91f460 |
rev | line source |
---|---|
0 | 1 /* |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1340
diff
changeset
|
2 * Copyright (c) 1997, 2009, Oracle and/or its affiliates. All rights reserved. |
0 | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | |
5 * This code is free software; you can redistribute it and/or modify it | |
6 * under the terms of the GNU General Public License version 2 only, as | |
7 * published by the Free Software Foundation. | |
8 * | |
9 * This code is distributed in the hope that it will be useful, but WITHOUT | |
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
12 * version 2 for more details (a copy is included in the LICENSE file that | |
13 * accompanied this code). | |
14 * | |
15 * You should have received a copy of the GNU General Public License version | |
16 * 2 along with this work; if not, write to the Free Software Foundation, | |
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
18 * | |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1340
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1340
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1340
diff
changeset
|
21 * questions. |
0 | 22 * |
23 */ | |
24 | |
25 // Portions of code courtesy of Clifford Click | |
26 | |
27 // Optimization - Graph Style | |
28 | |
29 #include "incls/_precompiled.incl" | |
30 #include "incls/_type.cpp.incl" | |
31 | |
32 // Dictionary of types shared among compilations. | |
33 Dict* Type::_shared_type_dict = NULL; | |
34 | |
35 // Array which maps compiler types to Basic Types | |
36 const BasicType Type::_basic_type[Type::lastype] = { | |
37 T_ILLEGAL, // Bad | |
38 T_ILLEGAL, // Control | |
39 T_VOID, // Top | |
40 T_INT, // Int | |
41 T_LONG, // Long | |
42 T_VOID, // Half | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
43 T_NARROWOOP, // NarrowOop |
0 | 44 |
45 T_ILLEGAL, // Tuple | |
46 T_ARRAY, // Array | |
47 | |
48 T_ADDRESS, // AnyPtr // shows up in factory methods for NULL_PTR | |
49 T_ADDRESS, // RawPtr | |
50 T_OBJECT, // OopPtr | |
51 T_OBJECT, // InstPtr | |
52 T_OBJECT, // AryPtr | |
53 T_OBJECT, // KlassPtr | |
54 | |
55 T_OBJECT, // Function | |
56 T_ILLEGAL, // Abio | |
57 T_ADDRESS, // Return_Address | |
58 T_ILLEGAL, // Memory | |
59 T_FLOAT, // FloatTop | |
60 T_FLOAT, // FloatCon | |
61 T_FLOAT, // FloatBot | |
62 T_DOUBLE, // DoubleTop | |
63 T_DOUBLE, // DoubleCon | |
64 T_DOUBLE, // DoubleBot | |
65 T_ILLEGAL, // Bottom | |
66 }; | |
67 | |
68 // Map ideal registers (machine types) to ideal types | |
69 const Type *Type::mreg2type[_last_machine_leaf]; | |
70 | |
71 // Map basic types to canonical Type* pointers. | |
72 const Type* Type:: _const_basic_type[T_CONFLICT+1]; | |
73 | |
74 // Map basic types to constant-zero Types. | |
75 const Type* Type:: _zero_type[T_CONFLICT+1]; | |
76 | |
77 // Map basic types to array-body alias types. | |
78 const TypeAryPtr* TypeAryPtr::_array_body_type[T_CONFLICT+1]; | |
79 | |
80 //============================================================================= | |
81 // Convenience common pre-built types. | |
82 const Type *Type::ABIO; // State-of-machine only | |
83 const Type *Type::BOTTOM; // All values | |
84 const Type *Type::CONTROL; // Control only | |
85 const Type *Type::DOUBLE; // All doubles | |
86 const Type *Type::FLOAT; // All floats | |
87 const Type *Type::HALF; // Placeholder half of doublewide type | |
88 const Type *Type::MEMORY; // Abstract store only | |
89 const Type *Type::RETURN_ADDRESS; | |
90 const Type *Type::TOP; // No values in set | |
91 | |
92 //------------------------------get_const_type--------------------------- | |
93 const Type* Type::get_const_type(ciType* type) { | |
94 if (type == NULL) { | |
95 return NULL; | |
96 } else if (type->is_primitive_type()) { | |
97 return get_const_basic_type(type->basic_type()); | |
98 } else { | |
99 return TypeOopPtr::make_from_klass(type->as_klass()); | |
100 } | |
101 } | |
102 | |
103 //---------------------------array_element_basic_type--------------------------------- | |
104 // Mapping to the array element's basic type. | |
105 BasicType Type::array_element_basic_type() const { | |
106 BasicType bt = basic_type(); | |
107 if (bt == T_INT) { | |
108 if (this == TypeInt::INT) return T_INT; | |
109 if (this == TypeInt::CHAR) return T_CHAR; | |
110 if (this == TypeInt::BYTE) return T_BYTE; | |
111 if (this == TypeInt::BOOL) return T_BOOLEAN; | |
112 if (this == TypeInt::SHORT) return T_SHORT; | |
113 return T_VOID; | |
114 } | |
115 return bt; | |
116 } | |
117 | |
118 //---------------------------get_typeflow_type--------------------------------- | |
119 // Import a type produced by ciTypeFlow. | |
120 const Type* Type::get_typeflow_type(ciType* type) { | |
121 switch (type->basic_type()) { | |
122 | |
123 case ciTypeFlow::StateVector::T_BOTTOM: | |
124 assert(type == ciTypeFlow::StateVector::bottom_type(), ""); | |
125 return Type::BOTTOM; | |
126 | |
127 case ciTypeFlow::StateVector::T_TOP: | |
128 assert(type == ciTypeFlow::StateVector::top_type(), ""); | |
129 return Type::TOP; | |
130 | |
131 case ciTypeFlow::StateVector::T_NULL: | |
132 assert(type == ciTypeFlow::StateVector::null_type(), ""); | |
133 return TypePtr::NULL_PTR; | |
134 | |
135 case ciTypeFlow::StateVector::T_LONG2: | |
136 // The ciTypeFlow pass pushes a long, then the half. | |
137 // We do the same. | |
138 assert(type == ciTypeFlow::StateVector::long2_type(), ""); | |
139 return TypeInt::TOP; | |
140 | |
141 case ciTypeFlow::StateVector::T_DOUBLE2: | |
142 // The ciTypeFlow pass pushes double, then the half. | |
143 // Our convention is the same. | |
144 assert(type == ciTypeFlow::StateVector::double2_type(), ""); | |
145 return Type::TOP; | |
146 | |
147 case T_ADDRESS: | |
148 assert(type->is_return_address(), ""); | |
149 return TypeRawPtr::make((address)(intptr_t)type->as_return_address()->bci()); | |
150 | |
151 default: | |
152 // make sure we did not mix up the cases: | |
153 assert(type != ciTypeFlow::StateVector::bottom_type(), ""); | |
154 assert(type != ciTypeFlow::StateVector::top_type(), ""); | |
155 assert(type != ciTypeFlow::StateVector::null_type(), ""); | |
156 assert(type != ciTypeFlow::StateVector::long2_type(), ""); | |
157 assert(type != ciTypeFlow::StateVector::double2_type(), ""); | |
158 assert(!type->is_return_address(), ""); | |
159 | |
160 return Type::get_const_type(type); | |
161 } | |
162 } | |
163 | |
164 | |
165 //------------------------------make------------------------------------------- | |
166 // Create a simple Type, with default empty symbol sets. Then hashcons it | |
167 // and look for an existing copy in the type dictionary. | |
168 const Type *Type::make( enum TYPES t ) { | |
169 return (new Type(t))->hashcons(); | |
170 } | |
223 | 171 |
0 | 172 //------------------------------cmp-------------------------------------------- |
173 int Type::cmp( const Type *const t1, const Type *const t2 ) { | |
174 if( t1->_base != t2->_base ) | |
175 return 1; // Missed badly | |
176 assert(t1 != t2 || t1->eq(t2), "eq must be reflexive"); | |
177 return !t1->eq(t2); // Return ZERO if equal | |
178 } | |
179 | |
180 //------------------------------hash------------------------------------------- | |
181 int Type::uhash( const Type *const t ) { | |
182 return t->hash(); | |
183 } | |
184 | |
1620
d678e3277048
6964479: widen normalization of small int and long values should be symmetric
kvn
parents:
1552
diff
changeset
|
185 #define SMALLINT ((juint)3) // a value too insignificant to consider widening |
d678e3277048
6964479: widen normalization of small int and long values should be symmetric
kvn
parents:
1552
diff
changeset
|
186 |
0 | 187 //--------------------------Initialize_shared---------------------------------- |
188 void Type::Initialize_shared(Compile* current) { | |
189 // This method does not need to be locked because the first system | |
190 // compilations (stub compilations) occur serially. If they are | |
191 // changed to proceed in parallel, then this section will need | |
192 // locking. | |
193 | |
194 Arena* save = current->type_arena(); | |
195 Arena* shared_type_arena = new Arena(); | |
196 | |
197 current->set_type_arena(shared_type_arena); | |
198 _shared_type_dict = | |
199 new (shared_type_arena) Dict( (CmpKey)Type::cmp, (Hash)Type::uhash, | |
200 shared_type_arena, 128 ); | |
201 current->set_type_dict(_shared_type_dict); | |
202 | |
203 // Make shared pre-built types. | |
204 CONTROL = make(Control); // Control only | |
205 TOP = make(Top); // No values in set | |
206 MEMORY = make(Memory); // Abstract store only | |
207 ABIO = make(Abio); // State-of-machine only | |
208 RETURN_ADDRESS=make(Return_Address); | |
209 FLOAT = make(FloatBot); // All floats | |
210 DOUBLE = make(DoubleBot); // All doubles | |
211 BOTTOM = make(Bottom); // Everything | |
212 HALF = make(Half); // Placeholder half of doublewide type | |
213 | |
214 TypeF::ZERO = TypeF::make(0.0); // Float 0 (positive zero) | |
215 TypeF::ONE = TypeF::make(1.0); // Float 1 | |
216 | |
217 TypeD::ZERO = TypeD::make(0.0); // Double 0 (positive zero) | |
218 TypeD::ONE = TypeD::make(1.0); // Double 1 | |
219 | |
220 TypeInt::MINUS_1 = TypeInt::make(-1); // -1 | |
221 TypeInt::ZERO = TypeInt::make( 0); // 0 | |
222 TypeInt::ONE = TypeInt::make( 1); // 1 | |
223 TypeInt::BOOL = TypeInt::make(0,1, WidenMin); // 0 or 1, FALSE or TRUE. | |
224 TypeInt::CC = TypeInt::make(-1, 1, WidenMin); // -1, 0 or 1, condition codes | |
225 TypeInt::CC_LT = TypeInt::make(-1,-1, WidenMin); // == TypeInt::MINUS_1 | |
226 TypeInt::CC_GT = TypeInt::make( 1, 1, WidenMin); // == TypeInt::ONE | |
227 TypeInt::CC_EQ = TypeInt::make( 0, 0, WidenMin); // == TypeInt::ZERO | |
228 TypeInt::CC_LE = TypeInt::make(-1, 0, WidenMin); | |
229 TypeInt::CC_GE = TypeInt::make( 0, 1, WidenMin); // == TypeInt::BOOL | |
230 TypeInt::BYTE = TypeInt::make(-128,127, WidenMin); // Bytes | |
624 | 231 TypeInt::UBYTE = TypeInt::make(0, 255, WidenMin); // Unsigned Bytes |
0 | 232 TypeInt::CHAR = TypeInt::make(0,65535, WidenMin); // Java chars |
233 TypeInt::SHORT = TypeInt::make(-32768,32767, WidenMin); // Java shorts | |
234 TypeInt::POS = TypeInt::make(0,max_jint, WidenMin); // Non-neg values | |
235 TypeInt::POS1 = TypeInt::make(1,max_jint, WidenMin); // Positive values | |
236 TypeInt::INT = TypeInt::make(min_jint,max_jint, WidenMax); // 32-bit integers | |
237 TypeInt::SYMINT = TypeInt::make(-max_jint,max_jint,WidenMin); // symmetric range | |
238 // CmpL is overloaded both as the bytecode computation returning | |
239 // a trinary (-1,0,+1) integer result AND as an efficient long | |
240 // compare returning optimizer ideal-type flags. | |
241 assert( TypeInt::CC_LT == TypeInt::MINUS_1, "types must match for CmpL to work" ); | |
242 assert( TypeInt::CC_GT == TypeInt::ONE, "types must match for CmpL to work" ); | |
243 assert( TypeInt::CC_EQ == TypeInt::ZERO, "types must match for CmpL to work" ); | |
244 assert( TypeInt::CC_GE == TypeInt::BOOL, "types must match for CmpL to work" ); | |
1620
d678e3277048
6964479: widen normalization of small int and long values should be symmetric
kvn
parents:
1552
diff
changeset
|
245 assert( (juint)(TypeInt::CC->_hi - TypeInt::CC->_lo) <= SMALLINT, "CC is truly small"); |
0 | 246 |
247 TypeLong::MINUS_1 = TypeLong::make(-1); // -1 | |
248 TypeLong::ZERO = TypeLong::make( 0); // 0 | |
249 TypeLong::ONE = TypeLong::make( 1); // 1 | |
250 TypeLong::POS = TypeLong::make(0,max_jlong, WidenMin); // Non-neg values | |
251 TypeLong::LONG = TypeLong::make(min_jlong,max_jlong,WidenMax); // 64-bit integers | |
252 TypeLong::INT = TypeLong::make((jlong)min_jint,(jlong)max_jint,WidenMin); | |
253 TypeLong::UINT = TypeLong::make(0,(jlong)max_juint,WidenMin); | |
254 | |
255 const Type **fboth =(const Type**)shared_type_arena->Amalloc_4(2*sizeof(Type*)); | |
256 fboth[0] = Type::CONTROL; | |
257 fboth[1] = Type::CONTROL; | |
258 TypeTuple::IFBOTH = TypeTuple::make( 2, fboth ); | |
259 | |
260 const Type **ffalse =(const Type**)shared_type_arena->Amalloc_4(2*sizeof(Type*)); | |
261 ffalse[0] = Type::CONTROL; | |
262 ffalse[1] = Type::TOP; | |
263 TypeTuple::IFFALSE = TypeTuple::make( 2, ffalse ); | |
264 | |
265 const Type **fneither =(const Type**)shared_type_arena->Amalloc_4(2*sizeof(Type*)); | |
266 fneither[0] = Type::TOP; | |
267 fneither[1] = Type::TOP; | |
268 TypeTuple::IFNEITHER = TypeTuple::make( 2, fneither ); | |
269 | |
270 const Type **ftrue =(const Type**)shared_type_arena->Amalloc_4(2*sizeof(Type*)); | |
271 ftrue[0] = Type::TOP; | |
272 ftrue[1] = Type::CONTROL; | |
273 TypeTuple::IFTRUE = TypeTuple::make( 2, ftrue ); | |
274 | |
275 const Type **floop =(const Type**)shared_type_arena->Amalloc_4(2*sizeof(Type*)); | |
276 floop[0] = Type::CONTROL; | |
277 floop[1] = TypeInt::INT; | |
278 TypeTuple::LOOPBODY = TypeTuple::make( 2, floop ); | |
279 | |
280 TypePtr::NULL_PTR= TypePtr::make( AnyPtr, TypePtr::Null, 0 ); | |
281 TypePtr::NOTNULL = TypePtr::make( AnyPtr, TypePtr::NotNull, OffsetBot ); | |
282 TypePtr::BOTTOM = TypePtr::make( AnyPtr, TypePtr::BotPTR, OffsetBot ); | |
283 | |
284 TypeRawPtr::BOTTOM = TypeRawPtr::make( TypePtr::BotPTR ); | |
285 TypeRawPtr::NOTNULL= TypeRawPtr::make( TypePtr::NotNull ); | |
286 | |
287 const Type **fmembar = TypeTuple::fields(0); | |
288 TypeTuple::MEMBAR = TypeTuple::make(TypeFunc::Parms+0, fmembar); | |
289 | |
290 const Type **fsc = (const Type**)shared_type_arena->Amalloc_4(2*sizeof(Type*)); | |
291 fsc[0] = TypeInt::CC; | |
292 fsc[1] = Type::MEMORY; | |
293 TypeTuple::STORECONDITIONAL = TypeTuple::make(2, fsc); | |
294 | |
295 TypeInstPtr::NOTNULL = TypeInstPtr::make(TypePtr::NotNull, current->env()->Object_klass()); | |
296 TypeInstPtr::BOTTOM = TypeInstPtr::make(TypePtr::BotPTR, current->env()->Object_klass()); | |
297 TypeInstPtr::MIRROR = TypeInstPtr::make(TypePtr::NotNull, current->env()->Class_klass()); | |
298 TypeInstPtr::MARK = TypeInstPtr::make(TypePtr::BotPTR, current->env()->Object_klass(), | |
299 false, 0, oopDesc::mark_offset_in_bytes()); | |
300 TypeInstPtr::KLASS = TypeInstPtr::make(TypePtr::BotPTR, current->env()->Object_klass(), | |
301 false, 0, oopDesc::klass_offset_in_bytes()); | |
992 | 302 TypeOopPtr::BOTTOM = TypeOopPtr::make(TypePtr::BotPTR, OffsetBot, TypeOopPtr::InstanceBot); |
0 | 303 |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
304 TypeNarrowOop::NULL_PTR = TypeNarrowOop::make( TypePtr::NULL_PTR ); |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
305 TypeNarrowOop::BOTTOM = TypeNarrowOop::make( TypeInstPtr::BOTTOM ); |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
306 |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
307 mreg2type[Op_Node] = Type::BOTTOM; |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
308 mreg2type[Op_Set ] = 0; |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
309 mreg2type[Op_RegN] = TypeNarrowOop::BOTTOM; |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
310 mreg2type[Op_RegI] = TypeInt::INT; |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
311 mreg2type[Op_RegP] = TypePtr::BOTTOM; |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
312 mreg2type[Op_RegF] = Type::FLOAT; |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
313 mreg2type[Op_RegD] = Type::DOUBLE; |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
314 mreg2type[Op_RegL] = TypeLong::LONG; |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
315 mreg2type[Op_RegFlags] = TypeInt::CC; |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
316 |
0 | 317 TypeAryPtr::RANGE = TypeAryPtr::make( TypePtr::BotPTR, TypeAry::make(Type::BOTTOM,TypeInt::POS), current->env()->Object_klass(), false, arrayOopDesc::length_offset_in_bytes()); |
163 | 318 |
319 TypeAryPtr::NARROWOOPS = TypeAryPtr::make(TypePtr::BotPTR, TypeAry::make(TypeNarrowOop::BOTTOM, TypeInt::POS), NULL /*ciArrayKlass::make(o)*/, false, Type::OffsetBot); | |
320 | |
321 #ifdef _LP64 | |
322 if (UseCompressedOops) { | |
323 TypeAryPtr::OOPS = TypeAryPtr::NARROWOOPS; | |
324 } else | |
325 #endif | |
326 { | |
327 // There is no shared klass for Object[]. See note in TypeAryPtr::klass(). | |
328 TypeAryPtr::OOPS = TypeAryPtr::make(TypePtr::BotPTR, TypeAry::make(TypeInstPtr::BOTTOM,TypeInt::POS), NULL /*ciArrayKlass::make(o)*/, false, Type::OffsetBot); | |
329 } | |
0 | 330 TypeAryPtr::BYTES = TypeAryPtr::make(TypePtr::BotPTR, TypeAry::make(TypeInt::BYTE ,TypeInt::POS), ciTypeArrayKlass::make(T_BYTE), true, Type::OffsetBot); |
331 TypeAryPtr::SHORTS = TypeAryPtr::make(TypePtr::BotPTR, TypeAry::make(TypeInt::SHORT ,TypeInt::POS), ciTypeArrayKlass::make(T_SHORT), true, Type::OffsetBot); | |
332 TypeAryPtr::CHARS = TypeAryPtr::make(TypePtr::BotPTR, TypeAry::make(TypeInt::CHAR ,TypeInt::POS), ciTypeArrayKlass::make(T_CHAR), true, Type::OffsetBot); | |
333 TypeAryPtr::INTS = TypeAryPtr::make(TypePtr::BotPTR, TypeAry::make(TypeInt::INT ,TypeInt::POS), ciTypeArrayKlass::make(T_INT), true, Type::OffsetBot); | |
334 TypeAryPtr::LONGS = TypeAryPtr::make(TypePtr::BotPTR, TypeAry::make(TypeLong::LONG ,TypeInt::POS), ciTypeArrayKlass::make(T_LONG), true, Type::OffsetBot); | |
335 TypeAryPtr::FLOATS = TypeAryPtr::make(TypePtr::BotPTR, TypeAry::make(Type::FLOAT ,TypeInt::POS), ciTypeArrayKlass::make(T_FLOAT), true, Type::OffsetBot); | |
336 TypeAryPtr::DOUBLES = TypeAryPtr::make(TypePtr::BotPTR, TypeAry::make(Type::DOUBLE ,TypeInt::POS), ciTypeArrayKlass::make(T_DOUBLE), true, Type::OffsetBot); | |
337 | |
163 | 338 // Nobody should ask _array_body_type[T_NARROWOOP]. Use NULL as assert. |
339 TypeAryPtr::_array_body_type[T_NARROWOOP] = NULL; | |
0 | 340 TypeAryPtr::_array_body_type[T_OBJECT] = TypeAryPtr::OOPS; |
163 | 341 TypeAryPtr::_array_body_type[T_ARRAY] = TypeAryPtr::OOPS; // arrays are stored in oop arrays |
0 | 342 TypeAryPtr::_array_body_type[T_BYTE] = TypeAryPtr::BYTES; |
343 TypeAryPtr::_array_body_type[T_BOOLEAN] = TypeAryPtr::BYTES; // boolean[] is a byte array | |
344 TypeAryPtr::_array_body_type[T_SHORT] = TypeAryPtr::SHORTS; | |
345 TypeAryPtr::_array_body_type[T_CHAR] = TypeAryPtr::CHARS; | |
346 TypeAryPtr::_array_body_type[T_INT] = TypeAryPtr::INTS; | |
347 TypeAryPtr::_array_body_type[T_LONG] = TypeAryPtr::LONGS; | |
348 TypeAryPtr::_array_body_type[T_FLOAT] = TypeAryPtr::FLOATS; | |
349 TypeAryPtr::_array_body_type[T_DOUBLE] = TypeAryPtr::DOUBLES; | |
350 | |
351 TypeKlassPtr::OBJECT = TypeKlassPtr::make( TypePtr::NotNull, current->env()->Object_klass(), 0 ); | |
352 TypeKlassPtr::OBJECT_OR_NULL = TypeKlassPtr::make( TypePtr::BotPTR, current->env()->Object_klass(), 0 ); | |
353 | |
354 const Type **fi2c = TypeTuple::fields(2); | |
355 fi2c[TypeFunc::Parms+0] = TypeInstPtr::BOTTOM; // methodOop | |
356 fi2c[TypeFunc::Parms+1] = TypeRawPtr::BOTTOM; // argument pointer | |
357 TypeTuple::START_I2C = TypeTuple::make(TypeFunc::Parms+2, fi2c); | |
358 | |
359 const Type **intpair = TypeTuple::fields(2); | |
360 intpair[0] = TypeInt::INT; | |
361 intpair[1] = TypeInt::INT; | |
362 TypeTuple::INT_PAIR = TypeTuple::make(2, intpair); | |
363 | |
364 const Type **longpair = TypeTuple::fields(2); | |
365 longpair[0] = TypeLong::LONG; | |
366 longpair[1] = TypeLong::LONG; | |
367 TypeTuple::LONG_PAIR = TypeTuple::make(2, longpair); | |
368 | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
369 _const_basic_type[T_NARROWOOP] = TypeNarrowOop::BOTTOM; |
0 | 370 _const_basic_type[T_BOOLEAN] = TypeInt::BOOL; |
371 _const_basic_type[T_CHAR] = TypeInt::CHAR; | |
372 _const_basic_type[T_BYTE] = TypeInt::BYTE; | |
373 _const_basic_type[T_SHORT] = TypeInt::SHORT; | |
374 _const_basic_type[T_INT] = TypeInt::INT; | |
375 _const_basic_type[T_LONG] = TypeLong::LONG; | |
376 _const_basic_type[T_FLOAT] = Type::FLOAT; | |
377 _const_basic_type[T_DOUBLE] = Type::DOUBLE; | |
378 _const_basic_type[T_OBJECT] = TypeInstPtr::BOTTOM; | |
379 _const_basic_type[T_ARRAY] = TypeInstPtr::BOTTOM; // there is no separate bottom for arrays | |
380 _const_basic_type[T_VOID] = TypePtr::NULL_PTR; // reflection represents void this way | |
381 _const_basic_type[T_ADDRESS] = TypeRawPtr::BOTTOM; // both interpreter return addresses & random raw ptrs | |
382 _const_basic_type[T_CONFLICT]= Type::BOTTOM; // why not? | |
383 | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
384 _zero_type[T_NARROWOOP] = TypeNarrowOop::NULL_PTR; |
0 | 385 _zero_type[T_BOOLEAN] = TypeInt::ZERO; // false == 0 |
386 _zero_type[T_CHAR] = TypeInt::ZERO; // '\0' == 0 | |
387 _zero_type[T_BYTE] = TypeInt::ZERO; // 0x00 == 0 | |
388 _zero_type[T_SHORT] = TypeInt::ZERO; // 0x0000 == 0 | |
389 _zero_type[T_INT] = TypeInt::ZERO; | |
390 _zero_type[T_LONG] = TypeLong::ZERO; | |
391 _zero_type[T_FLOAT] = TypeF::ZERO; | |
392 _zero_type[T_DOUBLE] = TypeD::ZERO; | |
393 _zero_type[T_OBJECT] = TypePtr::NULL_PTR; | |
394 _zero_type[T_ARRAY] = TypePtr::NULL_PTR; // null array is null oop | |
395 _zero_type[T_ADDRESS] = TypePtr::NULL_PTR; // raw pointers use the same null | |
396 _zero_type[T_VOID] = Type::TOP; // the only void value is no value at all | |
397 | |
398 // get_zero_type() should not happen for T_CONFLICT | |
399 _zero_type[T_CONFLICT]= NULL; | |
400 | |
401 // Restore working type arena. | |
402 current->set_type_arena(save); | |
403 current->set_type_dict(NULL); | |
404 } | |
405 | |
406 //------------------------------Initialize------------------------------------- | |
407 void Type::Initialize(Compile* current) { | |
408 assert(current->type_arena() != NULL, "must have created type arena"); | |
409 | |
410 if (_shared_type_dict == NULL) { | |
411 Initialize_shared(current); | |
412 } | |
413 | |
414 Arena* type_arena = current->type_arena(); | |
415 | |
416 // Create the hash-cons'ing dictionary with top-level storage allocation | |
417 Dict *tdic = new (type_arena) Dict( (CmpKey)Type::cmp,(Hash)Type::uhash, type_arena, 128 ); | |
418 current->set_type_dict(tdic); | |
419 | |
420 // Transfer the shared types. | |
421 DictI i(_shared_type_dict); | |
422 for( ; i.test(); ++i ) { | |
423 Type* t = (Type*)i._value; | |
424 tdic->Insert(t,t); // New Type, insert into Type table | |
425 } | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
426 |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
427 #ifdef ASSERT |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
428 verify_lastype(); |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
429 #endif |
0 | 430 } |
431 | |
432 //------------------------------hashcons--------------------------------------- | |
433 // Do the hash-cons trick. If the Type already exists in the type table, | |
434 // delete the current Type and return the existing Type. Otherwise stick the | |
435 // current Type in the Type table. | |
436 const Type *Type::hashcons(void) { | |
437 debug_only(base()); // Check the assertion in Type::base(). | |
438 // Look up the Type in the Type dictionary | |
439 Dict *tdic = type_dict(); | |
440 Type* old = (Type*)(tdic->Insert(this, this, false)); | |
441 if( old ) { // Pre-existing Type? | |
442 if( old != this ) // Yes, this guy is not the pre-existing? | |
443 delete this; // Yes, Nuke this guy | |
444 assert( old->_dual, "" ); | |
445 return old; // Return pre-existing | |
446 } | |
447 | |
448 // Every type has a dual (to make my lattice symmetric). | |
449 // Since we just discovered a new Type, compute its dual right now. | |
450 assert( !_dual, "" ); // No dual yet | |
451 _dual = xdual(); // Compute the dual | |
452 if( cmp(this,_dual)==0 ) { // Handle self-symmetric | |
453 _dual = this; | |
454 return this; | |
455 } | |
456 assert( !_dual->_dual, "" ); // No reverse dual yet | |
457 assert( !(*tdic)[_dual], "" ); // Dual not in type system either | |
458 // New Type, insert into Type table | |
459 tdic->Insert((void*)_dual,(void*)_dual); | |
460 ((Type*)_dual)->_dual = this; // Finish up being symmetric | |
461 #ifdef ASSERT | |
462 Type *dual_dual = (Type*)_dual->xdual(); | |
463 assert( eq(dual_dual), "xdual(xdual()) should be identity" ); | |
464 delete dual_dual; | |
465 #endif | |
466 return this; // Return new Type | |
467 } | |
468 | |
469 //------------------------------eq--------------------------------------------- | |
470 // Structural equality check for Type representations | |
471 bool Type::eq( const Type * ) const { | |
472 return true; // Nothing else can go wrong | |
473 } | |
474 | |
475 //------------------------------hash------------------------------------------- | |
476 // Type-specific hashing function. | |
477 int Type::hash(void) const { | |
478 return _base; | |
479 } | |
480 | |
481 //------------------------------is_finite-------------------------------------- | |
482 // Has a finite value | |
483 bool Type::is_finite() const { | |
484 return false; | |
485 } | |
486 | |
487 //------------------------------is_nan----------------------------------------- | |
488 // Is not a number (NaN) | |
489 bool Type::is_nan() const { | |
490 return false; | |
491 } | |
492 | |
820
915cc9c5ebc6
6837094: False positive for "meet not symmetric" failure
kvn
parents:
628
diff
changeset
|
493 //----------------------interface_vs_oop--------------------------------------- |
915cc9c5ebc6
6837094: False positive for "meet not symmetric" failure
kvn
parents:
628
diff
changeset
|
494 #ifdef ASSERT |
915cc9c5ebc6
6837094: False positive for "meet not symmetric" failure
kvn
parents:
628
diff
changeset
|
495 bool Type::interface_vs_oop(const Type *t) const { |
915cc9c5ebc6
6837094: False positive for "meet not symmetric" failure
kvn
parents:
628
diff
changeset
|
496 bool result = false; |
915cc9c5ebc6
6837094: False positive for "meet not symmetric" failure
kvn
parents:
628
diff
changeset
|
497 |
992 | 498 const TypePtr* this_ptr = this->make_ptr(); // In case it is narrow_oop |
499 const TypePtr* t_ptr = t->make_ptr(); | |
500 if( this_ptr == NULL || t_ptr == NULL ) | |
501 return result; | |
502 | |
503 const TypeInstPtr* this_inst = this_ptr->isa_instptr(); | |
504 const TypeInstPtr* t_inst = t_ptr->isa_instptr(); | |
820
915cc9c5ebc6
6837094: False positive for "meet not symmetric" failure
kvn
parents:
628
diff
changeset
|
505 if( this_inst && this_inst->is_loaded() && t_inst && t_inst->is_loaded() ) { |
915cc9c5ebc6
6837094: False positive for "meet not symmetric" failure
kvn
parents:
628
diff
changeset
|
506 bool this_interface = this_inst->klass()->is_interface(); |
915cc9c5ebc6
6837094: False positive for "meet not symmetric" failure
kvn
parents:
628
diff
changeset
|
507 bool t_interface = t_inst->klass()->is_interface(); |
915cc9c5ebc6
6837094: False positive for "meet not symmetric" failure
kvn
parents:
628
diff
changeset
|
508 result = this_interface ^ t_interface; |
915cc9c5ebc6
6837094: False positive for "meet not symmetric" failure
kvn
parents:
628
diff
changeset
|
509 } |
915cc9c5ebc6
6837094: False positive for "meet not symmetric" failure
kvn
parents:
628
diff
changeset
|
510 |
915cc9c5ebc6
6837094: False positive for "meet not symmetric" failure
kvn
parents:
628
diff
changeset
|
511 return result; |
915cc9c5ebc6
6837094: False positive for "meet not symmetric" failure
kvn
parents:
628
diff
changeset
|
512 } |
915cc9c5ebc6
6837094: False positive for "meet not symmetric" failure
kvn
parents:
628
diff
changeset
|
513 #endif |
915cc9c5ebc6
6837094: False positive for "meet not symmetric" failure
kvn
parents:
628
diff
changeset
|
514 |
0 | 515 //------------------------------meet------------------------------------------- |
516 // Compute the MEET of two types. NOT virtual. It enforces that meet is | |
517 // commutative and the lattice is symmetric. | |
518 const Type *Type::meet( const Type *t ) const { | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
519 if (isa_narrowoop() && t->isa_narrowoop()) { |
221
1e026f8da827
6710487: More than half of JDI Regression tests hang with COOPs in -Xcomp mode
kvn
parents:
183
diff
changeset
|
520 const Type* result = make_ptr()->meet(t->make_ptr()); |
1e026f8da827
6710487: More than half of JDI Regression tests hang with COOPs in -Xcomp mode
kvn
parents:
183
diff
changeset
|
521 return result->make_narrowoop(); |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
522 } |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
523 |
0 | 524 const Type *mt = xmeet(t); |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
525 if (isa_narrowoop() || t->isa_narrowoop()) return mt; |
0 | 526 #ifdef ASSERT |
527 assert( mt == t->xmeet(this), "meet not commutative" ); | |
528 const Type* dual_join = mt->_dual; | |
529 const Type *t2t = dual_join->xmeet(t->_dual); | |
530 const Type *t2this = dual_join->xmeet( _dual); | |
531 | |
532 // Interface meet Oop is Not Symmetric: | |
533 // Interface:AnyNull meet Oop:AnyNull == Interface:AnyNull | |
534 // Interface:NotNull meet Oop:NotNull == java/lang/Object:NotNull | |
820
915cc9c5ebc6
6837094: False positive for "meet not symmetric" failure
kvn
parents:
628
diff
changeset
|
535 |
915cc9c5ebc6
6837094: False positive for "meet not symmetric" failure
kvn
parents:
628
diff
changeset
|
536 if( !interface_vs_oop(t) && (t2t != t->_dual || t2this != _dual) ) { |
0 | 537 tty->print_cr("=== Meet Not Symmetric ==="); |
538 tty->print("t = "); t->dump(); tty->cr(); | |
539 tty->print("this= "); dump(); tty->cr(); | |
540 tty->print("mt=(t meet this)= "); mt->dump(); tty->cr(); | |
541 | |
542 tty->print("t_dual= "); t->_dual->dump(); tty->cr(); | |
543 tty->print("this_dual= "); _dual->dump(); tty->cr(); | |
544 tty->print("mt_dual= "); mt->_dual->dump(); tty->cr(); | |
545 | |
546 tty->print("mt_dual meet t_dual= "); t2t ->dump(); tty->cr(); | |
547 tty->print("mt_dual meet this_dual= "); t2this ->dump(); tty->cr(); | |
548 | |
549 fatal("meet not symmetric" ); | |
550 } | |
551 #endif | |
552 return mt; | |
553 } | |
554 | |
555 //------------------------------xmeet------------------------------------------ | |
556 // Compute the MEET of two types. It returns a new Type object. | |
557 const Type *Type::xmeet( const Type *t ) const { | |
558 // Perform a fast test for common case; meeting the same types together. | |
559 if( this == t ) return this; // Meeting same type-rep? | |
560 | |
561 // Meeting TOP with anything? | |
562 if( _base == Top ) return t; | |
563 | |
564 // Meeting BOTTOM with anything? | |
565 if( _base == Bottom ) return BOTTOM; | |
566 | |
567 // Current "this->_base" is one of: Bad, Multi, Control, Top, | |
568 // Abio, Abstore, Floatxxx, Doublexxx, Bottom, lastype. | |
569 switch (t->base()) { // Switch on original type | |
570 | |
571 // Cut in half the number of cases I must handle. Only need cases for when | |
572 // the given enum "t->type" is less than or equal to the local enum "type". | |
573 case FloatCon: | |
574 case DoubleCon: | |
575 case Int: | |
576 case Long: | |
577 return t->xmeet(this); | |
578 | |
579 case OopPtr: | |
580 return t->xmeet(this); | |
581 | |
582 case InstPtr: | |
583 return t->xmeet(this); | |
584 | |
585 case KlassPtr: | |
586 return t->xmeet(this); | |
587 | |
588 case AryPtr: | |
589 return t->xmeet(this); | |
590 | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
591 case NarrowOop: |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
592 return t->xmeet(this); |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
593 |
0 | 594 case Bad: // Type check |
595 default: // Bogus type not in lattice | |
596 typerr(t); | |
597 return Type::BOTTOM; | |
598 | |
599 case Bottom: // Ye Olde Default | |
600 return t; | |
601 | |
602 case FloatTop: | |
603 if( _base == FloatTop ) return this; | |
604 case FloatBot: // Float | |
605 if( _base == FloatBot || _base == FloatTop ) return FLOAT; | |
606 if( _base == DoubleTop || _base == DoubleBot ) return Type::BOTTOM; | |
607 typerr(t); | |
608 return Type::BOTTOM; | |
609 | |
610 case DoubleTop: | |
611 if( _base == DoubleTop ) return this; | |
612 case DoubleBot: // Double | |
613 if( _base == DoubleBot || _base == DoubleTop ) return DOUBLE; | |
614 if( _base == FloatTop || _base == FloatBot ) return Type::BOTTOM; | |
615 typerr(t); | |
616 return Type::BOTTOM; | |
617 | |
618 // These next few cases must match exactly or it is a compile-time error. | |
619 case Control: // Control of code | |
620 case Abio: // State of world outside of program | |
621 case Memory: | |
622 if( _base == t->_base ) return this; | |
623 typerr(t); | |
624 return Type::BOTTOM; | |
625 | |
626 case Top: // Top of the lattice | |
627 return this; | |
628 } | |
629 | |
630 // The type is unchanged | |
631 return this; | |
632 } | |
633 | |
634 //-----------------------------filter------------------------------------------ | |
635 const Type *Type::filter( const Type *kills ) const { | |
636 const Type* ft = join(kills); | |
637 if (ft->empty()) | |
638 return Type::TOP; // Canonical empty value | |
639 return ft; | |
640 } | |
641 | |
642 //------------------------------xdual------------------------------------------ | |
643 // Compute dual right now. | |
644 const Type::TYPES Type::dual_type[Type::lastype] = { | |
645 Bad, // Bad | |
646 Control, // Control | |
647 Bottom, // Top | |
648 Bad, // Int - handled in v-call | |
649 Bad, // Long - handled in v-call | |
650 Half, // Half | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
651 Bad, // NarrowOop - handled in v-call |
0 | 652 |
653 Bad, // Tuple - handled in v-call | |
654 Bad, // Array - handled in v-call | |
655 | |
656 Bad, // AnyPtr - handled in v-call | |
657 Bad, // RawPtr - handled in v-call | |
658 Bad, // OopPtr - handled in v-call | |
659 Bad, // InstPtr - handled in v-call | |
660 Bad, // AryPtr - handled in v-call | |
661 Bad, // KlassPtr - handled in v-call | |
662 | |
663 Bad, // Function - handled in v-call | |
664 Abio, // Abio | |
665 Return_Address,// Return_Address | |
666 Memory, // Memory | |
667 FloatBot, // FloatTop | |
668 FloatCon, // FloatCon | |
669 FloatTop, // FloatBot | |
670 DoubleBot, // DoubleTop | |
671 DoubleCon, // DoubleCon | |
672 DoubleTop, // DoubleBot | |
673 Top // Bottom | |
674 }; | |
675 | |
676 const Type *Type::xdual() const { | |
677 // Note: the base() accessor asserts the sanity of _base. | |
678 assert(dual_type[base()] != Bad, "implement with v-call"); | |
679 return new Type(dual_type[_base]); | |
680 } | |
681 | |
682 //------------------------------has_memory------------------------------------- | |
683 bool Type::has_memory() const { | |
684 Type::TYPES tx = base(); | |
685 if (tx == Memory) return true; | |
686 if (tx == Tuple) { | |
687 const TypeTuple *t = is_tuple(); | |
688 for (uint i=0; i < t->cnt(); i++) { | |
689 tx = t->field_at(i)->base(); | |
690 if (tx == Memory) return true; | |
691 } | |
692 } | |
693 return false; | |
694 } | |
695 | |
696 #ifndef PRODUCT | |
697 //------------------------------dump2------------------------------------------ | |
698 void Type::dump2( Dict &d, uint depth, outputStream *st ) const { | |
699 st->print(msg[_base]); | |
700 } | |
701 | |
702 //------------------------------dump------------------------------------------- | |
703 void Type::dump_on(outputStream *st) const { | |
704 ResourceMark rm; | |
705 Dict d(cmpkey,hashkey); // Stop recursive type dumping | |
706 dump2(d,1, st); | |
163 | 707 if (is_ptr_to_narrowoop()) { |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
708 st->print(" [narrow]"); |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
709 } |
0 | 710 } |
711 | |
712 //------------------------------data------------------------------------------- | |
713 const char * const Type::msg[Type::lastype] = { | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
714 "bad","control","top","int:","long:","half", "narrowoop:", |
0 | 715 "tuple:", "aryptr", |
716 "anyptr:", "rawptr:", "java:", "inst:", "ary:", "klass:", | |
717 "func", "abIO", "return_address", "memory", | |
718 "float_top", "ftcon:", "float", | |
719 "double_top", "dblcon:", "double", | |
720 "bottom" | |
721 }; | |
722 #endif | |
723 | |
724 //------------------------------singleton-------------------------------------- | |
725 // TRUE if Type is a singleton type, FALSE otherwise. Singletons are simple | |
726 // constants (Ldi nodes). Singletons are integer, float or double constants. | |
727 bool Type::singleton(void) const { | |
728 return _base == Top || _base == Half; | |
729 } | |
730 | |
731 //------------------------------empty------------------------------------------ | |
732 // TRUE if Type is a type with no values, FALSE otherwise. | |
733 bool Type::empty(void) const { | |
734 switch (_base) { | |
735 case DoubleTop: | |
736 case FloatTop: | |
737 case Top: | |
738 return true; | |
739 | |
740 case Half: | |
741 case Abio: | |
742 case Return_Address: | |
743 case Memory: | |
744 case Bottom: | |
745 case FloatBot: | |
746 case DoubleBot: | |
747 return false; // never a singleton, therefore never empty | |
748 } | |
749 | |
750 ShouldNotReachHere(); | |
751 return false; | |
752 } | |
753 | |
754 //------------------------------dump_stats------------------------------------- | |
755 // Dump collected statistics to stderr | |
756 #ifndef PRODUCT | |
757 void Type::dump_stats() { | |
758 tty->print("Types made: %d\n", type_dict()->Size()); | |
759 } | |
760 #endif | |
761 | |
762 //------------------------------typerr----------------------------------------- | |
763 void Type::typerr( const Type *t ) const { | |
764 #ifndef PRODUCT | |
765 tty->print("\nError mixing types: "); | |
766 dump(); | |
767 tty->print(" and "); | |
768 t->dump(); | |
769 tty->print("\n"); | |
770 #endif | |
771 ShouldNotReachHere(); | |
772 } | |
773 | |
774 //------------------------------isa_oop_ptr------------------------------------ | |
775 // Return true if type is an oop pointer type. False for raw pointers. | |
776 static char isa_oop_ptr_tbl[Type::lastype] = { | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
777 0,0,0,0,0,0,0/*narrowoop*/,0/*tuple*/, 0/*ary*/, |
0 | 778 0/*anyptr*/,0/*rawptr*/,1/*OopPtr*/,1/*InstPtr*/,1/*AryPtr*/,1/*KlassPtr*/, |
779 0/*func*/,0,0/*return_address*/,0, | |
780 /*floats*/0,0,0, /*doubles*/0,0,0, | |
781 0 | |
782 }; | |
783 bool Type::isa_oop_ptr() const { | |
784 return isa_oop_ptr_tbl[_base] != 0; | |
785 } | |
786 | |
787 //------------------------------dump_stats------------------------------------- | |
788 // // Check that arrays match type enum | |
789 #ifndef PRODUCT | |
790 void Type::verify_lastype() { | |
791 // Check that arrays match enumeration | |
792 assert( Type::dual_type [Type::lastype - 1] == Type::Top, "did not update array"); | |
793 assert( strcmp(Type::msg [Type::lastype - 1],"bottom") == 0, "did not update array"); | |
794 // assert( PhiNode::tbl [Type::lastype - 1] == NULL, "did not update array"); | |
795 assert( Matcher::base2reg[Type::lastype - 1] == 0, "did not update array"); | |
796 assert( isa_oop_ptr_tbl [Type::lastype - 1] == (char)0, "did not update array"); | |
797 } | |
798 #endif | |
799 | |
800 //============================================================================= | |
801 // Convenience common pre-built types. | |
802 const TypeF *TypeF::ZERO; // Floating point zero | |
803 const TypeF *TypeF::ONE; // Floating point one | |
804 | |
805 //------------------------------make------------------------------------------- | |
806 // Create a float constant | |
807 const TypeF *TypeF::make(float f) { | |
808 return (TypeF*)(new TypeF(f))->hashcons(); | |
809 } | |
810 | |
811 //------------------------------meet------------------------------------------- | |
812 // Compute the MEET of two types. It returns a new Type object. | |
813 const Type *TypeF::xmeet( const Type *t ) const { | |
814 // Perform a fast test for common case; meeting the same types together. | |
815 if( this == t ) return this; // Meeting same type-rep? | |
816 | |
817 // Current "this->_base" is FloatCon | |
818 switch (t->base()) { // Switch on original type | |
819 case AnyPtr: // Mixing with oops happens when javac | |
820 case RawPtr: // reuses local variables | |
821 case OopPtr: | |
822 case InstPtr: | |
823 case KlassPtr: | |
824 case AryPtr: | |
293
c3e045194476
6731641: assert(m->adr_type() == mach->adr_type(),"matcher should not change adr type")
kvn
parents:
247
diff
changeset
|
825 case NarrowOop: |
0 | 826 case Int: |
827 case Long: | |
828 case DoubleTop: | |
829 case DoubleCon: | |
830 case DoubleBot: | |
831 case Bottom: // Ye Olde Default | |
832 return Type::BOTTOM; | |
833 | |
834 case FloatBot: | |
835 return t; | |
836 | |
837 default: // All else is a mistake | |
838 typerr(t); | |
839 | |
840 case FloatCon: // Float-constant vs Float-constant? | |
841 if( jint_cast(_f) != jint_cast(t->getf()) ) // unequal constants? | |
842 // must compare bitwise as positive zero, negative zero and NaN have | |
843 // all the same representation in C++ | |
844 return FLOAT; // Return generic float | |
845 // Equal constants | |
846 case Top: | |
847 case FloatTop: | |
848 break; // Return the float constant | |
849 } | |
850 return this; // Return the float constant | |
851 } | |
852 | |
853 //------------------------------xdual------------------------------------------ | |
854 // Dual: symmetric | |
855 const Type *TypeF::xdual() const { | |
856 return this; | |
857 } | |
858 | |
859 //------------------------------eq--------------------------------------------- | |
860 // Structural equality check for Type representations | |
861 bool TypeF::eq( const Type *t ) const { | |
862 if( g_isnan(_f) || | |
863 g_isnan(t->getf()) ) { | |
864 // One or both are NANs. If both are NANs return true, else false. | |
865 return (g_isnan(_f) && g_isnan(t->getf())); | |
866 } | |
867 if (_f == t->getf()) { | |
868 // (NaN is impossible at this point, since it is not equal even to itself) | |
869 if (_f == 0.0) { | |
870 // difference between positive and negative zero | |
871 if (jint_cast(_f) != jint_cast(t->getf())) return false; | |
872 } | |
873 return true; | |
874 } | |
875 return false; | |
876 } | |
877 | |
878 //------------------------------hash------------------------------------------- | |
879 // Type-specific hashing function. | |
880 int TypeF::hash(void) const { | |
881 return *(int*)(&_f); | |
882 } | |
883 | |
884 //------------------------------is_finite-------------------------------------- | |
885 // Has a finite value | |
886 bool TypeF::is_finite() const { | |
887 return g_isfinite(getf()) != 0; | |
888 } | |
889 | |
890 //------------------------------is_nan----------------------------------------- | |
891 // Is not a number (NaN) | |
892 bool TypeF::is_nan() const { | |
893 return g_isnan(getf()) != 0; | |
894 } | |
895 | |
896 //------------------------------dump2------------------------------------------ | |
897 // Dump float constant Type | |
898 #ifndef PRODUCT | |
899 void TypeF::dump2( Dict &d, uint depth, outputStream *st ) const { | |
900 Type::dump2(d,depth, st); | |
901 st->print("%f", _f); | |
902 } | |
903 #endif | |
904 | |
905 //------------------------------singleton-------------------------------------- | |
906 // TRUE if Type is a singleton type, FALSE otherwise. Singletons are simple | |
907 // constants (Ldi nodes). Singletons are integer, float or double constants | |
908 // or a single symbol. | |
909 bool TypeF::singleton(void) const { | |
910 return true; // Always a singleton | |
911 } | |
912 | |
913 bool TypeF::empty(void) const { | |
914 return false; // always exactly a singleton | |
915 } | |
916 | |
917 //============================================================================= | |
918 // Convenience common pre-built types. | |
919 const TypeD *TypeD::ZERO; // Floating point zero | |
920 const TypeD *TypeD::ONE; // Floating point one | |
921 | |
922 //------------------------------make------------------------------------------- | |
923 const TypeD *TypeD::make(double d) { | |
924 return (TypeD*)(new TypeD(d))->hashcons(); | |
925 } | |
926 | |
927 //------------------------------meet------------------------------------------- | |
928 // Compute the MEET of two types. It returns a new Type object. | |
929 const Type *TypeD::xmeet( const Type *t ) const { | |
930 // Perform a fast test for common case; meeting the same types together. | |
931 if( this == t ) return this; // Meeting same type-rep? | |
932 | |
933 // Current "this->_base" is DoubleCon | |
934 switch (t->base()) { // Switch on original type | |
935 case AnyPtr: // Mixing with oops happens when javac | |
936 case RawPtr: // reuses local variables | |
937 case OopPtr: | |
938 case InstPtr: | |
939 case KlassPtr: | |
940 case AryPtr: | |
183
d4dbd9f91680
6711083: 64bit JVM crashes with Internal Error (type.cpp:763) - ShouldNotReachHere() with enabled COOPs
never
parents:
163
diff
changeset
|
941 case NarrowOop: |
0 | 942 case Int: |
943 case Long: | |
944 case FloatTop: | |
945 case FloatCon: | |
946 case FloatBot: | |
947 case Bottom: // Ye Olde Default | |
948 return Type::BOTTOM; | |
949 | |
950 case DoubleBot: | |
951 return t; | |
952 | |
953 default: // All else is a mistake | |
954 typerr(t); | |
955 | |
956 case DoubleCon: // Double-constant vs Double-constant? | |
957 if( jlong_cast(_d) != jlong_cast(t->getd()) ) // unequal constants? (see comment in TypeF::xmeet) | |
958 return DOUBLE; // Return generic double | |
959 case Top: | |
960 case DoubleTop: | |
961 break; | |
962 } | |
963 return this; // Return the double constant | |
964 } | |
965 | |
966 //------------------------------xdual------------------------------------------ | |
967 // Dual: symmetric | |
968 const Type *TypeD::xdual() const { | |
969 return this; | |
970 } | |
971 | |
972 //------------------------------eq--------------------------------------------- | |
973 // Structural equality check for Type representations | |
974 bool TypeD::eq( const Type *t ) const { | |
975 if( g_isnan(_d) || | |
976 g_isnan(t->getd()) ) { | |
977 // One or both are NANs. If both are NANs return true, else false. | |
978 return (g_isnan(_d) && g_isnan(t->getd())); | |
979 } | |
980 if (_d == t->getd()) { | |
981 // (NaN is impossible at this point, since it is not equal even to itself) | |
982 if (_d == 0.0) { | |
983 // difference between positive and negative zero | |
984 if (jlong_cast(_d) != jlong_cast(t->getd())) return false; | |
985 } | |
986 return true; | |
987 } | |
988 return false; | |
989 } | |
990 | |
991 //------------------------------hash------------------------------------------- | |
992 // Type-specific hashing function. | |
993 int TypeD::hash(void) const { | |
994 return *(int*)(&_d); | |
995 } | |
996 | |
997 //------------------------------is_finite-------------------------------------- | |
998 // Has a finite value | |
999 bool TypeD::is_finite() const { | |
1000 return g_isfinite(getd()) != 0; | |
1001 } | |
1002 | |
1003 //------------------------------is_nan----------------------------------------- | |
1004 // Is not a number (NaN) | |
1005 bool TypeD::is_nan() const { | |
1006 return g_isnan(getd()) != 0; | |
1007 } | |
1008 | |
1009 //------------------------------dump2------------------------------------------ | |
1010 // Dump double constant Type | |
1011 #ifndef PRODUCT | |
1012 void TypeD::dump2( Dict &d, uint depth, outputStream *st ) const { | |
1013 Type::dump2(d,depth,st); | |
1014 st->print("%f", _d); | |
1015 } | |
1016 #endif | |
1017 | |
1018 //------------------------------singleton-------------------------------------- | |
1019 // TRUE if Type is a singleton type, FALSE otherwise. Singletons are simple | |
1020 // constants (Ldi nodes). Singletons are integer, float or double constants | |
1021 // or a single symbol. | |
1022 bool TypeD::singleton(void) const { | |
1023 return true; // Always a singleton | |
1024 } | |
1025 | |
1026 bool TypeD::empty(void) const { | |
1027 return false; // always exactly a singleton | |
1028 } | |
1029 | |
1030 //============================================================================= | |
1031 // Convience common pre-built types. | |
1032 const TypeInt *TypeInt::MINUS_1;// -1 | |
1033 const TypeInt *TypeInt::ZERO; // 0 | |
1034 const TypeInt *TypeInt::ONE; // 1 | |
1035 const TypeInt *TypeInt::BOOL; // 0 or 1, FALSE or TRUE. | |
1036 const TypeInt *TypeInt::CC; // -1,0 or 1, condition codes | |
1037 const TypeInt *TypeInt::CC_LT; // [-1] == MINUS_1 | |
1038 const TypeInt *TypeInt::CC_GT; // [1] == ONE | |
1039 const TypeInt *TypeInt::CC_EQ; // [0] == ZERO | |
1040 const TypeInt *TypeInt::CC_LE; // [-1,0] | |
1041 const TypeInt *TypeInt::CC_GE; // [0,1] == BOOL (!) | |
1042 const TypeInt *TypeInt::BYTE; // Bytes, -128 to 127 | |
624 | 1043 const TypeInt *TypeInt::UBYTE; // Unsigned Bytes, 0 to 255 |
0 | 1044 const TypeInt *TypeInt::CHAR; // Java chars, 0-65535 |
1045 const TypeInt *TypeInt::SHORT; // Java shorts, -32768-32767 | |
1046 const TypeInt *TypeInt::POS; // Positive 32-bit integers or zero | |
1047 const TypeInt *TypeInt::POS1; // Positive 32-bit integers | |
1048 const TypeInt *TypeInt::INT; // 32-bit integers | |
1049 const TypeInt *TypeInt::SYMINT; // symmetric range [-max_jint..max_jint] | |
1050 | |
1051 //------------------------------TypeInt---------------------------------------- | |
1052 TypeInt::TypeInt( jint lo, jint hi, int w ) : Type(Int), _lo(lo), _hi(hi), _widen(w) { | |
1053 } | |
1054 | |
1055 //------------------------------make------------------------------------------- | |
1056 const TypeInt *TypeInt::make( jint lo ) { | |
1057 return (TypeInt*)(new TypeInt(lo,lo,WidenMin))->hashcons(); | |
1058 } | |
1059 | |
1620
d678e3277048
6964479: widen normalization of small int and long values should be symmetric
kvn
parents:
1552
diff
changeset
|
1060 static int normalize_int_widen( jint lo, jint hi, int w ) { |
0 | 1061 // Certain normalizations keep us sane when comparing types. |
1062 // The 'SMALLINT' covers constants and also CC and its relatives. | |
1063 if (lo <= hi) { | |
1620
d678e3277048
6964479: widen normalization of small int and long values should be symmetric
kvn
parents:
1552
diff
changeset
|
1064 if ((juint)(hi - lo) <= SMALLINT) w = Type::WidenMin; |
d678e3277048
6964479: widen normalization of small int and long values should be symmetric
kvn
parents:
1552
diff
changeset
|
1065 if ((juint)(hi - lo) >= max_juint) w = Type::WidenMax; // TypeInt::INT |
d678e3277048
6964479: widen normalization of small int and long values should be symmetric
kvn
parents:
1552
diff
changeset
|
1066 } else { |
d678e3277048
6964479: widen normalization of small int and long values should be symmetric
kvn
parents:
1552
diff
changeset
|
1067 if ((juint)(lo - hi) <= SMALLINT) w = Type::WidenMin; |
d678e3277048
6964479: widen normalization of small int and long values should be symmetric
kvn
parents:
1552
diff
changeset
|
1068 if ((juint)(lo - hi) >= max_juint) w = Type::WidenMin; // dual TypeInt::INT |
0 | 1069 } |
1620
d678e3277048
6964479: widen normalization of small int and long values should be symmetric
kvn
parents:
1552
diff
changeset
|
1070 return w; |
d678e3277048
6964479: widen normalization of small int and long values should be symmetric
kvn
parents:
1552
diff
changeset
|
1071 } |
d678e3277048
6964479: widen normalization of small int and long values should be symmetric
kvn
parents:
1552
diff
changeset
|
1072 |
d678e3277048
6964479: widen normalization of small int and long values should be symmetric
kvn
parents:
1552
diff
changeset
|
1073 const TypeInt *TypeInt::make( jint lo, jint hi, int w ) { |
d678e3277048
6964479: widen normalization of small int and long values should be symmetric
kvn
parents:
1552
diff
changeset
|
1074 w = normalize_int_widen(lo, hi, w); |
0 | 1075 return (TypeInt*)(new TypeInt(lo,hi,w))->hashcons(); |
1076 } | |
1077 | |
1078 //------------------------------meet------------------------------------------- | |
1079 // Compute the MEET of two types. It returns a new Type representation object | |
1080 // with reference count equal to the number of Types pointing at it. | |
1081 // Caller should wrap a Types around it. | |
1082 const Type *TypeInt::xmeet( const Type *t ) const { | |
1083 // Perform a fast test for common case; meeting the same types together. | |
1084 if( this == t ) return this; // Meeting same type? | |
1085 | |
1086 // Currently "this->_base" is a TypeInt | |
1087 switch (t->base()) { // Switch on original type | |
1088 case AnyPtr: // Mixing with oops happens when javac | |
1089 case RawPtr: // reuses local variables | |
1090 case OopPtr: | |
1091 case InstPtr: | |
1092 case KlassPtr: | |
1093 case AryPtr: | |
183
d4dbd9f91680
6711083: 64bit JVM crashes with Internal Error (type.cpp:763) - ShouldNotReachHere() with enabled COOPs
never
parents:
163
diff
changeset
|
1094 case NarrowOop: |
0 | 1095 case Long: |
1096 case FloatTop: | |
1097 case FloatCon: | |
1098 case FloatBot: | |
1099 case DoubleTop: | |
1100 case DoubleCon: | |
1101 case DoubleBot: | |
1102 case Bottom: // Ye Olde Default | |
1103 return Type::BOTTOM; | |
1104 default: // All else is a mistake | |
1105 typerr(t); | |
1106 case Top: // No change | |
1107 return this; | |
1108 case Int: // Int vs Int? | |
1109 break; | |
1110 } | |
1111 | |
1112 // Expand covered set | |
1113 const TypeInt *r = t->is_int(); | |
1620
d678e3277048
6964479: widen normalization of small int and long values should be symmetric
kvn
parents:
1552
diff
changeset
|
1114 return make( MIN2(_lo,r->_lo), MAX2(_hi,r->_hi), MAX2(_widen,r->_widen) ); |
0 | 1115 } |
1116 | |
1117 //------------------------------xdual------------------------------------------ | |
1118 // Dual: reverse hi & lo; flip widen | |
1119 const Type *TypeInt::xdual() const { | |
1620
d678e3277048
6964479: widen normalization of small int and long values should be symmetric
kvn
parents:
1552
diff
changeset
|
1120 int w = normalize_int_widen(_hi,_lo, WidenMax-_widen); |
d678e3277048
6964479: widen normalization of small int and long values should be symmetric
kvn
parents:
1552
diff
changeset
|
1121 return new TypeInt(_hi,_lo,w); |
0 | 1122 } |
1123 | |
1124 //------------------------------widen------------------------------------------ | |
1125 // Only happens for optimistic top-down optimizations. | |
1009
03b336640699
6885584: A particular class structure causes large allocation spike for jit
never
parents:
992
diff
changeset
|
1126 const Type *TypeInt::widen( const Type *old, const Type* limit ) const { |
0 | 1127 // Coming from TOP or such; no widening |
1128 if( old->base() != Int ) return this; | |
1129 const TypeInt *ot = old->is_int(); | |
1130 | |
1131 // If new guy is equal to old guy, no widening | |
1132 if( _lo == ot->_lo && _hi == ot->_hi ) | |
1133 return old; | |
1134 | |
1135 // If new guy contains old, then we widened | |
1136 if( _lo <= ot->_lo && _hi >= ot->_hi ) { | |
1137 // New contains old | |
1138 // If new guy is already wider than old, no widening | |
1139 if( _widen > ot->_widen ) return this; | |
1140 // If old guy was a constant, do not bother | |
1141 if (ot->_lo == ot->_hi) return this; | |
1142 // Now widen new guy. | |
1143 // Check for widening too far | |
1144 if (_widen == WidenMax) { | |
1009
03b336640699
6885584: A particular class structure causes large allocation spike for jit
never
parents:
992
diff
changeset
|
1145 int max = max_jint; |
03b336640699
6885584: A particular class structure causes large allocation spike for jit
never
parents:
992
diff
changeset
|
1146 int min = min_jint; |
03b336640699
6885584: A particular class structure causes large allocation spike for jit
never
parents:
992
diff
changeset
|
1147 if (limit->isa_int()) { |
03b336640699
6885584: A particular class structure causes large allocation spike for jit
never
parents:
992
diff
changeset
|
1148 max = limit->is_int()->_hi; |
03b336640699
6885584: A particular class structure causes large allocation spike for jit
never
parents:
992
diff
changeset
|
1149 min = limit->is_int()->_lo; |
03b336640699
6885584: A particular class structure causes large allocation spike for jit
never
parents:
992
diff
changeset
|
1150 } |
03b336640699
6885584: A particular class structure causes large allocation spike for jit
never
parents:
992
diff
changeset
|
1151 if (min < _lo && _hi < max) { |
0 | 1152 // If neither endpoint is extremal yet, push out the endpoint |
1153 // which is closer to its respective limit. | |
1154 if (_lo >= 0 || // easy common case | |
1009
03b336640699
6885584: A particular class structure causes large allocation spike for jit
never
parents:
992
diff
changeset
|
1155 (juint)(_lo - min) >= (juint)(max - _hi)) { |
0 | 1156 // Try to widen to an unsigned range type of 31 bits: |
1009
03b336640699
6885584: A particular class structure causes large allocation spike for jit
never
parents:
992
diff
changeset
|
1157 return make(_lo, max, WidenMax); |
0 | 1158 } else { |
1009
03b336640699
6885584: A particular class structure causes large allocation spike for jit
never
parents:
992
diff
changeset
|
1159 return make(min, _hi, WidenMax); |
0 | 1160 } |
1161 } | |
1162 return TypeInt::INT; | |
1163 } | |
1164 // Returned widened new guy | |
1165 return make(_lo,_hi,_widen+1); | |
1166 } | |
1167 | |
1168 // If old guy contains new, then we probably widened too far & dropped to | |
1169 // bottom. Return the wider fellow. | |
1170 if ( ot->_lo <= _lo && ot->_hi >= _hi ) | |
1171 return old; | |
1172 | |
1173 //fatal("Integer value range is not subset"); | |
1174 //return this; | |
1175 return TypeInt::INT; | |
1176 } | |
1177 | |
1178 //------------------------------narrow--------------------------------------- | |
1179 // Only happens for pessimistic optimizations. | |
1180 const Type *TypeInt::narrow( const Type *old ) const { | |
1181 if (_lo >= _hi) return this; // already narrow enough | |
1182 if (old == NULL) return this; | |
1183 const TypeInt* ot = old->isa_int(); | |
1184 if (ot == NULL) return this; | |
1185 jint olo = ot->_lo; | |
1186 jint ohi = ot->_hi; | |
1187 | |
1188 // If new guy is equal to old guy, no narrowing | |
1189 if (_lo == olo && _hi == ohi) return old; | |
1190 | |
1191 // If old guy was maximum range, allow the narrowing | |
1192 if (olo == min_jint && ohi == max_jint) return this; | |
1193 | |
1194 if (_lo < olo || _hi > ohi) | |
1195 return this; // doesn't narrow; pretty wierd | |
1196 | |
1197 // The new type narrows the old type, so look for a "death march". | |
1198 // See comments on PhaseTransform::saturate. | |
1199 juint nrange = _hi - _lo; | |
1200 juint orange = ohi - olo; | |
1201 if (nrange < max_juint - 1 && nrange > (orange >> 1) + (SMALLINT*2)) { | |
1202 // Use the new type only if the range shrinks a lot. | |
1203 // We do not want the optimizer computing 2^31 point by point. | |
1204 return old; | |
1205 } | |
1206 | |
1207 return this; | |
1208 } | |
1209 | |
1210 //-----------------------------filter------------------------------------------ | |
1211 const Type *TypeInt::filter( const Type *kills ) const { | |
1212 const TypeInt* ft = join(kills)->isa_int(); | |
1620
d678e3277048
6964479: widen normalization of small int and long values should be symmetric
kvn
parents:
1552
diff
changeset
|
1213 if (ft == NULL || ft->empty()) |
0 | 1214 return Type::TOP; // Canonical empty value |
1215 if (ft->_widen < this->_widen) { | |
1216 // Do not allow the value of kill->_widen to affect the outcome. | |
1217 // The widen bits must be allowed to run freely through the graph. | |
1218 ft = TypeInt::make(ft->_lo, ft->_hi, this->_widen); | |
1219 } | |
1220 return ft; | |
1221 } | |
1222 | |
1223 //------------------------------eq--------------------------------------------- | |
1224 // Structural equality check for Type representations | |
1225 bool TypeInt::eq( const Type *t ) const { | |
1226 const TypeInt *r = t->is_int(); // Handy access | |
1227 return r->_lo == _lo && r->_hi == _hi && r->_widen == _widen; | |
1228 } | |
1229 | |
1230 //------------------------------hash------------------------------------------- | |
1231 // Type-specific hashing function. | |
1232 int TypeInt::hash(void) const { | |
1233 return _lo+_hi+_widen+(int)Type::Int; | |
1234 } | |
1235 | |
1236 //------------------------------is_finite-------------------------------------- | |
1237 // Has a finite value | |
1238 bool TypeInt::is_finite() const { | |
1239 return true; | |
1240 } | |
1241 | |
1242 //------------------------------dump2------------------------------------------ | |
1243 // Dump TypeInt | |
1244 #ifndef PRODUCT | |
1245 static const char* intname(char* buf, jint n) { | |
1246 if (n == min_jint) | |
1247 return "min"; | |
1248 else if (n < min_jint + 10000) | |
1249 sprintf(buf, "min+" INT32_FORMAT, n - min_jint); | |
1250 else if (n == max_jint) | |
1251 return "max"; | |
1252 else if (n > max_jint - 10000) | |
1253 sprintf(buf, "max-" INT32_FORMAT, max_jint - n); | |
1254 else | |
1255 sprintf(buf, INT32_FORMAT, n); | |
1256 return buf; | |
1257 } | |
1258 | |
1259 void TypeInt::dump2( Dict &d, uint depth, outputStream *st ) const { | |
1260 char buf[40], buf2[40]; | |
1261 if (_lo == min_jint && _hi == max_jint) | |
1262 st->print("int"); | |
1263 else if (is_con()) | |
1264 st->print("int:%s", intname(buf, get_con())); | |
1265 else if (_lo == BOOL->_lo && _hi == BOOL->_hi) | |
1266 st->print("bool"); | |
1267 else if (_lo == BYTE->_lo && _hi == BYTE->_hi) | |
1268 st->print("byte"); | |
1269 else if (_lo == CHAR->_lo && _hi == CHAR->_hi) | |
1270 st->print("char"); | |
1271 else if (_lo == SHORT->_lo && _hi == SHORT->_hi) | |
1272 st->print("short"); | |
1273 else if (_hi == max_jint) | |
1274 st->print("int:>=%s", intname(buf, _lo)); | |
1275 else if (_lo == min_jint) | |
1276 st->print("int:<=%s", intname(buf, _hi)); | |
1277 else | |
1278 st->print("int:%s..%s", intname(buf, _lo), intname(buf2, _hi)); | |
1279 | |
1280 if (_widen != 0 && this != TypeInt::INT) | |
1281 st->print(":%.*s", _widen, "wwww"); | |
1282 } | |
1283 #endif | |
1284 | |
1285 //------------------------------singleton-------------------------------------- | |
1286 // TRUE if Type is a singleton type, FALSE otherwise. Singletons are simple | |
1287 // constants. | |
1288 bool TypeInt::singleton(void) const { | |
1289 return _lo >= _hi; | |
1290 } | |
1291 | |
1292 bool TypeInt::empty(void) const { | |
1293 return _lo > _hi; | |
1294 } | |
1295 | |
1296 //============================================================================= | |
1297 // Convenience common pre-built types. | |
1298 const TypeLong *TypeLong::MINUS_1;// -1 | |
1299 const TypeLong *TypeLong::ZERO; // 0 | |
1300 const TypeLong *TypeLong::ONE; // 1 | |
1301 const TypeLong *TypeLong::POS; // >=0 | |
1302 const TypeLong *TypeLong::LONG; // 64-bit integers | |
1303 const TypeLong *TypeLong::INT; // 32-bit subrange | |
1304 const TypeLong *TypeLong::UINT; // 32-bit unsigned subrange | |
1305 | |
1306 //------------------------------TypeLong--------------------------------------- | |
1307 TypeLong::TypeLong( jlong lo, jlong hi, int w ) : Type(Long), _lo(lo), _hi(hi), _widen(w) { | |
1308 } | |
1309 | |
1310 //------------------------------make------------------------------------------- | |
1311 const TypeLong *TypeLong::make( jlong lo ) { | |
1312 return (TypeLong*)(new TypeLong(lo,lo,WidenMin))->hashcons(); | |
1313 } | |
1314 | |
1620
d678e3277048
6964479: widen normalization of small int and long values should be symmetric
kvn
parents:
1552
diff
changeset
|
1315 static int normalize_long_widen( jlong lo, jlong hi, int w ) { |
0 | 1316 // Certain normalizations keep us sane when comparing types. |
1620
d678e3277048
6964479: widen normalization of small int and long values should be symmetric
kvn
parents:
1552
diff
changeset
|
1317 // The 'SMALLINT' covers constants. |
0 | 1318 if (lo <= hi) { |
1620
d678e3277048
6964479: widen normalization of small int and long values should be symmetric
kvn
parents:
1552
diff
changeset
|
1319 if ((julong)(hi - lo) <= SMALLINT) w = Type::WidenMin; |
d678e3277048
6964479: widen normalization of small int and long values should be symmetric
kvn
parents:
1552
diff
changeset
|
1320 if ((julong)(hi - lo) >= max_julong) w = Type::WidenMax; // TypeLong::LONG |
d678e3277048
6964479: widen normalization of small int and long values should be symmetric
kvn
parents:
1552
diff
changeset
|
1321 } else { |
d678e3277048
6964479: widen normalization of small int and long values should be symmetric
kvn
parents:
1552
diff
changeset
|
1322 if ((julong)(lo - hi) <= SMALLINT) w = Type::WidenMin; |
d678e3277048
6964479: widen normalization of small int and long values should be symmetric
kvn
parents:
1552
diff
changeset
|
1323 if ((julong)(lo - hi) >= max_julong) w = Type::WidenMin; // dual TypeLong::LONG |
0 | 1324 } |
1620
d678e3277048
6964479: widen normalization of small int and long values should be symmetric
kvn
parents:
1552
diff
changeset
|
1325 return w; |
d678e3277048
6964479: widen normalization of small int and long values should be symmetric
kvn
parents:
1552
diff
changeset
|
1326 } |
d678e3277048
6964479: widen normalization of small int and long values should be symmetric
kvn
parents:
1552
diff
changeset
|
1327 |
d678e3277048
6964479: widen normalization of small int and long values should be symmetric
kvn
parents:
1552
diff
changeset
|
1328 const TypeLong *TypeLong::make( jlong lo, jlong hi, int w ) { |
d678e3277048
6964479: widen normalization of small int and long values should be symmetric
kvn
parents:
1552
diff
changeset
|
1329 w = normalize_long_widen(lo, hi, w); |
0 | 1330 return (TypeLong*)(new TypeLong(lo,hi,w))->hashcons(); |
1331 } | |
1332 | |
1333 | |
1334 //------------------------------meet------------------------------------------- | |
1335 // Compute the MEET of two types. It returns a new Type representation object | |
1336 // with reference count equal to the number of Types pointing at it. | |
1337 // Caller should wrap a Types around it. | |
1338 const Type *TypeLong::xmeet( const Type *t ) const { | |
1339 // Perform a fast test for common case; meeting the same types together. | |
1340 if( this == t ) return this; // Meeting same type? | |
1341 | |
1342 // Currently "this->_base" is a TypeLong | |
1343 switch (t->base()) { // Switch on original type | |
1344 case AnyPtr: // Mixing with oops happens when javac | |
1345 case RawPtr: // reuses local variables | |
1346 case OopPtr: | |
1347 case InstPtr: | |
1348 case KlassPtr: | |
1349 case AryPtr: | |
183
d4dbd9f91680
6711083: 64bit JVM crashes with Internal Error (type.cpp:763) - ShouldNotReachHere() with enabled COOPs
never
parents:
163
diff
changeset
|
1350 case NarrowOop: |
0 | 1351 case Int: |
1352 case FloatTop: | |
1353 case FloatCon: | |
1354 case FloatBot: | |
1355 case DoubleTop: | |
1356 case DoubleCon: | |
1357 case DoubleBot: | |
1358 case Bottom: // Ye Olde Default | |
1359 return Type::BOTTOM; | |
1360 default: // All else is a mistake | |
1361 typerr(t); | |
1362 case Top: // No change | |
1363 return this; | |
1364 case Long: // Long vs Long? | |
1365 break; | |
1366 } | |
1367 | |
1368 // Expand covered set | |
1369 const TypeLong *r = t->is_long(); // Turn into a TypeLong | |
1620
d678e3277048
6964479: widen normalization of small int and long values should be symmetric
kvn
parents:
1552
diff
changeset
|
1370 return make( MIN2(_lo,r->_lo), MAX2(_hi,r->_hi), MAX2(_widen,r->_widen) ); |
0 | 1371 } |
1372 | |
1373 //------------------------------xdual------------------------------------------ | |
1374 // Dual: reverse hi & lo; flip widen | |
1375 const Type *TypeLong::xdual() const { | |
1620
d678e3277048
6964479: widen normalization of small int and long values should be symmetric
kvn
parents:
1552
diff
changeset
|
1376 int w = normalize_long_widen(_hi,_lo, WidenMax-_widen); |
d678e3277048
6964479: widen normalization of small int and long values should be symmetric
kvn
parents:
1552
diff
changeset
|
1377 return new TypeLong(_hi,_lo,w); |
0 | 1378 } |
1379 | |
1380 //------------------------------widen------------------------------------------ | |
1381 // Only happens for optimistic top-down optimizations. | |
1009
03b336640699
6885584: A particular class structure causes large allocation spike for jit
never
parents:
992
diff
changeset
|
1382 const Type *TypeLong::widen( const Type *old, const Type* limit ) const { |
0 | 1383 // Coming from TOP or such; no widening |
1384 if( old->base() != Long ) return this; | |
1385 const TypeLong *ot = old->is_long(); | |
1386 | |
1387 // If new guy is equal to old guy, no widening | |
1388 if( _lo == ot->_lo && _hi == ot->_hi ) | |
1389 return old; | |
1390 | |
1391 // If new guy contains old, then we widened | |
1392 if( _lo <= ot->_lo && _hi >= ot->_hi ) { | |
1393 // New contains old | |
1394 // If new guy is already wider than old, no widening | |
1395 if( _widen > ot->_widen ) return this; | |
1396 // If old guy was a constant, do not bother | |
1397 if (ot->_lo == ot->_hi) return this; | |
1398 // Now widen new guy. | |
1399 // Check for widening too far | |
1400 if (_widen == WidenMax) { | |
1009
03b336640699
6885584: A particular class structure causes large allocation spike for jit
never
parents:
992
diff
changeset
|
1401 jlong max = max_jlong; |
03b336640699
6885584: A particular class structure causes large allocation spike for jit
never
parents:
992
diff
changeset
|
1402 jlong min = min_jlong; |
03b336640699
6885584: A particular class structure causes large allocation spike for jit
never
parents:
992
diff
changeset
|
1403 if (limit->isa_long()) { |
03b336640699
6885584: A particular class structure causes large allocation spike for jit
never
parents:
992
diff
changeset
|
1404 max = limit->is_long()->_hi; |
03b336640699
6885584: A particular class structure causes large allocation spike for jit
never
parents:
992
diff
changeset
|
1405 min = limit->is_long()->_lo; |
03b336640699
6885584: A particular class structure causes large allocation spike for jit
never
parents:
992
diff
changeset
|
1406 } |
03b336640699
6885584: A particular class structure causes large allocation spike for jit
never
parents:
992
diff
changeset
|
1407 if (min < _lo && _hi < max) { |
0 | 1408 // If neither endpoint is extremal yet, push out the endpoint |
1409 // which is closer to its respective limit. | |
1410 if (_lo >= 0 || // easy common case | |
1009
03b336640699
6885584: A particular class structure causes large allocation spike for jit
never
parents:
992
diff
changeset
|
1411 (julong)(_lo - min) >= (julong)(max - _hi)) { |
0 | 1412 // Try to widen to an unsigned range type of 32/63 bits: |
1009
03b336640699
6885584: A particular class structure causes large allocation spike for jit
never
parents:
992
diff
changeset
|
1413 if (max >= max_juint && _hi < max_juint) |
0 | 1414 return make(_lo, max_juint, WidenMax); |
1415 else | |
1009
03b336640699
6885584: A particular class structure causes large allocation spike for jit
never
parents:
992
diff
changeset
|
1416 return make(_lo, max, WidenMax); |
0 | 1417 } else { |
1009
03b336640699
6885584: A particular class structure causes large allocation spike for jit
never
parents:
992
diff
changeset
|
1418 return make(min, _hi, WidenMax); |
0 | 1419 } |
1420 } | |
1421 return TypeLong::LONG; | |
1422 } | |
1423 // Returned widened new guy | |
1424 return make(_lo,_hi,_widen+1); | |
1425 } | |
1426 | |
1427 // If old guy contains new, then we probably widened too far & dropped to | |
1428 // bottom. Return the wider fellow. | |
1429 if ( ot->_lo <= _lo && ot->_hi >= _hi ) | |
1430 return old; | |
1431 | |
1432 // fatal("Long value range is not subset"); | |
1433 // return this; | |
1434 return TypeLong::LONG; | |
1435 } | |
1436 | |
1437 //------------------------------narrow---------------------------------------- | |
1438 // Only happens for pessimistic optimizations. | |
1439 const Type *TypeLong::narrow( const Type *old ) const { | |
1440 if (_lo >= _hi) return this; // already narrow enough | |
1441 if (old == NULL) return this; | |
1442 const TypeLong* ot = old->isa_long(); | |
1443 if (ot == NULL) return this; | |
1444 jlong olo = ot->_lo; | |
1445 jlong ohi = ot->_hi; | |
1446 | |
1447 // If new guy is equal to old guy, no narrowing | |
1448 if (_lo == olo && _hi == ohi) return old; | |
1449 | |
1450 // If old guy was maximum range, allow the narrowing | |
1451 if (olo == min_jlong && ohi == max_jlong) return this; | |
1452 | |
1453 if (_lo < olo || _hi > ohi) | |
1454 return this; // doesn't narrow; pretty wierd | |
1455 | |
1456 // The new type narrows the old type, so look for a "death march". | |
1457 // See comments on PhaseTransform::saturate. | |
1458 julong nrange = _hi - _lo; | |
1459 julong orange = ohi - olo; | |
1460 if (nrange < max_julong - 1 && nrange > (orange >> 1) + (SMALLINT*2)) { | |
1461 // Use the new type only if the range shrinks a lot. | |
1462 // We do not want the optimizer computing 2^31 point by point. | |
1463 return old; | |
1464 } | |
1465 | |
1466 return this; | |
1467 } | |
1468 | |
1469 //-----------------------------filter------------------------------------------ | |
1470 const Type *TypeLong::filter( const Type *kills ) const { | |
1471 const TypeLong* ft = join(kills)->isa_long(); | |
1620
d678e3277048
6964479: widen normalization of small int and long values should be symmetric
kvn
parents:
1552
diff
changeset
|
1472 if (ft == NULL || ft->empty()) |
0 | 1473 return Type::TOP; // Canonical empty value |
1474 if (ft->_widen < this->_widen) { | |
1475 // Do not allow the value of kill->_widen to affect the outcome. | |
1476 // The widen bits must be allowed to run freely through the graph. | |
1477 ft = TypeLong::make(ft->_lo, ft->_hi, this->_widen); | |
1478 } | |
1479 return ft; | |
1480 } | |
1481 | |
1482 //------------------------------eq--------------------------------------------- | |
1483 // Structural equality check for Type representations | |
1484 bool TypeLong::eq( const Type *t ) const { | |
1485 const TypeLong *r = t->is_long(); // Handy access | |
1486 return r->_lo == _lo && r->_hi == _hi && r->_widen == _widen; | |
1487 } | |
1488 | |
1489 //------------------------------hash------------------------------------------- | |
1490 // Type-specific hashing function. | |
1491 int TypeLong::hash(void) const { | |
1492 return (int)(_lo+_hi+_widen+(int)Type::Long); | |
1493 } | |
1494 | |
1495 //------------------------------is_finite-------------------------------------- | |
1496 // Has a finite value | |
1497 bool TypeLong::is_finite() const { | |
1498 return true; | |
1499 } | |
1500 | |
1501 //------------------------------dump2------------------------------------------ | |
1502 // Dump TypeLong | |
1503 #ifndef PRODUCT | |
1504 static const char* longnamenear(jlong x, const char* xname, char* buf, jlong n) { | |
1505 if (n > x) { | |
1506 if (n >= x + 10000) return NULL; | |
1507 sprintf(buf, "%s+" INT64_FORMAT, xname, n - x); | |
1508 } else if (n < x) { | |
1509 if (n <= x - 10000) return NULL; | |
1510 sprintf(buf, "%s-" INT64_FORMAT, xname, x - n); | |
1511 } else { | |
1512 return xname; | |
1513 } | |
1514 return buf; | |
1515 } | |
1516 | |
1517 static const char* longname(char* buf, jlong n) { | |
1518 const char* str; | |
1519 if (n == min_jlong) | |
1520 return "min"; | |
1521 else if (n < min_jlong + 10000) | |
1522 sprintf(buf, "min+" INT64_FORMAT, n - min_jlong); | |
1523 else if (n == max_jlong) | |
1524 return "max"; | |
1525 else if (n > max_jlong - 10000) | |
1526 sprintf(buf, "max-" INT64_FORMAT, max_jlong - n); | |
1527 else if ((str = longnamenear(max_juint, "maxuint", buf, n)) != NULL) | |
1528 return str; | |
1529 else if ((str = longnamenear(max_jint, "maxint", buf, n)) != NULL) | |
1530 return str; | |
1531 else if ((str = longnamenear(min_jint, "minint", buf, n)) != NULL) | |
1532 return str; | |
1533 else | |
1534 sprintf(buf, INT64_FORMAT, n); | |
1535 return buf; | |
1536 } | |
1537 | |
1538 void TypeLong::dump2( Dict &d, uint depth, outputStream *st ) const { | |
1539 char buf[80], buf2[80]; | |
1540 if (_lo == min_jlong && _hi == max_jlong) | |
1541 st->print("long"); | |
1542 else if (is_con()) | |
1543 st->print("long:%s", longname(buf, get_con())); | |
1544 else if (_hi == max_jlong) | |
1545 st->print("long:>=%s", longname(buf, _lo)); | |
1546 else if (_lo == min_jlong) | |
1547 st->print("long:<=%s", longname(buf, _hi)); | |
1548 else | |
1549 st->print("long:%s..%s", longname(buf, _lo), longname(buf2, _hi)); | |
1550 | |
1551 if (_widen != 0 && this != TypeLong::LONG) | |
1552 st->print(":%.*s", _widen, "wwww"); | |
1553 } | |
1554 #endif | |
1555 | |
1556 //------------------------------singleton-------------------------------------- | |
1557 // TRUE if Type is a singleton type, FALSE otherwise. Singletons are simple | |
1558 // constants | |
1559 bool TypeLong::singleton(void) const { | |
1560 return _lo >= _hi; | |
1561 } | |
1562 | |
1563 bool TypeLong::empty(void) const { | |
1564 return _lo > _hi; | |
1565 } | |
1566 | |
1567 //============================================================================= | |
1568 // Convenience common pre-built types. | |
1569 const TypeTuple *TypeTuple::IFBOTH; // Return both arms of IF as reachable | |
1570 const TypeTuple *TypeTuple::IFFALSE; | |
1571 const TypeTuple *TypeTuple::IFTRUE; | |
1572 const TypeTuple *TypeTuple::IFNEITHER; | |
1573 const TypeTuple *TypeTuple::LOOPBODY; | |
1574 const TypeTuple *TypeTuple::MEMBAR; | |
1575 const TypeTuple *TypeTuple::STORECONDITIONAL; | |
1576 const TypeTuple *TypeTuple::START_I2C; | |
1577 const TypeTuple *TypeTuple::INT_PAIR; | |
1578 const TypeTuple *TypeTuple::LONG_PAIR; | |
1579 | |
1580 | |
1581 //------------------------------make------------------------------------------- | |
1582 // Make a TypeTuple from the range of a method signature | |
1583 const TypeTuple *TypeTuple::make_range(ciSignature* sig) { | |
1584 ciType* return_type = sig->return_type(); | |
1585 uint total_fields = TypeFunc::Parms + return_type->size(); | |
1586 const Type **field_array = fields(total_fields); | |
1587 switch (return_type->basic_type()) { | |
1588 case T_LONG: | |
1589 field_array[TypeFunc::Parms] = TypeLong::LONG; | |
1590 field_array[TypeFunc::Parms+1] = Type::HALF; | |
1591 break; | |
1592 case T_DOUBLE: | |
1593 field_array[TypeFunc::Parms] = Type::DOUBLE; | |
1594 field_array[TypeFunc::Parms+1] = Type::HALF; | |
1595 break; | |
1596 case T_OBJECT: | |
1597 case T_ARRAY: | |
1598 case T_BOOLEAN: | |
1599 case T_CHAR: | |
1600 case T_FLOAT: | |
1601 case T_BYTE: | |
1602 case T_SHORT: | |
1603 case T_INT: | |
1604 field_array[TypeFunc::Parms] = get_const_type(return_type); | |
1605 break; | |
1606 case T_VOID: | |
1607 break; | |
1608 default: | |
1609 ShouldNotReachHere(); | |
1610 } | |
1611 return (TypeTuple*)(new TypeTuple(total_fields,field_array))->hashcons(); | |
1612 } | |
1613 | |
1614 // Make a TypeTuple from the domain of a method signature | |
1615 const TypeTuple *TypeTuple::make_domain(ciInstanceKlass* recv, ciSignature* sig) { | |
1616 uint total_fields = TypeFunc::Parms + sig->size(); | |
1617 | |
1618 uint pos = TypeFunc::Parms; | |
1619 const Type **field_array; | |
1620 if (recv != NULL) { | |
1621 total_fields++; | |
1622 field_array = fields(total_fields); | |
1623 // Use get_const_type here because it respects UseUniqueSubclasses: | |
1624 field_array[pos++] = get_const_type(recv)->join(TypePtr::NOTNULL); | |
1625 } else { | |
1626 field_array = fields(total_fields); | |
1627 } | |
1628 | |
1629 int i = 0; | |
1630 while (pos < total_fields) { | |
1631 ciType* type = sig->type_at(i); | |
1632 | |
1633 switch (type->basic_type()) { | |
1634 case T_LONG: | |
1635 field_array[pos++] = TypeLong::LONG; | |
1636 field_array[pos++] = Type::HALF; | |
1637 break; | |
1638 case T_DOUBLE: | |
1639 field_array[pos++] = Type::DOUBLE; | |
1640 field_array[pos++] = Type::HALF; | |
1641 break; | |
1642 case T_OBJECT: | |
1643 case T_ARRAY: | |
1644 case T_BOOLEAN: | |
1645 case T_CHAR: | |
1646 case T_FLOAT: | |
1647 case T_BYTE: | |
1648 case T_SHORT: | |
1649 case T_INT: | |
1650 field_array[pos++] = get_const_type(type); | |
1651 break; | |
1652 default: | |
1653 ShouldNotReachHere(); | |
1654 } | |
1655 i++; | |
1656 } | |
1657 return (TypeTuple*)(new TypeTuple(total_fields,field_array))->hashcons(); | |
1658 } | |
1659 | |
1660 const TypeTuple *TypeTuple::make( uint cnt, const Type **fields ) { | |
1661 return (TypeTuple*)(new TypeTuple(cnt,fields))->hashcons(); | |
1662 } | |
1663 | |
1664 //------------------------------fields----------------------------------------- | |
1665 // Subroutine call type with space allocated for argument types | |
1666 const Type **TypeTuple::fields( uint arg_cnt ) { | |
1667 const Type **flds = (const Type **)(Compile::current()->type_arena()->Amalloc_4((TypeFunc::Parms+arg_cnt)*sizeof(Type*) )); | |
1668 flds[TypeFunc::Control ] = Type::CONTROL; | |
1669 flds[TypeFunc::I_O ] = Type::ABIO; | |
1670 flds[TypeFunc::Memory ] = Type::MEMORY; | |
1671 flds[TypeFunc::FramePtr ] = TypeRawPtr::BOTTOM; | |
1672 flds[TypeFunc::ReturnAdr] = Type::RETURN_ADDRESS; | |
1673 | |
1674 return flds; | |
1675 } | |
1676 | |
1677 //------------------------------meet------------------------------------------- | |
1678 // Compute the MEET of two types. It returns a new Type object. | |
1679 const Type *TypeTuple::xmeet( const Type *t ) const { | |
1680 // Perform a fast test for common case; meeting the same types together. | |
1681 if( this == t ) return this; // Meeting same type-rep? | |
1682 | |
1683 // Current "this->_base" is Tuple | |
1684 switch (t->base()) { // switch on original type | |
1685 | |
1686 case Bottom: // Ye Olde Default | |
1687 return t; | |
1688 | |
1689 default: // All else is a mistake | |
1690 typerr(t); | |
1691 | |
1692 case Tuple: { // Meeting 2 signatures? | |
1693 const TypeTuple *x = t->is_tuple(); | |
1694 assert( _cnt == x->_cnt, "" ); | |
1695 const Type **fields = (const Type **)(Compile::current()->type_arena()->Amalloc_4( _cnt*sizeof(Type*) )); | |
1696 for( uint i=0; i<_cnt; i++ ) | |
1697 fields[i] = field_at(i)->xmeet( x->field_at(i) ); | |
1698 return TypeTuple::make(_cnt,fields); | |
1699 } | |
1700 case Top: | |
1701 break; | |
1702 } | |
1703 return this; // Return the double constant | |
1704 } | |
1705 | |
1706 //------------------------------xdual------------------------------------------ | |
1707 // Dual: compute field-by-field dual | |
1708 const Type *TypeTuple::xdual() const { | |
1709 const Type **fields = (const Type **)(Compile::current()->type_arena()->Amalloc_4( _cnt*sizeof(Type*) )); | |
1710 for( uint i=0; i<_cnt; i++ ) | |
1711 fields[i] = _fields[i]->dual(); | |
1712 return new TypeTuple(_cnt,fields); | |
1713 } | |
1714 | |
1715 //------------------------------eq--------------------------------------------- | |
1716 // Structural equality check for Type representations | |
1717 bool TypeTuple::eq( const Type *t ) const { | |
1718 const TypeTuple *s = (const TypeTuple *)t; | |
1719 if (_cnt != s->_cnt) return false; // Unequal field counts | |
1720 for (uint i = 0; i < _cnt; i++) | |
1721 if (field_at(i) != s->field_at(i)) // POINTER COMPARE! NO RECURSION! | |
1722 return false; // Missed | |
1723 return true; | |
1724 } | |
1725 | |
1726 //------------------------------hash------------------------------------------- | |
1727 // Type-specific hashing function. | |
1728 int TypeTuple::hash(void) const { | |
1729 intptr_t sum = _cnt; | |
1730 for( uint i=0; i<_cnt; i++ ) | |
1731 sum += (intptr_t)_fields[i]; // Hash on pointers directly | |
1732 return sum; | |
1733 } | |
1734 | |
1735 //------------------------------dump2------------------------------------------ | |
1736 // Dump signature Type | |
1737 #ifndef PRODUCT | |
1738 void TypeTuple::dump2( Dict &d, uint depth, outputStream *st ) const { | |
1739 st->print("{"); | |
1740 if( !depth || d[this] ) { // Check for recursive print | |
1741 st->print("...}"); | |
1742 return; | |
1743 } | |
1744 d.Insert((void*)this, (void*)this); // Stop recursion | |
1745 if( _cnt ) { | |
1746 uint i; | |
1747 for( i=0; i<_cnt-1; i++ ) { | |
1748 st->print("%d:", i); | |
1749 _fields[i]->dump2(d, depth-1, st); | |
1750 st->print(", "); | |
1751 } | |
1752 st->print("%d:", i); | |
1753 _fields[i]->dump2(d, depth-1, st); | |
1754 } | |
1755 st->print("}"); | |
1756 } | |
1757 #endif | |
1758 | |
1759 //------------------------------singleton-------------------------------------- | |
1760 // TRUE if Type is a singleton type, FALSE otherwise. Singletons are simple | |
1761 // constants (Ldi nodes). Singletons are integer, float or double constants | |
1762 // or a single symbol. | |
1763 bool TypeTuple::singleton(void) const { | |
1764 return false; // Never a singleton | |
1765 } | |
1766 | |
1767 bool TypeTuple::empty(void) const { | |
1768 for( uint i=0; i<_cnt; i++ ) { | |
1769 if (_fields[i]->empty()) return true; | |
1770 } | |
1771 return false; | |
1772 } | |
1773 | |
1774 //============================================================================= | |
1775 // Convenience common pre-built types. | |
1776 | |
1777 inline const TypeInt* normalize_array_size(const TypeInt* size) { | |
1778 // Certain normalizations keep us sane when comparing types. | |
1779 // We do not want arrayOop variables to differ only by the wideness | |
1780 // of their index types. Pick minimum wideness, since that is the | |
1781 // forced wideness of small ranges anyway. | |
1782 if (size->_widen != Type::WidenMin) | |
1783 return TypeInt::make(size->_lo, size->_hi, Type::WidenMin); | |
1784 else | |
1785 return size; | |
1786 } | |
1787 | |
1788 //------------------------------make------------------------------------------- | |
1789 const TypeAry *TypeAry::make( const Type *elem, const TypeInt *size) { | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
1790 if (UseCompressedOops && elem->isa_oopptr()) { |
221
1e026f8da827
6710487: More than half of JDI Regression tests hang with COOPs in -Xcomp mode
kvn
parents:
183
diff
changeset
|
1791 elem = elem->make_narrowoop(); |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
1792 } |
0 | 1793 size = normalize_array_size(size); |
1794 return (TypeAry*)(new TypeAry(elem,size))->hashcons(); | |
1795 } | |
1796 | |
1797 //------------------------------meet------------------------------------------- | |
1798 // Compute the MEET of two types. It returns a new Type object. | |
1799 const Type *TypeAry::xmeet( const Type *t ) const { | |
1800 // Perform a fast test for common case; meeting the same types together. | |
1801 if( this == t ) return this; // Meeting same type-rep? | |
1802 | |
1803 // Current "this->_base" is Ary | |
1804 switch (t->base()) { // switch on original type | |
1805 | |
1806 case Bottom: // Ye Olde Default | |
1807 return t; | |
1808 | |
1809 default: // All else is a mistake | |
1810 typerr(t); | |
1811 | |
1812 case Array: { // Meeting 2 arrays? | |
1813 const TypeAry *a = t->is_ary(); | |
1814 return TypeAry::make(_elem->meet(a->_elem), | |
1815 _size->xmeet(a->_size)->is_int()); | |
1816 } | |
1817 case Top: | |
1818 break; | |
1819 } | |
1820 return this; // Return the double constant | |
1821 } | |
1822 | |
1823 //------------------------------xdual------------------------------------------ | |
1824 // Dual: compute field-by-field dual | |
1825 const Type *TypeAry::xdual() const { | |
1826 const TypeInt* size_dual = _size->dual()->is_int(); | |
1827 size_dual = normalize_array_size(size_dual); | |
1828 return new TypeAry( _elem->dual(), size_dual); | |
1829 } | |
1830 | |
1831 //------------------------------eq--------------------------------------------- | |
1832 // Structural equality check for Type representations | |
1833 bool TypeAry::eq( const Type *t ) const { | |
1834 const TypeAry *a = (const TypeAry*)t; | |
1835 return _elem == a->_elem && | |
1836 _size == a->_size; | |
1837 } | |
1838 | |
1839 //------------------------------hash------------------------------------------- | |
1840 // Type-specific hashing function. | |
1841 int TypeAry::hash(void) const { | |
1842 return (intptr_t)_elem + (intptr_t)_size; | |
1843 } | |
1844 | |
820
915cc9c5ebc6
6837094: False positive for "meet not symmetric" failure
kvn
parents:
628
diff
changeset
|
1845 //----------------------interface_vs_oop--------------------------------------- |
915cc9c5ebc6
6837094: False positive for "meet not symmetric" failure
kvn
parents:
628
diff
changeset
|
1846 #ifdef ASSERT |
915cc9c5ebc6
6837094: False positive for "meet not symmetric" failure
kvn
parents:
628
diff
changeset
|
1847 bool TypeAry::interface_vs_oop(const Type *t) const { |
915cc9c5ebc6
6837094: False positive for "meet not symmetric" failure
kvn
parents:
628
diff
changeset
|
1848 const TypeAry* t_ary = t->is_ary(); |
915cc9c5ebc6
6837094: False positive for "meet not symmetric" failure
kvn
parents:
628
diff
changeset
|
1849 if (t_ary) { |
915cc9c5ebc6
6837094: False positive for "meet not symmetric" failure
kvn
parents:
628
diff
changeset
|
1850 return _elem->interface_vs_oop(t_ary->_elem); |
915cc9c5ebc6
6837094: False positive for "meet not symmetric" failure
kvn
parents:
628
diff
changeset
|
1851 } |
915cc9c5ebc6
6837094: False positive for "meet not symmetric" failure
kvn
parents:
628
diff
changeset
|
1852 return false; |
915cc9c5ebc6
6837094: False positive for "meet not symmetric" failure
kvn
parents:
628
diff
changeset
|
1853 } |
915cc9c5ebc6
6837094: False positive for "meet not symmetric" failure
kvn
parents:
628
diff
changeset
|
1854 #endif |
915cc9c5ebc6
6837094: False positive for "meet not symmetric" failure
kvn
parents:
628
diff
changeset
|
1855 |
0 | 1856 //------------------------------dump2------------------------------------------ |
1857 #ifndef PRODUCT | |
1858 void TypeAry::dump2( Dict &d, uint depth, outputStream *st ) const { | |
1859 _elem->dump2(d, depth, st); | |
1860 st->print("["); | |
1861 _size->dump2(d, depth, st); | |
1862 st->print("]"); | |
1863 } | |
1864 #endif | |
1865 | |
1866 //------------------------------singleton-------------------------------------- | |
1867 // TRUE if Type is a singleton type, FALSE otherwise. Singletons are simple | |
1868 // constants (Ldi nodes). Singletons are integer, float or double constants | |
1869 // or a single symbol. | |
1870 bool TypeAry::singleton(void) const { | |
1871 return false; // Never a singleton | |
1872 } | |
1873 | |
1874 bool TypeAry::empty(void) const { | |
1875 return _elem->empty() || _size->empty(); | |
1876 } | |
1877 | |
1878 //--------------------------ary_must_be_exact---------------------------------- | |
1879 bool TypeAry::ary_must_be_exact() const { | |
1880 if (!UseExactTypes) return false; | |
1881 // This logic looks at the element type of an array, and returns true | |
1882 // if the element type is either a primitive or a final instance class. | |
1883 // In such cases, an array built on this ary must have no subclasses. | |
1884 if (_elem == BOTTOM) return false; // general array not exact | |
1885 if (_elem == TOP ) return false; // inverted general array not exact | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
1886 const TypeOopPtr* toop = NULL; |
221
1e026f8da827
6710487: More than half of JDI Regression tests hang with COOPs in -Xcomp mode
kvn
parents:
183
diff
changeset
|
1887 if (UseCompressedOops && _elem->isa_narrowoop()) { |
1e026f8da827
6710487: More than half of JDI Regression tests hang with COOPs in -Xcomp mode
kvn
parents:
183
diff
changeset
|
1888 toop = _elem->make_ptr()->isa_oopptr(); |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
1889 } else { |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
1890 toop = _elem->isa_oopptr(); |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
1891 } |
0 | 1892 if (!toop) return true; // a primitive type, like int |
1893 ciKlass* tklass = toop->klass(); | |
1894 if (tklass == NULL) return false; // unloaded class | |
1895 if (!tklass->is_loaded()) return false; // unloaded class | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
1896 const TypeInstPtr* tinst; |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
1897 if (_elem->isa_narrowoop()) |
221
1e026f8da827
6710487: More than half of JDI Regression tests hang with COOPs in -Xcomp mode
kvn
parents:
183
diff
changeset
|
1898 tinst = _elem->make_ptr()->isa_instptr(); |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
1899 else |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
1900 tinst = _elem->isa_instptr(); |
221
1e026f8da827
6710487: More than half of JDI Regression tests hang with COOPs in -Xcomp mode
kvn
parents:
183
diff
changeset
|
1901 if (tinst) |
1e026f8da827
6710487: More than half of JDI Regression tests hang with COOPs in -Xcomp mode
kvn
parents:
183
diff
changeset
|
1902 return tklass->as_instance_klass()->is_final(); |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
1903 const TypeAryPtr* tap; |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
1904 if (_elem->isa_narrowoop()) |
221
1e026f8da827
6710487: More than half of JDI Regression tests hang with COOPs in -Xcomp mode
kvn
parents:
183
diff
changeset
|
1905 tap = _elem->make_ptr()->isa_aryptr(); |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
1906 else |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
1907 tap = _elem->isa_aryptr(); |
221
1e026f8da827
6710487: More than half of JDI Regression tests hang with COOPs in -Xcomp mode
kvn
parents:
183
diff
changeset
|
1908 if (tap) |
1e026f8da827
6710487: More than half of JDI Regression tests hang with COOPs in -Xcomp mode
kvn
parents:
183
diff
changeset
|
1909 return tap->ary()->ary_must_be_exact(); |
0 | 1910 return false; |
1911 } | |
1912 | |
1913 //============================================================================= | |
1914 // Convenience common pre-built types. | |
1915 const TypePtr *TypePtr::NULL_PTR; | |
1916 const TypePtr *TypePtr::NOTNULL; | |
1917 const TypePtr *TypePtr::BOTTOM; | |
1918 | |
1919 //------------------------------meet------------------------------------------- | |
1920 // Meet over the PTR enum | |
1921 const TypePtr::PTR TypePtr::ptr_meet[TypePtr::lastPTR][TypePtr::lastPTR] = { | |
1922 // TopPTR, AnyNull, Constant, Null, NotNull, BotPTR, | |
1923 { /* Top */ TopPTR, AnyNull, Constant, Null, NotNull, BotPTR,}, | |
1924 { /* AnyNull */ AnyNull, AnyNull, Constant, BotPTR, NotNull, BotPTR,}, | |
1925 { /* Constant*/ Constant, Constant, Constant, BotPTR, NotNull, BotPTR,}, | |
1926 { /* Null */ Null, BotPTR, BotPTR, Null, BotPTR, BotPTR,}, | |
1927 { /* NotNull */ NotNull, NotNull, NotNull, BotPTR, NotNull, BotPTR,}, | |
1928 { /* BotPTR */ BotPTR, BotPTR, BotPTR, BotPTR, BotPTR, BotPTR,} | |
1929 }; | |
1930 | |
1931 //------------------------------make------------------------------------------- | |
1932 const TypePtr *TypePtr::make( TYPES t, enum PTR ptr, int offset ) { | |
1933 return (TypePtr*)(new TypePtr(t,ptr,offset))->hashcons(); | |
1934 } | |
1935 | |
1936 //------------------------------cast_to_ptr_type------------------------------- | |
1937 const Type *TypePtr::cast_to_ptr_type(PTR ptr) const { | |
1938 assert(_base == AnyPtr, "subclass must override cast_to_ptr_type"); | |
1939 if( ptr == _ptr ) return this; | |
1940 return make(_base, ptr, _offset); | |
1941 } | |
1942 | |
1943 //------------------------------get_con---------------------------------------- | |
1944 intptr_t TypePtr::get_con() const { | |
1945 assert( _ptr == Null, "" ); | |
1946 return _offset; | |
1947 } | |
1948 | |
1949 //------------------------------meet------------------------------------------- | |
1950 // Compute the MEET of two types. It returns a new Type object. | |
1951 const Type *TypePtr::xmeet( const Type *t ) const { | |
1952 // Perform a fast test for common case; meeting the same types together. | |
1953 if( this == t ) return this; // Meeting same type-rep? | |
1954 | |
1955 // Current "this->_base" is AnyPtr | |
1956 switch (t->base()) { // switch on original type | |
1957 case Int: // Mixing ints & oops happens when javac | |
1958 case Long: // reuses local variables | |
1959 case FloatTop: | |
1960 case FloatCon: | |
1961 case FloatBot: | |
1962 case DoubleTop: | |
1963 case DoubleCon: | |
1964 case DoubleBot: | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
1965 case NarrowOop: |
0 | 1966 case Bottom: // Ye Olde Default |
1967 return Type::BOTTOM; | |
1968 case Top: | |
1969 return this; | |
1970 | |
1971 case AnyPtr: { // Meeting to AnyPtrs | |
1972 const TypePtr *tp = t->is_ptr(); | |
1973 return make( AnyPtr, meet_ptr(tp->ptr()), meet_offset(tp->offset()) ); | |
1974 } | |
1975 case RawPtr: // For these, flip the call around to cut down | |
1976 case OopPtr: | |
1977 case InstPtr: // on the cases I have to handle. | |
1978 case KlassPtr: | |
1979 case AryPtr: | |
1980 return t->xmeet(this); // Call in reverse direction | |
1981 default: // All else is a mistake | |
1982 typerr(t); | |
1983 | |
1984 } | |
1985 return this; | |
1986 } | |
1987 | |
1988 //------------------------------meet_offset------------------------------------ | |
1989 int TypePtr::meet_offset( int offset ) const { | |
1990 // Either is 'TOP' offset? Return the other offset! | |
1991 if( _offset == OffsetTop ) return offset; | |
1992 if( offset == OffsetTop ) return _offset; | |
1993 // If either is different, return 'BOTTOM' offset | |
1994 if( _offset != offset ) return OffsetBot; | |
1995 return _offset; | |
1996 } | |
1997 | |
1998 //------------------------------dual_offset------------------------------------ | |
1999 int TypePtr::dual_offset( ) const { | |
2000 if( _offset == OffsetTop ) return OffsetBot;// Map 'TOP' into 'BOTTOM' | |
2001 if( _offset == OffsetBot ) return OffsetTop;// Map 'BOTTOM' into 'TOP' | |
2002 return _offset; // Map everything else into self | |
2003 } | |
2004 | |
2005 //------------------------------xdual------------------------------------------ | |
2006 // Dual: compute field-by-field dual | |
2007 const TypePtr::PTR TypePtr::ptr_dual[TypePtr::lastPTR] = { | |
2008 BotPTR, NotNull, Constant, Null, AnyNull, TopPTR | |
2009 }; | |
2010 const Type *TypePtr::xdual() const { | |
2011 return new TypePtr( AnyPtr, dual_ptr(), dual_offset() ); | |
2012 } | |
2013 | |
306
af945ba2e739
6741738: TypePtr::add_offset() set incorrect offset when the add overflows
kvn
parents:
293
diff
changeset
|
2014 //------------------------------xadd_offset------------------------------------ |
af945ba2e739
6741738: TypePtr::add_offset() set incorrect offset when the add overflows
kvn
parents:
293
diff
changeset
|
2015 int TypePtr::xadd_offset( intptr_t offset ) const { |
af945ba2e739
6741738: TypePtr::add_offset() set incorrect offset when the add overflows
kvn
parents:
293
diff
changeset
|
2016 // Adding to 'TOP' offset? Return 'TOP'! |
af945ba2e739
6741738: TypePtr::add_offset() set incorrect offset when the add overflows
kvn
parents:
293
diff
changeset
|
2017 if( _offset == OffsetTop || offset == OffsetTop ) return OffsetTop; |
af945ba2e739
6741738: TypePtr::add_offset() set incorrect offset when the add overflows
kvn
parents:
293
diff
changeset
|
2018 // Adding to 'BOTTOM' offset? Return 'BOTTOM'! |
af945ba2e739
6741738: TypePtr::add_offset() set incorrect offset when the add overflows
kvn
parents:
293
diff
changeset
|
2019 if( _offset == OffsetBot || offset == OffsetBot ) return OffsetBot; |
af945ba2e739
6741738: TypePtr::add_offset() set incorrect offset when the add overflows
kvn
parents:
293
diff
changeset
|
2020 // Addition overflows or "accidentally" equals to OffsetTop? Return 'BOTTOM'! |
af945ba2e739
6741738: TypePtr::add_offset() set incorrect offset when the add overflows
kvn
parents:
293
diff
changeset
|
2021 offset += (intptr_t)_offset; |
af945ba2e739
6741738: TypePtr::add_offset() set incorrect offset when the add overflows
kvn
parents:
293
diff
changeset
|
2022 if (offset != (int)offset || offset == OffsetTop) return OffsetBot; |
af945ba2e739
6741738: TypePtr::add_offset() set incorrect offset when the add overflows
kvn
parents:
293
diff
changeset
|
2023 |
af945ba2e739
6741738: TypePtr::add_offset() set incorrect offset when the add overflows
kvn
parents:
293
diff
changeset
|
2024 // assert( _offset >= 0 && _offset+offset >= 0, "" ); |
af945ba2e739
6741738: TypePtr::add_offset() set incorrect offset when the add overflows
kvn
parents:
293
diff
changeset
|
2025 // It is possible to construct a negative offset during PhaseCCP |
af945ba2e739
6741738: TypePtr::add_offset() set incorrect offset when the add overflows
kvn
parents:
293
diff
changeset
|
2026 |
af945ba2e739
6741738: TypePtr::add_offset() set incorrect offset when the add overflows
kvn
parents:
293
diff
changeset
|
2027 return (int)offset; // Sum valid offsets |
af945ba2e739
6741738: TypePtr::add_offset() set incorrect offset when the add overflows
kvn
parents:
293
diff
changeset
|
2028 } |
af945ba2e739
6741738: TypePtr::add_offset() set incorrect offset when the add overflows
kvn
parents:
293
diff
changeset
|
2029 |
0 | 2030 //------------------------------add_offset------------------------------------- |
306
af945ba2e739
6741738: TypePtr::add_offset() set incorrect offset when the add overflows
kvn
parents:
293
diff
changeset
|
2031 const TypePtr *TypePtr::add_offset( intptr_t offset ) const { |
af945ba2e739
6741738: TypePtr::add_offset() set incorrect offset when the add overflows
kvn
parents:
293
diff
changeset
|
2032 return make( AnyPtr, _ptr, xadd_offset(offset) ); |
0 | 2033 } |
2034 | |
2035 //------------------------------eq--------------------------------------------- | |
2036 // Structural equality check for Type representations | |
2037 bool TypePtr::eq( const Type *t ) const { | |
2038 const TypePtr *a = (const TypePtr*)t; | |
2039 return _ptr == a->ptr() && _offset == a->offset(); | |
2040 } | |
2041 | |
2042 //------------------------------hash------------------------------------------- | |
2043 // Type-specific hashing function. | |
2044 int TypePtr::hash(void) const { | |
2045 return _ptr + _offset; | |
2046 } | |
2047 | |
2048 //------------------------------dump2------------------------------------------ | |
2049 const char *const TypePtr::ptr_msg[TypePtr::lastPTR] = { | |
2050 "TopPTR","AnyNull","Constant","NULL","NotNull","BotPTR" | |
2051 }; | |
2052 | |
2053 #ifndef PRODUCT | |
2054 void TypePtr::dump2( Dict &d, uint depth, outputStream *st ) const { | |
2055 if( _ptr == Null ) st->print("NULL"); | |
2056 else st->print("%s *", ptr_msg[_ptr]); | |
2057 if( _offset == OffsetTop ) st->print("+top"); | |
2058 else if( _offset == OffsetBot ) st->print("+bot"); | |
2059 else if( _offset ) st->print("+%d", _offset); | |
2060 } | |
2061 #endif | |
2062 | |
2063 //------------------------------singleton-------------------------------------- | |
2064 // TRUE if Type is a singleton type, FALSE otherwise. Singletons are simple | |
2065 // constants | |
2066 bool TypePtr::singleton(void) const { | |
2067 // TopPTR, Null, AnyNull, Constant are all singletons | |
2068 return (_offset != OffsetBot) && !below_centerline(_ptr); | |
2069 } | |
2070 | |
2071 bool TypePtr::empty(void) const { | |
2072 return (_offset == OffsetTop) || above_centerline(_ptr); | |
2073 } | |
2074 | |
2075 //============================================================================= | |
2076 // Convenience common pre-built types. | |
2077 const TypeRawPtr *TypeRawPtr::BOTTOM; | |
2078 const TypeRawPtr *TypeRawPtr::NOTNULL; | |
2079 | |
2080 //------------------------------make------------------------------------------- | |
2081 const TypeRawPtr *TypeRawPtr::make( enum PTR ptr ) { | |
2082 assert( ptr != Constant, "what is the constant?" ); | |
2083 assert( ptr != Null, "Use TypePtr for NULL" ); | |
2084 return (TypeRawPtr*)(new TypeRawPtr(ptr,0))->hashcons(); | |
2085 } | |
2086 | |
2087 const TypeRawPtr *TypeRawPtr::make( address bits ) { | |
2088 assert( bits, "Use TypePtr for NULL" ); | |
2089 return (TypeRawPtr*)(new TypeRawPtr(Constant,bits))->hashcons(); | |
2090 } | |
2091 | |
2092 //------------------------------cast_to_ptr_type------------------------------- | |
2093 const Type *TypeRawPtr::cast_to_ptr_type(PTR ptr) const { | |
2094 assert( ptr != Constant, "what is the constant?" ); | |
2095 assert( ptr != Null, "Use TypePtr for NULL" ); | |
2096 assert( _bits==0, "Why cast a constant address?"); | |
2097 if( ptr == _ptr ) return this; | |
2098 return make(ptr); | |
2099 } | |
2100 | |
2101 //------------------------------get_con---------------------------------------- | |
2102 intptr_t TypeRawPtr::get_con() const { | |
2103 assert( _ptr == Null || _ptr == Constant, "" ); | |
2104 return (intptr_t)_bits; | |
2105 } | |
2106 | |
2107 //------------------------------meet------------------------------------------- | |
2108 // Compute the MEET of two types. It returns a new Type object. | |
2109 const Type *TypeRawPtr::xmeet( const Type *t ) const { | |
2110 // Perform a fast test for common case; meeting the same types together. | |
2111 if( this == t ) return this; // Meeting same type-rep? | |
2112 | |
2113 // Current "this->_base" is RawPtr | |
2114 switch( t->base() ) { // switch on original type | |
2115 case Bottom: // Ye Olde Default | |
2116 return t; | |
2117 case Top: | |
2118 return this; | |
2119 case AnyPtr: // Meeting to AnyPtrs | |
2120 break; | |
2121 case RawPtr: { // might be top, bot, any/not or constant | |
2122 enum PTR tptr = t->is_ptr()->ptr(); | |
2123 enum PTR ptr = meet_ptr( tptr ); | |
2124 if( ptr == Constant ) { // Cannot be equal constants, so... | |
2125 if( tptr == Constant && _ptr != Constant) return t; | |
2126 if( _ptr == Constant && tptr != Constant) return this; | |
2127 ptr = NotNull; // Fall down in lattice | |
2128 } | |
2129 return make( ptr ); | |
2130 } | |
2131 | |
2132 case OopPtr: | |
2133 case InstPtr: | |
2134 case KlassPtr: | |
2135 case AryPtr: | |
2136 return TypePtr::BOTTOM; // Oop meet raw is not well defined | |
2137 default: // All else is a mistake | |
2138 typerr(t); | |
2139 } | |
2140 | |
2141 // Found an AnyPtr type vs self-RawPtr type | |
2142 const TypePtr *tp = t->is_ptr(); | |
2143 switch (tp->ptr()) { | |
2144 case TypePtr::TopPTR: return this; | |
2145 case TypePtr::BotPTR: return t; | |
2146 case TypePtr::Null: | |
2147 if( _ptr == TypePtr::TopPTR ) return t; | |
2148 return TypeRawPtr::BOTTOM; | |
2149 case TypePtr::NotNull: return TypePtr::make( AnyPtr, meet_ptr(TypePtr::NotNull), tp->meet_offset(0) ); | |
2150 case TypePtr::AnyNull: | |
2151 if( _ptr == TypePtr::Constant) return this; | |
2152 return make( meet_ptr(TypePtr::AnyNull) ); | |
2153 default: ShouldNotReachHere(); | |
2154 } | |
2155 return this; | |
2156 } | |
2157 | |
2158 //------------------------------xdual------------------------------------------ | |
2159 // Dual: compute field-by-field dual | |
2160 const Type *TypeRawPtr::xdual() const { | |
2161 return new TypeRawPtr( dual_ptr(), _bits ); | |
2162 } | |
2163 | |
2164 //------------------------------add_offset------------------------------------- | |
306
af945ba2e739
6741738: TypePtr::add_offset() set incorrect offset when the add overflows
kvn
parents:
293
diff
changeset
|
2165 const TypePtr *TypeRawPtr::add_offset( intptr_t offset ) const { |
0 | 2166 if( offset == OffsetTop ) return BOTTOM; // Undefined offset-> undefined pointer |
2167 if( offset == OffsetBot ) return BOTTOM; // Unknown offset-> unknown pointer | |
2168 if( offset == 0 ) return this; // No change | |
2169 switch (_ptr) { | |
2170 case TypePtr::TopPTR: | |
2171 case TypePtr::BotPTR: | |
2172 case TypePtr::NotNull: | |
2173 return this; | |
2174 case TypePtr::Null: | |
2175 case TypePtr::Constant: | |
2176 return make( _bits+offset ); | |
2177 default: ShouldNotReachHere(); | |
2178 } | |
2179 return NULL; // Lint noise | |
2180 } | |
2181 | |
2182 //------------------------------eq--------------------------------------------- | |
2183 // Structural equality check for Type representations | |
2184 bool TypeRawPtr::eq( const Type *t ) const { | |
2185 const TypeRawPtr *a = (const TypeRawPtr*)t; | |
2186 return _bits == a->_bits && TypePtr::eq(t); | |
2187 } | |
2188 | |
2189 //------------------------------hash------------------------------------------- | |
2190 // Type-specific hashing function. | |
2191 int TypeRawPtr::hash(void) const { | |
2192 return (intptr_t)_bits + TypePtr::hash(); | |
2193 } | |
2194 | |
2195 //------------------------------dump2------------------------------------------ | |
2196 #ifndef PRODUCT | |
2197 void TypeRawPtr::dump2( Dict &d, uint depth, outputStream *st ) const { | |
2198 if( _ptr == Constant ) | |
2199 st->print(INTPTR_FORMAT, _bits); | |
2200 else | |
2201 st->print("rawptr:%s", ptr_msg[_ptr]); | |
2202 } | |
2203 #endif | |
2204 | |
2205 //============================================================================= | |
2206 // Convenience common pre-built type. | |
2207 const TypeOopPtr *TypeOopPtr::BOTTOM; | |
2208 | |
163 | 2209 //------------------------------TypeOopPtr------------------------------------- |
2210 TypeOopPtr::TypeOopPtr( TYPES t, PTR ptr, ciKlass* k, bool xk, ciObject* o, int offset, int instance_id ) | |
2211 : TypePtr(t, ptr, offset), | |
2212 _const_oop(o), _klass(k), | |
2213 _klass_is_exact(xk), | |
2214 _is_ptr_to_narrowoop(false), | |
2215 _instance_id(instance_id) { | |
2216 #ifdef _LP64 | |
2217 if (UseCompressedOops && _offset != 0) { | |
2218 if (klass() == NULL) { | |
2219 assert(this->isa_aryptr(), "only arrays without klass"); | |
2220 _is_ptr_to_narrowoop = true; | |
2221 } else if (_offset == oopDesc::klass_offset_in_bytes()) { | |
2222 _is_ptr_to_narrowoop = true; | |
2223 } else if (this->isa_aryptr()) { | |
2224 _is_ptr_to_narrowoop = (klass()->is_obj_array_klass() && | |
2225 _offset != arrayOopDesc::length_offset_in_bytes()); | |
2226 } else if (klass() == ciEnv::current()->Class_klass() && | |
2227 (_offset == java_lang_Class::klass_offset_in_bytes() || | |
2228 _offset == java_lang_Class::array_klass_offset_in_bytes())) { | |
2229 // Special hidden fields from the Class. | |
2230 assert(this->isa_instptr(), "must be an instance ptr."); | |
2231 _is_ptr_to_narrowoop = true; | |
2232 } else if (klass()->is_instance_klass()) { | |
2233 ciInstanceKlass* ik = klass()->as_instance_klass(); | |
2234 ciField* field = NULL; | |
2235 if (this->isa_klassptr()) { | |
2236 // Perm objects don't use compressed references, except for | |
2237 // static fields which are currently compressed. | |
2238 field = ik->get_field_by_offset(_offset, true); | |
2239 if (field != NULL) { | |
2240 BasicType basic_elem_type = field->layout_type(); | |
2241 _is_ptr_to_narrowoop = (basic_elem_type == T_OBJECT || | |
2242 basic_elem_type == T_ARRAY); | |
2243 } | |
2244 } else if (_offset == OffsetBot || _offset == OffsetTop) { | |
2245 // unsafe access | |
2246 _is_ptr_to_narrowoop = true; | |
2247 } else { // exclude unsafe ops | |
2248 assert(this->isa_instptr(), "must be an instance ptr."); | |
2249 // Field which contains a compressed oop references. | |
2250 field = ik->get_field_by_offset(_offset, false); | |
2251 if (field != NULL) { | |
2252 BasicType basic_elem_type = field->layout_type(); | |
2253 _is_ptr_to_narrowoop = (basic_elem_type == T_OBJECT || | |
2254 basic_elem_type == T_ARRAY); | |
2255 } else if (klass()->equals(ciEnv::current()->Object_klass())) { | |
2256 // Compile::find_alias_type() cast exactness on all types to verify | |
2257 // that it does not affect alias type. | |
2258 _is_ptr_to_narrowoop = true; | |
2259 } else { | |
2260 // Type for the copy start in LibraryCallKit::inline_native_clone(). | |
2261 assert(!klass_is_exact(), "only non-exact klass"); | |
2262 _is_ptr_to_narrowoop = true; | |
2263 } | |
2264 } | |
2265 } | |
2266 } | |
2267 #endif | |
2268 } | |
2269 | |
0 | 2270 //------------------------------make------------------------------------------- |
2271 const TypeOopPtr *TypeOopPtr::make(PTR ptr, | |
958
c7e94e8fff43
6880053: assert(alloc_obj->as_CheckCastPP()->type() != TypeInstPtr::NOTNULL)
kvn
parents:
827
diff
changeset
|
2272 int offset, int instance_id) { |
0 | 2273 assert(ptr != Constant, "no constant generic pointers"); |
2274 ciKlass* k = ciKlassKlass::make(); | |
2275 bool xk = false; | |
2276 ciObject* o = NULL; | |
958
c7e94e8fff43
6880053: assert(alloc_obj->as_CheckCastPP()->type() != TypeInstPtr::NOTNULL)
kvn
parents:
827
diff
changeset
|
2277 return (TypeOopPtr*)(new TypeOopPtr(OopPtr, ptr, k, xk, o, offset, instance_id))->hashcons(); |
0 | 2278 } |
2279 | |
2280 | |
2281 //------------------------------cast_to_ptr_type------------------------------- | |
2282 const Type *TypeOopPtr::cast_to_ptr_type(PTR ptr) const { | |
2283 assert(_base == OopPtr, "subclass must override cast_to_ptr_type"); | |
2284 if( ptr == _ptr ) return this; | |
992 | 2285 return make(ptr, _offset, _instance_id); |
0 | 2286 } |
2287 | |
247 | 2288 //-----------------------------cast_to_instance_id---------------------------- |
223 | 2289 const TypeOopPtr *TypeOopPtr::cast_to_instance_id(int instance_id) const { |
0 | 2290 // There are no instances of a general oop. |
2291 // Return self unchanged. | |
2292 return this; | |
2293 } | |
2294 | |
2295 //-----------------------------cast_to_exactness------------------------------- | |
2296 const Type *TypeOopPtr::cast_to_exactness(bool klass_is_exact) const { | |
2297 // There is no such thing as an exact general oop. | |
2298 // Return self unchanged. | |
2299 return this; | |
2300 } | |
2301 | |
2302 | |
2303 //------------------------------as_klass_type---------------------------------- | |
2304 // Return the klass type corresponding to this instance or array type. | |
2305 // It is the type that is loaded from an object of this type. | |
2306 const TypeKlassPtr* TypeOopPtr::as_klass_type() const { | |
2307 ciKlass* k = klass(); | |
2308 bool xk = klass_is_exact(); | |
2309 if (k == NULL || !k->is_java_klass()) | |
2310 return TypeKlassPtr::OBJECT; | |
2311 else | |
2312 return TypeKlassPtr::make(xk? Constant: NotNull, k, 0); | |
2313 } | |
2314 | |
2315 | |
2316 //------------------------------meet------------------------------------------- | |
2317 // Compute the MEET of two types. It returns a new Type object. | |
2318 const Type *TypeOopPtr::xmeet( const Type *t ) const { | |
2319 // Perform a fast test for common case; meeting the same types together. | |
2320 if( this == t ) return this; // Meeting same type-rep? | |
2321 | |
2322 // Current "this->_base" is OopPtr | |
2323 switch (t->base()) { // switch on original type | |
2324 | |
2325 case Int: // Mixing ints & oops happens when javac | |
2326 case Long: // reuses local variables | |
2327 case FloatTop: | |
2328 case FloatCon: | |
2329 case FloatBot: | |
2330 case DoubleTop: | |
2331 case DoubleCon: | |
2332 case DoubleBot: | |
293
c3e045194476
6731641: assert(m->adr_type() == mach->adr_type(),"matcher should not change adr type")
kvn
parents:
247
diff
changeset
|
2333 case NarrowOop: |
0 | 2334 case Bottom: // Ye Olde Default |
2335 return Type::BOTTOM; | |
2336 case Top: | |
2337 return this; | |
2338 | |
2339 default: // All else is a mistake | |
2340 typerr(t); | |
2341 | |
2342 case RawPtr: | |
2343 return TypePtr::BOTTOM; // Oop meet raw is not well defined | |
2344 | |
2345 case AnyPtr: { | |
2346 // Found an AnyPtr type vs self-OopPtr type | |
2347 const TypePtr *tp = t->is_ptr(); | |
2348 int offset = meet_offset(tp->offset()); | |
2349 PTR ptr = meet_ptr(tp->ptr()); | |
2350 switch (tp->ptr()) { | |
2351 case Null: | |
2352 if (ptr == Null) return TypePtr::make(AnyPtr, ptr, offset); | |
2353 // else fall through: | |
2354 case TopPTR: | |
992 | 2355 case AnyNull: { |
2356 int instance_id = meet_instance_id(InstanceTop); | |
2357 return make(ptr, offset, instance_id); | |
2358 } | |
0 | 2359 case BotPTR: |
2360 case NotNull: | |
2361 return TypePtr::make(AnyPtr, ptr, offset); | |
2362 default: typerr(t); | |
2363 } | |
2364 } | |
2365 | |
2366 case OopPtr: { // Meeting to other OopPtrs | |
2367 const TypeOopPtr *tp = t->is_oopptr(); | |
958
c7e94e8fff43
6880053: assert(alloc_obj->as_CheckCastPP()->type() != TypeInstPtr::NOTNULL)
kvn
parents:
827
diff
changeset
|
2368 int instance_id = meet_instance_id(tp->instance_id()); |
c7e94e8fff43
6880053: assert(alloc_obj->as_CheckCastPP()->type() != TypeInstPtr::NOTNULL)
kvn
parents:
827
diff
changeset
|
2369 return make( meet_ptr(tp->ptr()), meet_offset(tp->offset()), instance_id ); |
0 | 2370 } |
2371 | |
2372 case InstPtr: // For these, flip the call around to cut down | |
2373 case KlassPtr: // on the cases I have to handle. | |
2374 case AryPtr: | |
2375 return t->xmeet(this); // Call in reverse direction | |
2376 | |
2377 } // End of switch | |
2378 return this; // Return the double constant | |
2379 } | |
2380 | |
2381 | |
2382 //------------------------------xdual------------------------------------------ | |
2383 // Dual of a pure heap pointer. No relevant klass or oop information. | |
2384 const Type *TypeOopPtr::xdual() const { | |
2385 assert(klass() == ciKlassKlass::make(), "no klasses here"); | |
2386 assert(const_oop() == NULL, "no constants here"); | |
223 | 2387 return new TypeOopPtr(_base, dual_ptr(), klass(), klass_is_exact(), const_oop(), dual_offset(), dual_instance_id() ); |
0 | 2388 } |
2389 | |
2390 //--------------------------make_from_klass_common----------------------------- | |
2391 // Computes the element-type given a klass. | |
2392 const TypeOopPtr* TypeOopPtr::make_from_klass_common(ciKlass *klass, bool klass_change, bool try_for_exact) { | |
2393 assert(klass->is_java_klass(), "must be java language klass"); | |
2394 if (klass->is_instance_klass()) { | |
2395 Compile* C = Compile::current(); | |
2396 Dependencies* deps = C->dependencies(); | |
2397 assert((deps != NULL) == (C->method() != NULL && C->method()->code_size() > 0), "sanity"); | |
2398 // Element is an instance | |
2399 bool klass_is_exact = false; | |
2400 if (klass->is_loaded()) { | |
2401 // Try to set klass_is_exact. | |
2402 ciInstanceKlass* ik = klass->as_instance_klass(); | |
2403 klass_is_exact = ik->is_final(); | |
2404 if (!klass_is_exact && klass_change | |
2405 && deps != NULL && UseUniqueSubclasses) { | |
2406 ciInstanceKlass* sub = ik->unique_concrete_subklass(); | |
2407 if (sub != NULL) { | |
2408 deps->assert_abstract_with_unique_concrete_subtype(ik, sub); | |
2409 klass = ik = sub; | |
2410 klass_is_exact = sub->is_final(); | |
2411 } | |
2412 } | |
2413 if (!klass_is_exact && try_for_exact | |
2414 && deps != NULL && UseExactTypes) { | |
2415 if (!ik->is_interface() && !ik->has_subklass()) { | |
2416 // Add a dependence; if concrete subclass added we need to recompile | |
2417 deps->assert_leaf_type(ik); | |
2418 klass_is_exact = true; | |
2419 } | |
2420 } | |
2421 } | |
2422 return TypeInstPtr::make(TypePtr::BotPTR, klass, klass_is_exact, NULL, 0); | |
2423 } else if (klass->is_obj_array_klass()) { | |
2424 // Element is an object array. Recursively call ourself. | |
2425 const TypeOopPtr *etype = TypeOopPtr::make_from_klass_common(klass->as_obj_array_klass()->element_klass(), false, try_for_exact); | |
2426 bool xk = etype->klass_is_exact(); | |
2427 const TypeAry* arr0 = TypeAry::make(etype, TypeInt::POS); | |
2428 // We used to pass NotNull in here, asserting that the sub-arrays | |
2429 // are all not-null. This is not true in generally, as code can | |
2430 // slam NULLs down in the subarrays. | |
2431 const TypeAryPtr* arr = TypeAryPtr::make(TypePtr::BotPTR, arr0, klass, xk, 0); | |
2432 return arr; | |
2433 } else if (klass->is_type_array_klass()) { | |
2434 // Element is an typeArray | |
2435 const Type* etype = get_const_basic_type(klass->as_type_array_klass()->element_type()); | |
2436 const TypeAry* arr0 = TypeAry::make(etype, TypeInt::POS); | |
2437 // We used to pass NotNull in here, asserting that the array pointer | |
2438 // is not-null. That was not true in general. | |
2439 const TypeAryPtr* arr = TypeAryPtr::make(TypePtr::BotPTR, arr0, klass, true, 0); | |
2440 return arr; | |
2441 } else { | |
2442 ShouldNotReachHere(); | |
2443 return NULL; | |
2444 } | |
2445 } | |
2446 | |
2447 //------------------------------make_from_constant----------------------------- | |
2448 // Make a java pointer from an oop constant | |
989
148e5441d916
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
958
diff
changeset
|
2449 const TypeOopPtr* TypeOopPtr::make_from_constant(ciObject* o, bool require_constant) { |
1137
97125851f396
6829187: compiler optimizations required for JSR 292
twisti
parents:
1009
diff
changeset
|
2450 if (o->is_method_data() || o->is_method() || o->is_cpcache()) { |
0 | 2451 // Treat much like a typeArray of bytes, like below, but fake the type... |
2452 const Type* etype = (Type*)get_const_basic_type(T_BYTE); | |
2453 const TypeAry* arr0 = TypeAry::make(etype, TypeInt::POS); | |
2454 ciKlass *klass = ciTypeArrayKlass::make((BasicType) T_BYTE); | |
989
148e5441d916
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
958
diff
changeset
|
2455 assert(o->can_be_constant(), "method data oops should be tenured"); |
0 | 2456 const TypeAryPtr* arr = TypeAryPtr::make(TypePtr::Constant, o, arr0, klass, true, 0); |
2457 return arr; | |
2458 } else { | |
2459 assert(o->is_java_object(), "must be java language object"); | |
2460 assert(!o->is_null_object(), "null object not yet handled here."); | |
2461 ciKlass *klass = o->klass(); | |
2462 if (klass->is_instance_klass()) { | |
2463 // Element is an instance | |
989
148e5441d916
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
958
diff
changeset
|
2464 if (require_constant) { |
148e5441d916
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
958
diff
changeset
|
2465 if (!o->can_be_constant()) return NULL; |
148e5441d916
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
958
diff
changeset
|
2466 } else if (!o->should_be_constant()) { |
0 | 2467 return TypeInstPtr::make(TypePtr::NotNull, klass, true, NULL, 0); |
2468 } | |
2469 return TypeInstPtr::make(o); | |
2470 } else if (klass->is_obj_array_klass()) { | |
2471 // Element is an object array. Recursively call ourself. | |
2472 const Type *etype = | |
2473 TypeOopPtr::make_from_klass_raw(klass->as_obj_array_klass()->element_klass()); | |
2474 const TypeAry* arr0 = TypeAry::make(etype, TypeInt::make(o->as_array()->length())); | |
2475 // We used to pass NotNull in here, asserting that the sub-arrays | |
2476 // are all not-null. This is not true in generally, as code can | |
2477 // slam NULLs down in the subarrays. | |
989
148e5441d916
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
958
diff
changeset
|
2478 if (require_constant) { |
148e5441d916
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
958
diff
changeset
|
2479 if (!o->can_be_constant()) return NULL; |
148e5441d916
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
958
diff
changeset
|
2480 } else if (!o->should_be_constant()) { |
0 | 2481 return TypeAryPtr::make(TypePtr::NotNull, arr0, klass, true, 0); |
2482 } | |
2483 const TypeAryPtr* arr = TypeAryPtr::make(TypePtr::Constant, o, arr0, klass, true, 0); | |
2484 return arr; | |
2485 } else if (klass->is_type_array_klass()) { | |
2486 // Element is an typeArray | |
2487 const Type* etype = | |
2488 (Type*)get_const_basic_type(klass->as_type_array_klass()->element_type()); | |
2489 const TypeAry* arr0 = TypeAry::make(etype, TypeInt::make(o->as_array()->length())); | |
2490 // We used to pass NotNull in here, asserting that the array pointer | |
2491 // is not-null. That was not true in general. | |
989
148e5441d916
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
958
diff
changeset
|
2492 if (require_constant) { |
148e5441d916
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
958
diff
changeset
|
2493 if (!o->can_be_constant()) return NULL; |
148e5441d916
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
958
diff
changeset
|
2494 } else if (!o->should_be_constant()) { |
0 | 2495 return TypeAryPtr::make(TypePtr::NotNull, arr0, klass, true, 0); |
2496 } | |
2497 const TypeAryPtr* arr = TypeAryPtr::make(TypePtr::Constant, o, arr0, klass, true, 0); | |
2498 return arr; | |
2499 } | |
2500 } | |
2501 | |
2502 ShouldNotReachHere(); | |
2503 return NULL; | |
2504 } | |
2505 | |
2506 //------------------------------get_con---------------------------------------- | |
2507 intptr_t TypeOopPtr::get_con() const { | |
2508 assert( _ptr == Null || _ptr == Constant, "" ); | |
2509 assert( _offset >= 0, "" ); | |
2510 | |
2511 if (_offset != 0) { | |
2512 // After being ported to the compiler interface, the compiler no longer | |
2513 // directly manipulates the addresses of oops. Rather, it only has a pointer | |
2514 // to a handle at compile time. This handle is embedded in the generated | |
2515 // code and dereferenced at the time the nmethod is made. Until that time, | |
2516 // it is not reasonable to do arithmetic with the addresses of oops (we don't | |
2517 // have access to the addresses!). This does not seem to currently happen, | |
605 | 2518 // but this assertion here is to help prevent its occurence. |
0 | 2519 tty->print_cr("Found oop constant with non-zero offset"); |
2520 ShouldNotReachHere(); | |
2521 } | |
2522 | |
989
148e5441d916
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
958
diff
changeset
|
2523 return (intptr_t)const_oop()->constant_encoding(); |
0 | 2524 } |
2525 | |
2526 | |
2527 //-----------------------------filter------------------------------------------ | |
2528 // Do not allow interface-vs.-noninterface joins to collapse to top. | |
2529 const Type *TypeOopPtr::filter( const Type *kills ) const { | |
2530 | |
2531 const Type* ft = join(kills); | |
2532 const TypeInstPtr* ftip = ft->isa_instptr(); | |
2533 const TypeInstPtr* ktip = kills->isa_instptr(); | |
555 | 2534 const TypeKlassPtr* ftkp = ft->isa_klassptr(); |
2535 const TypeKlassPtr* ktkp = kills->isa_klassptr(); | |
0 | 2536 |
2537 if (ft->empty()) { | |
2538 // Check for evil case of 'this' being a class and 'kills' expecting an | |
2539 // interface. This can happen because the bytecodes do not contain | |
2540 // enough type info to distinguish a Java-level interface variable | |
2541 // from a Java-level object variable. If we meet 2 classes which | |
2542 // both implement interface I, but their meet is at 'j/l/O' which | |
2543 // doesn't implement I, we have no way to tell if the result should | |
2544 // be 'I' or 'j/l/O'. Thus we'll pick 'j/l/O'. If this then flows | |
2545 // into a Phi which "knows" it's an Interface type we'll have to | |
2546 // uplift the type. | |
2547 if (!empty() && ktip != NULL && ktip->is_loaded() && ktip->klass()->is_interface()) | |
2548 return kills; // Uplift to interface | |
555 | 2549 if (!empty() && ktkp != NULL && ktkp->klass()->is_loaded() && ktkp->klass()->is_interface()) |
2550 return kills; // Uplift to interface | |
0 | 2551 |
2552 return Type::TOP; // Canonical empty value | |
2553 } | |
2554 | |
2555 // If we have an interface-typed Phi or cast and we narrow to a class type, | |
2556 // the join should report back the class. However, if we have a J/L/Object | |
2557 // class-typed Phi and an interface flows in, it's possible that the meet & | |
2558 // join report an interface back out. This isn't possible but happens | |
2559 // because the type system doesn't interact well with interfaces. | |
2560 if (ftip != NULL && ktip != NULL && | |
2561 ftip->is_loaded() && ftip->klass()->is_interface() && | |
2562 ktip->is_loaded() && !ktip->klass()->is_interface()) { | |
2563 // Happens in a CTW of rt.jar, 320-341, no extra flags | |
1335
ae4032fb0a5b
6894807: No ClassCastException for HashAttributeSet constructors if run with -Xcomp
kvn
parents:
1009
diff
changeset
|
2564 assert(!ftip->klass_is_exact(), "interface could not be exact"); |
0 | 2565 return ktip->cast_to_ptr_type(ftip->ptr()); |
2566 } | |
1335
ae4032fb0a5b
6894807: No ClassCastException for HashAttributeSet constructors if run with -Xcomp
kvn
parents:
1009
diff
changeset
|
2567 // Interface klass type could be exact in opposite to interface type, |
ae4032fb0a5b
6894807: No ClassCastException for HashAttributeSet constructors if run with -Xcomp
kvn
parents:
1009
diff
changeset
|
2568 // return it here instead of incorrect Constant ptr J/L/Object (6894807). |
555 | 2569 if (ftkp != NULL && ktkp != NULL && |
2570 ftkp->is_loaded() && ftkp->klass()->is_interface() && | |
1335
ae4032fb0a5b
6894807: No ClassCastException for HashAttributeSet constructors if run with -Xcomp
kvn
parents:
1009
diff
changeset
|
2571 !ftkp->klass_is_exact() && // Keep exact interface klass |
555 | 2572 ktkp->is_loaded() && !ktkp->klass()->is_interface()) { |
2573 return ktkp->cast_to_ptr_type(ftkp->ptr()); | |
2574 } | |
0 | 2575 |
2576 return ft; | |
2577 } | |
2578 | |
2579 //------------------------------eq--------------------------------------------- | |
2580 // Structural equality check for Type representations | |
2581 bool TypeOopPtr::eq( const Type *t ) const { | |
2582 const TypeOopPtr *a = (const TypeOopPtr*)t; | |
2583 if (_klass_is_exact != a->_klass_is_exact || | |
2584 _instance_id != a->_instance_id) return false; | |
2585 ciObject* one = const_oop(); | |
2586 ciObject* two = a->const_oop(); | |
2587 if (one == NULL || two == NULL) { | |
2588 return (one == two) && TypePtr::eq(t); | |
2589 } else { | |
2590 return one->equals(two) && TypePtr::eq(t); | |
2591 } | |
2592 } | |
2593 | |
2594 //------------------------------hash------------------------------------------- | |
2595 // Type-specific hashing function. | |
2596 int TypeOopPtr::hash(void) const { | |
2597 return | |
2598 (const_oop() ? const_oop()->hash() : 0) + | |
2599 _klass_is_exact + | |
2600 _instance_id + | |
2601 TypePtr::hash(); | |
2602 } | |
2603 | |
2604 //------------------------------dump2------------------------------------------ | |
2605 #ifndef PRODUCT | |
2606 void TypeOopPtr::dump2( Dict &d, uint depth, outputStream *st ) const { | |
2607 st->print("oopptr:%s", ptr_msg[_ptr]); | |
2608 if( _klass_is_exact ) st->print(":exact"); | |
2609 if( const_oop() ) st->print(INTPTR_FORMAT, const_oop()); | |
2610 switch( _offset ) { | |
2611 case OffsetTop: st->print("+top"); break; | |
2612 case OffsetBot: st->print("+any"); break; | |
2613 case 0: break; | |
2614 default: st->print("+%d",_offset); break; | |
2615 } | |
223 | 2616 if (_instance_id == InstanceTop) |
2617 st->print(",iid=top"); | |
2618 else if (_instance_id != InstanceBot) | |
0 | 2619 st->print(",iid=%d",_instance_id); |
2620 } | |
2621 #endif | |
2622 | |
2623 //------------------------------singleton-------------------------------------- | |
2624 // TRUE if Type is a singleton type, FALSE otherwise. Singletons are simple | |
2625 // constants | |
2626 bool TypeOopPtr::singleton(void) const { | |
2627 // detune optimizer to not generate constant oop + constant offset as a constant! | |
2628 // TopPTR, Null, AnyNull, Constant are all singletons | |
2629 return (_offset == 0) && !below_centerline(_ptr); | |
2630 } | |
2631 | |
2632 //------------------------------add_offset------------------------------------- | |
306
af945ba2e739
6741738: TypePtr::add_offset() set incorrect offset when the add overflows
kvn
parents:
293
diff
changeset
|
2633 const TypePtr *TypeOopPtr::add_offset( intptr_t offset ) const { |
992 | 2634 return make( _ptr, xadd_offset(offset), _instance_id); |
0 | 2635 } |
2636 | |
223 | 2637 //------------------------------meet_instance_id-------------------------------- |
2638 int TypeOopPtr::meet_instance_id( int instance_id ) const { | |
2639 // Either is 'TOP' instance? Return the other instance! | |
2640 if( _instance_id == InstanceTop ) return instance_id; | |
2641 if( instance_id == InstanceTop ) return _instance_id; | |
2642 // If either is different, return 'BOTTOM' instance | |
2643 if( _instance_id != instance_id ) return InstanceBot; | |
2644 return _instance_id; | |
0 | 2645 } |
2646 | |
223 | 2647 //------------------------------dual_instance_id-------------------------------- |
2648 int TypeOopPtr::dual_instance_id( ) const { | |
2649 if( _instance_id == InstanceTop ) return InstanceBot; // Map TOP into BOTTOM | |
2650 if( _instance_id == InstanceBot ) return InstanceTop; // Map BOTTOM into TOP | |
2651 return _instance_id; // Map everything else into self | |
2652 } | |
2653 | |
2654 | |
0 | 2655 //============================================================================= |
2656 // Convenience common pre-built types. | |
2657 const TypeInstPtr *TypeInstPtr::NOTNULL; | |
2658 const TypeInstPtr *TypeInstPtr::BOTTOM; | |
2659 const TypeInstPtr *TypeInstPtr::MIRROR; | |
2660 const TypeInstPtr *TypeInstPtr::MARK; | |
2661 const TypeInstPtr *TypeInstPtr::KLASS; | |
2662 | |
2663 //------------------------------TypeInstPtr------------------------------------- | |
2664 TypeInstPtr::TypeInstPtr(PTR ptr, ciKlass* k, bool xk, ciObject* o, int off, int instance_id) | |
2665 : TypeOopPtr(InstPtr, ptr, k, xk, o, off, instance_id), _name(k->name()) { | |
2666 assert(k != NULL && | |
2667 (k->is_loaded() || o == NULL), | |
2668 "cannot have constants with non-loaded klass"); | |
2669 }; | |
2670 | |
2671 //------------------------------make------------------------------------------- | |
2672 const TypeInstPtr *TypeInstPtr::make(PTR ptr, | |
2673 ciKlass* k, | |
2674 bool xk, | |
2675 ciObject* o, | |
2676 int offset, | |
2677 int instance_id) { | |
2678 assert( !k->is_loaded() || k->is_instance_klass() || | |
2679 k->is_method_klass(), "Must be for instance or method"); | |
2680 // Either const_oop() is NULL or else ptr is Constant | |
2681 assert( (!o && ptr != Constant) || (o && ptr == Constant), | |
2682 "constant pointers must have a value supplied" ); | |
2683 // Ptr is never Null | |
2684 assert( ptr != Null, "NULL pointers are not typed" ); | |
2685 | |
247 | 2686 assert(instance_id <= 0 || xk || !UseExactTypes, "instances are always exactly typed"); |
0 | 2687 if (!UseExactTypes) xk = false; |
2688 if (ptr == Constant) { | |
2689 // Note: This case includes meta-object constants, such as methods. | |
2690 xk = true; | |
2691 } else if (k->is_loaded()) { | |
2692 ciInstanceKlass* ik = k->as_instance_klass(); | |
2693 if (!xk && ik->is_final()) xk = true; // no inexact final klass | |
2694 if (xk && ik->is_interface()) xk = false; // no exact interface | |
2695 } | |
2696 | |
2697 // Now hash this baby | |
2698 TypeInstPtr *result = | |
2699 (TypeInstPtr*)(new TypeInstPtr(ptr, k, xk, o ,offset, instance_id))->hashcons(); | |
2700 | |
2701 return result; | |
2702 } | |
2703 | |
2704 | |
2705 //------------------------------cast_to_ptr_type------------------------------- | |
2706 const Type *TypeInstPtr::cast_to_ptr_type(PTR ptr) const { | |
2707 if( ptr == _ptr ) return this; | |
2708 // Reconstruct _sig info here since not a problem with later lazy | |
2709 // construction, _sig will show up on demand. | |
223 | 2710 return make(ptr, klass(), klass_is_exact(), const_oop(), _offset, _instance_id); |
0 | 2711 } |
2712 | |
2713 | |
2714 //-----------------------------cast_to_exactness------------------------------- | |
2715 const Type *TypeInstPtr::cast_to_exactness(bool klass_is_exact) const { | |
2716 if( klass_is_exact == _klass_is_exact ) return this; | |
2717 if (!UseExactTypes) return this; | |
2718 if (!_klass->is_loaded()) return this; | |
2719 ciInstanceKlass* ik = _klass->as_instance_klass(); | |
2720 if( (ik->is_final() || _const_oop) ) return this; // cannot clear xk | |
2721 if( ik->is_interface() ) return this; // cannot set xk | |
2722 return make(ptr(), klass(), klass_is_exact, const_oop(), _offset, _instance_id); | |
2723 } | |
2724 | |
247 | 2725 //-----------------------------cast_to_instance_id---------------------------- |
223 | 2726 const TypeOopPtr *TypeInstPtr::cast_to_instance_id(int instance_id) const { |
2727 if( instance_id == _instance_id ) return this; | |
247 | 2728 return make(_ptr, klass(), _klass_is_exact, const_oop(), _offset, instance_id); |
0 | 2729 } |
2730 | |
2731 //------------------------------xmeet_unloaded--------------------------------- | |
2732 // Compute the MEET of two InstPtrs when at least one is unloaded. | |
2733 // Assume classes are different since called after check for same name/class-loader | |
2734 const TypeInstPtr *TypeInstPtr::xmeet_unloaded(const TypeInstPtr *tinst) const { | |
2735 int off = meet_offset(tinst->offset()); | |
2736 PTR ptr = meet_ptr(tinst->ptr()); | |
992 | 2737 int instance_id = meet_instance_id(tinst->instance_id()); |
0 | 2738 |
2739 const TypeInstPtr *loaded = is_loaded() ? this : tinst; | |
2740 const TypeInstPtr *unloaded = is_loaded() ? tinst : this; | |
2741 if( loaded->klass()->equals(ciEnv::current()->Object_klass()) ) { | |
2742 // | |
2743 // Meet unloaded class with java/lang/Object | |
2744 // | |
2745 // Meet | |
2746 // | Unloaded Class | |
2747 // Object | TOP | AnyNull | Constant | NotNull | BOTTOM | | |
2748 // =================================================================== | |
2749 // TOP | ..........................Unloaded......................| | |
2750 // AnyNull | U-AN |................Unloaded......................| | |
2751 // Constant | ... O-NN .................................. | O-BOT | | |
2752 // NotNull | ... O-NN .................................. | O-BOT | | |
2753 // BOTTOM | ........................Object-BOTTOM ..................| | |
2754 // | |
2755 assert(loaded->ptr() != TypePtr::Null, "insanity check"); | |
2756 // | |
2757 if( loaded->ptr() == TypePtr::TopPTR ) { return unloaded; } | |
992 | 2758 else if (loaded->ptr() == TypePtr::AnyNull) { return TypeInstPtr::make( ptr, unloaded->klass(), false, NULL, off, instance_id ); } |
0 | 2759 else if (loaded->ptr() == TypePtr::BotPTR ) { return TypeInstPtr::BOTTOM; } |
2760 else if (loaded->ptr() == TypePtr::Constant || loaded->ptr() == TypePtr::NotNull) { | |
2761 if (unloaded->ptr() == TypePtr::BotPTR ) { return TypeInstPtr::BOTTOM; } | |
2762 else { return TypeInstPtr::NOTNULL; } | |
2763 } | |
2764 else if( unloaded->ptr() == TypePtr::TopPTR ) { return unloaded; } | |
2765 | |
2766 return unloaded->cast_to_ptr_type(TypePtr::AnyNull)->is_instptr(); | |
2767 } | |
2768 | |
2769 // Both are unloaded, not the same class, not Object | |
2770 // Or meet unloaded with a different loaded class, not java/lang/Object | |
2771 if( ptr != TypePtr::BotPTR ) { | |
2772 return TypeInstPtr::NOTNULL; | |
2773 } | |
2774 return TypeInstPtr::BOTTOM; | |
2775 } | |
2776 | |
2777 | |
2778 //------------------------------meet------------------------------------------- | |
2779 // Compute the MEET of two types. It returns a new Type object. | |
2780 const Type *TypeInstPtr::xmeet( const Type *t ) const { | |
2781 // Perform a fast test for common case; meeting the same types together. | |
2782 if( this == t ) return this; // Meeting same type-rep? | |
2783 | |
2784 // Current "this->_base" is Pointer | |
2785 switch (t->base()) { // switch on original type | |
2786 | |
2787 case Int: // Mixing ints & oops happens when javac | |
2788 case Long: // reuses local variables | |
2789 case FloatTop: | |
2790 case FloatCon: | |
2791 case FloatBot: | |
2792 case DoubleTop: | |
2793 case DoubleCon: | |
2794 case DoubleBot: | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
2795 case NarrowOop: |
0 | 2796 case Bottom: // Ye Olde Default |
2797 return Type::BOTTOM; | |
2798 case Top: | |
2799 return this; | |
2800 | |
2801 default: // All else is a mistake | |
2802 typerr(t); | |
2803 | |
2804 case RawPtr: return TypePtr::BOTTOM; | |
2805 | |
2806 case AryPtr: { // All arrays inherit from Object class | |
2807 const TypeAryPtr *tp = t->is_aryptr(); | |
2808 int offset = meet_offset(tp->offset()); | |
2809 PTR ptr = meet_ptr(tp->ptr()); | |
223 | 2810 int instance_id = meet_instance_id(tp->instance_id()); |
0 | 2811 switch (ptr) { |
2812 case TopPTR: | |
2813 case AnyNull: // Fall 'down' to dual of object klass | |
2814 if (klass()->equals(ciEnv::current()->Object_klass())) { | |
223 | 2815 return TypeAryPtr::make(ptr, tp->ary(), tp->klass(), tp->klass_is_exact(), offset, instance_id); |
0 | 2816 } else { |
2817 // cannot subclass, so the meet has to fall badly below the centerline | |
2818 ptr = NotNull; | |
223 | 2819 instance_id = InstanceBot; |
2820 return TypeInstPtr::make( ptr, ciEnv::current()->Object_klass(), false, NULL, offset, instance_id); | |
0 | 2821 } |
2822 case Constant: | |
2823 case NotNull: | |
2824 case BotPTR: // Fall down to object klass | |
2825 // LCA is object_klass, but if we subclass from the top we can do better | |
2826 if( above_centerline(_ptr) ) { // if( _ptr == TopPTR || _ptr == AnyNull ) | |
2827 // If 'this' (InstPtr) is above the centerline and it is Object class | |
605 | 2828 // then we can subclass in the Java class hierarchy. |
0 | 2829 if (klass()->equals(ciEnv::current()->Object_klass())) { |
2830 // that is, tp's array type is a subtype of my klass | |
1279
2432acbee618
6930035: C2 type system incorrectly handles case j.l.Object->meet(constant AryPtr)
kvn
parents:
1137
diff
changeset
|
2831 return TypeAryPtr::make(ptr, (ptr == Constant ? tp->const_oop() : NULL), |
2432acbee618
6930035: C2 type system incorrectly handles case j.l.Object->meet(constant AryPtr)
kvn
parents:
1137
diff
changeset
|
2832 tp->ary(), tp->klass(), tp->klass_is_exact(), offset, instance_id); |
0 | 2833 } |
2834 } | |
2835 // The other case cannot happen, since I cannot be a subtype of an array. | |
2836 // The meet falls down to Object class below centerline. | |
2837 if( ptr == Constant ) | |
2838 ptr = NotNull; | |
223 | 2839 instance_id = InstanceBot; |
2840 return make( ptr, ciEnv::current()->Object_klass(), false, NULL, offset, instance_id ); | |
0 | 2841 default: typerr(t); |
2842 } | |
2843 } | |
2844 | |
2845 case OopPtr: { // Meeting to OopPtrs | |
2846 // Found a OopPtr type vs self-InstPtr type | |
958
c7e94e8fff43
6880053: assert(alloc_obj->as_CheckCastPP()->type() != TypeInstPtr::NOTNULL)
kvn
parents:
827
diff
changeset
|
2847 const TypeOopPtr *tp = t->is_oopptr(); |
0 | 2848 int offset = meet_offset(tp->offset()); |
2849 PTR ptr = meet_ptr(tp->ptr()); | |
2850 switch (tp->ptr()) { | |
2851 case TopPTR: | |
223 | 2852 case AnyNull: { |
2853 int instance_id = meet_instance_id(InstanceTop); | |
0 | 2854 return make(ptr, klass(), klass_is_exact(), |
223 | 2855 (ptr == Constant ? const_oop() : NULL), offset, instance_id); |
2856 } | |
0 | 2857 case NotNull: |
958
c7e94e8fff43
6880053: assert(alloc_obj->as_CheckCastPP()->type() != TypeInstPtr::NOTNULL)
kvn
parents:
827
diff
changeset
|
2858 case BotPTR: { |
c7e94e8fff43
6880053: assert(alloc_obj->as_CheckCastPP()->type() != TypeInstPtr::NOTNULL)
kvn
parents:
827
diff
changeset
|
2859 int instance_id = meet_instance_id(tp->instance_id()); |
c7e94e8fff43
6880053: assert(alloc_obj->as_CheckCastPP()->type() != TypeInstPtr::NOTNULL)
kvn
parents:
827
diff
changeset
|
2860 return TypeOopPtr::make(ptr, offset, instance_id); |
c7e94e8fff43
6880053: assert(alloc_obj->as_CheckCastPP()->type() != TypeInstPtr::NOTNULL)
kvn
parents:
827
diff
changeset
|
2861 } |
0 | 2862 default: typerr(t); |
2863 } | |
2864 } | |
2865 | |
2866 case AnyPtr: { // Meeting to AnyPtrs | |
2867 // Found an AnyPtr type vs self-InstPtr type | |
2868 const TypePtr *tp = t->is_ptr(); | |
2869 int offset = meet_offset(tp->offset()); | |
2870 PTR ptr = meet_ptr(tp->ptr()); | |
2871 switch (tp->ptr()) { | |
2872 case Null: | |
2873 if( ptr == Null ) return TypePtr::make( AnyPtr, ptr, offset ); | |
223 | 2874 // else fall through to AnyNull |
0 | 2875 case TopPTR: |
223 | 2876 case AnyNull: { |
2877 int instance_id = meet_instance_id(InstanceTop); | |
0 | 2878 return make( ptr, klass(), klass_is_exact(), |
223 | 2879 (ptr == Constant ? const_oop() : NULL), offset, instance_id); |
2880 } | |
0 | 2881 case NotNull: |
2882 case BotPTR: | |
2883 return TypePtr::make( AnyPtr, ptr, offset ); | |
2884 default: typerr(t); | |
2885 } | |
2886 } | |
2887 | |
2888 /* | |
2889 A-top } | |
2890 / | \ } Tops | |
2891 B-top A-any C-top } | |
2892 | / | \ | } Any-nulls | |
2893 B-any | C-any } | |
2894 | | | | |
2895 B-con A-con C-con } constants; not comparable across classes | |
2896 | | | | |
2897 B-not | C-not } | |
2898 | \ | / | } not-nulls | |
2899 B-bot A-not C-bot } | |
2900 \ | / } Bottoms | |
2901 A-bot } | |
2902 */ | |
2903 | |
2904 case InstPtr: { // Meeting 2 Oops? | |
2905 // Found an InstPtr sub-type vs self-InstPtr type | |
2906 const TypeInstPtr *tinst = t->is_instptr(); | |
2907 int off = meet_offset( tinst->offset() ); | |
2908 PTR ptr = meet_ptr( tinst->ptr() ); | |
223 | 2909 int instance_id = meet_instance_id(tinst->instance_id()); |
0 | 2910 |
2911 // Check for easy case; klasses are equal (and perhaps not loaded!) | |
2912 // If we have constants, then we created oops so classes are loaded | |
2913 // and we can handle the constants further down. This case handles | |
2914 // both-not-loaded or both-loaded classes | |
2915 if (ptr != Constant && klass()->equals(tinst->klass()) && klass_is_exact() == tinst->klass_is_exact()) { | |
2916 return make( ptr, klass(), klass_is_exact(), NULL, off, instance_id ); | |
2917 } | |
2918 | |
2919 // Classes require inspection in the Java klass hierarchy. Must be loaded. | |
2920 ciKlass* tinst_klass = tinst->klass(); | |
2921 ciKlass* this_klass = this->klass(); | |
2922 bool tinst_xk = tinst->klass_is_exact(); | |
2923 bool this_xk = this->klass_is_exact(); | |
2924 if (!tinst_klass->is_loaded() || !this_klass->is_loaded() ) { | |
2925 // One of these classes has not been loaded | |
2926 const TypeInstPtr *unloaded_meet = xmeet_unloaded(tinst); | |
2927 #ifndef PRODUCT | |
2928 if( PrintOpto && Verbose ) { | |
2929 tty->print("meet of unloaded classes resulted in: "); unloaded_meet->dump(); tty->cr(); | |
2930 tty->print(" this == "); this->dump(); tty->cr(); | |
2931 tty->print(" tinst == "); tinst->dump(); tty->cr(); | |
2932 } | |
2933 #endif | |
2934 return unloaded_meet; | |
2935 } | |
2936 | |
2937 // Handle mixing oops and interfaces first. | |
2938 if( this_klass->is_interface() && !tinst_klass->is_interface() ) { | |
2939 ciKlass *tmp = tinst_klass; // Swap interface around | |
2940 tinst_klass = this_klass; | |
2941 this_klass = tmp; | |
2942 bool tmp2 = tinst_xk; | |
2943 tinst_xk = this_xk; | |
2944 this_xk = tmp2; | |
2945 } | |
2946 if (tinst_klass->is_interface() && | |
2947 !(this_klass->is_interface() || | |
2948 // Treat java/lang/Object as an honorary interface, | |
2949 // because we need a bottom for the interface hierarchy. | |
2950 this_klass == ciEnv::current()->Object_klass())) { | |
2951 // Oop meets interface! | |
2952 | |
2953 // See if the oop subtypes (implements) interface. | |
2954 ciKlass *k; | |
2955 bool xk; | |
2956 if( this_klass->is_subtype_of( tinst_klass ) ) { | |
2957 // Oop indeed subtypes. Now keep oop or interface depending | |
2958 // on whether we are both above the centerline or either is | |
2959 // below the centerline. If we are on the centerline | |
2960 // (e.g., Constant vs. AnyNull interface), use the constant. | |
2961 k = below_centerline(ptr) ? tinst_klass : this_klass; | |
2962 // If we are keeping this_klass, keep its exactness too. | |
2963 xk = below_centerline(ptr) ? tinst_xk : this_xk; | |
2964 } else { // Does not implement, fall to Object | |
2965 // Oop does not implement interface, so mixing falls to Object | |
2966 // just like the verifier does (if both are above the | |
2967 // centerline fall to interface) | |
2968 k = above_centerline(ptr) ? tinst_klass : ciEnv::current()->Object_klass(); | |
2969 xk = above_centerline(ptr) ? tinst_xk : false; | |
2970 // Watch out for Constant vs. AnyNull interface. | |
2971 if (ptr == Constant) ptr = NotNull; // forget it was a constant | |
247 | 2972 instance_id = InstanceBot; |
0 | 2973 } |
2974 ciObject* o = NULL; // the Constant value, if any | |
2975 if (ptr == Constant) { | |
2976 // Find out which constant. | |
2977 o = (this_klass == klass()) ? const_oop() : tinst->const_oop(); | |
2978 } | |
223 | 2979 return make( ptr, k, xk, o, off, instance_id ); |
0 | 2980 } |
2981 | |
2982 // Either oop vs oop or interface vs interface or interface vs Object | |
2983 | |
2984 // !!! Here's how the symmetry requirement breaks down into invariants: | |
2985 // If we split one up & one down AND they subtype, take the down man. | |
2986 // If we split one up & one down AND they do NOT subtype, "fall hard". | |
2987 // If both are up and they subtype, take the subtype class. | |
2988 // If both are up and they do NOT subtype, "fall hard". | |
2989 // If both are down and they subtype, take the supertype class. | |
2990 // If both are down and they do NOT subtype, "fall hard". | |
2991 // Constants treated as down. | |
2992 | |
2993 // Now, reorder the above list; observe that both-down+subtype is also | |
2994 // "fall hard"; "fall hard" becomes the default case: | |
2995 // If we split one up & one down AND they subtype, take the down man. | |
2996 // If both are up and they subtype, take the subtype class. | |
2997 | |
2998 // If both are down and they subtype, "fall hard". | |
2999 // If both are down and they do NOT subtype, "fall hard". | |
3000 // If both are up and they do NOT subtype, "fall hard". | |
3001 // If we split one up & one down AND they do NOT subtype, "fall hard". | |
3002 | |
3003 // If a proper subtype is exact, and we return it, we return it exactly. | |
3004 // If a proper supertype is exact, there can be no subtyping relationship! | |
3005 // If both types are equal to the subtype, exactness is and-ed below the | |
3006 // centerline and or-ed above it. (N.B. Constants are always exact.) | |
3007 | |
3008 // Check for subtyping: | |
3009 ciKlass *subtype = NULL; | |
3010 bool subtype_exact = false; | |
3011 if( tinst_klass->equals(this_klass) ) { | |
3012 subtype = this_klass; | |
3013 subtype_exact = below_centerline(ptr) ? (this_xk & tinst_xk) : (this_xk | tinst_xk); | |
3014 } else if( !tinst_xk && this_klass->is_subtype_of( tinst_klass ) ) { | |
3015 subtype = this_klass; // Pick subtyping class | |
3016 subtype_exact = this_xk; | |
3017 } else if( !this_xk && tinst_klass->is_subtype_of( this_klass ) ) { | |
3018 subtype = tinst_klass; // Pick subtyping class | |
3019 subtype_exact = tinst_xk; | |
3020 } | |
3021 | |
3022 if( subtype ) { | |
3023 if( above_centerline(ptr) ) { // both are up? | |
3024 this_klass = tinst_klass = subtype; | |
3025 this_xk = tinst_xk = subtype_exact; | |
3026 } else if( above_centerline(this ->_ptr) && !above_centerline(tinst->_ptr) ) { | |
3027 this_klass = tinst_klass; // tinst is down; keep down man | |
3028 this_xk = tinst_xk; | |
3029 } else if( above_centerline(tinst->_ptr) && !above_centerline(this ->_ptr) ) { | |
3030 tinst_klass = this_klass; // this is down; keep down man | |
3031 tinst_xk = this_xk; | |
3032 } else { | |
3033 this_xk = subtype_exact; // either they are equal, or we'll do an LCA | |
3034 } | |
3035 } | |
3036 | |
3037 // Check for classes now being equal | |
3038 if (tinst_klass->equals(this_klass)) { | |
3039 // If the klasses are equal, the constants may still differ. Fall to | |
3040 // NotNull if they do (neither constant is NULL; that is a special case | |
3041 // handled elsewhere). | |
3042 ciObject* o = NULL; // Assume not constant when done | |
3043 ciObject* this_oop = const_oop(); | |
3044 ciObject* tinst_oop = tinst->const_oop(); | |
3045 if( ptr == Constant ) { | |
3046 if (this_oop != NULL && tinst_oop != NULL && | |
3047 this_oop->equals(tinst_oop) ) | |
3048 o = this_oop; | |
3049 else if (above_centerline(this ->_ptr)) | |
3050 o = tinst_oop; | |
3051 else if (above_centerline(tinst ->_ptr)) | |
3052 o = this_oop; | |
3053 else | |
3054 ptr = NotNull; | |
3055 } | |
3056 return make( ptr, this_klass, this_xk, o, off, instance_id ); | |
3057 } // Else classes are not equal | |
3058 | |
3059 // Since klasses are different, we require a LCA in the Java | |
3060 // class hierarchy - which means we have to fall to at least NotNull. | |
3061 if( ptr == TopPTR || ptr == AnyNull || ptr == Constant ) | |
3062 ptr = NotNull; | |
247 | 3063 instance_id = InstanceBot; |
0 | 3064 |
3065 // Now we find the LCA of Java classes | |
3066 ciKlass* k = this_klass->least_common_ancestor(tinst_klass); | |
223 | 3067 return make( ptr, k, false, NULL, off, instance_id ); |
0 | 3068 } // End of case InstPtr |
3069 | |
3070 case KlassPtr: | |
3071 return TypeInstPtr::BOTTOM; | |
3072 | |
3073 } // End of switch | |
3074 return this; // Return the double constant | |
3075 } | |
3076 | |
3077 | |
3078 //------------------------java_mirror_type-------------------------------------- | |
3079 ciType* TypeInstPtr::java_mirror_type() const { | |
3080 // must be a singleton type | |
3081 if( const_oop() == NULL ) return NULL; | |
3082 | |
3083 // must be of type java.lang.Class | |
3084 if( klass() != ciEnv::current()->Class_klass() ) return NULL; | |
3085 | |
3086 return const_oop()->as_instance()->java_mirror_type(); | |
3087 } | |
3088 | |
3089 | |
3090 //------------------------------xdual------------------------------------------ | |
3091 // Dual: do NOT dual on klasses. This means I do NOT understand the Java | |
605 | 3092 // inheritance mechanism. |
0 | 3093 const Type *TypeInstPtr::xdual() const { |
223 | 3094 return new TypeInstPtr( dual_ptr(), klass(), klass_is_exact(), const_oop(), dual_offset(), dual_instance_id() ); |
0 | 3095 } |
3096 | |
3097 //------------------------------eq--------------------------------------------- | |
3098 // Structural equality check for Type representations | |
3099 bool TypeInstPtr::eq( const Type *t ) const { | |
3100 const TypeInstPtr *p = t->is_instptr(); | |
3101 return | |
3102 klass()->equals(p->klass()) && | |
3103 TypeOopPtr::eq(p); // Check sub-type stuff | |
3104 } | |
3105 | |
3106 //------------------------------hash------------------------------------------- | |
3107 // Type-specific hashing function. | |
3108 int TypeInstPtr::hash(void) const { | |
3109 int hash = klass()->hash() + TypeOopPtr::hash(); | |
3110 return hash; | |
3111 } | |
3112 | |
3113 //------------------------------dump2------------------------------------------ | |
3114 // Dump oop Type | |
3115 #ifndef PRODUCT | |
3116 void TypeInstPtr::dump2( Dict &d, uint depth, outputStream *st ) const { | |
3117 // Print the name of the klass. | |
3118 klass()->print_name_on(st); | |
3119 | |
3120 switch( _ptr ) { | |
3121 case Constant: | |
3122 // TO DO: Make CI print the hex address of the underlying oop. | |
3123 if (WizardMode || Verbose) { | |
3124 const_oop()->print_oop(st); | |
3125 } | |
3126 case BotPTR: | |
3127 if (!WizardMode && !Verbose) { | |
3128 if( _klass_is_exact ) st->print(":exact"); | |
3129 break; | |
3130 } | |
3131 case TopPTR: | |
3132 case AnyNull: | |
3133 case NotNull: | |
3134 st->print(":%s", ptr_msg[_ptr]); | |
3135 if( _klass_is_exact ) st->print(":exact"); | |
3136 break; | |
3137 } | |
3138 | |
3139 if( _offset ) { // Dump offset, if any | |
3140 if( _offset == OffsetBot ) st->print("+any"); | |
3141 else if( _offset == OffsetTop ) st->print("+unknown"); | |
3142 else st->print("+%d", _offset); | |
3143 } | |
3144 | |
3145 st->print(" *"); | |
223 | 3146 if (_instance_id == InstanceTop) |
3147 st->print(",iid=top"); | |
3148 else if (_instance_id != InstanceBot) | |
0 | 3149 st->print(",iid=%d",_instance_id); |
3150 } | |
3151 #endif | |
3152 | |
3153 //------------------------------add_offset------------------------------------- | |
306
af945ba2e739
6741738: TypePtr::add_offset() set incorrect offset when the add overflows
kvn
parents:
293
diff
changeset
|
3154 const TypePtr *TypeInstPtr::add_offset( intptr_t offset ) const { |
0 | 3155 return make( _ptr, klass(), klass_is_exact(), const_oop(), xadd_offset(offset), _instance_id ); |
3156 } | |
3157 | |
3158 //============================================================================= | |
3159 // Convenience common pre-built types. | |
3160 const TypeAryPtr *TypeAryPtr::RANGE; | |
3161 const TypeAryPtr *TypeAryPtr::OOPS; | |
163 | 3162 const TypeAryPtr *TypeAryPtr::NARROWOOPS; |
0 | 3163 const TypeAryPtr *TypeAryPtr::BYTES; |
3164 const TypeAryPtr *TypeAryPtr::SHORTS; | |
3165 const TypeAryPtr *TypeAryPtr::CHARS; | |
3166 const TypeAryPtr *TypeAryPtr::INTS; | |
3167 const TypeAryPtr *TypeAryPtr::LONGS; | |
3168 const TypeAryPtr *TypeAryPtr::FLOATS; | |
3169 const TypeAryPtr *TypeAryPtr::DOUBLES; | |
3170 | |
3171 //------------------------------make------------------------------------------- | |
3172 const TypeAryPtr *TypeAryPtr::make( PTR ptr, const TypeAry *ary, ciKlass* k, bool xk, int offset, int instance_id ) { | |
3173 assert(!(k == NULL && ary->_elem->isa_int()), | |
3174 "integral arrays must be pre-equipped with a class"); | |
3175 if (!xk) xk = ary->ary_must_be_exact(); | |
247 | 3176 assert(instance_id <= 0 || xk || !UseExactTypes, "instances are always exactly typed"); |
0 | 3177 if (!UseExactTypes) xk = (ptr == Constant); |
3178 return (TypeAryPtr*)(new TypeAryPtr(ptr, NULL, ary, k, xk, offset, instance_id))->hashcons(); | |
3179 } | |
3180 | |
3181 //------------------------------make------------------------------------------- | |
3182 const TypeAryPtr *TypeAryPtr::make( PTR ptr, ciObject* o, const TypeAry *ary, ciKlass* k, bool xk, int offset, int instance_id ) { | |
3183 assert(!(k == NULL && ary->_elem->isa_int()), | |
3184 "integral arrays must be pre-equipped with a class"); | |
3185 assert( (ptr==Constant && o) || (ptr!=Constant && !o), "" ); | |
3186 if (!xk) xk = (o != NULL) || ary->ary_must_be_exact(); | |
247 | 3187 assert(instance_id <= 0 || xk || !UseExactTypes, "instances are always exactly typed"); |
0 | 3188 if (!UseExactTypes) xk = (ptr == Constant); |
3189 return (TypeAryPtr*)(new TypeAryPtr(ptr, o, ary, k, xk, offset, instance_id))->hashcons(); | |
3190 } | |
3191 | |
3192 //------------------------------cast_to_ptr_type------------------------------- | |
3193 const Type *TypeAryPtr::cast_to_ptr_type(PTR ptr) const { | |
3194 if( ptr == _ptr ) return this; | |
223 | 3195 return make(ptr, const_oop(), _ary, klass(), klass_is_exact(), _offset, _instance_id); |
0 | 3196 } |
3197 | |
3198 | |
3199 //-----------------------------cast_to_exactness------------------------------- | |
3200 const Type *TypeAryPtr::cast_to_exactness(bool klass_is_exact) const { | |
3201 if( klass_is_exact == _klass_is_exact ) return this; | |
3202 if (!UseExactTypes) return this; | |
3203 if (_ary->ary_must_be_exact()) return this; // cannot clear xk | |
3204 return make(ptr(), const_oop(), _ary, klass(), klass_is_exact, _offset, _instance_id); | |
3205 } | |
3206 | |
247 | 3207 //-----------------------------cast_to_instance_id---------------------------- |
223 | 3208 const TypeOopPtr *TypeAryPtr::cast_to_instance_id(int instance_id) const { |
3209 if( instance_id == _instance_id ) return this; | |
247 | 3210 return make(_ptr, const_oop(), _ary, klass(), _klass_is_exact, _offset, instance_id); |
0 | 3211 } |
3212 | |
3213 //-----------------------------narrow_size_type------------------------------- | |
3214 // Local cache for arrayOopDesc::max_array_length(etype), | |
3215 // which is kind of slow (and cached elsewhere by other users). | |
3216 static jint max_array_length_cache[T_CONFLICT+1]; | |
3217 static jint max_array_length(BasicType etype) { | |
3218 jint& cache = max_array_length_cache[etype]; | |
3219 jint res = cache; | |
3220 if (res == 0) { | |
3221 switch (etype) { | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
3222 case T_NARROWOOP: |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
3223 etype = T_OBJECT; |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
3224 break; |
0 | 3225 case T_CONFLICT: |
3226 case T_ILLEGAL: | |
3227 case T_VOID: | |
3228 etype = T_BYTE; // will produce conservatively high value | |
3229 } | |
3230 cache = res = arrayOopDesc::max_array_length(etype); | |
3231 } | |
3232 return res; | |
3233 } | |
3234 | |
3235 // Narrow the given size type to the index range for the given array base type. | |
3236 // Return NULL if the resulting int type becomes empty. | |
366
8261ee795323
6711100: 64bit fastdebug server vm crashes with assert(_base == Int,"Not an Int")
rasbold
parents:
306
diff
changeset
|
3237 const TypeInt* TypeAryPtr::narrow_size_type(const TypeInt* size) const { |
0 | 3238 jint hi = size->_hi; |
3239 jint lo = size->_lo; | |
3240 jint min_lo = 0; | |
366
8261ee795323
6711100: 64bit fastdebug server vm crashes with assert(_base == Int,"Not an Int")
rasbold
parents:
306
diff
changeset
|
3241 jint max_hi = max_array_length(elem()->basic_type()); |
0 | 3242 //if (index_not_size) --max_hi; // type of a valid array index, FTR |
3243 bool chg = false; | |
3244 if (lo < min_lo) { lo = min_lo; chg = true; } | |
3245 if (hi > max_hi) { hi = max_hi; chg = true; } | |
605 | 3246 // Negative length arrays will produce weird intermediate dead fast-path code |
0 | 3247 if (lo > hi) |
366
8261ee795323
6711100: 64bit fastdebug server vm crashes with assert(_base == Int,"Not an Int")
rasbold
parents:
306
diff
changeset
|
3248 return TypeInt::ZERO; |
0 | 3249 if (!chg) |
3250 return size; | |
3251 return TypeInt::make(lo, hi, Type::WidenMin); | |
3252 } | |
3253 | |
3254 //-------------------------------cast_to_size---------------------------------- | |
3255 const TypeAryPtr* TypeAryPtr::cast_to_size(const TypeInt* new_size) const { | |
3256 assert(new_size != NULL, ""); | |
366
8261ee795323
6711100: 64bit fastdebug server vm crashes with assert(_base == Int,"Not an Int")
rasbold
parents:
306
diff
changeset
|
3257 new_size = narrow_size_type(new_size); |
0 | 3258 if (new_size == size()) return this; |
3259 const TypeAry* new_ary = TypeAry::make(elem(), new_size); | |
223 | 3260 return make(ptr(), const_oop(), new_ary, klass(), klass_is_exact(), _offset, _instance_id); |
0 | 3261 } |
3262 | |
3263 | |
3264 //------------------------------eq--------------------------------------------- | |
3265 // Structural equality check for Type representations | |
3266 bool TypeAryPtr::eq( const Type *t ) const { | |
3267 const TypeAryPtr *p = t->is_aryptr(); | |
3268 return | |
3269 _ary == p->_ary && // Check array | |
3270 TypeOopPtr::eq(p); // Check sub-parts | |
3271 } | |
3272 | |
3273 //------------------------------hash------------------------------------------- | |
3274 // Type-specific hashing function. | |
3275 int TypeAryPtr::hash(void) const { | |
3276 return (intptr_t)_ary + TypeOopPtr::hash(); | |
3277 } | |
3278 | |
3279 //------------------------------meet------------------------------------------- | |
3280 // Compute the MEET of two types. It returns a new Type object. | |
3281 const Type *TypeAryPtr::xmeet( const Type *t ) const { | |
3282 // Perform a fast test for common case; meeting the same types together. | |
3283 if( this == t ) return this; // Meeting same type-rep? | |
3284 // Current "this->_base" is Pointer | |
3285 switch (t->base()) { // switch on original type | |
3286 | |
3287 // Mixing ints & oops happens when javac reuses local variables | |
3288 case Int: | |
3289 case Long: | |
3290 case FloatTop: | |
3291 case FloatCon: | |
3292 case FloatBot: | |
3293 case DoubleTop: | |
3294 case DoubleCon: | |
3295 case DoubleBot: | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
3296 case NarrowOop: |
0 | 3297 case Bottom: // Ye Olde Default |
3298 return Type::BOTTOM; | |
3299 case Top: | |
3300 return this; | |
3301 | |
3302 default: // All else is a mistake | |
3303 typerr(t); | |
3304 | |
3305 case OopPtr: { // Meeting to OopPtrs | |
3306 // Found a OopPtr type vs self-AryPtr type | |
958
c7e94e8fff43
6880053: assert(alloc_obj->as_CheckCastPP()->type() != TypeInstPtr::NOTNULL)
kvn
parents:
827
diff
changeset
|
3307 const TypeOopPtr *tp = t->is_oopptr(); |
0 | 3308 int offset = meet_offset(tp->offset()); |
3309 PTR ptr = meet_ptr(tp->ptr()); | |
3310 switch (tp->ptr()) { | |
3311 case TopPTR: | |
223 | 3312 case AnyNull: { |
3313 int instance_id = meet_instance_id(InstanceTop); | |
3314 return make(ptr, (ptr == Constant ? const_oop() : NULL), | |
3315 _ary, _klass, _klass_is_exact, offset, instance_id); | |
3316 } | |
0 | 3317 case BotPTR: |
958
c7e94e8fff43
6880053: assert(alloc_obj->as_CheckCastPP()->type() != TypeInstPtr::NOTNULL)
kvn
parents:
827
diff
changeset
|
3318 case NotNull: { |
c7e94e8fff43
6880053: assert(alloc_obj->as_CheckCastPP()->type() != TypeInstPtr::NOTNULL)
kvn
parents:
827
diff
changeset
|
3319 int instance_id = meet_instance_id(tp->instance_id()); |
c7e94e8fff43
6880053: assert(alloc_obj->as_CheckCastPP()->type() != TypeInstPtr::NOTNULL)
kvn
parents:
827
diff
changeset
|
3320 return TypeOopPtr::make(ptr, offset, instance_id); |
c7e94e8fff43
6880053: assert(alloc_obj->as_CheckCastPP()->type() != TypeInstPtr::NOTNULL)
kvn
parents:
827
diff
changeset
|
3321 } |
0 | 3322 default: ShouldNotReachHere(); |
3323 } | |
3324 } | |
3325 | |
3326 case AnyPtr: { // Meeting two AnyPtrs | |
3327 // Found an AnyPtr type vs self-AryPtr type | |
3328 const TypePtr *tp = t->is_ptr(); | |
3329 int offset = meet_offset(tp->offset()); | |
3330 PTR ptr = meet_ptr(tp->ptr()); | |
3331 switch (tp->ptr()) { | |
3332 case TopPTR: | |
3333 return this; | |
3334 case BotPTR: | |
3335 case NotNull: | |
3336 return TypePtr::make(AnyPtr, ptr, offset); | |
3337 case Null: | |
3338 if( ptr == Null ) return TypePtr::make(AnyPtr, ptr, offset); | |
223 | 3339 // else fall through to AnyNull |
3340 case AnyNull: { | |
3341 int instance_id = meet_instance_id(InstanceTop); | |
3342 return make( ptr, (ptr == Constant ? const_oop() : NULL), | |
3343 _ary, _klass, _klass_is_exact, offset, instance_id); | |
3344 } | |
0 | 3345 default: ShouldNotReachHere(); |
3346 } | |
3347 } | |
3348 | |
3349 case RawPtr: return TypePtr::BOTTOM; | |
3350 | |
3351 case AryPtr: { // Meeting 2 references? | |
3352 const TypeAryPtr *tap = t->is_aryptr(); | |
3353 int off = meet_offset(tap->offset()); | |
3354 const TypeAry *tary = _ary->meet(tap->_ary)->is_ary(); | |
3355 PTR ptr = meet_ptr(tap->ptr()); | |
223 | 3356 int instance_id = meet_instance_id(tap->instance_id()); |
0 | 3357 ciKlass* lazy_klass = NULL; |
3358 if (tary->_elem->isa_int()) { | |
3359 // Integral array element types have irrelevant lattice relations. | |
3360 // It is the klass that determines array layout, not the element type. | |
3361 if (_klass == NULL) | |
3362 lazy_klass = tap->_klass; | |
3363 else if (tap->_klass == NULL || tap->_klass == _klass) { | |
3364 lazy_klass = _klass; | |
3365 } else { | |
3366 // Something like byte[int+] meets char[int+]. | |
3367 // This must fall to bottom, not (int[-128..65535])[int+]. | |
247 | 3368 instance_id = InstanceBot; |
0 | 3369 tary = TypeAry::make(Type::BOTTOM, tary->_size); |
3370 } | |
3371 } | |
3372 bool xk; | |
3373 switch (tap->ptr()) { | |
3374 case AnyNull: | |
3375 case TopPTR: | |
3376 // Compute new klass on demand, do not use tap->_klass | |
3377 xk = (tap->_klass_is_exact | this->_klass_is_exact); | |
223 | 3378 return make( ptr, const_oop(), tary, lazy_klass, xk, off, instance_id ); |
0 | 3379 case Constant: { |
3380 ciObject* o = const_oop(); | |
3381 if( _ptr == Constant ) { | |
3382 if( tap->const_oop() != NULL && !o->equals(tap->const_oop()) ) { | |
989
148e5441d916
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
958
diff
changeset
|
3383 xk = (klass() == tap->klass()); |
0 | 3384 ptr = NotNull; |
3385 o = NULL; | |
247 | 3386 instance_id = InstanceBot; |
989
148e5441d916
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
958
diff
changeset
|
3387 } else { |
148e5441d916
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
958
diff
changeset
|
3388 xk = true; |
0 | 3389 } |
3390 } else if( above_centerline(_ptr) ) { | |
3391 o = tap->const_oop(); | |
989
148e5441d916
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
958
diff
changeset
|
3392 xk = true; |
148e5441d916
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
958
diff
changeset
|
3393 } else { |
148e5441d916
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
958
diff
changeset
|
3394 xk = this->_klass_is_exact; |
0 | 3395 } |
223 | 3396 return TypeAryPtr::make( ptr, o, tary, tap->_klass, xk, off, instance_id ); |
0 | 3397 } |
3398 case NotNull: | |
3399 case BotPTR: | |
3400 // Compute new klass on demand, do not use tap->_klass | |
3401 if (above_centerline(this->_ptr)) | |
3402 xk = tap->_klass_is_exact; | |
3403 else if (above_centerline(tap->_ptr)) | |
3404 xk = this->_klass_is_exact; | |
3405 else xk = (tap->_klass_is_exact & this->_klass_is_exact) && | |
3406 (klass() == tap->klass()); // Only precise for identical arrays | |
223 | 3407 return TypeAryPtr::make( ptr, NULL, tary, lazy_klass, xk, off, instance_id ); |
0 | 3408 default: ShouldNotReachHere(); |
3409 } | |
3410 } | |
3411 | |
3412 // All arrays inherit from Object class | |
3413 case InstPtr: { | |
3414 const TypeInstPtr *tp = t->is_instptr(); | |
3415 int offset = meet_offset(tp->offset()); | |
3416 PTR ptr = meet_ptr(tp->ptr()); | |
223 | 3417 int instance_id = meet_instance_id(tp->instance_id()); |
0 | 3418 switch (ptr) { |
3419 case TopPTR: | |
3420 case AnyNull: // Fall 'down' to dual of object klass | |
3421 if( tp->klass()->equals(ciEnv::current()->Object_klass()) ) { | |
223 | 3422 return TypeAryPtr::make( ptr, _ary, _klass, _klass_is_exact, offset, instance_id ); |
0 | 3423 } else { |
3424 // cannot subclass, so the meet has to fall badly below the centerline | |
3425 ptr = NotNull; | |
223 | 3426 instance_id = InstanceBot; |
3427 return TypeInstPtr::make( ptr, ciEnv::current()->Object_klass(), false, NULL,offset, instance_id); | |
0 | 3428 } |
3429 case Constant: | |
3430 case NotNull: | |
3431 case BotPTR: // Fall down to object klass | |
3432 // LCA is object_klass, but if we subclass from the top we can do better | |
3433 if (above_centerline(tp->ptr())) { | |
3434 // If 'tp' is above the centerline and it is Object class | |
605 | 3435 // then we can subclass in the Java class hierarchy. |
0 | 3436 if( tp->klass()->equals(ciEnv::current()->Object_klass()) ) { |
3437 // that is, my array type is a subtype of 'tp' klass | |
1279
2432acbee618
6930035: C2 type system incorrectly handles case j.l.Object->meet(constant AryPtr)
kvn
parents:
1137
diff
changeset
|
3438 return make( ptr, (ptr == Constant ? const_oop() : NULL), |
2432acbee618
6930035: C2 type system incorrectly handles case j.l.Object->meet(constant AryPtr)
kvn
parents:
1137
diff
changeset
|
3439 _ary, _klass, _klass_is_exact, offset, instance_id ); |
0 | 3440 } |
3441 } | |
3442 // The other case cannot happen, since t cannot be a subtype of an array. | |
3443 // The meet falls down to Object class below centerline. | |
3444 if( ptr == Constant ) | |
3445 ptr = NotNull; | |
223 | 3446 instance_id = InstanceBot; |
3447 return TypeInstPtr::make( ptr, ciEnv::current()->Object_klass(), false, NULL,offset, instance_id); | |
0 | 3448 default: typerr(t); |
3449 } | |
3450 } | |
3451 | |
3452 case KlassPtr: | |
3453 return TypeInstPtr::BOTTOM; | |
3454 | |
3455 } | |
3456 return this; // Lint noise | |
3457 } | |
3458 | |
3459 //------------------------------xdual------------------------------------------ | |
3460 // Dual: compute field-by-field dual | |
3461 const Type *TypeAryPtr::xdual() const { | |
223 | 3462 return new TypeAryPtr( dual_ptr(), _const_oop, _ary->dual()->is_ary(),_klass, _klass_is_exact, dual_offset(), dual_instance_id() ); |
0 | 3463 } |
3464 | |
820
915cc9c5ebc6
6837094: False positive for "meet not symmetric" failure
kvn
parents:
628
diff
changeset
|
3465 //----------------------interface_vs_oop--------------------------------------- |
915cc9c5ebc6
6837094: False positive for "meet not symmetric" failure
kvn
parents:
628
diff
changeset
|
3466 #ifdef ASSERT |
915cc9c5ebc6
6837094: False positive for "meet not symmetric" failure
kvn
parents:
628
diff
changeset
|
3467 bool TypeAryPtr::interface_vs_oop(const Type *t) const { |
915cc9c5ebc6
6837094: False positive for "meet not symmetric" failure
kvn
parents:
628
diff
changeset
|
3468 const TypeAryPtr* t_aryptr = t->isa_aryptr(); |
915cc9c5ebc6
6837094: False positive for "meet not symmetric" failure
kvn
parents:
628
diff
changeset
|
3469 if (t_aryptr) { |
915cc9c5ebc6
6837094: False positive for "meet not symmetric" failure
kvn
parents:
628
diff
changeset
|
3470 return _ary->interface_vs_oop(t_aryptr->_ary); |
915cc9c5ebc6
6837094: False positive for "meet not symmetric" failure
kvn
parents:
628
diff
changeset
|
3471 } |
915cc9c5ebc6
6837094: False positive for "meet not symmetric" failure
kvn
parents:
628
diff
changeset
|
3472 return false; |
915cc9c5ebc6
6837094: False positive for "meet not symmetric" failure
kvn
parents:
628
diff
changeset
|
3473 } |
915cc9c5ebc6
6837094: False positive for "meet not symmetric" failure
kvn
parents:
628
diff
changeset
|
3474 #endif |
915cc9c5ebc6
6837094: False positive for "meet not symmetric" failure
kvn
parents:
628
diff
changeset
|
3475 |
0 | 3476 //------------------------------dump2------------------------------------------ |
3477 #ifndef PRODUCT | |
3478 void TypeAryPtr::dump2( Dict &d, uint depth, outputStream *st ) const { | |
3479 _ary->dump2(d,depth,st); | |
3480 switch( _ptr ) { | |
3481 case Constant: | |
3482 const_oop()->print(st); | |
3483 break; | |
3484 case BotPTR: | |
3485 if (!WizardMode && !Verbose) { | |
3486 if( _klass_is_exact ) st->print(":exact"); | |
3487 break; | |
3488 } | |
3489 case TopPTR: | |
3490 case AnyNull: | |
3491 case NotNull: | |
3492 st->print(":%s", ptr_msg[_ptr]); | |
3493 if( _klass_is_exact ) st->print(":exact"); | |
3494 break; | |
3495 } | |
3496 | |
64
b8f5ba577b02
6673473: (Escape Analysis) Add the instance's field information to PhiNode
kvn
parents:
0
diff
changeset
|
3497 if( _offset != 0 ) { |
b8f5ba577b02
6673473: (Escape Analysis) Add the instance's field information to PhiNode
kvn
parents:
0
diff
changeset
|
3498 int header_size = objArrayOopDesc::header_size() * wordSize; |
b8f5ba577b02
6673473: (Escape Analysis) Add the instance's field information to PhiNode
kvn
parents:
0
diff
changeset
|
3499 if( _offset == OffsetTop ) st->print("+undefined"); |
b8f5ba577b02
6673473: (Escape Analysis) Add the instance's field information to PhiNode
kvn
parents:
0
diff
changeset
|
3500 else if( _offset == OffsetBot ) st->print("+any"); |
b8f5ba577b02
6673473: (Escape Analysis) Add the instance's field information to PhiNode
kvn
parents:
0
diff
changeset
|
3501 else if( _offset < header_size ) st->print("+%d", _offset); |
b8f5ba577b02
6673473: (Escape Analysis) Add the instance's field information to PhiNode
kvn
parents:
0
diff
changeset
|
3502 else { |
b8f5ba577b02
6673473: (Escape Analysis) Add the instance's field information to PhiNode
kvn
parents:
0
diff
changeset
|
3503 BasicType basic_elem_type = elem()->basic_type(); |
b8f5ba577b02
6673473: (Escape Analysis) Add the instance's field information to PhiNode
kvn
parents:
0
diff
changeset
|
3504 int array_base = arrayOopDesc::base_offset_in_bytes(basic_elem_type); |
b8f5ba577b02
6673473: (Escape Analysis) Add the instance's field information to PhiNode
kvn
parents:
0
diff
changeset
|
3505 int elem_size = type2aelembytes(basic_elem_type); |
b8f5ba577b02
6673473: (Escape Analysis) Add the instance's field information to PhiNode
kvn
parents:
0
diff
changeset
|
3506 st->print("[%d]", (_offset - array_base)/elem_size); |
b8f5ba577b02
6673473: (Escape Analysis) Add the instance's field information to PhiNode
kvn
parents:
0
diff
changeset
|
3507 } |
b8f5ba577b02
6673473: (Escape Analysis) Add the instance's field information to PhiNode
kvn
parents:
0
diff
changeset
|
3508 } |
b8f5ba577b02
6673473: (Escape Analysis) Add the instance's field information to PhiNode
kvn
parents:
0
diff
changeset
|
3509 st->print(" *"); |
223 | 3510 if (_instance_id == InstanceTop) |
3511 st->print(",iid=top"); | |
3512 else if (_instance_id != InstanceBot) | |
0 | 3513 st->print(",iid=%d",_instance_id); |
3514 } | |
3515 #endif | |
3516 | |
3517 bool TypeAryPtr::empty(void) const { | |
3518 if (_ary->empty()) return true; | |
3519 return TypeOopPtr::empty(); | |
3520 } | |
3521 | |
3522 //------------------------------add_offset------------------------------------- | |
306
af945ba2e739
6741738: TypePtr::add_offset() set incorrect offset when the add overflows
kvn
parents:
293
diff
changeset
|
3523 const TypePtr *TypeAryPtr::add_offset( intptr_t offset ) const { |
0 | 3524 return make( _ptr, _const_oop, _ary, _klass, _klass_is_exact, xadd_offset(offset), _instance_id ); |
3525 } | |
3526 | |
3527 | |
3528 //============================================================================= | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
3529 const TypeNarrowOop *TypeNarrowOop::BOTTOM; |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
3530 const TypeNarrowOop *TypeNarrowOop::NULL_PTR; |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
3531 |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
3532 |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
3533 const TypeNarrowOop* TypeNarrowOop::make(const TypePtr* type) { |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
3534 return (const TypeNarrowOop*)(new TypeNarrowOop(type))->hashcons(); |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
3535 } |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
3536 |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
3537 //------------------------------hash------------------------------------------- |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
3538 // Type-specific hashing function. |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
3539 int TypeNarrowOop::hash(void) const { |
827
bf3489cc0aa0
6856025: assert(_base >= OopPtr && _base <= KlassPtr,"Not a Java pointer")
never
parents:
820
diff
changeset
|
3540 return _ptrtype->hash() + 7; |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
3541 } |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
3542 |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
3543 |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
3544 bool TypeNarrowOop::eq( const Type *t ) const { |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
3545 const TypeNarrowOop* tc = t->isa_narrowoop(); |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
3546 if (tc != NULL) { |
827
bf3489cc0aa0
6856025: assert(_base >= OopPtr && _base <= KlassPtr,"Not a Java pointer")
never
parents:
820
diff
changeset
|
3547 if (_ptrtype->base() != tc->_ptrtype->base()) { |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
3548 return false; |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
3549 } |
827
bf3489cc0aa0
6856025: assert(_base >= OopPtr && _base <= KlassPtr,"Not a Java pointer")
never
parents:
820
diff
changeset
|
3550 return tc->_ptrtype->eq(_ptrtype); |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
3551 } |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
3552 return false; |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
3553 } |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
3554 |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
3555 bool TypeNarrowOop::singleton(void) const { // TRUE if type is a singleton |
827
bf3489cc0aa0
6856025: assert(_base >= OopPtr && _base <= KlassPtr,"Not a Java pointer")
never
parents:
820
diff
changeset
|
3556 return _ptrtype->singleton(); |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
3557 } |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
3558 |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
3559 bool TypeNarrowOop::empty(void) const { |
827
bf3489cc0aa0
6856025: assert(_base >= OopPtr && _base <= KlassPtr,"Not a Java pointer")
never
parents:
820
diff
changeset
|
3560 return _ptrtype->empty(); |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
3561 } |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
3562 |
293
c3e045194476
6731641: assert(m->adr_type() == mach->adr_type(),"matcher should not change adr type")
kvn
parents:
247
diff
changeset
|
3563 //------------------------------xmeet------------------------------------------ |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
3564 // Compute the MEET of two types. It returns a new Type object. |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
3565 const Type *TypeNarrowOop::xmeet( const Type *t ) const { |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
3566 // Perform a fast test for common case; meeting the same types together. |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
3567 if( this == t ) return this; // Meeting same type-rep? |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
3568 |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
3569 |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
3570 // Current "this->_base" is OopPtr |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
3571 switch (t->base()) { // switch on original type |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
3572 |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
3573 case Int: // Mixing ints & oops happens when javac |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
3574 case Long: // reuses local variables |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
3575 case FloatTop: |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
3576 case FloatCon: |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
3577 case FloatBot: |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
3578 case DoubleTop: |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
3579 case DoubleCon: |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
3580 case DoubleBot: |
293
c3e045194476
6731641: assert(m->adr_type() == mach->adr_type(),"matcher should not change adr type")
kvn
parents:
247
diff
changeset
|
3581 case AnyPtr: |
c3e045194476
6731641: assert(m->adr_type() == mach->adr_type(),"matcher should not change adr type")
kvn
parents:
247
diff
changeset
|
3582 case RawPtr: |
c3e045194476
6731641: assert(m->adr_type() == mach->adr_type(),"matcher should not change adr type")
kvn
parents:
247
diff
changeset
|
3583 case OopPtr: |
c3e045194476
6731641: assert(m->adr_type() == mach->adr_type(),"matcher should not change adr type")
kvn
parents:
247
diff
changeset
|
3584 case InstPtr: |
c3e045194476
6731641: assert(m->adr_type() == mach->adr_type(),"matcher should not change adr type")
kvn
parents:
247
diff
changeset
|
3585 case KlassPtr: |
c3e045194476
6731641: assert(m->adr_type() == mach->adr_type(),"matcher should not change adr type")
kvn
parents:
247
diff
changeset
|
3586 case AryPtr: |
c3e045194476
6731641: assert(m->adr_type() == mach->adr_type(),"matcher should not change adr type")
kvn
parents:
247
diff
changeset
|
3587 |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
3588 case Bottom: // Ye Olde Default |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
3589 return Type::BOTTOM; |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
3590 case Top: |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
3591 return this; |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
3592 |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
3593 case NarrowOop: { |
827
bf3489cc0aa0
6856025: assert(_base >= OopPtr && _base <= KlassPtr,"Not a Java pointer")
never
parents:
820
diff
changeset
|
3594 const Type* result = _ptrtype->xmeet(t->make_ptr()); |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
3595 if (result->isa_ptr()) { |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
3596 return TypeNarrowOop::make(result->is_ptr()); |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
3597 } |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
3598 return result; |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
3599 } |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
3600 |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
3601 default: // All else is a mistake |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
3602 typerr(t); |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
3603 |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
3604 } // End of switch |
293
c3e045194476
6731641: assert(m->adr_type() == mach->adr_type(),"matcher should not change adr type")
kvn
parents:
247
diff
changeset
|
3605 |
c3e045194476
6731641: assert(m->adr_type() == mach->adr_type(),"matcher should not change adr type")
kvn
parents:
247
diff
changeset
|
3606 return this; |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
3607 } |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
3608 |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
3609 const Type *TypeNarrowOop::xdual() const { // Compute dual right now. |
827
bf3489cc0aa0
6856025: assert(_base >= OopPtr && _base <= KlassPtr,"Not a Java pointer")
never
parents:
820
diff
changeset
|
3610 const TypePtr* odual = _ptrtype->dual()->is_ptr(); |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
3611 return new TypeNarrowOop(odual); |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
3612 } |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
3613 |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
3614 const Type *TypeNarrowOop::filter( const Type *kills ) const { |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
3615 if (kills->isa_narrowoop()) { |
827
bf3489cc0aa0
6856025: assert(_base >= OopPtr && _base <= KlassPtr,"Not a Java pointer")
never
parents:
820
diff
changeset
|
3616 const Type* ft =_ptrtype->filter(kills->is_narrowoop()->_ptrtype); |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
3617 if (ft->empty()) |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
3618 return Type::TOP; // Canonical empty value |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
3619 if (ft->isa_ptr()) { |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
3620 return make(ft->isa_ptr()); |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
3621 } |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
3622 return ft; |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
3623 } else if (kills->isa_ptr()) { |
827
bf3489cc0aa0
6856025: assert(_base >= OopPtr && _base <= KlassPtr,"Not a Java pointer")
never
parents:
820
diff
changeset
|
3624 const Type* ft = _ptrtype->join(kills); |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
3625 if (ft->empty()) |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
3626 return Type::TOP; // Canonical empty value |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
3627 return ft; |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
3628 } else { |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
3629 return Type::TOP; |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
3630 } |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
3631 } |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
3632 |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
3633 |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
3634 intptr_t TypeNarrowOop::get_con() const { |
827
bf3489cc0aa0
6856025: assert(_base >= OopPtr && _base <= KlassPtr,"Not a Java pointer")
never
parents:
820
diff
changeset
|
3635 return _ptrtype->get_con(); |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
3636 } |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
3637 |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
3638 #ifndef PRODUCT |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
3639 void TypeNarrowOop::dump2( Dict & d, uint depth, outputStream *st ) const { |
417 | 3640 st->print("narrowoop: "); |
827
bf3489cc0aa0
6856025: assert(_base >= OopPtr && _base <= KlassPtr,"Not a Java pointer")
never
parents:
820
diff
changeset
|
3641 _ptrtype->dump2(d, depth, st); |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
3642 } |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
3643 #endif |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
3644 |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
3645 |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
3646 //============================================================================= |
0 | 3647 // Convenience common pre-built types. |
3648 | |
3649 // Not-null object klass or below | |
3650 const TypeKlassPtr *TypeKlassPtr::OBJECT; | |
3651 const TypeKlassPtr *TypeKlassPtr::OBJECT_OR_NULL; | |
3652 | |
3653 //------------------------------TypeKlasPtr------------------------------------ | |
3654 TypeKlassPtr::TypeKlassPtr( PTR ptr, ciKlass* klass, int offset ) | |
3655 : TypeOopPtr(KlassPtr, ptr, klass, (ptr==Constant), (ptr==Constant ? klass : NULL), offset, 0) { | |
3656 } | |
3657 | |
3658 //------------------------------make------------------------------------------- | |
3659 // ptr to klass 'k', if Constant, or possibly to a sub-klass if not a Constant | |
3660 const TypeKlassPtr *TypeKlassPtr::make( PTR ptr, ciKlass* k, int offset ) { | |
3661 assert( k != NULL, "Expect a non-NULL klass"); | |
3662 assert(k->is_instance_klass() || k->is_array_klass() || | |
3663 k->is_method_klass(), "Incorrect type of klass oop"); | |
3664 TypeKlassPtr *r = | |
3665 (TypeKlassPtr*)(new TypeKlassPtr(ptr, k, offset))->hashcons(); | |
3666 | |
3667 return r; | |
3668 } | |
3669 | |
3670 //------------------------------eq--------------------------------------------- | |
3671 // Structural equality check for Type representations | |
3672 bool TypeKlassPtr::eq( const Type *t ) const { | |
3673 const TypeKlassPtr *p = t->is_klassptr(); | |
3674 return | |
3675 klass()->equals(p->klass()) && | |
3676 TypeOopPtr::eq(p); | |
3677 } | |
3678 | |
3679 //------------------------------hash------------------------------------------- | |
3680 // Type-specific hashing function. | |
3681 int TypeKlassPtr::hash(void) const { | |
3682 return klass()->hash() + TypeOopPtr::hash(); | |
3683 } | |
3684 | |
3685 | |
3686 //------------------------------klass------------------------------------------ | |
3687 // Return the defining klass for this class | |
3688 ciKlass* TypeAryPtr::klass() const { | |
3689 if( _klass ) return _klass; // Return cached value, if possible | |
3690 | |
3691 // Oops, need to compute _klass and cache it | |
3692 ciKlass* k_ary = NULL; | |
3693 const TypeInstPtr *tinst; | |
3694 const TypeAryPtr *tary; | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
3695 const Type* el = elem(); |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
3696 if (el->isa_narrowoop()) { |
221
1e026f8da827
6710487: More than half of JDI Regression tests hang with COOPs in -Xcomp mode
kvn
parents:
183
diff
changeset
|
3697 el = el->make_ptr(); |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
3698 } |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
3699 |
0 | 3700 // Get element klass |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
3701 if ((tinst = el->isa_instptr()) != NULL) { |
0 | 3702 // Compute array klass from element klass |
3703 k_ary = ciObjArrayKlass::make(tinst->klass()); | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
3704 } else if ((tary = el->isa_aryptr()) != NULL) { |
0 | 3705 // Compute array klass from element klass |
3706 ciKlass* k_elem = tary->klass(); | |
3707 // If element type is something like bottom[], k_elem will be null. | |
3708 if (k_elem != NULL) | |
3709 k_ary = ciObjArrayKlass::make(k_elem); | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
3710 } else if ((el->base() == Type::Top) || |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
3711 (el->base() == Type::Bottom)) { |
0 | 3712 // element type of Bottom occurs from meet of basic type |
3713 // and object; Top occurs when doing join on Bottom. | |
3714 // Leave k_ary at NULL. | |
3715 } else { | |
3716 // Cannot compute array klass directly from basic type, | |
3717 // since subtypes of TypeInt all have basic type T_INT. | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
3718 assert(!el->isa_int(), |
0 | 3719 "integral arrays must be pre-equipped with a class"); |
3720 // Compute array klass directly from basic type | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
3721 k_ary = ciTypeArrayKlass::make(el->basic_type()); |
0 | 3722 } |
3723 | |
163 | 3724 if( this != TypeAryPtr::OOPS ) { |
0 | 3725 // The _klass field acts as a cache of the underlying |
3726 // ciKlass for this array type. In order to set the field, | |
3727 // we need to cast away const-ness. | |
3728 // | |
3729 // IMPORTANT NOTE: we *never* set the _klass field for the | |
3730 // type TypeAryPtr::OOPS. This Type is shared between all | |
3731 // active compilations. However, the ciKlass which represents | |
3732 // this Type is *not* shared between compilations, so caching | |
3733 // this value would result in fetching a dangling pointer. | |
3734 // | |
3735 // Recomputing the underlying ciKlass for each request is | |
3736 // a bit less efficient than caching, but calls to | |
3737 // TypeAryPtr::OOPS->klass() are not common enough to matter. | |
3738 ((TypeAryPtr*)this)->_klass = k_ary; | |
163 | 3739 if (UseCompressedOops && k_ary != NULL && k_ary->is_obj_array_klass() && |
3740 _offset != 0 && _offset != arrayOopDesc::length_offset_in_bytes()) { | |
3741 ((TypeAryPtr*)this)->_is_ptr_to_narrowoop = true; | |
3742 } | |
3743 } | |
0 | 3744 return k_ary; |
3745 } | |
3746 | |
3747 | |
3748 //------------------------------add_offset------------------------------------- | |
3749 // Access internals of klass object | |
306
af945ba2e739
6741738: TypePtr::add_offset() set incorrect offset when the add overflows
kvn
parents:
293
diff
changeset
|
3750 const TypePtr *TypeKlassPtr::add_offset( intptr_t offset ) const { |
0 | 3751 return make( _ptr, klass(), xadd_offset(offset) ); |
3752 } | |
3753 | |
3754 //------------------------------cast_to_ptr_type------------------------------- | |
3755 const Type *TypeKlassPtr::cast_to_ptr_type(PTR ptr) const { | |
557
465813e0303a
6794939: assert(_base == OopPtr,"subclass must override cast_to_ptr_type")
kvn
parents:
555
diff
changeset
|
3756 assert(_base == KlassPtr, "subclass must override cast_to_ptr_type"); |
0 | 3757 if( ptr == _ptr ) return this; |
3758 return make(ptr, _klass, _offset); | |
3759 } | |
3760 | |
3761 | |
3762 //-----------------------------cast_to_exactness------------------------------- | |
3763 const Type *TypeKlassPtr::cast_to_exactness(bool klass_is_exact) const { | |
3764 if( klass_is_exact == _klass_is_exact ) return this; | |
3765 if (!UseExactTypes) return this; | |
3766 return make(klass_is_exact ? Constant : NotNull, _klass, _offset); | |
3767 } | |
3768 | |
3769 | |
3770 //-----------------------------as_instance_type-------------------------------- | |
3771 // Corresponding type for an instance of the given class. | |
3772 // It will be NotNull, and exact if and only if the klass type is exact. | |
3773 const TypeOopPtr* TypeKlassPtr::as_instance_type() const { | |
3774 ciKlass* k = klass(); | |
3775 bool xk = klass_is_exact(); | |
3776 //return TypeInstPtr::make(TypePtr::NotNull, k, xk, NULL, 0); | |
3777 const TypeOopPtr* toop = TypeOopPtr::make_from_klass_raw(k); | |
3778 toop = toop->cast_to_ptr_type(TypePtr::NotNull)->is_oopptr(); | |
3779 return toop->cast_to_exactness(xk)->is_oopptr(); | |
3780 } | |
3781 | |
3782 | |
3783 //------------------------------xmeet------------------------------------------ | |
3784 // Compute the MEET of two types, return a new Type object. | |
3785 const Type *TypeKlassPtr::xmeet( const Type *t ) const { | |
3786 // Perform a fast test for common case; meeting the same types together. | |
3787 if( this == t ) return this; // Meeting same type-rep? | |
3788 | |
3789 // Current "this->_base" is Pointer | |
3790 switch (t->base()) { // switch on original type | |
3791 | |
3792 case Int: // Mixing ints & oops happens when javac | |
3793 case Long: // reuses local variables | |
3794 case FloatTop: | |
3795 case FloatCon: | |
3796 case FloatBot: | |
3797 case DoubleTop: | |
3798 case DoubleCon: | |
3799 case DoubleBot: | |
293
c3e045194476
6731641: assert(m->adr_type() == mach->adr_type(),"matcher should not change adr type")
kvn
parents:
247
diff
changeset
|
3800 case NarrowOop: |
0 | 3801 case Bottom: // Ye Olde Default |
3802 return Type::BOTTOM; | |
3803 case Top: | |
3804 return this; | |
3805 | |
3806 default: // All else is a mistake | |
3807 typerr(t); | |
3808 | |
3809 case RawPtr: return TypePtr::BOTTOM; | |
3810 | |
3811 case OopPtr: { // Meeting to OopPtrs | |
3812 // Found a OopPtr type vs self-KlassPtr type | |
3813 const TypePtr *tp = t->is_oopptr(); | |
3814 int offset = meet_offset(tp->offset()); | |
3815 PTR ptr = meet_ptr(tp->ptr()); | |
3816 switch (tp->ptr()) { | |
3817 case TopPTR: | |
3818 case AnyNull: | |
3819 return make(ptr, klass(), offset); | |
3820 case BotPTR: | |
3821 case NotNull: | |
3822 return TypePtr::make(AnyPtr, ptr, offset); | |
3823 default: typerr(t); | |
3824 } | |
3825 } | |
3826 | |
3827 case AnyPtr: { // Meeting to AnyPtrs | |
3828 // Found an AnyPtr type vs self-KlassPtr type | |
3829 const TypePtr *tp = t->is_ptr(); | |
3830 int offset = meet_offset(tp->offset()); | |
3831 PTR ptr = meet_ptr(tp->ptr()); | |
3832 switch (tp->ptr()) { | |
3833 case TopPTR: | |
3834 return this; | |
3835 case Null: | |
3836 if( ptr == Null ) return TypePtr::make( AnyPtr, ptr, offset ); | |
3837 case AnyNull: | |
3838 return make( ptr, klass(), offset ); | |
3839 case BotPTR: | |
3840 case NotNull: | |
3841 return TypePtr::make(AnyPtr, ptr, offset); | |
3842 default: typerr(t); | |
3843 } | |
3844 } | |
3845 | |
3846 case AryPtr: // Meet with AryPtr | |
3847 case InstPtr: // Meet with InstPtr | |
3848 return TypeInstPtr::BOTTOM; | |
3849 | |
3850 // | |
3851 // A-top } | |
3852 // / | \ } Tops | |
3853 // B-top A-any C-top } | |
3854 // | / | \ | } Any-nulls | |
3855 // B-any | C-any } | |
3856 // | | | | |
3857 // B-con A-con C-con } constants; not comparable across classes | |
3858 // | | | | |
3859 // B-not | C-not } | |
3860 // | \ | / | } not-nulls | |
3861 // B-bot A-not C-bot } | |
3862 // \ | / } Bottoms | |
3863 // A-bot } | |
3864 // | |
3865 | |
3866 case KlassPtr: { // Meet two KlassPtr types | |
3867 const TypeKlassPtr *tkls = t->is_klassptr(); | |
3868 int off = meet_offset(tkls->offset()); | |
3869 PTR ptr = meet_ptr(tkls->ptr()); | |
3870 | |
3871 // Check for easy case; klasses are equal (and perhaps not loaded!) | |
3872 // If we have constants, then we created oops so classes are loaded | |
3873 // and we can handle the constants further down. This case handles | |
3874 // not-loaded classes | |
3875 if( ptr != Constant && tkls->klass()->equals(klass()) ) { | |
3876 return make( ptr, klass(), off ); | |
3877 } | |
3878 | |
3879 // Classes require inspection in the Java klass hierarchy. Must be loaded. | |
3880 ciKlass* tkls_klass = tkls->klass(); | |
3881 ciKlass* this_klass = this->klass(); | |
3882 assert( tkls_klass->is_loaded(), "This class should have been loaded."); | |
3883 assert( this_klass->is_loaded(), "This class should have been loaded."); | |
3884 | |
3885 // If 'this' type is above the centerline and is a superclass of the | |
3886 // other, we can treat 'this' as having the same type as the other. | |
3887 if ((above_centerline(this->ptr())) && | |
3888 tkls_klass->is_subtype_of(this_klass)) { | |
3889 this_klass = tkls_klass; | |
3890 } | |
3891 // If 'tinst' type is above the centerline and is a superclass of the | |
3892 // other, we can treat 'tinst' as having the same type as the other. | |
3893 if ((above_centerline(tkls->ptr())) && | |
3894 this_klass->is_subtype_of(tkls_klass)) { | |
3895 tkls_klass = this_klass; | |
3896 } | |
3897 | |
3898 // Check for classes now being equal | |
3899 if (tkls_klass->equals(this_klass)) { | |
3900 // If the klasses are equal, the constants may still differ. Fall to | |
3901 // NotNull if they do (neither constant is NULL; that is a special case | |
3902 // handled elsewhere). | |
3903 ciObject* o = NULL; // Assume not constant when done | |
3904 ciObject* this_oop = const_oop(); | |
3905 ciObject* tkls_oop = tkls->const_oop(); | |
3906 if( ptr == Constant ) { | |
3907 if (this_oop != NULL && tkls_oop != NULL && | |
3908 this_oop->equals(tkls_oop) ) | |
3909 o = this_oop; | |
3910 else if (above_centerline(this->ptr())) | |
3911 o = tkls_oop; | |
3912 else if (above_centerline(tkls->ptr())) | |
3913 o = this_oop; | |
3914 else | |
3915 ptr = NotNull; | |
3916 } | |
3917 return make( ptr, this_klass, off ); | |
3918 } // Else classes are not equal | |
3919 | |
3920 // Since klasses are different, we require the LCA in the Java | |
3921 // class hierarchy - which means we have to fall to at least NotNull. | |
3922 if( ptr == TopPTR || ptr == AnyNull || ptr == Constant ) | |
3923 ptr = NotNull; | |
3924 // Now we find the LCA of Java classes | |
3925 ciKlass* k = this_klass->least_common_ancestor(tkls_klass); | |
3926 return make( ptr, k, off ); | |
3927 } // End of case KlassPtr | |
3928 | |
3929 } // End of switch | |
3930 return this; // Return the double constant | |
3931 } | |
3932 | |
3933 //------------------------------xdual------------------------------------------ | |
3934 // Dual: compute field-by-field dual | |
3935 const Type *TypeKlassPtr::xdual() const { | |
3936 return new TypeKlassPtr( dual_ptr(), klass(), dual_offset() ); | |
3937 } | |
3938 | |
3939 //------------------------------dump2------------------------------------------ | |
3940 // Dump Klass Type | |
3941 #ifndef PRODUCT | |
3942 void TypeKlassPtr::dump2( Dict & d, uint depth, outputStream *st ) const { | |
3943 switch( _ptr ) { | |
3944 case Constant: | |
3945 st->print("precise "); | |
3946 case NotNull: | |
3947 { | |
3948 const char *name = klass()->name()->as_utf8(); | |
3949 if( name ) { | |
3950 st->print("klass %s: " INTPTR_FORMAT, name, klass()); | |
3951 } else { | |
3952 ShouldNotReachHere(); | |
3953 } | |
3954 } | |
3955 case BotPTR: | |
3956 if( !WizardMode && !Verbose && !_klass_is_exact ) break; | |
3957 case TopPTR: | |
3958 case AnyNull: | |
3959 st->print(":%s", ptr_msg[_ptr]); | |
3960 if( _klass_is_exact ) st->print(":exact"); | |
3961 break; | |
3962 } | |
3963 | |
3964 if( _offset ) { // Dump offset, if any | |
3965 if( _offset == OffsetBot ) { st->print("+any"); } | |
3966 else if( _offset == OffsetTop ) { st->print("+unknown"); } | |
3967 else { st->print("+%d", _offset); } | |
3968 } | |
3969 | |
3970 st->print(" *"); | |
3971 } | |
3972 #endif | |
3973 | |
3974 | |
3975 | |
3976 //============================================================================= | |
3977 // Convenience common pre-built types. | |
3978 | |
3979 //------------------------------make------------------------------------------- | |
3980 const TypeFunc *TypeFunc::make( const TypeTuple *domain, const TypeTuple *range ) { | |
3981 return (TypeFunc*)(new TypeFunc(domain,range))->hashcons(); | |
3982 } | |
3983 | |
3984 //------------------------------make------------------------------------------- | |
3985 const TypeFunc *TypeFunc::make(ciMethod* method) { | |
3986 Compile* C = Compile::current(); | |
3987 const TypeFunc* tf = C->last_tf(method); // check cache | |
3988 if (tf != NULL) return tf; // The hit rate here is almost 50%. | |
3989 const TypeTuple *domain; | |
1137
97125851f396
6829187: compiler optimizations required for JSR 292
twisti
parents:
1009
diff
changeset
|
3990 if (method->is_static()) { |
0 | 3991 domain = TypeTuple::make_domain(NULL, method->signature()); |
3992 } else { | |
3993 domain = TypeTuple::make_domain(method->holder(), method->signature()); | |
3994 } | |
3995 const TypeTuple *range = TypeTuple::make_range(method->signature()); | |
3996 tf = TypeFunc::make(domain, range); | |
3997 C->set_last_tf(method, tf); // fill cache | |
3998 return tf; | |
3999 } | |
4000 | |
4001 //------------------------------meet------------------------------------------- | |
4002 // Compute the MEET of two types. It returns a new Type object. | |
4003 const Type *TypeFunc::xmeet( const Type *t ) const { | |
4004 // Perform a fast test for common case; meeting the same types together. | |
4005 if( this == t ) return this; // Meeting same type-rep? | |
4006 | |
4007 // Current "this->_base" is Func | |
4008 switch (t->base()) { // switch on original type | |
4009 | |
4010 case Bottom: // Ye Olde Default | |
4011 return t; | |
4012 | |
4013 default: // All else is a mistake | |
4014 typerr(t); | |
4015 | |
4016 case Top: | |
4017 break; | |
4018 } | |
4019 return this; // Return the double constant | |
4020 } | |
4021 | |
4022 //------------------------------xdual------------------------------------------ | |
4023 // Dual: compute field-by-field dual | |
4024 const Type *TypeFunc::xdual() const { | |
4025 return this; | |
4026 } | |
4027 | |
4028 //------------------------------eq--------------------------------------------- | |
4029 // Structural equality check for Type representations | |
4030 bool TypeFunc::eq( const Type *t ) const { | |
4031 const TypeFunc *a = (const TypeFunc*)t; | |
4032 return _domain == a->_domain && | |
4033 _range == a->_range; | |
4034 } | |
4035 | |
4036 //------------------------------hash------------------------------------------- | |
4037 // Type-specific hashing function. | |
4038 int TypeFunc::hash(void) const { | |
4039 return (intptr_t)_domain + (intptr_t)_range; | |
4040 } | |
4041 | |
4042 //------------------------------dump2------------------------------------------ | |
4043 // Dump Function Type | |
4044 #ifndef PRODUCT | |
4045 void TypeFunc::dump2( Dict &d, uint depth, outputStream *st ) const { | |
4046 if( _range->_cnt <= Parms ) | |
4047 st->print("void"); | |
4048 else { | |
4049 uint i; | |
4050 for (i = Parms; i < _range->_cnt-1; i++) { | |
4051 _range->field_at(i)->dump2(d,depth,st); | |
4052 st->print("/"); | |
4053 } | |
4054 _range->field_at(i)->dump2(d,depth,st); | |
4055 } | |
4056 st->print(" "); | |
4057 st->print("( "); | |
4058 if( !depth || d[this] ) { // Check for recursive dump | |
4059 st->print("...)"); | |
4060 return; | |
4061 } | |
4062 d.Insert((void*)this,(void*)this); // Stop recursion | |
4063 if (Parms < _domain->_cnt) | |
4064 _domain->field_at(Parms)->dump2(d,depth-1,st); | |
4065 for (uint i = Parms+1; i < _domain->_cnt; i++) { | |
4066 st->print(", "); | |
4067 _domain->field_at(i)->dump2(d,depth-1,st); | |
4068 } | |
4069 st->print(" )"); | |
4070 } | |
4071 | |
4072 //------------------------------print_flattened-------------------------------- | |
4073 // Print a 'flattened' signature | |
4074 static const char * const flat_type_msg[Type::lastype] = { | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
4075 "bad","control","top","int","long","_", "narrowoop", |
0 | 4076 "tuple:", "array:", |
4077 "ptr", "rawptr", "ptr", "ptr", "ptr", "ptr", | |
4078 "func", "abIO", "return_address", "mem", | |
4079 "float_top", "ftcon:", "flt", | |
4080 "double_top", "dblcon:", "dbl", | |
4081 "bottom" | |
4082 }; | |
4083 | |
4084 void TypeFunc::print_flattened() const { | |
4085 if( _range->_cnt <= Parms ) | |
4086 tty->print("void"); | |
4087 else { | |
4088 uint i; | |
4089 for (i = Parms; i < _range->_cnt-1; i++) | |
4090 tty->print("%s/",flat_type_msg[_range->field_at(i)->base()]); | |
4091 tty->print("%s",flat_type_msg[_range->field_at(i)->base()]); | |
4092 } | |
4093 tty->print(" ( "); | |
4094 if (Parms < _domain->_cnt) | |
4095 tty->print("%s",flat_type_msg[_domain->field_at(Parms)->base()]); | |
4096 for (uint i = Parms+1; i < _domain->_cnt; i++) | |
4097 tty->print(", %s",flat_type_msg[_domain->field_at(i)->base()]); | |
4098 tty->print(" )"); | |
4099 } | |
4100 #endif | |
4101 | |
4102 //------------------------------singleton-------------------------------------- | |
4103 // TRUE if Type is a singleton type, FALSE otherwise. Singletons are simple | |
4104 // constants (Ldi nodes). Singletons are integer, float or double constants | |
4105 // or a single symbol. | |
4106 bool TypeFunc::singleton(void) const { | |
4107 return false; // Never a singleton | |
4108 } | |
4109 | |
4110 bool TypeFunc::empty(void) const { | |
4111 return false; // Never empty | |
4112 } | |
4113 | |
4114 | |
4115 BasicType TypeFunc::return_type() const{ | |
4116 if (range()->cnt() == TypeFunc::Parms) { | |
4117 return T_VOID; | |
4118 } | |
4119 return range()->field_at(TypeFunc::Parms)->basic_type(); | |
4120 } |