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