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