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