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