Mercurial > hg > truffle
annotate src/share/vm/opto/type.cpp @ 14440:41b780b43b74
8029015: PPC64 (part 216): opto: trap based null and range checks
Summary: On PPC64 use tdi instruction that does a compare and raises SIGTRAP for NULL and range checks.
Reviewed-by: kvn
author | goetz |
---|---|
date | Wed, 27 Nov 2013 16:16:21 -0800 |
parents | 15120a36272d |
children | abec000618bf |
rev | line source |
---|---|
0 | 1 /* |
7623
203f64878aab
7102489: RFE: cleanup jlong typedef on __APPLE__and _LLP64 systems.
hseigel
parents:
6890
diff
changeset
|
2 * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. |
0 | 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * | |
5 * This code is free software; you can redistribute it and/or modify it | |
6 * under the terms of the GNU General Public License version 2 only, as | |
7 * published by the Free Software Foundation. | |
8 * | |
9 * This code is distributed in the hope that it will be useful, but WITHOUT | |
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
12 * version 2 for more details (a copy is included in the LICENSE file that | |
13 * accompanied this code). | |
14 * | |
15 * You should have received a copy of the GNU General Public License version | |
16 * 2 along with this work; if not, write to the Free Software Foundation, | |
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
18 * | |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1340
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1340
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1340
diff
changeset
|
21 * questions. |
0 | 22 * |
23 */ | |
24 | |
1972 | 25 #include "precompiled.hpp" |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6198
diff
changeset
|
26 #include "ci/ciMethodData.hpp" |
1972 | 27 #include "ci/ciTypeFlow.hpp" |
28 #include "classfile/symbolTable.hpp" | |
29 #include "classfile/systemDictionary.hpp" | |
30 #include "compiler/compileLog.hpp" | |
31 #include "libadt/dict.hpp" | |
32 #include "memory/gcLocker.hpp" | |
33 #include "memory/oopFactory.hpp" | |
34 #include "memory/resourceArea.hpp" | |
35 #include "oops/instanceKlass.hpp" | |
2376
c7f3d0b4570f
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
2354
diff
changeset
|
36 #include "oops/instanceMirrorKlass.hpp" |
1972 | 37 #include "oops/objArrayKlass.hpp" |
38 #include "oops/typeArrayKlass.hpp" | |
39 #include "opto/matcher.hpp" | |
40 #include "opto/node.hpp" | |
41 #include "opto/opcodes.hpp" | |
42 #include "opto/type.hpp" | |
43 | |
0 | 44 // Portions of code courtesy of Clifford Click |
45 | |
46 // Optimization - Graph Style | |
47 | |
48 // Dictionary of types shared among compilations. | |
49 Dict* Type::_shared_type_dict = NULL; | |
50 | |
51 // Array which maps compiler types to Basic Types | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6198
diff
changeset
|
52 Type::TypeInfo Type::_type_info[Type::lastype] = { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6198
diff
changeset
|
53 { Bad, T_ILLEGAL, "bad", false, Node::NotAMachineReg, relocInfo::none }, // Bad |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6198
diff
changeset
|
54 { Control, T_ILLEGAL, "control", false, 0, relocInfo::none }, // Control |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6198
diff
changeset
|
55 { Bottom, T_VOID, "top", false, 0, relocInfo::none }, // Top |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6198
diff
changeset
|
56 { Bad, T_INT, "int:", false, Op_RegI, relocInfo::none }, // Int |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6198
diff
changeset
|
57 { Bad, T_LONG, "long:", false, Op_RegL, relocInfo::none }, // Long |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6198
diff
changeset
|
58 { Half, T_VOID, "half", false, 0, relocInfo::none }, // Half |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6198
diff
changeset
|
59 { Bad, T_NARROWOOP, "narrowoop:", false, Op_RegN, relocInfo::none }, // NarrowOop |
6848
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6735
diff
changeset
|
60 { Bad, T_NARROWKLASS,"narrowklass:", false, Op_RegN, relocInfo::none }, // NarrowKlass |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6198
diff
changeset
|
61 { Bad, T_ILLEGAL, "tuple:", false, Node::NotAMachineReg, relocInfo::none }, // Tuple |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6198
diff
changeset
|
62 { Bad, T_ARRAY, "array:", false, Node::NotAMachineReg, relocInfo::none }, // Array |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6198
diff
changeset
|
63 |
14437
15120a36272d
8028767: PPC64: (part 121): smaller shared changes needed to build C2
goetz
parents:
13014
diff
changeset
|
64 #ifdef SPARC |
15120a36272d
8028767: PPC64: (part 121): smaller shared changes needed to build C2
goetz
parents:
13014
diff
changeset
|
65 { Bad, T_ILLEGAL, "vectors:", false, 0, relocInfo::none }, // VectorS |
15120a36272d
8028767: PPC64: (part 121): smaller shared changes needed to build C2
goetz
parents:
13014
diff
changeset
|
66 { Bad, T_ILLEGAL, "vectord:", false, Op_RegD, relocInfo::none }, // VectorD |
15120a36272d
8028767: PPC64: (part 121): smaller shared changes needed to build C2
goetz
parents:
13014
diff
changeset
|
67 { Bad, T_ILLEGAL, "vectorx:", false, 0, relocInfo::none }, // VectorX |
15120a36272d
8028767: PPC64: (part 121): smaller shared changes needed to build C2
goetz
parents:
13014
diff
changeset
|
68 { Bad, T_ILLEGAL, "vectory:", false, 0, relocInfo::none }, // VectorY |
15120a36272d
8028767: PPC64: (part 121): smaller shared changes needed to build C2
goetz
parents:
13014
diff
changeset
|
69 #elif defined(PPC64) |
15120a36272d
8028767: PPC64: (part 121): smaller shared changes needed to build C2
goetz
parents:
13014
diff
changeset
|
70 { Bad, T_ILLEGAL, "vectors:", false, 0, relocInfo::none }, // VectorS |
15120a36272d
8028767: PPC64: (part 121): smaller shared changes needed to build C2
goetz
parents:
13014
diff
changeset
|
71 { Bad, T_ILLEGAL, "vectord:", false, Op_RegL, relocInfo::none }, // VectorD |
15120a36272d
8028767: PPC64: (part 121): smaller shared changes needed to build C2
goetz
parents:
13014
diff
changeset
|
72 { Bad, T_ILLEGAL, "vectorx:", false, 0, relocInfo::none }, // VectorX |
15120a36272d
8028767: PPC64: (part 121): smaller shared changes needed to build C2
goetz
parents:
13014
diff
changeset
|
73 { Bad, T_ILLEGAL, "vectory:", false, 0, relocInfo::none }, // VectorY |
15120a36272d
8028767: PPC64: (part 121): smaller shared changes needed to build C2
goetz
parents:
13014
diff
changeset
|
74 #else // all other |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6198
diff
changeset
|
75 { 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
|
76 { 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
|
77 { 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
|
78 { Bad, T_ILLEGAL, "vectory:", false, Op_VecY, relocInfo::none }, // VectorY |
14437
15120a36272d
8028767: PPC64: (part 121): smaller shared changes needed to build C2
goetz
parents:
13014
diff
changeset
|
79 #endif |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6198
diff
changeset
|
80 { 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
|
81 { 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
|
82 { 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
|
83 { 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
|
84 { 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
|
85 { 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
|
86 { 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
|
87 { 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
|
88 { 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
|
89 { 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
|
90 { 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
|
91 { 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
|
92 { 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
|
93 { 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
|
94 { 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
|
95 { 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
|
96 { 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
|
97 { Top, T_ILLEGAL, "bottom", false, 0, relocInfo::none } // Bottom |
0 | 98 }; |
99 | |
100 // Map ideal registers (machine types) to ideal types | |
101 const Type *Type::mreg2type[_last_machine_leaf]; | |
102 | |
103 // Map basic types to canonical Type* pointers. | |
104 const Type* Type:: _const_basic_type[T_CONFLICT+1]; | |
105 | |
106 // Map basic types to constant-zero Types. | |
107 const Type* Type:: _zero_type[T_CONFLICT+1]; | |
108 | |
109 // Map basic types to array-body alias types. | |
110 const TypeAryPtr* TypeAryPtr::_array_body_type[T_CONFLICT+1]; | |
111 | |
112 //============================================================================= | |
113 // Convenience common pre-built types. | |
114 const Type *Type::ABIO; // State-of-machine only | |
115 const Type *Type::BOTTOM; // All values | |
116 const Type *Type::CONTROL; // Control only | |
117 const Type *Type::DOUBLE; // All doubles | |
118 const Type *Type::FLOAT; // All floats | |
119 const Type *Type::HALF; // Placeholder half of doublewide type | |
120 const Type *Type::MEMORY; // Abstract store only | |
121 const Type *Type::RETURN_ADDRESS; | |
122 const Type *Type::TOP; // No values in set | |
123 | |
124 //------------------------------get_const_type--------------------------- | |
125 const Type* Type::get_const_type(ciType* type) { | |
126 if (type == NULL) { | |
127 return NULL; | |
128 } else if (type->is_primitive_type()) { | |
129 return get_const_basic_type(type->basic_type()); | |
130 } else { | |
131 return TypeOopPtr::make_from_klass(type->as_klass()); | |
132 } | |
133 } | |
134 | |
135 //---------------------------array_element_basic_type--------------------------------- | |
136 // Mapping to the array element's basic type. | |
137 BasicType Type::array_element_basic_type() const { | |
138 BasicType bt = basic_type(); | |
139 if (bt == T_INT) { | |
140 if (this == TypeInt::INT) return T_INT; | |
141 if (this == TypeInt::CHAR) return T_CHAR; | |
142 if (this == TypeInt::BYTE) return T_BYTE; | |
143 if (this == TypeInt::BOOL) return T_BOOLEAN; | |
144 if (this == TypeInt::SHORT) return T_SHORT; | |
145 return T_VOID; | |
146 } | |
147 return bt; | |
148 } | |
149 | |
150 //---------------------------get_typeflow_type--------------------------------- | |
151 // Import a type produced by ciTypeFlow. | |
152 const Type* Type::get_typeflow_type(ciType* type) { | |
153 switch (type->basic_type()) { | |
154 | |
155 case ciTypeFlow::StateVector::T_BOTTOM: | |
156 assert(type == ciTypeFlow::StateVector::bottom_type(), ""); | |
157 return Type::BOTTOM; | |
158 | |
159 case ciTypeFlow::StateVector::T_TOP: | |
160 assert(type == ciTypeFlow::StateVector::top_type(), ""); | |
161 return Type::TOP; | |
162 | |
163 case ciTypeFlow::StateVector::T_NULL: | |
164 assert(type == ciTypeFlow::StateVector::null_type(), ""); | |
165 return TypePtr::NULL_PTR; | |
166 | |
167 case ciTypeFlow::StateVector::T_LONG2: | |
168 // The ciTypeFlow pass pushes a long, then the half. | |
169 // We do the same. | |
170 assert(type == ciTypeFlow::StateVector::long2_type(), ""); | |
171 return TypeInt::TOP; | |
172 | |
173 case ciTypeFlow::StateVector::T_DOUBLE2: | |
174 // The ciTypeFlow pass pushes double, then the half. | |
175 // Our convention is the same. | |
176 assert(type == ciTypeFlow::StateVector::double2_type(), ""); | |
177 return Type::TOP; | |
178 | |
179 case T_ADDRESS: | |
180 assert(type->is_return_address(), ""); | |
181 return TypeRawPtr::make((address)(intptr_t)type->as_return_address()->bci()); | |
182 | |
183 default: | |
184 // make sure we did not mix up the cases: | |
185 assert(type != ciTypeFlow::StateVector::bottom_type(), ""); | |
186 assert(type != ciTypeFlow::StateVector::top_type(), ""); | |
187 assert(type != ciTypeFlow::StateVector::null_type(), ""); | |
188 assert(type != ciTypeFlow::StateVector::long2_type(), ""); | |
189 assert(type != ciTypeFlow::StateVector::double2_type(), ""); | |
190 assert(!type->is_return_address(), ""); | |
191 | |
192 return Type::get_const_type(type); | |
193 } | |
194 } | |
195 | |
196 | |
12190
edb5ab0f3fe5
8001107: @Stable annotation for constant folding of lazily evaluated variables
vlivanov
parents:
10278
diff
changeset
|
197 //-----------------------make_from_constant------------------------------------ |
edb5ab0f3fe5
8001107: @Stable annotation for constant folding of lazily evaluated variables
vlivanov
parents:
10278
diff
changeset
|
198 const Type* Type::make_from_constant(ciConstant constant, |
edb5ab0f3fe5
8001107: @Stable annotation for constant folding of lazily evaluated variables
vlivanov
parents:
10278
diff
changeset
|
199 bool require_constant, bool is_autobox_cache) { |
edb5ab0f3fe5
8001107: @Stable annotation for constant folding of lazily evaluated variables
vlivanov
parents:
10278
diff
changeset
|
200 switch (constant.basic_type()) { |
edb5ab0f3fe5
8001107: @Stable annotation for constant folding of lazily evaluated variables
vlivanov
parents:
10278
diff
changeset
|
201 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
|
202 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
|
203 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
|
204 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
|
205 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
|
206 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
|
207 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
|
208 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
|
209 case T_ARRAY: |
edb5ab0f3fe5
8001107: @Stable annotation for constant folding of lazily evaluated variables
vlivanov
parents:
10278
diff
changeset
|
210 case T_OBJECT: |
edb5ab0f3fe5
8001107: @Stable annotation for constant folding of lazily evaluated variables
vlivanov
parents:
10278
diff
changeset
|
211 { |
edb5ab0f3fe5
8001107: @Stable annotation for constant folding of lazily evaluated variables
vlivanov
parents:
10278
diff
changeset
|
212 // cases: |
edb5ab0f3fe5
8001107: @Stable annotation for constant folding of lazily evaluated variables
vlivanov
parents:
10278
diff
changeset
|
213 // can_be_constant = (oop not scavengable || ScavengeRootsInCode != 0) |
edb5ab0f3fe5
8001107: @Stable annotation for constant folding of lazily evaluated variables
vlivanov
parents:
10278
diff
changeset
|
214 // should_be_constant = (oop not scavengable || ScavengeRootsInCode >= 2) |
edb5ab0f3fe5
8001107: @Stable annotation for constant folding of lazily evaluated variables
vlivanov
parents:
10278
diff
changeset
|
215 // 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
|
216 ciObject* oop_constant = constant.as_object(); |
edb5ab0f3fe5
8001107: @Stable annotation for constant folding of lazily evaluated variables
vlivanov
parents:
10278
diff
changeset
|
217 if (oop_constant->is_null_object()) { |
edb5ab0f3fe5
8001107: @Stable annotation for constant folding of lazily evaluated variables
vlivanov
parents:
10278
diff
changeset
|
218 return Type::get_zero_type(T_OBJECT); |
edb5ab0f3fe5
8001107: @Stable annotation for constant folding of lazily evaluated variables
vlivanov
parents:
10278
diff
changeset
|
219 } 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
|
220 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
|
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 } |
edb5ab0f3fe5
8001107: @Stable annotation for constant folding of lazily evaluated variables
vlivanov
parents:
10278
diff
changeset
|
224 // Fall through to failure |
edb5ab0f3fe5
8001107: @Stable annotation for constant folding of lazily evaluated variables
vlivanov
parents:
10278
diff
changeset
|
225 return NULL; |
edb5ab0f3fe5
8001107: @Stable annotation for constant folding of lazily evaluated variables
vlivanov
parents:
10278
diff
changeset
|
226 } |
edb5ab0f3fe5
8001107: @Stable annotation for constant folding of lazily evaluated variables
vlivanov
parents:
10278
diff
changeset
|
227 |
edb5ab0f3fe5
8001107: @Stable annotation for constant folding of lazily evaluated variables
vlivanov
parents:
10278
diff
changeset
|
228 |
0 | 229 //------------------------------make------------------------------------------- |
230 // Create a simple Type, with default empty symbol sets. Then hashcons it | |
231 // and look for an existing copy in the type dictionary. | |
232 const Type *Type::make( enum TYPES t ) { | |
233 return (new Type(t))->hashcons(); | |
234 } | |
223 | 235 |
0 | 236 //------------------------------cmp-------------------------------------------- |
237 int Type::cmp( const Type *const t1, const Type *const t2 ) { | |
238 if( t1->_base != t2->_base ) | |
239 return 1; // Missed badly | |
240 assert(t1 != t2 || t1->eq(t2), "eq must be reflexive"); | |
241 return !t1->eq(t2); // Return ZERO if equal | |
242 } | |
243 | |
244 //------------------------------hash------------------------------------------- | |
245 int Type::uhash( const Type *const t ) { | |
246 return t->hash(); | |
247 } | |
248 | |
1620
d678e3277048
6964479: widen normalization of small int and long values should be symmetric
kvn
parents:
1552
diff
changeset
|
249 #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
|
250 |
0 | 251 //--------------------------Initialize_shared---------------------------------- |
252 void Type::Initialize_shared(Compile* current) { | |
253 // This method does not need to be locked because the first system | |
254 // compilations (stub compilations) occur serially. If they are | |
255 // changed to proceed in parallel, then this section will need | |
256 // locking. | |
257 | |
258 Arena* save = current->type_arena(); | |
6197 | 259 Arena* shared_type_arena = new (mtCompiler)Arena(); |
0 | 260 |
261 current->set_type_arena(shared_type_arena); | |
262 _shared_type_dict = | |
263 new (shared_type_arena) Dict( (CmpKey)Type::cmp, (Hash)Type::uhash, | |
264 shared_type_arena, 128 ); | |
265 current->set_type_dict(_shared_type_dict); | |
266 | |
267 // Make shared pre-built types. | |
268 CONTROL = make(Control); // Control only | |
269 TOP = make(Top); // No values in set | |
270 MEMORY = make(Memory); // Abstract store only | |
271 ABIO = make(Abio); // State-of-machine only | |
272 RETURN_ADDRESS=make(Return_Address); | |
273 FLOAT = make(FloatBot); // All floats | |
274 DOUBLE = make(DoubleBot); // All doubles | |
275 BOTTOM = make(Bottom); // Everything | |
276 HALF = make(Half); // Placeholder half of doublewide type | |
277 | |
278 TypeF::ZERO = TypeF::make(0.0); // Float 0 (positive zero) | |
279 TypeF::ONE = TypeF::make(1.0); // Float 1 | |
280 | |
281 TypeD::ZERO = TypeD::make(0.0); // Double 0 (positive zero) | |
282 TypeD::ONE = TypeD::make(1.0); // Double 1 | |
283 | |
284 TypeInt::MINUS_1 = TypeInt::make(-1); // -1 | |
285 TypeInt::ZERO = TypeInt::make( 0); // 0 | |
286 TypeInt::ONE = TypeInt::make( 1); // 1 | |
287 TypeInt::BOOL = TypeInt::make(0,1, WidenMin); // 0 or 1, FALSE or TRUE. | |
288 TypeInt::CC = TypeInt::make(-1, 1, WidenMin); // -1, 0 or 1, condition codes | |
289 TypeInt::CC_LT = TypeInt::make(-1,-1, WidenMin); // == TypeInt::MINUS_1 | |
290 TypeInt::CC_GT = TypeInt::make( 1, 1, WidenMin); // == TypeInt::ONE | |
291 TypeInt::CC_EQ = TypeInt::make( 0, 0, WidenMin); // == TypeInt::ZERO | |
292 TypeInt::CC_LE = TypeInt::make(-1, 0, WidenMin); | |
293 TypeInt::CC_GE = TypeInt::make( 0, 1, WidenMin); // == TypeInt::BOOL | |
294 TypeInt::BYTE = TypeInt::make(-128,127, WidenMin); // Bytes | |
624 | 295 TypeInt::UBYTE = TypeInt::make(0, 255, WidenMin); // Unsigned Bytes |
0 | 296 TypeInt::CHAR = TypeInt::make(0,65535, WidenMin); // Java chars |
297 TypeInt::SHORT = TypeInt::make(-32768,32767, WidenMin); // Java shorts | |
298 TypeInt::POS = TypeInt::make(0,max_jint, WidenMin); // Non-neg values | |
299 TypeInt::POS1 = TypeInt::make(1,max_jint, WidenMin); // Positive values | |
300 TypeInt::INT = TypeInt::make(min_jint,max_jint, WidenMax); // 32-bit integers | |
301 TypeInt::SYMINT = TypeInt::make(-max_jint,max_jint,WidenMin); // symmetric range | |
302 // CmpL is overloaded both as the bytecode computation returning | |
303 // a trinary (-1,0,+1) integer result AND as an efficient long | |
304 // compare returning optimizer ideal-type flags. | |
305 assert( TypeInt::CC_LT == TypeInt::MINUS_1, "types must match for CmpL to work" ); | |
306 assert( TypeInt::CC_GT == TypeInt::ONE, "types must match for CmpL to work" ); | |
307 assert( TypeInt::CC_EQ == TypeInt::ZERO, "types must match for CmpL to work" ); | |
308 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
|
309 assert( (juint)(TypeInt::CC->_hi - TypeInt::CC->_lo) <= SMALLINT, "CC is truly small"); |
0 | 310 |
311 TypeLong::MINUS_1 = TypeLong::make(-1); // -1 | |
312 TypeLong::ZERO = TypeLong::make( 0); // 0 | |
313 TypeLong::ONE = TypeLong::make( 1); // 1 | |
314 TypeLong::POS = TypeLong::make(0,max_jlong, WidenMin); // Non-neg values | |
315 TypeLong::LONG = TypeLong::make(min_jlong,max_jlong,WidenMax); // 64-bit integers | |
316 TypeLong::INT = TypeLong::make((jlong)min_jint,(jlong)max_jint,WidenMin); | |
317 TypeLong::UINT = TypeLong::make(0,(jlong)max_juint,WidenMin); | |
318 | |
319 const Type **fboth =(const Type**)shared_type_arena->Amalloc_4(2*sizeof(Type*)); | |
320 fboth[0] = Type::CONTROL; | |
321 fboth[1] = Type::CONTROL; | |
322 TypeTuple::IFBOTH = TypeTuple::make( 2, fboth ); | |
323 | |
324 const Type **ffalse =(const Type**)shared_type_arena->Amalloc_4(2*sizeof(Type*)); | |
325 ffalse[0] = Type::CONTROL; | |
326 ffalse[1] = Type::TOP; | |
327 TypeTuple::IFFALSE = TypeTuple::make( 2, ffalse ); | |
328 | |
329 const Type **fneither =(const Type**)shared_type_arena->Amalloc_4(2*sizeof(Type*)); | |
330 fneither[0] = Type::TOP; | |
331 fneither[1] = Type::TOP; | |
332 TypeTuple::IFNEITHER = TypeTuple::make( 2, fneither ); | |
333 | |
334 const Type **ftrue =(const Type**)shared_type_arena->Amalloc_4(2*sizeof(Type*)); | |
335 ftrue[0] = Type::TOP; | |
336 ftrue[1] = Type::CONTROL; | |
337 TypeTuple::IFTRUE = TypeTuple::make( 2, ftrue ); | |
338 | |
339 const Type **floop =(const Type**)shared_type_arena->Amalloc_4(2*sizeof(Type*)); | |
340 floop[0] = Type::CONTROL; | |
341 floop[1] = TypeInt::INT; | |
342 TypeTuple::LOOPBODY = TypeTuple::make( 2, floop ); | |
343 | |
344 TypePtr::NULL_PTR= TypePtr::make( AnyPtr, TypePtr::Null, 0 ); | |
345 TypePtr::NOTNULL = TypePtr::make( AnyPtr, TypePtr::NotNull, OffsetBot ); | |
346 TypePtr::BOTTOM = TypePtr::make( AnyPtr, TypePtr::BotPTR, OffsetBot ); | |
347 | |
348 TypeRawPtr::BOTTOM = TypeRawPtr::make( TypePtr::BotPTR ); | |
349 TypeRawPtr::NOTNULL= TypeRawPtr::make( TypePtr::NotNull ); | |
350 | |
351 const Type **fmembar = TypeTuple::fields(0); | |
352 TypeTuple::MEMBAR = TypeTuple::make(TypeFunc::Parms+0, fmembar); | |
353 | |
354 const Type **fsc = (const Type**)shared_type_arena->Amalloc_4(2*sizeof(Type*)); | |
355 fsc[0] = TypeInt::CC; | |
356 fsc[1] = Type::MEMORY; | |
357 TypeTuple::STORECONDITIONAL = TypeTuple::make(2, fsc); | |
358 | |
359 TypeInstPtr::NOTNULL = TypeInstPtr::make(TypePtr::NotNull, current->env()->Object_klass()); | |
360 TypeInstPtr::BOTTOM = TypeInstPtr::make(TypePtr::BotPTR, current->env()->Object_klass()); | |
361 TypeInstPtr::MIRROR = TypeInstPtr::make(TypePtr::NotNull, current->env()->Class_klass()); | |
362 TypeInstPtr::MARK = TypeInstPtr::make(TypePtr::BotPTR, current->env()->Object_klass(), | |
363 false, 0, oopDesc::mark_offset_in_bytes()); | |
364 TypeInstPtr::KLASS = TypeInstPtr::make(TypePtr::BotPTR, current->env()->Object_klass(), | |
365 false, 0, oopDesc::klass_offset_in_bytes()); | |
12966 | 366 TypeOopPtr::BOTTOM = TypeOopPtr::make(TypePtr::BotPTR, OffsetBot, TypeOopPtr::InstanceBot, NULL); |
0 | 367 |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6198
diff
changeset
|
368 TypeMetadataPtr::BOTTOM = TypeMetadataPtr::make(TypePtr::BotPTR, NULL, OffsetBot); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6198
diff
changeset
|
369 |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
370 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
|
371 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
|
372 |
6848
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6735
diff
changeset
|
373 TypeNarrowKlass::NULL_PTR = TypeNarrowKlass::make( TypePtr::NULL_PTR ); |
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6735
diff
changeset
|
374 |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
375 mreg2type[Op_Node] = Type::BOTTOM; |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
376 mreg2type[Op_Set ] = 0; |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
377 mreg2type[Op_RegN] = TypeNarrowOop::BOTTOM; |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
378 mreg2type[Op_RegI] = TypeInt::INT; |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
379 mreg2type[Op_RegP] = TypePtr::BOTTOM; |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
380 mreg2type[Op_RegF] = Type::FLOAT; |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
381 mreg2type[Op_RegD] = Type::DOUBLE; |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
382 mreg2type[Op_RegL] = TypeLong::LONG; |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
383 mreg2type[Op_RegFlags] = TypeInt::CC; |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
384 |
1761 | 385 TypeAryPtr::RANGE = TypeAryPtr::make( TypePtr::BotPTR, TypeAry::make(Type::BOTTOM,TypeInt::POS), NULL /* current->env()->Object_klass() */, false, arrayOopDesc::length_offset_in_bytes()); |
163 | 386 |
387 TypeAryPtr::NARROWOOPS = TypeAryPtr::make(TypePtr::BotPTR, TypeAry::make(TypeNarrowOop::BOTTOM, TypeInt::POS), NULL /*ciArrayKlass::make(o)*/, false, Type::OffsetBot); | |
388 | |
389 #ifdef _LP64 | |
390 if (UseCompressedOops) { | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6198
diff
changeset
|
391 assert(TypeAryPtr::NARROWOOPS->is_ptr_to_narrowoop(), "array of narrow oops must be ptr to narrow oop"); |
163 | 392 TypeAryPtr::OOPS = TypeAryPtr::NARROWOOPS; |
393 } else | |
394 #endif | |
395 { | |
396 // There is no shared klass for Object[]. See note in TypeAryPtr::klass(). | |
397 TypeAryPtr::OOPS = TypeAryPtr::make(TypePtr::BotPTR, TypeAry::make(TypeInstPtr::BOTTOM,TypeInt::POS), NULL /*ciArrayKlass::make(o)*/, false, Type::OffsetBot); | |
398 } | |
0 | 399 TypeAryPtr::BYTES = TypeAryPtr::make(TypePtr::BotPTR, TypeAry::make(TypeInt::BYTE ,TypeInt::POS), ciTypeArrayKlass::make(T_BYTE), true, Type::OffsetBot); |
400 TypeAryPtr::SHORTS = TypeAryPtr::make(TypePtr::BotPTR, TypeAry::make(TypeInt::SHORT ,TypeInt::POS), ciTypeArrayKlass::make(T_SHORT), true, Type::OffsetBot); | |
401 TypeAryPtr::CHARS = TypeAryPtr::make(TypePtr::BotPTR, TypeAry::make(TypeInt::CHAR ,TypeInt::POS), ciTypeArrayKlass::make(T_CHAR), true, Type::OffsetBot); | |
402 TypeAryPtr::INTS = TypeAryPtr::make(TypePtr::BotPTR, TypeAry::make(TypeInt::INT ,TypeInt::POS), ciTypeArrayKlass::make(T_INT), true, Type::OffsetBot); | |
403 TypeAryPtr::LONGS = TypeAryPtr::make(TypePtr::BotPTR, TypeAry::make(TypeLong::LONG ,TypeInt::POS), ciTypeArrayKlass::make(T_LONG), true, Type::OffsetBot); | |
404 TypeAryPtr::FLOATS = TypeAryPtr::make(TypePtr::BotPTR, TypeAry::make(Type::FLOAT ,TypeInt::POS), ciTypeArrayKlass::make(T_FLOAT), true, Type::OffsetBot); | |
405 TypeAryPtr::DOUBLES = TypeAryPtr::make(TypePtr::BotPTR, TypeAry::make(Type::DOUBLE ,TypeInt::POS), ciTypeArrayKlass::make(T_DOUBLE), true, Type::OffsetBot); | |
406 | |
163 | 407 // Nobody should ask _array_body_type[T_NARROWOOP]. Use NULL as assert. |
408 TypeAryPtr::_array_body_type[T_NARROWOOP] = NULL; | |
0 | 409 TypeAryPtr::_array_body_type[T_OBJECT] = TypeAryPtr::OOPS; |
163 | 410 TypeAryPtr::_array_body_type[T_ARRAY] = TypeAryPtr::OOPS; // arrays are stored in oop arrays |
0 | 411 TypeAryPtr::_array_body_type[T_BYTE] = TypeAryPtr::BYTES; |
412 TypeAryPtr::_array_body_type[T_BOOLEAN] = TypeAryPtr::BYTES; // boolean[] is a byte array | |
413 TypeAryPtr::_array_body_type[T_SHORT] = TypeAryPtr::SHORTS; | |
414 TypeAryPtr::_array_body_type[T_CHAR] = TypeAryPtr::CHARS; | |
415 TypeAryPtr::_array_body_type[T_INT] = TypeAryPtr::INTS; | |
416 TypeAryPtr::_array_body_type[T_LONG] = TypeAryPtr::LONGS; | |
417 TypeAryPtr::_array_body_type[T_FLOAT] = TypeAryPtr::FLOATS; | |
418 TypeAryPtr::_array_body_type[T_DOUBLE] = TypeAryPtr::DOUBLES; | |
419 | |
420 TypeKlassPtr::OBJECT = TypeKlassPtr::make( TypePtr::NotNull, current->env()->Object_klass(), 0 ); | |
421 TypeKlassPtr::OBJECT_OR_NULL = TypeKlassPtr::make( TypePtr::BotPTR, current->env()->Object_klass(), 0 ); | |
422 | |
423 const Type **fi2c = TypeTuple::fields(2); | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6198
diff
changeset
|
424 fi2c[TypeFunc::Parms+0] = TypeInstPtr::BOTTOM; // Method* |
0 | 425 fi2c[TypeFunc::Parms+1] = TypeRawPtr::BOTTOM; // argument pointer |
426 TypeTuple::START_I2C = TypeTuple::make(TypeFunc::Parms+2, fi2c); | |
427 | |
428 const Type **intpair = TypeTuple::fields(2); | |
429 intpair[0] = TypeInt::INT; | |
430 intpair[1] = TypeInt::INT; | |
431 TypeTuple::INT_PAIR = TypeTuple::make(2, intpair); | |
432 | |
433 const Type **longpair = TypeTuple::fields(2); | |
434 longpair[0] = TypeLong::LONG; | |
435 longpair[1] = TypeLong::LONG; | |
436 TypeTuple::LONG_PAIR = TypeTuple::make(2, longpair); | |
437 | |
12323 | 438 const Type **intccpair = TypeTuple::fields(2); |
439 intccpair[0] = TypeInt::INT; | |
440 intccpair[1] = TypeInt::CC; | |
441 TypeTuple::INT_CC_PAIR = TypeTuple::make(2, intccpair); | |
442 | |
12972
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12966
diff
changeset
|
443 const Type **longccpair = TypeTuple::fields(2); |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12966
diff
changeset
|
444 longccpair[0] = TypeLong::LONG; |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12966
diff
changeset
|
445 longccpair[1] = TypeInt::CC; |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12966
diff
changeset
|
446 TypeTuple::LONG_CC_PAIR = TypeTuple::make(2, longccpair); |
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12966
diff
changeset
|
447 |
6848
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6735
diff
changeset
|
448 _const_basic_type[T_NARROWOOP] = TypeNarrowOop::BOTTOM; |
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6735
diff
changeset
|
449 _const_basic_type[T_NARROWKLASS] = Type::BOTTOM; |
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6735
diff
changeset
|
450 _const_basic_type[T_BOOLEAN] = TypeInt::BOOL; |
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6735
diff
changeset
|
451 _const_basic_type[T_CHAR] = TypeInt::CHAR; |
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6735
diff
changeset
|
452 _const_basic_type[T_BYTE] = TypeInt::BYTE; |
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6735
diff
changeset
|
453 _const_basic_type[T_SHORT] = TypeInt::SHORT; |
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6735
diff
changeset
|
454 _const_basic_type[T_INT] = TypeInt::INT; |
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6735
diff
changeset
|
455 _const_basic_type[T_LONG] = TypeLong::LONG; |
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6735
diff
changeset
|
456 _const_basic_type[T_FLOAT] = Type::FLOAT; |
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6735
diff
changeset
|
457 _const_basic_type[T_DOUBLE] = Type::DOUBLE; |
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6735
diff
changeset
|
458 _const_basic_type[T_OBJECT] = TypeInstPtr::BOTTOM; |
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6735
diff
changeset
|
459 _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
|
460 _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
|
461 _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
|
462 _const_basic_type[T_CONFLICT] = Type::BOTTOM; // why not? |
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6735
diff
changeset
|
463 |
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6735
diff
changeset
|
464 _zero_type[T_NARROWOOP] = TypeNarrowOop::NULL_PTR; |
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6735
diff
changeset
|
465 _zero_type[T_NARROWKLASS] = TypeNarrowKlass::NULL_PTR; |
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6735
diff
changeset
|
466 _zero_type[T_BOOLEAN] = TypeInt::ZERO; // false == 0 |
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6735
diff
changeset
|
467 _zero_type[T_CHAR] = TypeInt::ZERO; // '\0' == 0 |
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6735
diff
changeset
|
468 _zero_type[T_BYTE] = TypeInt::ZERO; // 0x00 == 0 |
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6735
diff
changeset
|
469 _zero_type[T_SHORT] = TypeInt::ZERO; // 0x0000 == 0 |
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6735
diff
changeset
|
470 _zero_type[T_INT] = TypeInt::ZERO; |
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6735
diff
changeset
|
471 _zero_type[T_LONG] = TypeLong::ZERO; |
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6735
diff
changeset
|
472 _zero_type[T_FLOAT] = TypeF::ZERO; |
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6735
diff
changeset
|
473 _zero_type[T_DOUBLE] = TypeD::ZERO; |
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6735
diff
changeset
|
474 _zero_type[T_OBJECT] = TypePtr::NULL_PTR; |
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6735
diff
changeset
|
475 _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
|
476 _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
|
477 _zero_type[T_VOID] = Type::TOP; // the only void value is no value at all |
0 | 478 |
479 // get_zero_type() should not happen for T_CONFLICT | |
480 _zero_type[T_CONFLICT]= NULL; | |
481 | |
6179
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
2376
diff
changeset
|
482 // 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
|
483 if (Matcher::vector_size_supported(T_BYTE,4)) { |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
2376
diff
changeset
|
484 TypeVect::VECTS = TypeVect::make(T_BYTE,4); |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
2376
diff
changeset
|
485 } |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
2376
diff
changeset
|
486 if (Matcher::vector_size_supported(T_FLOAT,2)) { |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
2376
diff
changeset
|
487 TypeVect::VECTD = TypeVect::make(T_FLOAT,2); |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
2376
diff
changeset
|
488 } |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
2376
diff
changeset
|
489 if (Matcher::vector_size_supported(T_FLOAT,4)) { |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
2376
diff
changeset
|
490 TypeVect::VECTX = TypeVect::make(T_FLOAT,4); |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
2376
diff
changeset
|
491 } |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
2376
diff
changeset
|
492 if (Matcher::vector_size_supported(T_FLOAT,8)) { |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
2376
diff
changeset
|
493 TypeVect::VECTY = TypeVect::make(T_FLOAT,8); |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
2376
diff
changeset
|
494 } |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
2376
diff
changeset
|
495 mreg2type[Op_VecS] = TypeVect::VECTS; |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
2376
diff
changeset
|
496 mreg2type[Op_VecD] = TypeVect::VECTD; |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
2376
diff
changeset
|
497 mreg2type[Op_VecX] = TypeVect::VECTX; |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
2376
diff
changeset
|
498 mreg2type[Op_VecY] = TypeVect::VECTY; |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
2376
diff
changeset
|
499 |
0 | 500 // Restore working type arena. |
501 current->set_type_arena(save); | |
502 current->set_type_dict(NULL); | |
503 } | |
504 | |
505 //------------------------------Initialize------------------------------------- | |
506 void Type::Initialize(Compile* current) { | |
507 assert(current->type_arena() != NULL, "must have created type arena"); | |
508 | |
509 if (_shared_type_dict == NULL) { | |
510 Initialize_shared(current); | |
511 } | |
512 | |
513 Arena* type_arena = current->type_arena(); | |
514 | |
515 // Create the hash-cons'ing dictionary with top-level storage allocation | |
516 Dict *tdic = new (type_arena) Dict( (CmpKey)Type::cmp,(Hash)Type::uhash, type_arena, 128 ); | |
517 current->set_type_dict(tdic); | |
518 | |
519 // Transfer the shared types. | |
520 DictI i(_shared_type_dict); | |
521 for( ; i.test(); ++i ) { | |
522 Type* t = (Type*)i._value; | |
523 tdic->Insert(t,t); // New Type, insert into Type table | |
524 } | |
525 } | |
526 | |
527 //------------------------------hashcons--------------------------------------- | |
528 // Do the hash-cons trick. If the Type already exists in the type table, | |
529 // delete the current Type and return the existing Type. Otherwise stick the | |
530 // current Type in the Type table. | |
531 const Type *Type::hashcons(void) { | |
532 debug_only(base()); // Check the assertion in Type::base(). | |
533 // Look up the Type in the Type dictionary | |
534 Dict *tdic = type_dict(); | |
535 Type* old = (Type*)(tdic->Insert(this, this, false)); | |
536 if( old ) { // Pre-existing Type? | |
537 if( old != this ) // Yes, this guy is not the pre-existing? | |
538 delete this; // Yes, Nuke this guy | |
539 assert( old->_dual, "" ); | |
540 return old; // Return pre-existing | |
541 } | |
542 | |
543 // Every type has a dual (to make my lattice symmetric). | |
544 // Since we just discovered a new Type, compute its dual right now. | |
545 assert( !_dual, "" ); // No dual yet | |
546 _dual = xdual(); // Compute the dual | |
547 if( cmp(this,_dual)==0 ) { // Handle self-symmetric | |
548 _dual = this; | |
549 return this; | |
550 } | |
551 assert( !_dual->_dual, "" ); // No reverse dual yet | |
552 assert( !(*tdic)[_dual], "" ); // Dual not in type system either | |
553 // New Type, insert into Type table | |
554 tdic->Insert((void*)_dual,(void*)_dual); | |
555 ((Type*)_dual)->_dual = this; // Finish up being symmetric | |
556 #ifdef ASSERT | |
557 Type *dual_dual = (Type*)_dual->xdual(); | |
558 assert( eq(dual_dual), "xdual(xdual()) should be identity" ); | |
559 delete dual_dual; | |
560 #endif | |
561 return this; // Return new Type | |
562 } | |
563 | |
564 //------------------------------eq--------------------------------------------- | |
565 // Structural equality check for Type representations | |
566 bool Type::eq( const Type * ) const { | |
567 return true; // Nothing else can go wrong | |
568 } | |
569 | |
570 //------------------------------hash------------------------------------------- | |
571 // Type-specific hashing function. | |
572 int Type::hash(void) const { | |
573 return _base; | |
574 } | |
575 | |
576 //------------------------------is_finite-------------------------------------- | |
577 // Has a finite value | |
578 bool Type::is_finite() const { | |
579 return false; | |
580 } | |
581 | |
582 //------------------------------is_nan----------------------------------------- | |
583 // Is not a number (NaN) | |
584 bool Type::is_nan() const { | |
585 return false; | |
586 } | |
587 | |
820
915cc9c5ebc6
6837094: False positive for "meet not symmetric" failure
kvn
parents:
628
diff
changeset
|
588 //----------------------interface_vs_oop--------------------------------------- |
915cc9c5ebc6
6837094: False positive for "meet not symmetric" failure
kvn
parents:
628
diff
changeset
|
589 #ifdef ASSERT |
12966 | 590 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
|
591 bool result = false; |
915cc9c5ebc6
6837094: False positive for "meet not symmetric" failure
kvn
parents:
628
diff
changeset
|
592 |
992 | 593 const TypePtr* this_ptr = this->make_ptr(); // In case it is narrow_oop |
594 const TypePtr* t_ptr = t->make_ptr(); | |
595 if( this_ptr == NULL || t_ptr == NULL ) | |
596 return result; | |
597 | |
598 const TypeInstPtr* this_inst = this_ptr->isa_instptr(); | |
599 const TypeInstPtr* t_inst = t_ptr->isa_instptr(); | |
820
915cc9c5ebc6
6837094: False positive for "meet not symmetric" failure
kvn
parents:
628
diff
changeset
|
600 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
|
601 bool this_interface = this_inst->klass()->is_interface(); |
915cc9c5ebc6
6837094: False positive for "meet not symmetric" failure
kvn
parents:
628
diff
changeset
|
602 bool t_interface = t_inst->klass()->is_interface(); |
915cc9c5ebc6
6837094: False positive for "meet not symmetric" failure
kvn
parents:
628
diff
changeset
|
603 result = this_interface ^ t_interface; |
915cc9c5ebc6
6837094: False positive for "meet not symmetric" failure
kvn
parents:
628
diff
changeset
|
604 } |
915cc9c5ebc6
6837094: False positive for "meet not symmetric" failure
kvn
parents:
628
diff
changeset
|
605 |
915cc9c5ebc6
6837094: False positive for "meet not symmetric" failure
kvn
parents:
628
diff
changeset
|
606 return result; |
915cc9c5ebc6
6837094: False positive for "meet not symmetric" failure
kvn
parents:
628
diff
changeset
|
607 } |
12966 | 608 |
609 bool Type::interface_vs_oop(const Type *t) const { | |
610 if (interface_vs_oop_helper(t)) { | |
611 return true; | |
612 } | |
613 // Now check the speculative parts as well | |
614 const TypeOopPtr* this_spec = isa_oopptr() != NULL ? isa_oopptr()->speculative() : NULL; | |
615 const TypeOopPtr* t_spec = t->isa_oopptr() != NULL ? t->isa_oopptr()->speculative() : NULL; | |
616 if (this_spec != NULL && t_spec != NULL) { | |
617 if (this_spec->interface_vs_oop_helper(t_spec)) { | |
618 return true; | |
619 } | |
620 return false; | |
621 } | |
622 if (this_spec != NULL && this_spec->interface_vs_oop_helper(t)) { | |
623 return true; | |
624 } | |
625 if (t_spec != NULL && interface_vs_oop_helper(t_spec)) { | |
626 return true; | |
627 } | |
628 return false; | |
629 } | |
630 | |
820
915cc9c5ebc6
6837094: False positive for "meet not symmetric" failure
kvn
parents:
628
diff
changeset
|
631 #endif |
915cc9c5ebc6
6837094: False positive for "meet not symmetric" failure
kvn
parents:
628
diff
changeset
|
632 |
0 | 633 //------------------------------meet------------------------------------------- |
634 // Compute the MEET of two types. NOT virtual. It enforces that meet is | |
635 // commutative and the lattice is symmetric. | |
636 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
|
637 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
|
638 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
|
639 return result->make_narrowoop(); |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
640 } |
6848
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6735
diff
changeset
|
641 if (isa_narrowklass() && t->isa_narrowklass()) { |
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6735
diff
changeset
|
642 const Type* result = make_ptr()->meet(t->make_ptr()); |
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6735
diff
changeset
|
643 return result->make_narrowklass(); |
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6735
diff
changeset
|
644 } |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
645 |
0 | 646 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
|
647 if (isa_narrowoop() || t->isa_narrowoop()) return mt; |
6848
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6735
diff
changeset
|
648 if (isa_narrowklass() || t->isa_narrowklass()) return mt; |
0 | 649 #ifdef ASSERT |
650 assert( mt == t->xmeet(this), "meet not commutative" ); | |
651 const Type* dual_join = mt->_dual; | |
652 const Type *t2t = dual_join->xmeet(t->_dual); | |
653 const Type *t2this = dual_join->xmeet( _dual); | |
654 | |
655 // Interface meet Oop is Not Symmetric: | |
656 // Interface:AnyNull meet Oop:AnyNull == Interface:AnyNull | |
657 // Interface:NotNull meet Oop:NotNull == java/lang/Object:NotNull | |
820
915cc9c5ebc6
6837094: False positive for "meet not symmetric" failure
kvn
parents:
628
diff
changeset
|
658 |
915cc9c5ebc6
6837094: False positive for "meet not symmetric" failure
kvn
parents:
628
diff
changeset
|
659 if( !interface_vs_oop(t) && (t2t != t->_dual || t2this != _dual) ) { |
0 | 660 tty->print_cr("=== Meet Not Symmetric ==="); |
661 tty->print("t = "); t->dump(); tty->cr(); | |
662 tty->print("this= "); dump(); tty->cr(); | |
663 tty->print("mt=(t meet this)= "); mt->dump(); tty->cr(); | |
664 | |
665 tty->print("t_dual= "); t->_dual->dump(); tty->cr(); | |
666 tty->print("this_dual= "); _dual->dump(); tty->cr(); | |
667 tty->print("mt_dual= "); mt->_dual->dump(); tty->cr(); | |
668 | |
669 tty->print("mt_dual meet t_dual= "); t2t ->dump(); tty->cr(); | |
670 tty->print("mt_dual meet this_dual= "); t2this ->dump(); tty->cr(); | |
671 | |
672 fatal("meet not symmetric" ); | |
673 } | |
674 #endif | |
675 return mt; | |
676 } | |
677 | |
678 //------------------------------xmeet------------------------------------------ | |
679 // Compute the MEET of two types. It returns a new Type object. | |
680 const Type *Type::xmeet( const Type *t ) const { | |
681 // Perform a fast test for common case; meeting the same types together. | |
682 if( this == t ) return this; // Meeting same type-rep? | |
683 | |
684 // Meeting TOP with anything? | |
685 if( _base == Top ) return t; | |
686 | |
687 // Meeting BOTTOM with anything? | |
688 if( _base == Bottom ) return BOTTOM; | |
689 | |
690 // Current "this->_base" is one of: Bad, Multi, Control, Top, | |
691 // Abio, Abstore, Floatxxx, Doublexxx, Bottom, lastype. | |
692 switch (t->base()) { // Switch on original type | |
693 | |
694 // Cut in half the number of cases I must handle. Only need cases for when | |
695 // the given enum "t->type" is less than or equal to the local enum "type". | |
696 case FloatCon: | |
697 case DoubleCon: | |
698 case Int: | |
699 case Long: | |
700 return t->xmeet(this); | |
701 | |
702 case OopPtr: | |
703 return t->xmeet(this); | |
704 | |
705 case InstPtr: | |
706 return t->xmeet(this); | |
707 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6198
diff
changeset
|
708 case MetadataPtr: |
0 | 709 case KlassPtr: |
710 return t->xmeet(this); | |
711 | |
712 case AryPtr: | |
713 return t->xmeet(this); | |
714 | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
715 case NarrowOop: |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
716 return t->xmeet(this); |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
717 |
6848
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6735
diff
changeset
|
718 case NarrowKlass: |
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6735
diff
changeset
|
719 return t->xmeet(this); |
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6735
diff
changeset
|
720 |
0 | 721 case Bad: // Type check |
722 default: // Bogus type not in lattice | |
723 typerr(t); | |
724 return Type::BOTTOM; | |
725 | |
726 case Bottom: // Ye Olde Default | |
727 return t; | |
728 | |
729 case FloatTop: | |
730 if( _base == FloatTop ) return this; | |
731 case FloatBot: // Float | |
732 if( _base == FloatBot || _base == FloatTop ) return FLOAT; | |
733 if( _base == DoubleTop || _base == DoubleBot ) return Type::BOTTOM; | |
734 typerr(t); | |
735 return Type::BOTTOM; | |
736 | |
737 case DoubleTop: | |
738 if( _base == DoubleTop ) return this; | |
739 case DoubleBot: // Double | |
740 if( _base == DoubleBot || _base == DoubleTop ) return DOUBLE; | |
741 if( _base == FloatTop || _base == FloatBot ) return Type::BOTTOM; | |
742 typerr(t); | |
743 return Type::BOTTOM; | |
744 | |
745 // These next few cases must match exactly or it is a compile-time error. | |
746 case Control: // Control of code | |
747 case Abio: // State of world outside of program | |
748 case Memory: | |
749 if( _base == t->_base ) return this; | |
750 typerr(t); | |
751 return Type::BOTTOM; | |
752 | |
753 case Top: // Top of the lattice | |
754 return this; | |
755 } | |
756 | |
757 // The type is unchanged | |
758 return this; | |
759 } | |
760 | |
761 //-----------------------------filter------------------------------------------ | |
762 const Type *Type::filter( const Type *kills ) const { | |
763 const Type* ft = join(kills); | |
764 if (ft->empty()) | |
765 return Type::TOP; // Canonical empty value | |
766 return ft; | |
767 } | |
768 | |
769 //------------------------------xdual------------------------------------------ | |
770 // Compute dual right now. | |
771 const Type::TYPES Type::dual_type[Type::lastype] = { | |
772 Bad, // Bad | |
773 Control, // Control | |
774 Bottom, // Top | |
775 Bad, // Int - handled in v-call | |
776 Bad, // Long - handled in v-call | |
777 Half, // Half | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
778 Bad, // NarrowOop - handled in v-call |
6848
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6735
diff
changeset
|
779 Bad, // NarrowKlass - handled in v-call |
0 | 780 |
781 Bad, // Tuple - handled in v-call | |
782 Bad, // Array - handled in v-call | |
6179
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
2376
diff
changeset
|
783 Bad, // VectorS - handled in v-call |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
2376
diff
changeset
|
784 Bad, // VectorD - handled in v-call |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
2376
diff
changeset
|
785 Bad, // VectorX - handled in v-call |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
2376
diff
changeset
|
786 Bad, // VectorY - handled in v-call |
0 | 787 |
788 Bad, // AnyPtr - handled in v-call | |
789 Bad, // RawPtr - handled in v-call | |
790 Bad, // OopPtr - handled in v-call | |
791 Bad, // InstPtr - handled in v-call | |
792 Bad, // AryPtr - handled in v-call | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6198
diff
changeset
|
793 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6198
diff
changeset
|
794 Bad, // MetadataPtr - handled in v-call |
0 | 795 Bad, // KlassPtr - handled in v-call |
796 | |
797 Bad, // Function - handled in v-call | |
798 Abio, // Abio | |
799 Return_Address,// Return_Address | |
800 Memory, // Memory | |
801 FloatBot, // FloatTop | |
802 FloatCon, // FloatCon | |
803 FloatTop, // FloatBot | |
804 DoubleBot, // DoubleTop | |
805 DoubleCon, // DoubleCon | |
806 DoubleTop, // DoubleBot | |
807 Top // Bottom | |
808 }; | |
809 | |
810 const Type *Type::xdual() const { | |
811 // 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
|
812 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
|
813 return new Type(_type_info[_base].dual_type); |
0 | 814 } |
815 | |
816 //------------------------------has_memory------------------------------------- | |
817 bool Type::has_memory() const { | |
818 Type::TYPES tx = base(); | |
819 if (tx == Memory) return true; | |
820 if (tx == Tuple) { | |
821 const TypeTuple *t = is_tuple(); | |
822 for (uint i=0; i < t->cnt(); i++) { | |
823 tx = t->field_at(i)->base(); | |
824 if (tx == Memory) return true; | |
825 } | |
826 } | |
827 return false; | |
828 } | |
829 | |
830 #ifndef PRODUCT | |
831 //------------------------------dump2------------------------------------------ | |
832 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
|
833 st->print(_type_info[_base].msg); |
0 | 834 } |
835 | |
836 //------------------------------dump------------------------------------------- | |
837 void Type::dump_on(outputStream *st) const { | |
838 ResourceMark rm; | |
839 Dict d(cmpkey,hashkey); // Stop recursive type dumping | |
840 dump2(d,1, st); | |
163 | 841 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
|
842 st->print(" [narrow]"); |
6848
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6735
diff
changeset
|
843 } else if (is_ptr_to_narrowklass()) { |
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6735
diff
changeset
|
844 st->print(" [narrowklass]"); |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
845 } |
0 | 846 } |
847 #endif | |
848 | |
849 //------------------------------singleton-------------------------------------- | |
850 // TRUE if Type is a singleton type, FALSE otherwise. Singletons are simple | |
851 // constants (Ldi nodes). Singletons are integer, float or double constants. | |
852 bool Type::singleton(void) const { | |
853 return _base == Top || _base == Half; | |
854 } | |
855 | |
856 //------------------------------empty------------------------------------------ | |
857 // TRUE if Type is a type with no values, FALSE otherwise. | |
858 bool Type::empty(void) const { | |
859 switch (_base) { | |
860 case DoubleTop: | |
861 case FloatTop: | |
862 case Top: | |
863 return true; | |
864 | |
865 case Half: | |
866 case Abio: | |
867 case Return_Address: | |
868 case Memory: | |
869 case Bottom: | |
870 case FloatBot: | |
871 case DoubleBot: | |
872 return false; // never a singleton, therefore never empty | |
873 } | |
874 | |
875 ShouldNotReachHere(); | |
876 return false; | |
877 } | |
878 | |
879 //------------------------------dump_stats------------------------------------- | |
880 // Dump collected statistics to stderr | |
881 #ifndef PRODUCT | |
882 void Type::dump_stats() { | |
883 tty->print("Types made: %d\n", type_dict()->Size()); | |
884 } | |
885 #endif | |
886 | |
887 //------------------------------typerr----------------------------------------- | |
888 void Type::typerr( const Type *t ) const { | |
889 #ifndef PRODUCT | |
890 tty->print("\nError mixing types: "); | |
891 dump(); | |
892 tty->print(" and "); | |
893 t->dump(); | |
894 tty->print("\n"); | |
895 #endif | |
896 ShouldNotReachHere(); | |
897 } | |
898 | |
899 | |
900 //============================================================================= | |
901 // Convenience common pre-built types. | |
902 const TypeF *TypeF::ZERO; // Floating point zero | |
903 const TypeF *TypeF::ONE; // Floating point one | |
904 | |
905 //------------------------------make------------------------------------------- | |
906 // Create a float constant | |
907 const TypeF *TypeF::make(float f) { | |
908 return (TypeF*)(new TypeF(f))->hashcons(); | |
909 } | |
910 | |
911 //------------------------------meet------------------------------------------- | |
912 // Compute the MEET of two types. It returns a new Type object. | |
913 const Type *TypeF::xmeet( const Type *t ) const { | |
914 // Perform a fast test for common case; meeting the same types together. | |
915 if( this == t ) return this; // Meeting same type-rep? | |
916 | |
917 // Current "this->_base" is FloatCon | |
918 switch (t->base()) { // Switch on original type | |
919 case AnyPtr: // Mixing with oops happens when javac | |
920 case RawPtr: // reuses local variables | |
921 case OopPtr: | |
922 case InstPtr: | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6198
diff
changeset
|
923 case AryPtr: |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6198
diff
changeset
|
924 case MetadataPtr: |
0 | 925 case KlassPtr: |
293
c3e045194476
6731641: assert(m->adr_type() == mach->adr_type(),"matcher should not change adr type")
kvn
parents:
247
diff
changeset
|
926 case NarrowOop: |
6848
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6735
diff
changeset
|
927 case NarrowKlass: |
0 | 928 case Int: |
929 case Long: | |
930 case DoubleTop: | |
931 case DoubleCon: | |
932 case DoubleBot: | |
933 case Bottom: // Ye Olde Default | |
934 return Type::BOTTOM; | |
935 | |
936 case FloatBot: | |
937 return t; | |
938 | |
939 default: // All else is a mistake | |
940 typerr(t); | |
941 | |
942 case FloatCon: // Float-constant vs Float-constant? | |
943 if( jint_cast(_f) != jint_cast(t->getf()) ) // unequal constants? | |
944 // must compare bitwise as positive zero, negative zero and NaN have | |
945 // all the same representation in C++ | |
946 return FLOAT; // Return generic float | |
947 // Equal constants | |
948 case Top: | |
949 case FloatTop: | |
950 break; // Return the float constant | |
951 } | |
952 return this; // Return the float constant | |
953 } | |
954 | |
955 //------------------------------xdual------------------------------------------ | |
956 // Dual: symmetric | |
957 const Type *TypeF::xdual() const { | |
958 return this; | |
959 } | |
960 | |
961 //------------------------------eq--------------------------------------------- | |
962 // Structural equality check for Type representations | |
963 bool TypeF::eq( const Type *t ) const { | |
964 if( g_isnan(_f) || | |
965 g_isnan(t->getf()) ) { | |
966 // One or both are NANs. If both are NANs return true, else false. | |
967 return (g_isnan(_f) && g_isnan(t->getf())); | |
968 } | |
969 if (_f == t->getf()) { | |
970 // (NaN is impossible at this point, since it is not equal even to itself) | |
971 if (_f == 0.0) { | |
972 // difference between positive and negative zero | |
973 if (jint_cast(_f) != jint_cast(t->getf())) return false; | |
974 } | |
975 return true; | |
976 } | |
977 return false; | |
978 } | |
979 | |
980 //------------------------------hash------------------------------------------- | |
981 // Type-specific hashing function. | |
982 int TypeF::hash(void) const { | |
983 return *(int*)(&_f); | |
984 } | |
985 | |
986 //------------------------------is_finite-------------------------------------- | |
987 // Has a finite value | |
988 bool TypeF::is_finite() const { | |
989 return g_isfinite(getf()) != 0; | |
990 } | |
991 | |
992 //------------------------------is_nan----------------------------------------- | |
993 // Is not a number (NaN) | |
994 bool TypeF::is_nan() const { | |
995 return g_isnan(getf()) != 0; | |
996 } | |
997 | |
998 //------------------------------dump2------------------------------------------ | |
999 // Dump float constant Type | |
1000 #ifndef PRODUCT | |
1001 void TypeF::dump2( Dict &d, uint depth, outputStream *st ) const { | |
1002 Type::dump2(d,depth, st); | |
1003 st->print("%f", _f); | |
1004 } | |
1005 #endif | |
1006 | |
1007 //------------------------------singleton-------------------------------------- | |
1008 // TRUE if Type is a singleton type, FALSE otherwise. Singletons are simple | |
1009 // constants (Ldi nodes). Singletons are integer, float or double constants | |
1010 // or a single symbol. | |
1011 bool TypeF::singleton(void) const { | |
1012 return true; // Always a singleton | |
1013 } | |
1014 | |
1015 bool TypeF::empty(void) const { | |
1016 return false; // always exactly a singleton | |
1017 } | |
1018 | |
1019 //============================================================================= | |
1020 // Convenience common pre-built types. | |
1021 const TypeD *TypeD::ZERO; // Floating point zero | |
1022 const TypeD *TypeD::ONE; // Floating point one | |
1023 | |
1024 //------------------------------make------------------------------------------- | |
1025 const TypeD *TypeD::make(double d) { | |
1026 return (TypeD*)(new TypeD(d))->hashcons(); | |
1027 } | |
1028 | |
1029 //------------------------------meet------------------------------------------- | |
1030 // Compute the MEET of two types. It returns a new Type object. | |
1031 const Type *TypeD::xmeet( const Type *t ) const { | |
1032 // Perform a fast test for common case; meeting the same types together. | |
1033 if( this == t ) return this; // Meeting same type-rep? | |
1034 | |
1035 // Current "this->_base" is DoubleCon | |
1036 switch (t->base()) { // Switch on original type | |
1037 case AnyPtr: // Mixing with oops happens when javac | |
1038 case RawPtr: // reuses local variables | |
1039 case OopPtr: | |
1040 case InstPtr: | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6198
diff
changeset
|
1041 case AryPtr: |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6198
diff
changeset
|
1042 case MetadataPtr: |
0 | 1043 case KlassPtr: |
183
d4dbd9f91680
6711083: 64bit JVM crashes with Internal Error (type.cpp:763) - ShouldNotReachHere() with enabled COOPs
never
parents:
163
diff
changeset
|
1044 case NarrowOop: |
6848
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6735
diff
changeset
|
1045 case NarrowKlass: |
0 | 1046 case Int: |
1047 case Long: | |
1048 case FloatTop: | |
1049 case FloatCon: | |
1050 case FloatBot: | |
1051 case Bottom: // Ye Olde Default | |
1052 return Type::BOTTOM; | |
1053 | |
1054 case DoubleBot: | |
1055 return t; | |
1056 | |
1057 default: // All else is a mistake | |
1058 typerr(t); | |
1059 | |
1060 case DoubleCon: // Double-constant vs Double-constant? | |
1061 if( jlong_cast(_d) != jlong_cast(t->getd()) ) // unequal constants? (see comment in TypeF::xmeet) | |
1062 return DOUBLE; // Return generic double | |
1063 case Top: | |
1064 case DoubleTop: | |
1065 break; | |
1066 } | |
1067 return this; // Return the double constant | |
1068 } | |
1069 | |
1070 //------------------------------xdual------------------------------------------ | |
1071 // Dual: symmetric | |
1072 const Type *TypeD::xdual() const { | |
1073 return this; | |
1074 } | |
1075 | |
1076 //------------------------------eq--------------------------------------------- | |
1077 // Structural equality check for Type representations | |
1078 bool TypeD::eq( const Type *t ) const { | |
1079 if( g_isnan(_d) || | |
1080 g_isnan(t->getd()) ) { | |
1081 // One or both are NANs. If both are NANs return true, else false. | |
1082 return (g_isnan(_d) && g_isnan(t->getd())); | |
1083 } | |
1084 if (_d == t->getd()) { | |
1085 // (NaN is impossible at this point, since it is not equal even to itself) | |
1086 if (_d == 0.0) { | |
1087 // difference between positive and negative zero | |
1088 if (jlong_cast(_d) != jlong_cast(t->getd())) return false; | |
1089 } | |
1090 return true; | |
1091 } | |
1092 return false; | |
1093 } | |
1094 | |
1095 //------------------------------hash------------------------------------------- | |
1096 // Type-specific hashing function. | |
1097 int TypeD::hash(void) const { | |
1098 return *(int*)(&_d); | |
1099 } | |
1100 | |
1101 //------------------------------is_finite-------------------------------------- | |
1102 // Has a finite value | |
1103 bool TypeD::is_finite() const { | |
1104 return g_isfinite(getd()) != 0; | |
1105 } | |
1106 | |
1107 //------------------------------is_nan----------------------------------------- | |
1108 // Is not a number (NaN) | |
1109 bool TypeD::is_nan() const { | |
1110 return g_isnan(getd()) != 0; | |
1111 } | |
1112 | |
1113 //------------------------------dump2------------------------------------------ | |
1114 // Dump double constant Type | |
1115 #ifndef PRODUCT | |
1116 void TypeD::dump2( Dict &d, uint depth, outputStream *st ) const { | |
1117 Type::dump2(d,depth,st); | |
1118 st->print("%f", _d); | |
1119 } | |
1120 #endif | |
1121 | |
1122 //------------------------------singleton-------------------------------------- | |
1123 // TRUE if Type is a singleton type, FALSE otherwise. Singletons are simple | |
1124 // constants (Ldi nodes). Singletons are integer, float or double constants | |
1125 // or a single symbol. | |
1126 bool TypeD::singleton(void) const { | |
1127 return true; // Always a singleton | |
1128 } | |
1129 | |
1130 bool TypeD::empty(void) const { | |
1131 return false; // always exactly a singleton | |
1132 } | |
1133 | |
1134 //============================================================================= | |
1135 // Convience common pre-built types. | |
1136 const TypeInt *TypeInt::MINUS_1;// -1 | |
1137 const TypeInt *TypeInt::ZERO; // 0 | |
1138 const TypeInt *TypeInt::ONE; // 1 | |
1139 const TypeInt *TypeInt::BOOL; // 0 or 1, FALSE or TRUE. | |
1140 const TypeInt *TypeInt::CC; // -1,0 or 1, condition codes | |
1141 const TypeInt *TypeInt::CC_LT; // [-1] == MINUS_1 | |
1142 const TypeInt *TypeInt::CC_GT; // [1] == ONE | |
1143 const TypeInt *TypeInt::CC_EQ; // [0] == ZERO | |
1144 const TypeInt *TypeInt::CC_LE; // [-1,0] | |
1145 const TypeInt *TypeInt::CC_GE; // [0,1] == BOOL (!) | |
1146 const TypeInt *TypeInt::BYTE; // Bytes, -128 to 127 | |
624 | 1147 const TypeInt *TypeInt::UBYTE; // Unsigned Bytes, 0 to 255 |
0 | 1148 const TypeInt *TypeInt::CHAR; // Java chars, 0-65535 |
1149 const TypeInt *TypeInt::SHORT; // Java shorts, -32768-32767 | |
1150 const TypeInt *TypeInt::POS; // Positive 32-bit integers or zero | |
1151 const TypeInt *TypeInt::POS1; // Positive 32-bit integers | |
1152 const TypeInt *TypeInt::INT; // 32-bit integers | |
1153 const TypeInt *TypeInt::SYMINT; // symmetric range [-max_jint..max_jint] | |
1154 | |
1155 //------------------------------TypeInt---------------------------------------- | |
1156 TypeInt::TypeInt( jint lo, jint hi, int w ) : Type(Int), _lo(lo), _hi(hi), _widen(w) { | |
1157 } | |
1158 | |
1159 //------------------------------make------------------------------------------- | |
1160 const TypeInt *TypeInt::make( jint lo ) { | |
1161 return (TypeInt*)(new TypeInt(lo,lo,WidenMin))->hashcons(); | |
1162 } | |
1163 | |
1620
d678e3277048
6964479: widen normalization of small int and long values should be symmetric
kvn
parents:
1552
diff
changeset
|
1164 static int normalize_int_widen( jint lo, jint hi, int w ) { |
0 | 1165 // Certain normalizations keep us sane when comparing types. |
1166 // The 'SMALLINT' covers constants and also CC and its relatives. | |
1167 if (lo <= hi) { | |
1620
d678e3277048
6964479: widen normalization of small int and long values should be symmetric
kvn
parents:
1552
diff
changeset
|
1168 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
|
1169 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
|
1170 } else { |
d678e3277048
6964479: widen normalization of small int and long values should be symmetric
kvn
parents:
1552
diff
changeset
|
1171 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
|
1172 if ((juint)(lo - hi) >= max_juint) w = Type::WidenMin; // dual TypeInt::INT |
0 | 1173 } |
1620
d678e3277048
6964479: widen normalization of small int and long values should be symmetric
kvn
parents:
1552
diff
changeset
|
1174 return w; |
d678e3277048
6964479: widen normalization of small int and long values should be symmetric
kvn
parents:
1552
diff
changeset
|
1175 } |
d678e3277048
6964479: widen normalization of small int and long values should be symmetric
kvn
parents:
1552
diff
changeset
|
1176 |
d678e3277048
6964479: widen normalization of small int and long values should be symmetric
kvn
parents:
1552
diff
changeset
|
1177 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
|
1178 w = normalize_int_widen(lo, hi, w); |
0 | 1179 return (TypeInt*)(new TypeInt(lo,hi,w))->hashcons(); |
1180 } | |
1181 | |
1182 //------------------------------meet------------------------------------------- | |
1183 // Compute the MEET of two types. It returns a new Type representation object | |
1184 // with reference count equal to the number of Types pointing at it. | |
1185 // Caller should wrap a Types around it. | |
1186 const Type *TypeInt::xmeet( const Type *t ) const { | |
1187 // Perform a fast test for common case; meeting the same types together. | |
1188 if( this == t ) return this; // Meeting same type? | |
1189 | |
1190 // Currently "this->_base" is a TypeInt | |
1191 switch (t->base()) { // Switch on original type | |
1192 case AnyPtr: // Mixing with oops happens when javac | |
1193 case RawPtr: // reuses local variables | |
1194 case OopPtr: | |
1195 case InstPtr: | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6198
diff
changeset
|
1196 case AryPtr: |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6198
diff
changeset
|
1197 case MetadataPtr: |
0 | 1198 case KlassPtr: |
183
d4dbd9f91680
6711083: 64bit JVM crashes with Internal Error (type.cpp:763) - ShouldNotReachHere() with enabled COOPs
never
parents:
163
diff
changeset
|
1199 case NarrowOop: |
6848
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6735
diff
changeset
|
1200 case NarrowKlass: |
0 | 1201 case Long: |
1202 case FloatTop: | |
1203 case FloatCon: | |
1204 case FloatBot: | |
1205 case DoubleTop: | |
1206 case DoubleCon: | |
1207 case DoubleBot: | |
1208 case Bottom: // Ye Olde Default | |
1209 return Type::BOTTOM; | |
1210 default: // All else is a mistake | |
1211 typerr(t); | |
1212 case Top: // No change | |
1213 return this; | |
1214 case Int: // Int vs Int? | |
1215 break; | |
1216 } | |
1217 | |
1218 // Expand covered set | |
1219 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
|
1220 return make( MIN2(_lo,r->_lo), MAX2(_hi,r->_hi), MAX2(_widen,r->_widen) ); |
0 | 1221 } |
1222 | |
1223 //------------------------------xdual------------------------------------------ | |
1224 // Dual: reverse hi & lo; flip widen | |
1225 const Type *TypeInt::xdual() const { | |
1620
d678e3277048
6964479: widen normalization of small int and long values should be symmetric
kvn
parents:
1552
diff
changeset
|
1226 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
|
1227 return new TypeInt(_hi,_lo,w); |
0 | 1228 } |
1229 | |
1230 //------------------------------widen------------------------------------------ | |
1231 // 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
|
1232 const Type *TypeInt::widen( const Type *old, const Type* limit ) const { |
0 | 1233 // Coming from TOP or such; no widening |
1234 if( old->base() != Int ) return this; | |
1235 const TypeInt *ot = old->is_int(); | |
1236 | |
1237 // If new guy is equal to old guy, no widening | |
1238 if( _lo == ot->_lo && _hi == ot->_hi ) | |
1239 return old; | |
1240 | |
1241 // If new guy contains old, then we widened | |
1242 if( _lo <= ot->_lo && _hi >= ot->_hi ) { | |
1243 // New contains old | |
1244 // If new guy is already wider than old, no widening | |
1245 if( _widen > ot->_widen ) return this; | |
1246 // If old guy was a constant, do not bother | |
1247 if (ot->_lo == ot->_hi) return this; | |
1248 // Now widen new guy. | |
1249 // Check for widening too far | |
1250 if (_widen == WidenMax) { | |
1009
03b336640699
6885584: A particular class structure causes large allocation spike for jit
never
parents:
992
diff
changeset
|
1251 int max = max_jint; |
03b336640699
6885584: A particular class structure causes large allocation spike for jit
never
parents:
992
diff
changeset
|
1252 int min = min_jint; |
03b336640699
6885584: A particular class structure causes large allocation spike for jit
never
parents:
992
diff
changeset
|
1253 if (limit->isa_int()) { |
03b336640699
6885584: A particular class structure causes large allocation spike for jit
never
parents:
992
diff
changeset
|
1254 max = limit->is_int()->_hi; |
03b336640699
6885584: A particular class structure causes large allocation spike for jit
never
parents:
992
diff
changeset
|
1255 min = limit->is_int()->_lo; |
03b336640699
6885584: A particular class structure causes large allocation spike for jit
never
parents:
992
diff
changeset
|
1256 } |
03b336640699
6885584: A particular class structure causes large allocation spike for jit
never
parents:
992
diff
changeset
|
1257 if (min < _lo && _hi < max) { |
0 | 1258 // If neither endpoint is extremal yet, push out the endpoint |
1259 // which is closer to its respective limit. | |
1260 if (_lo >= 0 || // easy common case | |
1009
03b336640699
6885584: A particular class structure causes large allocation spike for jit
never
parents:
992
diff
changeset
|
1261 (juint)(_lo - min) >= (juint)(max - _hi)) { |
0 | 1262 // 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
|
1263 return make(_lo, max, WidenMax); |
0 | 1264 } else { |
1009
03b336640699
6885584: A particular class structure causes large allocation spike for jit
never
parents:
992
diff
changeset
|
1265 return make(min, _hi, WidenMax); |
0 | 1266 } |
1267 } | |
1268 return TypeInt::INT; | |
1269 } | |
1270 // Returned widened new guy | |
1271 return make(_lo,_hi,_widen+1); | |
1272 } | |
1273 | |
1274 // If old guy contains new, then we probably widened too far & dropped to | |
1275 // bottom. Return the wider fellow. | |
1276 if ( ot->_lo <= _lo && ot->_hi >= _hi ) | |
1277 return old; | |
1278 | |
1279 //fatal("Integer value range is not subset"); | |
1280 //return this; | |
1281 return TypeInt::INT; | |
1282 } | |
1283 | |
1284 //------------------------------narrow--------------------------------------- | |
1285 // Only happens for pessimistic optimizations. | |
1286 const Type *TypeInt::narrow( const Type *old ) const { | |
1287 if (_lo >= _hi) return this; // already narrow enough | |
1288 if (old == NULL) return this; | |
1289 const TypeInt* ot = old->isa_int(); | |
1290 if (ot == NULL) return this; | |
1291 jint olo = ot->_lo; | |
1292 jint ohi = ot->_hi; | |
1293 | |
1294 // If new guy is equal to old guy, no narrowing | |
1295 if (_lo == olo && _hi == ohi) return old; | |
1296 | |
1297 // If old guy was maximum range, allow the narrowing | |
1298 if (olo == min_jint && ohi == max_jint) return this; | |
1299 | |
1300 if (_lo < olo || _hi > ohi) | |
1301 return this; // doesn't narrow; pretty wierd | |
1302 | |
1303 // The new type narrows the old type, so look for a "death march". | |
1304 // See comments on PhaseTransform::saturate. | |
1305 juint nrange = _hi - _lo; | |
1306 juint orange = ohi - olo; | |
1307 if (nrange < max_juint - 1 && nrange > (orange >> 1) + (SMALLINT*2)) { | |
1308 // Use the new type only if the range shrinks a lot. | |
1309 // We do not want the optimizer computing 2^31 point by point. | |
1310 return old; | |
1311 } | |
1312 | |
1313 return this; | |
1314 } | |
1315 | |
1316 //-----------------------------filter------------------------------------------ | |
1317 const Type *TypeInt::filter( const Type *kills ) const { | |
1318 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
|
1319 if (ft == NULL || ft->empty()) |
0 | 1320 return Type::TOP; // Canonical empty value |
1321 if (ft->_widen < this->_widen) { | |
1322 // Do not allow the value of kill->_widen to affect the outcome. | |
1323 // The widen bits must be allowed to run freely through the graph. | |
1324 ft = TypeInt::make(ft->_lo, ft->_hi, this->_widen); | |
1325 } | |
1326 return ft; | |
1327 } | |
1328 | |
1329 //------------------------------eq--------------------------------------------- | |
1330 // Structural equality check for Type representations | |
1331 bool TypeInt::eq( const Type *t ) const { | |
1332 const TypeInt *r = t->is_int(); // Handy access | |
1333 return r->_lo == _lo && r->_hi == _hi && r->_widen == _widen; | |
1334 } | |
1335 | |
1336 //------------------------------hash------------------------------------------- | |
1337 // Type-specific hashing function. | |
1338 int TypeInt::hash(void) const { | |
1339 return _lo+_hi+_widen+(int)Type::Int; | |
1340 } | |
1341 | |
1342 //------------------------------is_finite-------------------------------------- | |
1343 // Has a finite value | |
1344 bool TypeInt::is_finite() const { | |
1345 return true; | |
1346 } | |
1347 | |
1348 //------------------------------dump2------------------------------------------ | |
1349 // Dump TypeInt | |
1350 #ifndef PRODUCT | |
1351 static const char* intname(char* buf, jint n) { | |
1352 if (n == min_jint) | |
1353 return "min"; | |
1354 else if (n < min_jint + 10000) | |
1355 sprintf(buf, "min+" INT32_FORMAT, n - min_jint); | |
1356 else if (n == max_jint) | |
1357 return "max"; | |
1358 else if (n > max_jint - 10000) | |
1359 sprintf(buf, "max-" INT32_FORMAT, max_jint - n); | |
1360 else | |
1361 sprintf(buf, INT32_FORMAT, n); | |
1362 return buf; | |
1363 } | |
1364 | |
1365 void TypeInt::dump2( Dict &d, uint depth, outputStream *st ) const { | |
1366 char buf[40], buf2[40]; | |
1367 if (_lo == min_jint && _hi == max_jint) | |
1368 st->print("int"); | |
1369 else if (is_con()) | |
1370 st->print("int:%s", intname(buf, get_con())); | |
1371 else if (_lo == BOOL->_lo && _hi == BOOL->_hi) | |
1372 st->print("bool"); | |
1373 else if (_lo == BYTE->_lo && _hi == BYTE->_hi) | |
1374 st->print("byte"); | |
1375 else if (_lo == CHAR->_lo && _hi == CHAR->_hi) | |
1376 st->print("char"); | |
1377 else if (_lo == SHORT->_lo && _hi == SHORT->_hi) | |
1378 st->print("short"); | |
1379 else if (_hi == max_jint) | |
1380 st->print("int:>=%s", intname(buf, _lo)); | |
1381 else if (_lo == min_jint) | |
1382 st->print("int:<=%s", intname(buf, _hi)); | |
1383 else | |
1384 st->print("int:%s..%s", intname(buf, _lo), intname(buf2, _hi)); | |
1385 | |
1386 if (_widen != 0 && this != TypeInt::INT) | |
1387 st->print(":%.*s", _widen, "wwww"); | |
1388 } | |
1389 #endif | |
1390 | |
1391 //------------------------------singleton-------------------------------------- | |
1392 // TRUE if Type is a singleton type, FALSE otherwise. Singletons are simple | |
1393 // constants. | |
1394 bool TypeInt::singleton(void) const { | |
1395 return _lo >= _hi; | |
1396 } | |
1397 | |
1398 bool TypeInt::empty(void) const { | |
1399 return _lo > _hi; | |
1400 } | |
1401 | |
1402 //============================================================================= | |
1403 // Convenience common pre-built types. | |
1404 const TypeLong *TypeLong::MINUS_1;// -1 | |
1405 const TypeLong *TypeLong::ZERO; // 0 | |
1406 const TypeLong *TypeLong::ONE; // 1 | |
1407 const TypeLong *TypeLong::POS; // >=0 | |
1408 const TypeLong *TypeLong::LONG; // 64-bit integers | |
1409 const TypeLong *TypeLong::INT; // 32-bit subrange | |
1410 const TypeLong *TypeLong::UINT; // 32-bit unsigned subrange | |
1411 | |
1412 //------------------------------TypeLong--------------------------------------- | |
1413 TypeLong::TypeLong( jlong lo, jlong hi, int w ) : Type(Long), _lo(lo), _hi(hi), _widen(w) { | |
1414 } | |
1415 | |
1416 //------------------------------make------------------------------------------- | |
1417 const TypeLong *TypeLong::make( jlong lo ) { | |
1418 return (TypeLong*)(new TypeLong(lo,lo,WidenMin))->hashcons(); | |
1419 } | |
1420 | |
1620
d678e3277048
6964479: widen normalization of small int and long values should be symmetric
kvn
parents:
1552
diff
changeset
|
1421 static int normalize_long_widen( jlong lo, jlong hi, int w ) { |
0 | 1422 // 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
|
1423 // The 'SMALLINT' covers constants. |
0 | 1424 if (lo <= hi) { |
1620
d678e3277048
6964479: widen normalization of small int and long values should be symmetric
kvn
parents:
1552
diff
changeset
|
1425 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
|
1426 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
|
1427 } else { |
d678e3277048
6964479: widen normalization of small int and long values should be symmetric
kvn
parents:
1552
diff
changeset
|
1428 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
|
1429 if ((julong)(lo - hi) >= max_julong) w = Type::WidenMin; // dual TypeLong::LONG |
0 | 1430 } |
1620
d678e3277048
6964479: widen normalization of small int and long values should be symmetric
kvn
parents:
1552
diff
changeset
|
1431 return w; |
d678e3277048
6964479: widen normalization of small int and long values should be symmetric
kvn
parents:
1552
diff
changeset
|
1432 } |
d678e3277048
6964479: widen normalization of small int and long values should be symmetric
kvn
parents:
1552
diff
changeset
|
1433 |
d678e3277048
6964479: widen normalization of small int and long values should be symmetric
kvn
parents:
1552
diff
changeset
|
1434 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
|
1435 w = normalize_long_widen(lo, hi, w); |
0 | 1436 return (TypeLong*)(new TypeLong(lo,hi,w))->hashcons(); |
1437 } | |
1438 | |
1439 | |
1440 //------------------------------meet------------------------------------------- | |
1441 // Compute the MEET of two types. It returns a new Type representation object | |
1442 // with reference count equal to the number of Types pointing at it. | |
1443 // Caller should wrap a Types around it. | |
1444 const Type *TypeLong::xmeet( const Type *t ) const { | |
1445 // Perform a fast test for common case; meeting the same types together. | |
1446 if( this == t ) return this; // Meeting same type? | |
1447 | |
1448 // Currently "this->_base" is a TypeLong | |
1449 switch (t->base()) { // Switch on original type | |
1450 case AnyPtr: // Mixing with oops happens when javac | |
1451 case RawPtr: // reuses local variables | |
1452 case OopPtr: | |
1453 case InstPtr: | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6198
diff
changeset
|
1454 case AryPtr: |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6198
diff
changeset
|
1455 case MetadataPtr: |
0 | 1456 case KlassPtr: |
183
d4dbd9f91680
6711083: 64bit JVM crashes with Internal Error (type.cpp:763) - ShouldNotReachHere() with enabled COOPs
never
parents:
163
diff
changeset
|
1457 case NarrowOop: |
6848
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6735
diff
changeset
|
1458 case NarrowKlass: |
0 | 1459 case Int: |
1460 case FloatTop: | |
1461 case FloatCon: | |
1462 case FloatBot: | |
1463 case DoubleTop: | |
1464 case DoubleCon: | |
1465 case DoubleBot: | |
1466 case Bottom: // Ye Olde Default | |
1467 return Type::BOTTOM; | |
1468 default: // All else is a mistake | |
1469 typerr(t); | |
1470 case Top: // No change | |
1471 return this; | |
1472 case Long: // Long vs Long? | |
1473 break; | |
1474 } | |
1475 | |
1476 // Expand covered set | |
1477 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
|
1478 return make( MIN2(_lo,r->_lo), MAX2(_hi,r->_hi), MAX2(_widen,r->_widen) ); |
0 | 1479 } |
1480 | |
1481 //------------------------------xdual------------------------------------------ | |
1482 // Dual: reverse hi & lo; flip widen | |
1483 const Type *TypeLong::xdual() const { | |
1620
d678e3277048
6964479: widen normalization of small int and long values should be symmetric
kvn
parents:
1552
diff
changeset
|
1484 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
|
1485 return new TypeLong(_hi,_lo,w); |
0 | 1486 } |
1487 | |
1488 //------------------------------widen------------------------------------------ | |
1489 // 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
|
1490 const Type *TypeLong::widen( const Type *old, const Type* limit ) const { |
0 | 1491 // Coming from TOP or such; no widening |
1492 if( old->base() != Long ) return this; | |
1493 const TypeLong *ot = old->is_long(); | |
1494 | |
1495 // If new guy is equal to old guy, no widening | |
1496 if( _lo == ot->_lo && _hi == ot->_hi ) | |
1497 return old; | |
1498 | |
1499 // If new guy contains old, then we widened | |
1500 if( _lo <= ot->_lo && _hi >= ot->_hi ) { | |
1501 // New contains old | |
1502 // If new guy is already wider than old, no widening | |
1503 if( _widen > ot->_widen ) return this; | |
1504 // If old guy was a constant, do not bother | |
1505 if (ot->_lo == ot->_hi) return this; | |
1506 // Now widen new guy. | |
1507 // Check for widening too far | |
1508 if (_widen == WidenMax) { | |
1009
03b336640699
6885584: A particular class structure causes large allocation spike for jit
never
parents:
992
diff
changeset
|
1509 jlong max = max_jlong; |
03b336640699
6885584: A particular class structure causes large allocation spike for jit
never
parents:
992
diff
changeset
|
1510 jlong min = min_jlong; |
03b336640699
6885584: A particular class structure causes large allocation spike for jit
never
parents:
992
diff
changeset
|
1511 if (limit->isa_long()) { |
03b336640699
6885584: A particular class structure causes large allocation spike for jit
never
parents:
992
diff
changeset
|
1512 max = limit->is_long()->_hi; |
03b336640699
6885584: A particular class structure causes large allocation spike for jit
never
parents:
992
diff
changeset
|
1513 min = limit->is_long()->_lo; |
03b336640699
6885584: A particular class structure causes large allocation spike for jit
never
parents:
992
diff
changeset
|
1514 } |
03b336640699
6885584: A particular class structure causes large allocation spike for jit
never
parents:
992
diff
changeset
|
1515 if (min < _lo && _hi < max) { |
0 | 1516 // If neither endpoint is extremal yet, push out the endpoint |
1517 // which is closer to its respective limit. | |
1518 if (_lo >= 0 || // easy common case | |
1009
03b336640699
6885584: A particular class structure causes large allocation spike for jit
never
parents:
992
diff
changeset
|
1519 (julong)(_lo - min) >= (julong)(max - _hi)) { |
0 | 1520 // 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
|
1521 if (max >= max_juint && _hi < max_juint) |
0 | 1522 return make(_lo, max_juint, WidenMax); |
1523 else | |
1009
03b336640699
6885584: A particular class structure causes large allocation spike for jit
never
parents:
992
diff
changeset
|
1524 return make(_lo, max, WidenMax); |
0 | 1525 } else { |
1009
03b336640699
6885584: A particular class structure causes large allocation spike for jit
never
parents:
992
diff
changeset
|
1526 return make(min, _hi, WidenMax); |
0 | 1527 } |
1528 } | |
1529 return TypeLong::LONG; | |
1530 } | |
1531 // Returned widened new guy | |
1532 return make(_lo,_hi,_widen+1); | |
1533 } | |
1534 | |
1535 // If old guy contains new, then we probably widened too far & dropped to | |
1536 // bottom. Return the wider fellow. | |
1537 if ( ot->_lo <= _lo && ot->_hi >= _hi ) | |
1538 return old; | |
1539 | |
1540 // fatal("Long value range is not subset"); | |
1541 // return this; | |
1542 return TypeLong::LONG; | |
1543 } | |
1544 | |
1545 //------------------------------narrow---------------------------------------- | |
1546 // Only happens for pessimistic optimizations. | |
1547 const Type *TypeLong::narrow( const Type *old ) const { | |
1548 if (_lo >= _hi) return this; // already narrow enough | |
1549 if (old == NULL) return this; | |
1550 const TypeLong* ot = old->isa_long(); | |
1551 if (ot == NULL) return this; | |
1552 jlong olo = ot->_lo; | |
1553 jlong ohi = ot->_hi; | |
1554 | |
1555 // If new guy is equal to old guy, no narrowing | |
1556 if (_lo == olo && _hi == ohi) return old; | |
1557 | |
1558 // If old guy was maximum range, allow the narrowing | |
1559 if (olo == min_jlong && ohi == max_jlong) return this; | |
1560 | |
1561 if (_lo < olo || _hi > ohi) | |
1562 return this; // doesn't narrow; pretty wierd | |
1563 | |
1564 // The new type narrows the old type, so look for a "death march". | |
1565 // See comments on PhaseTransform::saturate. | |
1566 julong nrange = _hi - _lo; | |
1567 julong orange = ohi - olo; | |
1568 if (nrange < max_julong - 1 && nrange > (orange >> 1) + (SMALLINT*2)) { | |
1569 // Use the new type only if the range shrinks a lot. | |
1570 // We do not want the optimizer computing 2^31 point by point. | |
1571 return old; | |
1572 } | |
1573 | |
1574 return this; | |
1575 } | |
1576 | |
1577 //-----------------------------filter------------------------------------------ | |
1578 const Type *TypeLong::filter( const Type *kills ) const { | |
1579 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
|
1580 if (ft == NULL || ft->empty()) |
0 | 1581 return Type::TOP; // Canonical empty value |
1582 if (ft->_widen < this->_widen) { | |
1583 // Do not allow the value of kill->_widen to affect the outcome. | |
1584 // The widen bits must be allowed to run freely through the graph. | |
1585 ft = TypeLong::make(ft->_lo, ft->_hi, this->_widen); | |
1586 } | |
1587 return ft; | |
1588 } | |
1589 | |
1590 //------------------------------eq--------------------------------------------- | |
1591 // Structural equality check for Type representations | |
1592 bool TypeLong::eq( const Type *t ) const { | |
1593 const TypeLong *r = t->is_long(); // Handy access | |
1594 return r->_lo == _lo && r->_hi == _hi && r->_widen == _widen; | |
1595 } | |
1596 | |
1597 //------------------------------hash------------------------------------------- | |
1598 // Type-specific hashing function. | |
1599 int TypeLong::hash(void) const { | |
1600 return (int)(_lo+_hi+_widen+(int)Type::Long); | |
1601 } | |
1602 | |
1603 //------------------------------is_finite-------------------------------------- | |
1604 // Has a finite value | |
1605 bool TypeLong::is_finite() const { | |
1606 return true; | |
1607 } | |
1608 | |
1609 //------------------------------dump2------------------------------------------ | |
1610 // Dump TypeLong | |
1611 #ifndef PRODUCT | |
1612 static const char* longnamenear(jlong x, const char* xname, char* buf, jlong n) { | |
1613 if (n > x) { | |
1614 if (n >= x + 10000) return NULL; | |
7623
203f64878aab
7102489: RFE: cleanup jlong typedef on __APPLE__and _LLP64 systems.
hseigel
parents:
6890
diff
changeset
|
1615 sprintf(buf, "%s+" JLONG_FORMAT, xname, n - x); |
0 | 1616 } else if (n < x) { |
1617 if (n <= x - 10000) return NULL; | |
7623
203f64878aab
7102489: RFE: cleanup jlong typedef on __APPLE__and _LLP64 systems.
hseigel
parents:
6890
diff
changeset
|
1618 sprintf(buf, "%s-" JLONG_FORMAT, xname, x - n); |
0 | 1619 } else { |
1620 return xname; | |
1621 } | |
1622 return buf; | |
1623 } | |
1624 | |
1625 static const char* longname(char* buf, jlong n) { | |
1626 const char* str; | |
1627 if (n == min_jlong) | |
1628 return "min"; | |
1629 else if (n < min_jlong + 10000) | |
7623
203f64878aab
7102489: RFE: cleanup jlong typedef on __APPLE__and _LLP64 systems.
hseigel
parents:
6890
diff
changeset
|
1630 sprintf(buf, "min+" JLONG_FORMAT, n - min_jlong); |
0 | 1631 else if (n == max_jlong) |
1632 return "max"; | |
1633 else if (n > max_jlong - 10000) | |
7623
203f64878aab
7102489: RFE: cleanup jlong typedef on __APPLE__and _LLP64 systems.
hseigel
parents:
6890
diff
changeset
|
1634 sprintf(buf, "max-" JLONG_FORMAT, max_jlong - n); |
0 | 1635 else if ((str = longnamenear(max_juint, "maxuint", buf, n)) != NULL) |
1636 return str; | |
1637 else if ((str = longnamenear(max_jint, "maxint", buf, n)) != NULL) | |
1638 return str; | |
1639 else if ((str = longnamenear(min_jint, "minint", buf, n)) != NULL) | |
1640 return str; | |
1641 else | |
7623
203f64878aab
7102489: RFE: cleanup jlong typedef on __APPLE__and _LLP64 systems.
hseigel
parents:
6890
diff
changeset
|
1642 sprintf(buf, JLONG_FORMAT, n); |
0 | 1643 return buf; |
1644 } | |
1645 | |
1646 void TypeLong::dump2( Dict &d, uint depth, outputStream *st ) const { | |
1647 char buf[80], buf2[80]; | |
1648 if (_lo == min_jlong && _hi == max_jlong) | |
1649 st->print("long"); | |
1650 else if (is_con()) | |
1651 st->print("long:%s", longname(buf, get_con())); | |
1652 else if (_hi == max_jlong) | |
1653 st->print("long:>=%s", longname(buf, _lo)); | |
1654 else if (_lo == min_jlong) | |
1655 st->print("long:<=%s", longname(buf, _hi)); | |
1656 else | |
1657 st->print("long:%s..%s", longname(buf, _lo), longname(buf2, _hi)); | |
1658 | |
1659 if (_widen != 0 && this != TypeLong::LONG) | |
1660 st->print(":%.*s", _widen, "wwww"); | |
1661 } | |
1662 #endif | |
1663 | |
1664 //------------------------------singleton-------------------------------------- | |
1665 // TRUE if Type is a singleton type, FALSE otherwise. Singletons are simple | |
1666 // constants | |
1667 bool TypeLong::singleton(void) const { | |
1668 return _lo >= _hi; | |
1669 } | |
1670 | |
1671 bool TypeLong::empty(void) const { | |
1672 return _lo > _hi; | |
1673 } | |
1674 | |
1675 //============================================================================= | |
1676 // Convenience common pre-built types. | |
1677 const TypeTuple *TypeTuple::IFBOTH; // Return both arms of IF as reachable | |
1678 const TypeTuple *TypeTuple::IFFALSE; | |
1679 const TypeTuple *TypeTuple::IFTRUE; | |
1680 const TypeTuple *TypeTuple::IFNEITHER; | |
1681 const TypeTuple *TypeTuple::LOOPBODY; | |
1682 const TypeTuple *TypeTuple::MEMBAR; | |
1683 const TypeTuple *TypeTuple::STORECONDITIONAL; | |
1684 const TypeTuple *TypeTuple::START_I2C; | |
1685 const TypeTuple *TypeTuple::INT_PAIR; | |
1686 const TypeTuple *TypeTuple::LONG_PAIR; | |
12323 | 1687 const TypeTuple *TypeTuple::INT_CC_PAIR; |
12972
59e8ad757e19
8026844: Various Math functions needs intrinsification
rbackman
parents:
12966
diff
changeset
|
1688 const TypeTuple *TypeTuple::LONG_CC_PAIR; |
0 | 1689 |
1690 | |
1691 //------------------------------make------------------------------------------- | |
1692 // Make a TypeTuple from the range of a method signature | |
1693 const TypeTuple *TypeTuple::make_range(ciSignature* sig) { | |
1694 ciType* return_type = sig->return_type(); | |
1695 uint total_fields = TypeFunc::Parms + return_type->size(); | |
1696 const Type **field_array = fields(total_fields); | |
1697 switch (return_type->basic_type()) { | |
1698 case T_LONG: | |
1699 field_array[TypeFunc::Parms] = TypeLong::LONG; | |
1700 field_array[TypeFunc::Parms+1] = Type::HALF; | |
1701 break; | |
1702 case T_DOUBLE: | |
1703 field_array[TypeFunc::Parms] = Type::DOUBLE; | |
1704 field_array[TypeFunc::Parms+1] = Type::HALF; | |
1705 break; | |
1706 case T_OBJECT: | |
1707 case T_ARRAY: | |
1708 case T_BOOLEAN: | |
1709 case T_CHAR: | |
1710 case T_FLOAT: | |
1711 case T_BYTE: | |
1712 case T_SHORT: | |
1713 case T_INT: | |
1714 field_array[TypeFunc::Parms] = get_const_type(return_type); | |
1715 break; | |
1716 case T_VOID: | |
1717 break; | |
1718 default: | |
1719 ShouldNotReachHere(); | |
1720 } | |
1721 return (TypeTuple*)(new TypeTuple(total_fields,field_array))->hashcons(); | |
1722 } | |
1723 | |
1724 // Make a TypeTuple from the domain of a method signature | |
1725 const TypeTuple *TypeTuple::make_domain(ciInstanceKlass* recv, ciSignature* sig) { | |
1726 uint total_fields = TypeFunc::Parms + sig->size(); | |
1727 | |
1728 uint pos = TypeFunc::Parms; | |
1729 const Type **field_array; | |
1730 if (recv != NULL) { | |
1731 total_fields++; | |
1732 field_array = fields(total_fields); | |
1733 // Use get_const_type here because it respects UseUniqueSubclasses: | |
1734 field_array[pos++] = get_const_type(recv)->join(TypePtr::NOTNULL); | |
1735 } else { | |
1736 field_array = fields(total_fields); | |
1737 } | |
1738 | |
1739 int i = 0; | |
1740 while (pos < total_fields) { | |
1741 ciType* type = sig->type_at(i); | |
1742 | |
1743 switch (type->basic_type()) { | |
1744 case T_LONG: | |
1745 field_array[pos++] = TypeLong::LONG; | |
1746 field_array[pos++] = Type::HALF; | |
1747 break; | |
1748 case T_DOUBLE: | |
1749 field_array[pos++] = Type::DOUBLE; | |
1750 field_array[pos++] = Type::HALF; | |
1751 break; | |
1752 case T_OBJECT: | |
1753 case T_ARRAY: | |
1754 case T_BOOLEAN: | |
1755 case T_CHAR: | |
1756 case T_FLOAT: | |
1757 case T_BYTE: | |
1758 case T_SHORT: | |
1759 case T_INT: | |
1760 field_array[pos++] = get_const_type(type); | |
1761 break; | |
1762 default: | |
1763 ShouldNotReachHere(); | |
1764 } | |
1765 i++; | |
1766 } | |
1767 return (TypeTuple*)(new TypeTuple(total_fields,field_array))->hashcons(); | |
1768 } | |
1769 | |
1770 const TypeTuple *TypeTuple::make( uint cnt, const Type **fields ) { | |
1771 return (TypeTuple*)(new TypeTuple(cnt,fields))->hashcons(); | |
1772 } | |
1773 | |
1774 //------------------------------fields----------------------------------------- | |
1775 // Subroutine call type with space allocated for argument types | |
1776 const Type **TypeTuple::fields( uint arg_cnt ) { | |
1777 const Type **flds = (const Type **)(Compile::current()->type_arena()->Amalloc_4((TypeFunc::Parms+arg_cnt)*sizeof(Type*) )); | |
1778 flds[TypeFunc::Control ] = Type::CONTROL; | |
1779 flds[TypeFunc::I_O ] = Type::ABIO; | |
1780 flds[TypeFunc::Memory ] = Type::MEMORY; | |
1781 flds[TypeFunc::FramePtr ] = TypeRawPtr::BOTTOM; | |
1782 flds[TypeFunc::ReturnAdr] = Type::RETURN_ADDRESS; | |
1783 | |
1784 return flds; | |
1785 } | |
1786 | |
1787 //------------------------------meet------------------------------------------- | |
1788 // Compute the MEET of two types. It returns a new Type object. | |
1789 const Type *TypeTuple::xmeet( const Type *t ) const { | |
1790 // Perform a fast test for common case; meeting the same types together. | |
1791 if( this == t ) return this; // Meeting same type-rep? | |
1792 | |
1793 // Current "this->_base" is Tuple | |
1794 switch (t->base()) { // switch on original type | |
1795 | |
1796 case Bottom: // Ye Olde Default | |
1797 return t; | |
1798 | |
1799 default: // All else is a mistake | |
1800 typerr(t); | |
1801 | |
1802 case Tuple: { // Meeting 2 signatures? | |
1803 const TypeTuple *x = t->is_tuple(); | |
1804 assert( _cnt == x->_cnt, "" ); | |
1805 const Type **fields = (const Type **)(Compile::current()->type_arena()->Amalloc_4( _cnt*sizeof(Type*) )); | |
1806 for( uint i=0; i<_cnt; i++ ) | |
1807 fields[i] = field_at(i)->xmeet( x->field_at(i) ); | |
1808 return TypeTuple::make(_cnt,fields); | |
1809 } | |
1810 case Top: | |
1811 break; | |
1812 } | |
1813 return this; // Return the double constant | |
1814 } | |
1815 | |
1816 //------------------------------xdual------------------------------------------ | |
1817 // Dual: compute field-by-field dual | |
1818 const Type *TypeTuple::xdual() const { | |
1819 const Type **fields = (const Type **)(Compile::current()->type_arena()->Amalloc_4( _cnt*sizeof(Type*) )); | |
1820 for( uint i=0; i<_cnt; i++ ) | |
1821 fields[i] = _fields[i]->dual(); | |
1822 return new TypeTuple(_cnt,fields); | |
1823 } | |
1824 | |
1825 //------------------------------eq--------------------------------------------- | |
1826 // Structural equality check for Type representations | |
1827 bool TypeTuple::eq( const Type *t ) const { | |
1828 const TypeTuple *s = (const TypeTuple *)t; | |
1829 if (_cnt != s->_cnt) return false; // Unequal field counts | |
1830 for (uint i = 0; i < _cnt; i++) | |
1831 if (field_at(i) != s->field_at(i)) // POINTER COMPARE! NO RECURSION! | |
1832 return false; // Missed | |
1833 return true; | |
1834 } | |
1835 | |
1836 //------------------------------hash------------------------------------------- | |
1837 // Type-specific hashing function. | |
1838 int TypeTuple::hash(void) const { | |
1839 intptr_t sum = _cnt; | |
1840 for( uint i=0; i<_cnt; i++ ) | |
1841 sum += (intptr_t)_fields[i]; // Hash on pointers directly | |
1842 return sum; | |
1843 } | |
1844 | |
1845 //------------------------------dump2------------------------------------------ | |
1846 // Dump signature Type | |
1847 #ifndef PRODUCT | |
1848 void TypeTuple::dump2( Dict &d, uint depth, outputStream *st ) const { | |
1849 st->print("{"); | |
1850 if( !depth || d[this] ) { // Check for recursive print | |
1851 st->print("...}"); | |
1852 return; | |
1853 } | |
1854 d.Insert((void*)this, (void*)this); // Stop recursion | |
1855 if( _cnt ) { | |
1856 uint i; | |
1857 for( i=0; i<_cnt-1; i++ ) { | |
1858 st->print("%d:", i); | |
1859 _fields[i]->dump2(d, depth-1, st); | |
1860 st->print(", "); | |
1861 } | |
1862 st->print("%d:", i); | |
1863 _fields[i]->dump2(d, depth-1, st); | |
1864 } | |
1865 st->print("}"); | |
1866 } | |
1867 #endif | |
1868 | |
1869 //------------------------------singleton-------------------------------------- | |
1870 // TRUE if Type is a singleton type, FALSE otherwise. Singletons are simple | |
1871 // constants (Ldi nodes). Singletons are integer, float or double constants | |
1872 // or a single symbol. | |
1873 bool TypeTuple::singleton(void) const { | |
1874 return false; // Never a singleton | |
1875 } | |
1876 | |
1877 bool TypeTuple::empty(void) const { | |
1878 for( uint i=0; i<_cnt; i++ ) { | |
1879 if (_fields[i]->empty()) return true; | |
1880 } | |
1881 return false; | |
1882 } | |
1883 | |
1884 //============================================================================= | |
1885 // Convenience common pre-built types. | |
1886 | |
1887 inline const TypeInt* normalize_array_size(const TypeInt* size) { | |
1888 // Certain normalizations keep us sane when comparing types. | |
1889 // We do not want arrayOop variables to differ only by the wideness | |
1890 // of their index types. Pick minimum wideness, since that is the | |
1891 // forced wideness of small ranges anyway. | |
1892 if (size->_widen != Type::WidenMin) | |
1893 return TypeInt::make(size->_lo, size->_hi, Type::WidenMin); | |
1894 else | |
1895 return size; | |
1896 } | |
1897 | |
1898 //------------------------------make------------------------------------------- | |
12190
edb5ab0f3fe5
8001107: @Stable annotation for constant folding of lazily evaluated variables
vlivanov
parents:
10278
diff
changeset
|
1899 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
|
1900 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
|
1901 elem = elem->make_narrowoop(); |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
1902 } |
0 | 1903 size = normalize_array_size(size); |
12190
edb5ab0f3fe5
8001107: @Stable annotation for constant folding of lazily evaluated variables
vlivanov
parents:
10278
diff
changeset
|
1904 return (TypeAry*)(new TypeAry(elem,size,stable))->hashcons(); |
0 | 1905 } |
1906 | |
1907 //------------------------------meet------------------------------------------- | |
1908 // Compute the MEET of two types. It returns a new Type object. | |
1909 const Type *TypeAry::xmeet( const Type *t ) const { | |
1910 // Perform a fast test for common case; meeting the same types together. | |
1911 if( this == t ) return this; // Meeting same type-rep? | |
1912 | |
1913 // Current "this->_base" is Ary | |
1914 switch (t->base()) { // switch on original type | |
1915 | |
1916 case Bottom: // Ye Olde Default | |
1917 return t; | |
1918 | |
1919 default: // All else is a mistake | |
1920 typerr(t); | |
1921 | |
1922 case Array: { // Meeting 2 arrays? | |
1923 const TypeAry *a = t->is_ary(); | |
1924 return TypeAry::make(_elem->meet(a->_elem), | |
12190
edb5ab0f3fe5
8001107: @Stable annotation for constant folding of lazily evaluated variables
vlivanov
parents:
10278
diff
changeset
|
1925 _size->xmeet(a->_size)->is_int(), |
edb5ab0f3fe5
8001107: @Stable annotation for constant folding of lazily evaluated variables
vlivanov
parents:
10278
diff
changeset
|
1926 _stable & a->_stable); |
0 | 1927 } |
1928 case Top: | |
1929 break; | |
1930 } | |
1931 return this; // Return the double constant | |
1932 } | |
1933 | |
1934 //------------------------------xdual------------------------------------------ | |
1935 // Dual: compute field-by-field dual | |
1936 const Type *TypeAry::xdual() const { | |
1937 const TypeInt* size_dual = _size->dual()->is_int(); | |
1938 size_dual = normalize_array_size(size_dual); | |
12190
edb5ab0f3fe5
8001107: @Stable annotation for constant folding of lazily evaluated variables
vlivanov
parents:
10278
diff
changeset
|
1939 return new TypeAry(_elem->dual(), size_dual, !_stable); |
0 | 1940 } |
1941 | |
1942 //------------------------------eq--------------------------------------------- | |
1943 // Structural equality check for Type representations | |
1944 bool TypeAry::eq( const Type *t ) const { | |
1945 const TypeAry *a = (const TypeAry*)t; | |
1946 return _elem == a->_elem && | |
12190
edb5ab0f3fe5
8001107: @Stable annotation for constant folding of lazily evaluated variables
vlivanov
parents:
10278
diff
changeset
|
1947 _stable == a->_stable && |
0 | 1948 _size == a->_size; |
1949 } | |
1950 | |
1951 //------------------------------hash------------------------------------------- | |
1952 // Type-specific hashing function. | |
1953 int TypeAry::hash(void) const { | |
12190
edb5ab0f3fe5
8001107: @Stable annotation for constant folding of lazily evaluated variables
vlivanov
parents:
10278
diff
changeset
|
1954 return (intptr_t)_elem + (intptr_t)_size + (_stable ? 43 : 0); |
0 | 1955 } |
1956 | |
820
915cc9c5ebc6
6837094: False positive for "meet not symmetric" failure
kvn
parents:
628
diff
changeset
|
1957 //----------------------interface_vs_oop--------------------------------------- |
915cc9c5ebc6
6837094: False positive for "meet not symmetric" failure
kvn
parents:
628
diff
changeset
|
1958 #ifdef ASSERT |
915cc9c5ebc6
6837094: False positive for "meet not symmetric" failure
kvn
parents:
628
diff
changeset
|
1959 bool TypeAry::interface_vs_oop(const Type *t) const { |
915cc9c5ebc6
6837094: False positive for "meet not symmetric" failure
kvn
parents:
628
diff
changeset
|
1960 const TypeAry* t_ary = t->is_ary(); |
915cc9c5ebc6
6837094: False positive for "meet not symmetric" failure
kvn
parents:
628
diff
changeset
|
1961 if (t_ary) { |
915cc9c5ebc6
6837094: False positive for "meet not symmetric" failure
kvn
parents:
628
diff
changeset
|
1962 return _elem->interface_vs_oop(t_ary->_elem); |
915cc9c5ebc6
6837094: False positive for "meet not symmetric" failure
kvn
parents:
628
diff
changeset
|
1963 } |
915cc9c5ebc6
6837094: False positive for "meet not symmetric" failure
kvn
parents:
628
diff
changeset
|
1964 return false; |
915cc9c5ebc6
6837094: False positive for "meet not symmetric" failure
kvn
parents:
628
diff
changeset
|
1965 } |
915cc9c5ebc6
6837094: False positive for "meet not symmetric" failure
kvn
parents:
628
diff
changeset
|
1966 #endif |
915cc9c5ebc6
6837094: False positive for "meet not symmetric" failure
kvn
parents:
628
diff
changeset
|
1967 |
0 | 1968 //------------------------------dump2------------------------------------------ |
1969 #ifndef PRODUCT | |
1970 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
|
1971 if (_stable) st->print("stable:"); |
0 | 1972 _elem->dump2(d, depth, st); |
1973 st->print("["); | |
1974 _size->dump2(d, depth, st); | |
1975 st->print("]"); | |
1976 } | |
1977 #endif | |
1978 | |
1979 //------------------------------singleton-------------------------------------- | |
1980 // TRUE if Type is a singleton type, FALSE otherwise. Singletons are simple | |
1981 // constants (Ldi nodes). Singletons are integer, float or double constants | |
1982 // or a single symbol. | |
1983 bool TypeAry::singleton(void) const { | |
1984 return false; // Never a singleton | |
1985 } | |
1986 | |
1987 bool TypeAry::empty(void) const { | |
1988 return _elem->empty() || _size->empty(); | |
1989 } | |
1990 | |
1991 //--------------------------ary_must_be_exact---------------------------------- | |
1992 bool TypeAry::ary_must_be_exact() const { | |
1993 if (!UseExactTypes) return false; | |
1994 // This logic looks at the element type of an array, and returns true | |
1995 // if the element type is either a primitive or a final instance class. | |
1996 // In such cases, an array built on this ary must have no subclasses. | |
1997 if (_elem == BOTTOM) return false; // general array not exact | |
1998 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
|
1999 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
|
2000 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
|
2001 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
|
2002 } else { |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
2003 toop = _elem->isa_oopptr(); |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
2004 } |
0 | 2005 if (!toop) return true; // a primitive type, like int |
2006 ciKlass* tklass = toop->klass(); | |
2007 if (tklass == NULL) return false; // unloaded class | |
2008 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
|
2009 const TypeInstPtr* tinst; |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
2010 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
|
2011 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
|
2012 else |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
2013 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
|
2014 if (tinst) |
1e026f8da827
6710487: More than half of JDI Regression tests hang with COOPs in -Xcomp mode
kvn
parents:
183
diff
changeset
|
2015 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
|
2016 const TypeAryPtr* tap; |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
2017 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
|
2018 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
|
2019 else |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
2020 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
|
2021 if (tap) |
1e026f8da827
6710487: More than half of JDI Regression tests hang with COOPs in -Xcomp mode
kvn
parents:
183
diff
changeset
|
2022 return tap->ary()->ary_must_be_exact(); |
0 | 2023 return false; |
2024 } | |
2025 | |
6179
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
2376
diff
changeset
|
2026 //==============================TypeVect======================================= |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
2376
diff
changeset
|
2027 // Convenience common pre-built types. |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
2376
diff
changeset
|
2028 const TypeVect *TypeVect::VECTS = NULL; // 32-bit vectors |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
2376
diff
changeset
|
2029 const TypeVect *TypeVect::VECTD = NULL; // 64-bit vectors |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
2376
diff
changeset
|
2030 const TypeVect *TypeVect::VECTX = NULL; // 128-bit vectors |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
2376
diff
changeset
|
2031 const TypeVect *TypeVect::VECTY = NULL; // 256-bit vectors |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
2376
diff
changeset
|
2032 |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
2376
diff
changeset
|
2033 //------------------------------make------------------------------------------- |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
2376
diff
changeset
|
2034 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
|
2035 BasicType elem_bt = elem->array_element_basic_type(); |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
2376
diff
changeset
|
2036 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
|
2037 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
|
2038 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
|
2039 int size = length * type2aelembytes(elem_bt); |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
2376
diff
changeset
|
2040 switch (Matcher::vector_ideal_reg(size)) { |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
2376
diff
changeset
|
2041 case Op_VecS: |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
2376
diff
changeset
|
2042 return (TypeVect*)(new TypeVectS(elem, length))->hashcons(); |
14437
15120a36272d
8028767: PPC64: (part 121): smaller shared changes needed to build C2
goetz
parents:
13014
diff
changeset
|
2043 case Op_RegL: |
6179
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
2376
diff
changeset
|
2044 case Op_VecD: |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
2376
diff
changeset
|
2045 case Op_RegD: |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
2376
diff
changeset
|
2046 return (TypeVect*)(new TypeVectD(elem, length))->hashcons(); |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
2376
diff
changeset
|
2047 case Op_VecX: |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
2376
diff
changeset
|
2048 return (TypeVect*)(new TypeVectX(elem, length))->hashcons(); |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
2376
diff
changeset
|
2049 case Op_VecY: |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
2376
diff
changeset
|
2050 return (TypeVect*)(new TypeVectY(elem, length))->hashcons(); |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
2376
diff
changeset
|
2051 } |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
2376
diff
changeset
|
2052 ShouldNotReachHere(); |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
2376
diff
changeset
|
2053 return NULL; |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
2376
diff
changeset
|
2054 } |
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 //------------------------------meet------------------------------------------- |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
2376
diff
changeset
|
2057 // 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
|
2058 const Type *TypeVect::xmeet( const Type *t ) const { |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
2376
diff
changeset
|
2059 // 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
|
2060 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
|
2061 |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
2376
diff
changeset
|
2062 // Current "this->_base" is Vector |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
2376
diff
changeset
|
2063 switch (t->base()) { // switch on original type |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
2376
diff
changeset
|
2064 |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
2376
diff
changeset
|
2065 case Bottom: // Ye Olde Default |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
2376
diff
changeset
|
2066 return t; |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
2376
diff
changeset
|
2067 |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
2376
diff
changeset
|
2068 default: // All else is a mistake |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
2376
diff
changeset
|
2069 typerr(t); |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
2376
diff
changeset
|
2070 |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
2376
diff
changeset
|
2071 case VectorS: |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
2376
diff
changeset
|
2072 case VectorD: |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
2376
diff
changeset
|
2073 case VectorX: |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
2376
diff
changeset
|
2074 case VectorY: { // Meeting 2 vectors? |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
2376
diff
changeset
|
2075 const TypeVect* v = t->is_vect(); |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
2376
diff
changeset
|
2076 assert( base() == v->base(), ""); |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
2376
diff
changeset
|
2077 assert(length() == v->length(), ""); |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
2376
diff
changeset
|
2078 assert(element_basic_type() == v->element_basic_type(), ""); |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
2376
diff
changeset
|
2079 return TypeVect::make(_elem->xmeet(v->_elem), _length); |
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 case Top: |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
2376
diff
changeset
|
2082 break; |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
2376
diff
changeset
|
2083 } |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
2376
diff
changeset
|
2084 return this; |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
2376
diff
changeset
|
2085 } |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
2376
diff
changeset
|
2086 |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
2376
diff
changeset
|
2087 //------------------------------xdual------------------------------------------ |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
2376
diff
changeset
|
2088 // Dual: compute field-by-field dual |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
2376
diff
changeset
|
2089 const Type *TypeVect::xdual() const { |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
2376
diff
changeset
|
2090 return new TypeVect(base(), _elem->dual(), _length); |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
2376
diff
changeset
|
2091 } |
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 //------------------------------eq--------------------------------------------- |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
2376
diff
changeset
|
2094 // Structural equality check for Type representations |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
2376
diff
changeset
|
2095 bool TypeVect::eq(const Type *t) const { |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
2376
diff
changeset
|
2096 const TypeVect *v = t->is_vect(); |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
2376
diff
changeset
|
2097 return (_elem == v->_elem) && (_length == v->_length); |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
2376
diff
changeset
|
2098 } |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
2376
diff
changeset
|
2099 |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
2376
diff
changeset
|
2100 //------------------------------hash------------------------------------------- |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
2376
diff
changeset
|
2101 // Type-specific hashing function. |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
2376
diff
changeset
|
2102 int TypeVect::hash(void) const { |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
2376
diff
changeset
|
2103 return (intptr_t)_elem + (intptr_t)_length; |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
2376
diff
changeset
|
2104 } |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
2376
diff
changeset
|
2105 |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
2376
diff
changeset
|
2106 //------------------------------singleton-------------------------------------- |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
2376
diff
changeset
|
2107 // 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
|
2108 // 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
|
2109 // 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
|
2110 bool TypeVect::singleton(void) const { |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
2376
diff
changeset
|
2111 // There is no Con node for vectors yet. |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
2376
diff
changeset
|
2112 // return _elem->singleton(); |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
2376
diff
changeset
|
2113 return false; |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
2376
diff
changeset
|
2114 } |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
2376
diff
changeset
|
2115 |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
2376
diff
changeset
|
2116 bool TypeVect::empty(void) const { |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
2376
diff
changeset
|
2117 return _elem->empty(); |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
2376
diff
changeset
|
2118 } |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
2376
diff
changeset
|
2119 |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
2376
diff
changeset
|
2120 //------------------------------dump2------------------------------------------ |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
2376
diff
changeset
|
2121 #ifndef PRODUCT |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
2376
diff
changeset
|
2122 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
|
2123 switch (base()) { |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
2376
diff
changeset
|
2124 case VectorS: |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
2376
diff
changeset
|
2125 st->print("vectors["); break; |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
2376
diff
changeset
|
2126 case VectorD: |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
2376
diff
changeset
|
2127 st->print("vectord["); break; |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
2376
diff
changeset
|
2128 case VectorX: |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
2376
diff
changeset
|
2129 st->print("vectorx["); break; |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
2376
diff
changeset
|
2130 case VectorY: |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
2376
diff
changeset
|
2131 st->print("vectory["); break; |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
2376
diff
changeset
|
2132 default: |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
2376
diff
changeset
|
2133 ShouldNotReachHere(); |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
2376
diff
changeset
|
2134 } |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
2376
diff
changeset
|
2135 st->print("%d]:{", _length); |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
2376
diff
changeset
|
2136 _elem->dump2(d, depth, st); |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
2376
diff
changeset
|
2137 st->print("}"); |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
2376
diff
changeset
|
2138 } |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
2376
diff
changeset
|
2139 #endif |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
2376
diff
changeset
|
2140 |
8c92982cbbc4
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
2376
diff
changeset
|
2141 |
0 | 2142 //============================================================================= |
2143 // Convenience common pre-built types. | |
2144 const TypePtr *TypePtr::NULL_PTR; | |
2145 const TypePtr *TypePtr::NOTNULL; | |
2146 const TypePtr *TypePtr::BOTTOM; | |
2147 | |
2148 //------------------------------meet------------------------------------------- | |
2149 // Meet over the PTR enum | |
2150 const TypePtr::PTR TypePtr::ptr_meet[TypePtr::lastPTR][TypePtr::lastPTR] = { | |
2151 // TopPTR, AnyNull, Constant, Null, NotNull, BotPTR, | |
2152 { /* Top */ TopPTR, AnyNull, Constant, Null, NotNull, BotPTR,}, | |
2153 { /* AnyNull */ AnyNull, AnyNull, Constant, BotPTR, NotNull, BotPTR,}, | |
2154 { /* Constant*/ Constant, Constant, Constant, BotPTR, NotNull, BotPTR,}, | |
2155 { /* Null */ Null, BotPTR, BotPTR, Null, BotPTR, BotPTR,}, | |
2156 { /* NotNull */ NotNull, NotNull, NotNull, BotPTR, NotNull, BotPTR,}, | |
2157 { /* BotPTR */ BotPTR, BotPTR, BotPTR, BotPTR, BotPTR, BotPTR,} | |
2158 }; | |
2159 | |
2160 //------------------------------make------------------------------------------- | |
2161 const TypePtr *TypePtr::make( TYPES t, enum PTR ptr, int offset ) { | |
2162 return (TypePtr*)(new TypePtr(t,ptr,offset))->hashcons(); | |
2163 } | |
2164 | |
2165 //------------------------------cast_to_ptr_type------------------------------- | |
2166 const Type *TypePtr::cast_to_ptr_type(PTR ptr) const { | |
2167 assert(_base == AnyPtr, "subclass must override cast_to_ptr_type"); | |
2168 if( ptr == _ptr ) return this; | |
2169 return make(_base, ptr, _offset); | |
2170 } | |
2171 | |
2172 //------------------------------get_con---------------------------------------- | |
2173 intptr_t TypePtr::get_con() const { | |
2174 assert( _ptr == Null, "" ); | |
2175 return _offset; | |
2176 } | |
2177 | |
2178 //------------------------------meet------------------------------------------- | |
2179 // Compute the MEET of two types. It returns a new Type object. | |
2180 const Type *TypePtr::xmeet( const Type *t ) const { | |
2181 // Perform a fast test for common case; meeting the same types together. | |
2182 if( this == t ) return this; // Meeting same type-rep? | |
2183 | |
2184 // Current "this->_base" is AnyPtr | |
2185 switch (t->base()) { // switch on original type | |
2186 case Int: // Mixing ints & oops happens when javac | |
2187 case Long: // reuses local variables | |
2188 case FloatTop: | |
2189 case FloatCon: | |
2190 case FloatBot: | |
2191 case DoubleTop: | |
2192 case DoubleCon: | |
2193 case DoubleBot: | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
2194 case NarrowOop: |
6848
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6735
diff
changeset
|
2195 case NarrowKlass: |
0 | 2196 case Bottom: // Ye Olde Default |
2197 return Type::BOTTOM; | |
2198 case Top: | |
2199 return this; | |
2200 | |
2201 case AnyPtr: { // Meeting to AnyPtrs | |
2202 const TypePtr *tp = t->is_ptr(); | |
2203 return make( AnyPtr, meet_ptr(tp->ptr()), meet_offset(tp->offset()) ); | |
2204 } | |
2205 case RawPtr: // For these, flip the call around to cut down | |
2206 case OopPtr: | |
2207 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
|
2208 case AryPtr: |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6198
diff
changeset
|
2209 case MetadataPtr: |
0 | 2210 case KlassPtr: |
2211 return t->xmeet(this); // Call in reverse direction | |
2212 default: // All else is a mistake | |
2213 typerr(t); | |
2214 | |
2215 } | |
2216 return this; | |
2217 } | |
2218 | |
2219 //------------------------------meet_offset------------------------------------ | |
2220 int TypePtr::meet_offset( int offset ) const { | |
2221 // Either is 'TOP' offset? Return the other offset! | |
2222 if( _offset == OffsetTop ) return offset; | |
2223 if( offset == OffsetTop ) return _offset; | |
2224 // If either is different, return 'BOTTOM' offset | |
2225 if( _offset != offset ) return OffsetBot; | |
2226 return _offset; | |
2227 } | |
2228 | |
2229 //------------------------------dual_offset------------------------------------ | |
2230 int TypePtr::dual_offset( ) const { | |
2231 if( _offset == OffsetTop ) return OffsetBot;// Map 'TOP' into 'BOTTOM' | |
2232 if( _offset == OffsetBot ) return OffsetTop;// Map 'BOTTOM' into 'TOP' | |
2233 return _offset; // Map everything else into self | |
2234 } | |
2235 | |
2236 //------------------------------xdual------------------------------------------ | |
2237 // Dual: compute field-by-field dual | |
2238 const TypePtr::PTR TypePtr::ptr_dual[TypePtr::lastPTR] = { | |
2239 BotPTR, NotNull, Constant, Null, AnyNull, TopPTR | |
2240 }; | |
2241 const Type *TypePtr::xdual() const { | |
2242 return new TypePtr( AnyPtr, dual_ptr(), dual_offset() ); | |
2243 } | |
2244 | |
306
af945ba2e739
6741738: TypePtr::add_offset() set incorrect offset when the add overflows
kvn
parents:
293
diff
changeset
|
2245 //------------------------------xadd_offset------------------------------------ |
af945ba2e739
6741738: TypePtr::add_offset() set incorrect offset when the add overflows
kvn
parents:
293
diff
changeset
|
2246 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
|
2247 // Adding to 'TOP' offset? Return 'TOP'! |
af945ba2e739
6741738: TypePtr::add_offset() set incorrect offset when the add overflows
kvn
parents:
293
diff
changeset
|
2248 if( _offset == OffsetTop || offset == OffsetTop ) return OffsetTop; |
af945ba2e739
6741738: TypePtr::add_offset() set incorrect offset when the add overflows
kvn
parents:
293
diff
changeset
|
2249 // Adding to 'BOTTOM' offset? Return 'BOTTOM'! |
af945ba2e739
6741738: TypePtr::add_offset() set incorrect offset when the add overflows
kvn
parents:
293
diff
changeset
|
2250 if( _offset == OffsetBot || offset == OffsetBot ) return OffsetBot; |
af945ba2e739
6741738: TypePtr::add_offset() set incorrect offset when the add overflows
kvn
parents:
293
diff
changeset
|
2251 // 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
|
2252 offset += (intptr_t)_offset; |
af945ba2e739
6741738: TypePtr::add_offset() set incorrect offset when the add overflows
kvn
parents:
293
diff
changeset
|
2253 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
|
2254 |
af945ba2e739
6741738: TypePtr::add_offset() set incorrect offset when the add overflows
kvn
parents:
293
diff
changeset
|
2255 // assert( _offset >= 0 && _offset+offset >= 0, "" ); |
af945ba2e739
6741738: TypePtr::add_offset() set incorrect offset when the add overflows
kvn
parents:
293
diff
changeset
|
2256 // 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
|
2257 |
af945ba2e739
6741738: TypePtr::add_offset() set incorrect offset when the add overflows
kvn
parents:
293
diff
changeset
|
2258 return (int)offset; // Sum valid offsets |
af945ba2e739
6741738: TypePtr::add_offset() set incorrect offset when the add overflows
kvn
parents:
293
diff
changeset
|
2259 } |
af945ba2e739
6741738: TypePtr::add_offset() set incorrect offset when the add overflows
kvn
parents:
293
diff
changeset
|
2260 |
0 | 2261 //------------------------------add_offset------------------------------------- |
306
af945ba2e739
6741738: TypePtr::add_offset() set incorrect offset when the add overflows
kvn
parents:
293
diff
changeset
|
2262 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
|
2263 return make( AnyPtr, _ptr, xadd_offset(offset) ); |
0 | 2264 } |
2265 | |
2266 //------------------------------eq--------------------------------------------- | |
2267 // Structural equality check for Type representations | |
2268 bool TypePtr::eq( const Type *t ) const { | |
2269 const TypePtr *a = (const TypePtr*)t; | |
2270 return _ptr == a->ptr() && _offset == a->offset(); | |
2271 } | |
2272 | |
2273 //------------------------------hash------------------------------------------- | |
2274 // Type-specific hashing function. | |
2275 int TypePtr::hash(void) const { | |
2276 return _ptr + _offset; | |
2277 } | |
2278 | |
2279 //------------------------------dump2------------------------------------------ | |
2280 const char *const TypePtr::ptr_msg[TypePtr::lastPTR] = { | |
2281 "TopPTR","AnyNull","Constant","NULL","NotNull","BotPTR" | |
2282 }; | |
2283 | |
2284 #ifndef PRODUCT | |
2285 void TypePtr::dump2( Dict &d, uint depth, outputStream *st ) const { | |
2286 if( _ptr == Null ) st->print("NULL"); | |
2287 else st->print("%s *", ptr_msg[_ptr]); | |
2288 if( _offset == OffsetTop ) st->print("+top"); | |
2289 else if( _offset == OffsetBot ) st->print("+bot"); | |
2290 else if( _offset ) st->print("+%d", _offset); | |
2291 } | |
2292 #endif | |
2293 | |
2294 //------------------------------singleton-------------------------------------- | |
2295 // TRUE if Type is a singleton type, FALSE otherwise. Singletons are simple | |
2296 // constants | |
2297 bool TypePtr::singleton(void) const { | |
2298 // TopPTR, Null, AnyNull, Constant are all singletons | |
2299 return (_offset != OffsetBot) && !below_centerline(_ptr); | |
2300 } | |
2301 | |
2302 bool TypePtr::empty(void) const { | |
2303 return (_offset == OffsetTop) || above_centerline(_ptr); | |
2304 } | |
2305 | |
2306 //============================================================================= | |
2307 // Convenience common pre-built types. | |
2308 const TypeRawPtr *TypeRawPtr::BOTTOM; | |
2309 const TypeRawPtr *TypeRawPtr::NOTNULL; | |
2310 | |
2311 //------------------------------make------------------------------------------- | |
2312 const TypeRawPtr *TypeRawPtr::make( enum PTR ptr ) { | |
2313 assert( ptr != Constant, "what is the constant?" ); | |
2314 assert( ptr != Null, "Use TypePtr for NULL" ); | |
2315 return (TypeRawPtr*)(new TypeRawPtr(ptr,0))->hashcons(); | |
2316 } | |
2317 | |
2318 const TypeRawPtr *TypeRawPtr::make( address bits ) { | |
2319 assert( bits, "Use TypePtr for NULL" ); | |
2320 return (TypeRawPtr*)(new TypeRawPtr(Constant,bits))->hashcons(); | |
2321 } | |
2322 | |
2323 //------------------------------cast_to_ptr_type------------------------------- | |
2324 const Type *TypeRawPtr::cast_to_ptr_type(PTR ptr) const { | |
2325 assert( ptr != Constant, "what is the constant?" ); | |
2326 assert( ptr != Null, "Use TypePtr for NULL" ); | |
2327 assert( _bits==0, "Why cast a constant address?"); | |
2328 if( ptr == _ptr ) return this; | |
2329 return make(ptr); | |
2330 } | |
2331 | |
2332 //------------------------------get_con---------------------------------------- | |
2333 intptr_t TypeRawPtr::get_con() const { | |
2334 assert( _ptr == Null || _ptr == Constant, "" ); | |
2335 return (intptr_t)_bits; | |
2336 } | |
2337 | |
2338 //------------------------------meet------------------------------------------- | |
2339 // Compute the MEET of two types. It returns a new Type object. | |
2340 const Type *TypeRawPtr::xmeet( const Type *t ) const { | |
2341 // Perform a fast test for common case; meeting the same types together. | |
2342 if( this == t ) return this; // Meeting same type-rep? | |
2343 | |
2344 // Current "this->_base" is RawPtr | |
2345 switch( t->base() ) { // switch on original type | |
2346 case Bottom: // Ye Olde Default | |
2347 return t; | |
2348 case Top: | |
2349 return this; | |
2350 case AnyPtr: // Meeting to AnyPtrs | |
2351 break; | |
2352 case RawPtr: { // might be top, bot, any/not or constant | |
2353 enum PTR tptr = t->is_ptr()->ptr(); | |
2354 enum PTR ptr = meet_ptr( tptr ); | |
2355 if( ptr == Constant ) { // Cannot be equal constants, so... | |
2356 if( tptr == Constant && _ptr != Constant) return t; | |
2357 if( _ptr == Constant && tptr != Constant) return this; | |
2358 ptr = NotNull; // Fall down in lattice | |
2359 } | |
2360 return make( ptr ); | |
2361 } | |
2362 | |
2363 case OopPtr: | |
2364 case InstPtr: | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6198
diff
changeset
|
2365 case AryPtr: |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6198
diff
changeset
|
2366 case MetadataPtr: |
0 | 2367 case KlassPtr: |
2368 return TypePtr::BOTTOM; // Oop meet raw is not well defined | |
2369 default: // All else is a mistake | |
2370 typerr(t); | |
2371 } | |
2372 | |
2373 // Found an AnyPtr type vs self-RawPtr type | |
2374 const TypePtr *tp = t->is_ptr(); | |
2375 switch (tp->ptr()) { | |
2376 case TypePtr::TopPTR: return this; | |
2377 case TypePtr::BotPTR: return t; | |
2378 case TypePtr::Null: | |
2379 if( _ptr == TypePtr::TopPTR ) return t; | |
2380 return TypeRawPtr::BOTTOM; | |
2381 case TypePtr::NotNull: return TypePtr::make( AnyPtr, meet_ptr(TypePtr::NotNull), tp->meet_offset(0) ); | |
2382 case TypePtr::AnyNull: | |
2383 if( _ptr == TypePtr::Constant) return this; | |
2384 return make( meet_ptr(TypePtr::AnyNull) ); | |
2385 default: ShouldNotReachHere(); | |
2386 } | |
2387 return this; | |
2388 } | |
2389 | |
2390 //------------------------------xdual------------------------------------------ | |
2391 // Dual: compute field-by-field dual | |
2392 const Type *TypeRawPtr::xdual() const { | |
2393 return new TypeRawPtr( dual_ptr(), _bits ); | |
2394 } | |
2395 | |
2396 //------------------------------add_offset------------------------------------- | |
306
af945ba2e739
6741738: TypePtr::add_offset() set incorrect offset when the add overflows
kvn
parents:
293
diff
changeset
|
2397 const TypePtr *TypeRawPtr::add_offset( intptr_t offset ) const { |
0 | 2398 if( offset == OffsetTop ) return BOTTOM; // Undefined offset-> undefined pointer |
2399 if( offset == OffsetBot ) return BOTTOM; // Unknown offset-> unknown pointer | |
2400 if( offset == 0 ) return this; // No change | |
2401 switch (_ptr) { | |
2402 case TypePtr::TopPTR: | |
2403 case TypePtr::BotPTR: | |
2404 case TypePtr::NotNull: | |
2405 return this; | |
2406 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
|
2407 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
|
2408 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
|
2409 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
|
2410 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
|
2411 } |
0 | 2412 default: ShouldNotReachHere(); |
2413 } | |
2414 return NULL; // Lint noise | |
2415 } | |
2416 | |
2417 //------------------------------eq--------------------------------------------- | |
2418 // Structural equality check for Type representations | |
2419 bool TypeRawPtr::eq( const Type *t ) const { | |
2420 const TypeRawPtr *a = (const TypeRawPtr*)t; | |
2421 return _bits == a->_bits && TypePtr::eq(t); | |
2422 } | |
2423 | |
2424 //------------------------------hash------------------------------------------- | |
2425 // Type-specific hashing function. | |
2426 int TypeRawPtr::hash(void) const { | |
2427 return (intptr_t)_bits + TypePtr::hash(); | |
2428 } | |
2429 | |
2430 //------------------------------dump2------------------------------------------ | |
2431 #ifndef PRODUCT | |
2432 void TypeRawPtr::dump2( Dict &d, uint depth, outputStream *st ) const { | |
2433 if( _ptr == Constant ) | |
2434 st->print(INTPTR_FORMAT, _bits); | |
2435 else | |
2436 st->print("rawptr:%s", ptr_msg[_ptr]); | |
2437 } | |
2438 #endif | |
2439 | |
2440 //============================================================================= | |
2441 // Convenience common pre-built type. | |
2442 const TypeOopPtr *TypeOopPtr::BOTTOM; | |
2443 | |
163 | 2444 //------------------------------TypeOopPtr------------------------------------- |
12966 | 2445 TypeOopPtr::TypeOopPtr(TYPES t, PTR ptr, ciKlass* k, bool xk, ciObject* o, int offset, int instance_id, const TypeOopPtr* speculative) |
163 | 2446 : TypePtr(t, ptr, offset), |
2447 _const_oop(o), _klass(k), | |
2448 _klass_is_exact(xk), | |
2449 _is_ptr_to_narrowoop(false), | |
6848
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6735
diff
changeset
|
2450 _is_ptr_to_narrowklass(false), |
10278 | 2451 _is_ptr_to_boxed_value(false), |
12966 | 2452 _instance_id(instance_id), |
2453 _speculative(speculative) { | |
10278 | 2454 if (Compile::current()->eliminate_boxing() && (t == InstPtr) && |
2455 (offset > 0) && xk && (k != 0) && k->is_instance_klass()) { | |
2456 _is_ptr_to_boxed_value = k->as_instance_klass()->is_boxed_value_offset(offset); | |
2457 } | |
163 | 2458 #ifdef _LP64 |
6848
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6735
diff
changeset
|
2459 if (_offset != 0) { |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6198
diff
changeset
|
2460 if (_offset == oopDesc::klass_offset_in_bytes()) { |
12226
7944aba7ba41
8015107: NPG: Use consistent naming for metaspace concepts
ehelin
parents:
10278
diff
changeset
|
2461 _is_ptr_to_narrowklass = UseCompressedClassPointers; |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6198
diff
changeset
|
2462 } else if (klass() == NULL) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6198
diff
changeset
|
2463 // Array with unknown body type |
163 | 2464 assert(this->isa_aryptr(), "only arrays without klass"); |
6848
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6735
diff
changeset
|
2465 _is_ptr_to_narrowoop = UseCompressedOops; |
163 | 2466 } else if (this->isa_aryptr()) { |
6848
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6735
diff
changeset
|
2467 _is_ptr_to_narrowoop = (UseCompressedOops && klass()->is_obj_array_klass() && |
163 | 2468 _offset != arrayOopDesc::length_offset_in_bytes()); |
2469 } else if (klass()->is_instance_klass()) { | |
2470 ciInstanceKlass* ik = klass()->as_instance_klass(); | |
2471 ciField* field = NULL; | |
2472 if (this->isa_klassptr()) { | |
2376
c7f3d0b4570f
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
2354
diff
changeset
|
2473 // Perm objects don't use compressed references |
163 | 2474 } else if (_offset == OffsetBot || _offset == OffsetTop) { |
2475 // unsafe access | |
6848
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6735
diff
changeset
|
2476 _is_ptr_to_narrowoop = UseCompressedOops; |
163 | 2477 } else { // exclude unsafe ops |
2478 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
|
2479 |
c7f3d0b4570f
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
2354
diff
changeset
|
2480 if (klass() == ciEnv::current()->Class_klass() && |
c7f3d0b4570f
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
2354
diff
changeset
|
2481 (_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
|
2482 _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
|
2483 // Special hidden fields from the Class. |
c7f3d0b4570f
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
2354
diff
changeset
|
2484 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
|
2485 _is_ptr_to_narrowoop = false; |
2376
c7f3d0b4570f
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
2354
diff
changeset
|
2486 } else if (klass() == ciEnv::current()->Class_klass() && |
6735
aed758eda82a
7195833: NPG: Rename instanceClassLoaderKlass, instanceRefKlass and instanceMirrorKlass
coleenp
parents:
6728
diff
changeset
|
2487 _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
|
2488 // Static fields |
c7f3d0b4570f
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
2354
diff
changeset
|
2489 assert(o != NULL, "must be constant"); |
c7f3d0b4570f
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
2354
diff
changeset
|
2490 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
|
2491 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
|
2492 assert(field != NULL, "missing field"); |
163 | 2493 BasicType basic_elem_type = field->layout_type(); |
6848
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6735
diff
changeset
|
2494 _is_ptr_to_narrowoop = UseCompressedOops && (basic_elem_type == T_OBJECT || |
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6735
diff
changeset
|
2495 basic_elem_type == T_ARRAY); |
163 | 2496 } else { |
2376
c7f3d0b4570f
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
2354
diff
changeset
|
2497 // 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
|
2498 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
|
2499 if (field != NULL) { |
c7f3d0b4570f
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
2354
diff
changeset
|
2500 BasicType basic_elem_type = field->layout_type(); |
6848
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6735
diff
changeset
|
2501 _is_ptr_to_narrowoop = UseCompressedOops && (basic_elem_type == T_OBJECT || |
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6735
diff
changeset
|
2502 basic_elem_type == T_ARRAY); |
2376
c7f3d0b4570f
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
2354
diff
changeset
|
2503 } 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
|
2504 // 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
|
2505 // that it does not affect alias type. |
6848
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6735
diff
changeset
|
2506 _is_ptr_to_narrowoop = UseCompressedOops; |
2376
c7f3d0b4570f
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
2354
diff
changeset
|
2507 } else { |
c7f3d0b4570f
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
2354
diff
changeset
|
2508 // 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
|
2509 _is_ptr_to_narrowoop = UseCompressedOops; |
2376
c7f3d0b4570f
7017732: move static fields into Class to prepare for perm gen removal
never
parents:
2354
diff
changeset
|
2510 } |
163 | 2511 } |
2512 } | |
2513 } | |
2514 } | |
2515 #endif | |
2516 } | |
2517 | |
0 | 2518 //------------------------------make------------------------------------------- |
2519 const TypeOopPtr *TypeOopPtr::make(PTR ptr, | |
12966 | 2520 int offset, int instance_id, const TypeOopPtr* speculative) { |
0 | 2521 assert(ptr != Constant, "no constant generic pointers"); |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6198
diff
changeset
|
2522 ciKlass* k = Compile::current()->env()->Object_klass(); |
0 | 2523 bool xk = false; |
2524 ciObject* o = NULL; | |
12966 | 2525 return (TypeOopPtr*)(new TypeOopPtr(OopPtr, ptr, k, xk, o, offset, instance_id, speculative))->hashcons(); |
0 | 2526 } |
2527 | |
2528 | |
2529 //------------------------------cast_to_ptr_type------------------------------- | |
2530 const Type *TypeOopPtr::cast_to_ptr_type(PTR ptr) const { | |
2531 assert(_base == OopPtr, "subclass must override cast_to_ptr_type"); | |
2532 if( ptr == _ptr ) return this; | |
12966 | 2533 return make(ptr, _offset, _instance_id, _speculative); |
0 | 2534 } |
2535 | |
247 | 2536 //-----------------------------cast_to_instance_id---------------------------- |
223 | 2537 const TypeOopPtr *TypeOopPtr::cast_to_instance_id(int instance_id) const { |
0 | 2538 // There are no instances of a general oop. |
2539 // Return self unchanged. | |
2540 return this; | |
2541 } | |
2542 | |
2543 //-----------------------------cast_to_exactness------------------------------- | |
2544 const Type *TypeOopPtr::cast_to_exactness(bool klass_is_exact) const { | |
2545 // There is no such thing as an exact general oop. | |
2546 // Return self unchanged. | |
2547 return this; | |
2548 } | |
2549 | |
2550 | |
2551 //------------------------------as_klass_type---------------------------------- | |
2552 // Return the klass type corresponding to this instance or array type. | |
2553 // It is the type that is loaded from an object of this type. | |
2554 const TypeKlassPtr* TypeOopPtr::as_klass_type() const { | |
2555 ciKlass* k = klass(); | |
2556 bool xk = klass_is_exact(); | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6198
diff
changeset
|
2557 if (k == NULL) |
0 | 2558 return TypeKlassPtr::OBJECT; |
2559 else | |
2560 return TypeKlassPtr::make(xk? Constant: NotNull, k, 0); | |
2561 } | |
2562 | |
12966 | 2563 const Type *TypeOopPtr::xmeet(const Type *t) const { |
2564 const Type* res = xmeet_helper(t); | |
2565 if (res->isa_oopptr() == NULL) { | |
2566 return res; | |
2567 } | |
2568 | |
2569 if (res->isa_oopptr() != NULL) { | |
2570 // type->speculative() == NULL means that speculation is no better | |
2571 // than type, i.e. type->speculative() == type. So there are 2 | |
2572 // ways to represent the fact that we have no useful speculative | |
2573 // data and we should use a single one to be able to test for | |
2574 // equality between types. Check whether type->speculative() == | |
2575 // type and set speculative to NULL if it is the case. | |
2576 const TypeOopPtr* res_oopptr = res->is_oopptr(); | |
2577 if (res_oopptr->remove_speculative() == res_oopptr->speculative()) { | |
2578 return res_oopptr->remove_speculative(); | |
2579 } | |
2580 } | |
2581 | |
2582 return res; | |
2583 } | |
0 | 2584 |
2585 //------------------------------meet------------------------------------------- | |
2586 // Compute the MEET of two types. It returns a new Type object. | |
12966 | 2587 const Type *TypeOopPtr::xmeet_helper(const Type *t) const { |
0 | 2588 // Perform a fast test for common case; meeting the same types together. |
2589 if( this == t ) return this; // Meeting same type-rep? | |
2590 | |
2591 // Current "this->_base" is OopPtr | |
2592 switch (t->base()) { // switch on original type | |
2593 | |
2594 case Int: // Mixing ints & oops happens when javac | |
2595 case Long: // reuses local variables | |
2596 case FloatTop: | |
2597 case FloatCon: | |
2598 case FloatBot: | |
2599 case DoubleTop: | |
2600 case DoubleCon: | |
2601 case DoubleBot: | |
293
c3e045194476
6731641: assert(m->adr_type() == mach->adr_type(),"matcher should not change adr type")
kvn
parents:
247
diff
changeset
|
2602 case NarrowOop: |
6848
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6735
diff
changeset
|
2603 case NarrowKlass: |
0 | 2604 case Bottom: // Ye Olde Default |
2605 return Type::BOTTOM; | |
2606 case Top: | |
2607 return this; | |
2608 | |
2609 default: // All else is a mistake | |
2610 typerr(t); | |
2611 | |
2612 case RawPtr: | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6198
diff
changeset
|
2613 case MetadataPtr: |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6198
diff
changeset
|
2614 case KlassPtr: |
0 | 2615 return TypePtr::BOTTOM; // Oop meet raw is not well defined |
2616 | |
2617 case AnyPtr: { | |
2618 // Found an AnyPtr type vs self-OopPtr type | |
2619 const TypePtr *tp = t->is_ptr(); | |
2620 int offset = meet_offset(tp->offset()); | |
2621 PTR ptr = meet_ptr(tp->ptr()); | |
2622 switch (tp->ptr()) { | |
2623 case Null: | |
2624 if (ptr == Null) return TypePtr::make(AnyPtr, ptr, offset); | |
2625 // else fall through: | |
2626 case TopPTR: | |
992 | 2627 case AnyNull: { |
2628 int instance_id = meet_instance_id(InstanceTop); | |
12966 | 2629 const TypeOopPtr* speculative = _speculative; |
2630 return make(ptr, offset, instance_id, speculative); | |
992 | 2631 } |
0 | 2632 case BotPTR: |
2633 case NotNull: | |
2634 return TypePtr::make(AnyPtr, ptr, offset); | |
2635 default: typerr(t); | |
2636 } | |
2637 } | |
2638 | |
2639 case OopPtr: { // Meeting to other OopPtrs | |
2640 const TypeOopPtr *tp = t->is_oopptr(); | |
958
c7e94e8fff43
6880053: assert(alloc_obj->as_CheckCastPP()->type() != TypeInstPtr::NOTNULL)
kvn
parents:
827
diff
changeset
|
2641 int instance_id = meet_instance_id(tp->instance_id()); |
12966 | 2642 const TypeOopPtr* speculative = meet_speculative(tp); |
2643 return make(meet_ptr(tp->ptr()), meet_offset(tp->offset()), instance_id, speculative); | |
0 | 2644 } |
2645 | |
2646 case InstPtr: // For these, flip the call around to cut down | |
2647 case AryPtr: | |
2648 return t->xmeet(this); // Call in reverse direction | |
2649 | |
2650 } // End of switch | |
2651 return this; // Return the double constant | |
2652 } | |
2653 | |
2654 | |
2655 //------------------------------xdual------------------------------------------ | |
2656 // Dual of a pure heap pointer. No relevant klass or oop information. | |
2657 const Type *TypeOopPtr::xdual() const { | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6198
diff
changeset
|
2658 assert(klass() == Compile::current()->env()->Object_klass(), "no klasses here"); |
0 | 2659 assert(const_oop() == NULL, "no constants here"); |
12966 | 2660 return new TypeOopPtr(_base, dual_ptr(), klass(), klass_is_exact(), const_oop(), dual_offset(), dual_instance_id(), dual_speculative()); |
0 | 2661 } |
2662 | |
2663 //--------------------------make_from_klass_common----------------------------- | |
2664 // Computes the element-type given a klass. | |
2665 const TypeOopPtr* TypeOopPtr::make_from_klass_common(ciKlass *klass, bool klass_change, bool try_for_exact) { | |
2666 if (klass->is_instance_klass()) { | |
2667 Compile* C = Compile::current(); | |
2668 Dependencies* deps = C->dependencies(); | |
2669 assert((deps != NULL) == (C->method() != NULL && C->method()->code_size() > 0), "sanity"); | |
2670 // Element is an instance | |
2671 bool klass_is_exact = false; | |
2672 if (klass->is_loaded()) { | |
2673 // Try to set klass_is_exact. | |
2674 ciInstanceKlass* ik = klass->as_instance_klass(); | |
2675 klass_is_exact = ik->is_final(); | |
2676 if (!klass_is_exact && klass_change | |
2677 && deps != NULL && UseUniqueSubclasses) { | |
2678 ciInstanceKlass* sub = ik->unique_concrete_subklass(); | |
2679 if (sub != NULL) { | |
2680 deps->assert_abstract_with_unique_concrete_subtype(ik, sub); | |
2681 klass = ik = sub; | |
2682 klass_is_exact = sub->is_final(); | |
2683 } | |
2684 } | |
2685 if (!klass_is_exact && try_for_exact | |
2686 && deps != NULL && UseExactTypes) { | |
2687 if (!ik->is_interface() && !ik->has_subklass()) { | |
2688 // Add a dependence; if concrete subclass added we need to recompile | |
2689 deps->assert_leaf_type(ik); | |
2690 klass_is_exact = true; | |
2691 } | |
2692 } | |
2693 } | |
2694 return TypeInstPtr::make(TypePtr::BotPTR, klass, klass_is_exact, NULL, 0); | |
2695 } else if (klass->is_obj_array_klass()) { | |
2696 // Element is an object array. Recursively call ourself. | |
2697 const TypeOopPtr *etype = TypeOopPtr::make_from_klass_common(klass->as_obj_array_klass()->element_klass(), false, try_for_exact); | |
2698 bool xk = etype->klass_is_exact(); | |
2699 const TypeAry* arr0 = TypeAry::make(etype, TypeInt::POS); | |
2700 // We used to pass NotNull in here, asserting that the sub-arrays | |
2701 // are all not-null. This is not true in generally, as code can | |
2702 // slam NULLs down in the subarrays. | |
2703 const TypeAryPtr* arr = TypeAryPtr::make(TypePtr::BotPTR, arr0, klass, xk, 0); | |
2704 return arr; | |
2705 } else if (klass->is_type_array_klass()) { | |
2706 // Element is an typeArray | |
2707 const Type* etype = get_const_basic_type(klass->as_type_array_klass()->element_type()); | |
2708 const TypeAry* arr0 = TypeAry::make(etype, TypeInt::POS); | |
2709 // We used to pass NotNull in here, asserting that the array pointer | |
2710 // is not-null. That was not true in general. | |
2711 const TypeAryPtr* arr = TypeAryPtr::make(TypePtr::BotPTR, arr0, klass, true, 0); | |
2712 return arr; | |
2713 } else { | |
2714 ShouldNotReachHere(); | |
2715 return NULL; | |
2716 } | |
2717 } | |
2718 | |
2719 //------------------------------make_from_constant----------------------------- | |
2720 // Make a java pointer from an oop constant | |
10278 | 2721 const TypeOopPtr* TypeOopPtr::make_from_constant(ciObject* o, |
2722 bool require_constant, | |
2723 bool is_autobox_cache) { | |
2724 assert(!o->is_null_object(), "null object not yet handled here."); | |
2725 ciKlass* klass = o->klass(); | |
2726 if (klass->is_instance_klass()) { | |
2727 // Element is an instance | |
2728 if (require_constant) { | |
2729 if (!o->can_be_constant()) return NULL; | |
2730 } else if (!o->should_be_constant()) { | |
2731 return TypeInstPtr::make(TypePtr::NotNull, klass, true, NULL, 0); | |
2732 } | |
2733 return TypeInstPtr::make(o); | |
2734 } else if (klass->is_obj_array_klass()) { | |
2735 // Element is an object array. Recursively call ourself. | |
2736 const TypeOopPtr *etype = | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6198
diff
changeset
|
2737 TypeOopPtr::make_from_klass_raw(klass->as_obj_array_klass()->element_klass()); |
10278 | 2738 if (is_autobox_cache) { |
2739 // The pointers in the autobox arrays are always non-null. | |
2740 etype = etype->cast_to_ptr_type(TypePtr::NotNull)->is_oopptr(); | |
2741 } | |
2742 const TypeAry* arr0 = TypeAry::make(etype, TypeInt::make(o->as_array()->length())); | |
2743 // We used to pass NotNull in here, asserting that the sub-arrays | |
2744 // are all not-null. This is not true in generally, as code can | |
2745 // slam NULLs down in the subarrays. | |
2746 if (require_constant) { | |
2747 if (!o->can_be_constant()) return NULL; | |
2748 } else if (!o->should_be_constant()) { | |
2749 return TypeAryPtr::make(TypePtr::NotNull, arr0, klass, true, 0); | |
2750 } | |
12966 | 2751 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
|
2752 return arr; |
10278 | 2753 } else if (klass->is_type_array_klass()) { |
2754 // Element is an typeArray | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6198
diff
changeset
|
2755 const Type* etype = |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6198
diff
changeset
|
2756 (Type*)get_const_basic_type(klass->as_type_array_klass()->element_type()); |
10278 | 2757 const TypeAry* arr0 = TypeAry::make(etype, TypeInt::make(o->as_array()->length())); |
2758 // We used to pass NotNull in here, asserting that the array pointer | |
2759 // is not-null. That was not true in general. | |
2760 if (require_constant) { | |
2761 if (!o->can_be_constant()) return NULL; | |
2762 } else if (!o->should_be_constant()) { | |
2763 return TypeAryPtr::make(TypePtr::NotNull, arr0, klass, true, 0); | |
2764 } | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6198
diff
changeset
|
2765 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
|
2766 return arr; |
0 | 2767 } |
2768 | |
6182
765ee2d1674b
7157365: jruby/bench.bench_timeout crashes with JVM internal error
twisti
parents:
6179
diff
changeset
|
2769 fatal("unhandled object type"); |
0 | 2770 return NULL; |
2771 } | |
2772 | |
2773 //------------------------------get_con---------------------------------------- | |
2774 intptr_t TypeOopPtr::get_con() const { | |
2775 assert( _ptr == Null || _ptr == Constant, "" ); | |
2776 assert( _offset >= 0, "" ); | |
2777 | |
2778 if (_offset != 0) { | |
2779 // After being ported to the compiler interface, the compiler no longer | |
2780 // directly manipulates the addresses of oops. Rather, it only has a pointer | |
2781 // to a handle at compile time. This handle is embedded in the generated | |
2782 // code and dereferenced at the time the nmethod is made. Until that time, | |
2783 // it is not reasonable to do arithmetic with the addresses of oops (we don't | |
2784 // have access to the addresses!). This does not seem to currently happen, | |
605 | 2785 // but this assertion here is to help prevent its occurence. |
0 | 2786 tty->print_cr("Found oop constant with non-zero offset"); |
2787 ShouldNotReachHere(); | |
2788 } | |
2789 | |
989
148e5441d916
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
958
diff
changeset
|
2790 return (intptr_t)const_oop()->constant_encoding(); |
0 | 2791 } |
2792 | |
2793 | |
2794 //-----------------------------filter------------------------------------------ | |
2795 // Do not allow interface-vs.-noninterface joins to collapse to top. | |
13014
6c2f07d1495f
8027140: Assertion in compiler when running bigapps/Kitchensink/stability
roland
parents:
12972
diff
changeset
|
2796 const Type *TypeOopPtr::filter(const Type *kills) const { |
0 | 2797 |
2798 const Type* ft = join(kills); | |
2799 const TypeInstPtr* ftip = ft->isa_instptr(); | |
2800 const TypeInstPtr* ktip = kills->isa_instptr(); | |
2801 | |
2802 if (ft->empty()) { | |
2803 // Check for evil case of 'this' being a class and 'kills' expecting an | |
2804 // interface. This can happen because the bytecodes do not contain | |
2805 // enough type info to distinguish a Java-level interface variable | |
2806 // from a Java-level object variable. If we meet 2 classes which | |
2807 // both implement interface I, but their meet is at 'j/l/O' which | |
2808 // doesn't implement I, we have no way to tell if the result should | |
2809 // be 'I' or 'j/l/O'. Thus we'll pick 'j/l/O'. If this then flows | |
2810 // into a Phi which "knows" it's an Interface type we'll have to | |
2811 // uplift the type. | |
2812 if (!empty() && ktip != NULL && ktip->is_loaded() && ktip->klass()->is_interface()) | |
2813 return kills; // Uplift to interface | |
2814 | |
2815 return Type::TOP; // Canonical empty value | |
2816 } | |
2817 | |
2818 // If we have an interface-typed Phi or cast and we narrow to a class type, | |
2819 // the join should report back the class. However, if we have a J/L/Object | |
2820 // class-typed Phi and an interface flows in, it's possible that the meet & | |
2821 // join report an interface back out. This isn't possible but happens | |
2822 // because the type system doesn't interact well with interfaces. | |
2823 if (ftip != NULL && ktip != NULL && | |
2824 ftip->is_loaded() && ftip->klass()->is_interface() && | |
2825 ktip->is_loaded() && !ktip->klass()->is_interface()) { | |
2826 // 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
|
2827 assert(!ftip->klass_is_exact(), "interface could not be exact"); |
0 | 2828 return ktip->cast_to_ptr_type(ftip->ptr()); |
2829 } | |
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 |
13014
6c2f07d1495f
8027140: Assertion in compiler when running bigapps/Kitchensink/stability
roland
parents:
12972
diff
changeset
|
4382 // Do not allow interface-vs.-noninterface joins to collapse to top. |
6c2f07d1495f
8027140: Assertion in compiler when running bigapps/Kitchensink/stability
roland
parents:
12972
diff
changeset
|
4383 const Type *TypeKlassPtr::filter(const Type *kills) const { |
6c2f07d1495f
8027140: Assertion in compiler when running bigapps/Kitchensink/stability
roland
parents:
12972
diff
changeset
|
4384 // logic here mirrors the one from TypeOopPtr::filter. See comments |
6c2f07d1495f
8027140: Assertion in compiler when running bigapps/Kitchensink/stability
roland
parents:
12972
diff
changeset
|
4385 // there. |
6c2f07d1495f
8027140: Assertion in compiler when running bigapps/Kitchensink/stability
roland
parents:
12972
diff
changeset
|
4386 const Type* ft = join(kills); |
6c2f07d1495f
8027140: Assertion in compiler when running bigapps/Kitchensink/stability
roland
parents:
12972
diff
changeset
|
4387 const TypeKlassPtr* ftkp = ft->isa_klassptr(); |
6c2f07d1495f
8027140: Assertion in compiler when running bigapps/Kitchensink/stability
roland
parents:
12972
diff
changeset
|
4388 const TypeKlassPtr* ktkp = kills->isa_klassptr(); |
6c2f07d1495f
8027140: Assertion in compiler when running bigapps/Kitchensink/stability
roland
parents:
12972
diff
changeset
|
4389 |
6c2f07d1495f
8027140: Assertion in compiler when running bigapps/Kitchensink/stability
roland
parents:
12972
diff
changeset
|
4390 if (ft->empty()) { |
6c2f07d1495f
8027140: Assertion in compiler when running bigapps/Kitchensink/stability
roland
parents:
12972
diff
changeset
|
4391 if (!empty() && ktkp != NULL && ktkp->klass()->is_loaded() && ktkp->klass()->is_interface()) |
6c2f07d1495f
8027140: Assertion in compiler when running bigapps/Kitchensink/stability
roland
parents:
12972
diff
changeset
|
4392 return kills; // Uplift to interface |
6c2f07d1495f
8027140: Assertion in compiler when running bigapps/Kitchensink/stability
roland
parents:
12972
diff
changeset
|
4393 |
6c2f07d1495f
8027140: Assertion in compiler when running bigapps/Kitchensink/stability
roland
parents:
12972
diff
changeset
|
4394 return Type::TOP; // Canonical empty value |
6c2f07d1495f
8027140: Assertion in compiler when running bigapps/Kitchensink/stability
roland
parents:
12972
diff
changeset
|
4395 } |
6c2f07d1495f
8027140: Assertion in compiler when running bigapps/Kitchensink/stability
roland
parents:
12972
diff
changeset
|
4396 |
6c2f07d1495f
8027140: Assertion in compiler when running bigapps/Kitchensink/stability
roland
parents:
12972
diff
changeset
|
4397 // Interface klass type could be exact in opposite to interface type, |
6c2f07d1495f
8027140: Assertion in compiler when running bigapps/Kitchensink/stability
roland
parents:
12972
diff
changeset
|
4398 // return it here instead of incorrect Constant ptr J/L/Object (6894807). |
6c2f07d1495f
8027140: Assertion in compiler when running bigapps/Kitchensink/stability
roland
parents:
12972
diff
changeset
|
4399 if (ftkp != NULL && ktkp != NULL && |
6c2f07d1495f
8027140: Assertion in compiler when running bigapps/Kitchensink/stability
roland
parents:
12972
diff
changeset
|
4400 ftkp->is_loaded() && ftkp->klass()->is_interface() && |
6c2f07d1495f
8027140: Assertion in compiler when running bigapps/Kitchensink/stability
roland
parents:
12972
diff
changeset
|
4401 !ftkp->klass_is_exact() && // Keep exact interface klass |
6c2f07d1495f
8027140: Assertion in compiler when running bigapps/Kitchensink/stability
roland
parents:
12972
diff
changeset
|
4402 ktkp->is_loaded() && !ktkp->klass()->is_interface()) { |
6c2f07d1495f
8027140: Assertion in compiler when running bigapps/Kitchensink/stability
roland
parents:
12972
diff
changeset
|
4403 return ktkp->cast_to_ptr_type(ftkp->ptr()); |
6c2f07d1495f
8027140: Assertion in compiler when running bigapps/Kitchensink/stability
roland
parents:
12972
diff
changeset
|
4404 } |
6c2f07d1495f
8027140: Assertion in compiler when running bigapps/Kitchensink/stability
roland
parents:
12972
diff
changeset
|
4405 |
6c2f07d1495f
8027140: Assertion in compiler when running bigapps/Kitchensink/stability
roland
parents:
12972
diff
changeset
|
4406 return ft; |
6c2f07d1495f
8027140: Assertion in compiler when running bigapps/Kitchensink/stability
roland
parents:
12972
diff
changeset
|
4407 } |
6c2f07d1495f
8027140: Assertion in compiler when running bigapps/Kitchensink/stability
roland
parents:
12972
diff
changeset
|
4408 |
1761 | 4409 //----------------------compute_klass------------------------------------------ |
4410 // Compute the defining klass for this class | |
4411 ciKlass* TypeAryPtr::compute_klass(DEBUG_ONLY(bool verify)) const { | |
4412 // Compute _klass based on element type. | |
0 | 4413 ciKlass* k_ary = NULL; |
4414 const TypeInstPtr *tinst; | |
4415 const TypeAryPtr *tary; | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
4416 const Type* el = elem(); |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
4417 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
|
4418 el = el->make_ptr(); |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
4419 } |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
4420 |
0 | 4421 // Get element klass |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
4422 if ((tinst = el->isa_instptr()) != NULL) { |
0 | 4423 // Compute array klass from element klass |
4424 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
|
4425 } else if ((tary = el->isa_aryptr()) != NULL) { |
0 | 4426 // Compute array klass from element klass |
4427 ciKlass* k_elem = tary->klass(); | |
4428 // If element type is something like bottom[], k_elem will be null. | |
4429 if (k_elem != NULL) | |
4430 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
|
4431 } 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
|
4432 (el->base() == Type::Bottom)) { |
0 | 4433 // element type of Bottom occurs from meet of basic type |
4434 // and object; Top occurs when doing join on Bottom. | |
4435 // Leave k_ary at NULL. | |
4436 } else { | |
4437 // Cannot compute array klass directly from basic type, | |
4438 // since subtypes of TypeInt all have basic type T_INT. | |
1761 | 4439 #ifdef ASSERT |
4440 if (verify && el->isa_int()) { | |
4441 // Check simple cases when verifying klass. | |
4442 BasicType bt = T_ILLEGAL; | |
4443 if (el == TypeInt::BYTE) { | |
4444 bt = T_BYTE; | |
4445 } else if (el == TypeInt::SHORT) { | |
4446 bt = T_SHORT; | |
4447 } else if (el == TypeInt::CHAR) { | |
4448 bt = T_CHAR; | |
4449 } else if (el == TypeInt::INT) { | |
4450 bt = T_INT; | |
4451 } else { | |
4452 return _klass; // just return specified klass | |
4453 } | |
4454 return ciTypeArrayKlass::make(bt); | |
4455 } | |
4456 #endif | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
64
diff
changeset
|
4457 assert(!el->isa_int(), |
0 | 4458 "integral arrays must be pre-equipped with a class"); |
4459 // 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
|
4460 k_ary = ciTypeArrayKlass::make(el->basic_type()); |
0 | 4461 } |
1761 | 4462 return k_ary; |
4463 } | |
4464 | |
4465 //------------------------------klass------------------------------------------ | |
4466 // Return the defining klass for this class | |
4467 ciKlass* TypeAryPtr::klass() const { | |
4468 if( _klass ) return _klass; // Return cached value, if possible | |
4469 | |
4470 // Oops, need to compute _klass and cache it | |
4471 ciKlass* k_ary = compute_klass(); | |
0 | 4472 |
2354
83f08886981c
7026631: field _klass is incorrectly set for dual type of TypeAryPtr::OOPS
kvn
parents:
2351
diff
changeset
|
4473 if( this != TypeAryPtr::OOPS && this->dual() != TypeAryPtr::OOPS ) { |
0 | 4474 // The _klass field acts as a cache of the underlying |
4475 // ciKlass for this array type. In order to set the field, | |
4476 // we need to cast away const-ness. | |
4477 // | |
4478 // IMPORTANT NOTE: we *never* set the _klass field for the | |
4479 // type TypeAryPtr::OOPS. This Type is shared between all | |
4480 // active compilations. However, the ciKlass which represents | |
4481 // this Type is *not* shared between compilations, so caching | |
4482 // this value would result in fetching a dangling pointer. | |
4483 // | |
4484 // Recomputing the underlying ciKlass for each request is | |
4485 // a bit less efficient than caching, but calls to | |
4486 // TypeAryPtr::OOPS->klass() are not common enough to matter. | |
4487 ((TypeAryPtr*)this)->_klass = k_ary; | |
163 | 4488 if (UseCompressedOops && k_ary != NULL && k_ary->is_obj_array_klass() && |
4489 _offset != 0 && _offset != arrayOopDesc::length_offset_in_bytes()) { | |
4490 ((TypeAryPtr*)this)->_is_ptr_to_narrowoop = true; | |
4491 } | |
4492 } | |
0 | 4493 return k_ary; |
4494 } | |
4495 | |
4496 | |
4497 //------------------------------add_offset------------------------------------- | |
4498 // Access internals of klass object | |
306
af945ba2e739
6741738: TypePtr::add_offset() set incorrect offset when the add overflows
kvn
parents:
293
diff
changeset
|
4499 const TypePtr *TypeKlassPtr::add_offset( intptr_t offset ) const { |
0 | 4500 return make( _ptr, klass(), xadd_offset(offset) ); |
4501 } | |
4502 | |
4503 //------------------------------cast_to_ptr_type------------------------------- | |
4504 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
|
4505 assert(_base == KlassPtr, "subclass must override cast_to_ptr_type"); |
0 | 4506 if( ptr == _ptr ) return this; |
4507 return make(ptr, _klass, _offset); | |
4508 } | |
4509 | |
4510 | |
4511 //-----------------------------cast_to_exactness------------------------------- | |
4512 const Type *TypeKlassPtr::cast_to_exactness(bool klass_is_exact) const { | |
4513 if( klass_is_exact == _klass_is_exact ) return this; | |
4514 if (!UseExactTypes) return this; | |
4515 return make(klass_is_exact ? Constant : NotNull, _klass, _offset); | |
4516 } | |
4517 | |
4518 | |
4519 //-----------------------------as_instance_type-------------------------------- | |
4520 // Corresponding type for an instance of the given class. | |
4521 // It will be NotNull, and exact if and only if the klass type is exact. | |
4522 const TypeOopPtr* TypeKlassPtr::as_instance_type() const { | |
4523 ciKlass* k = klass(); | |
4524 bool xk = klass_is_exact(); | |
4525 //return TypeInstPtr::make(TypePtr::NotNull, k, xk, NULL, 0); | |
4526 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
|
4527 guarantee(toop != NULL, "need type for given klass"); |
0 | 4528 toop = toop->cast_to_ptr_type(TypePtr::NotNull)->is_oopptr(); |
4529 return toop->cast_to_exactness(xk)->is_oopptr(); | |
4530 } | |
4531 | |
4532 | |
4533 //------------------------------xmeet------------------------------------------ | |
4534 // Compute the MEET of two types, return a new Type object. | |
4535 const Type *TypeKlassPtr::xmeet( const Type *t ) const { | |
4536 // Perform a fast test for common case; meeting the same types together. | |
4537 if( this == t ) return this; // Meeting same type-rep? | |
4538 | |
4539 // Current "this->_base" is Pointer | |
4540 switch (t->base()) { // switch on original type | |
4541 | |
4542 case Int: // Mixing ints & oops happens when javac | |
4543 case Long: // reuses local variables | |
4544 case FloatTop: | |
4545 case FloatCon: | |
4546 case FloatBot: | |
4547 case DoubleTop: | |
4548 case DoubleCon: | |
4549 case DoubleBot: | |
293
c3e045194476
6731641: assert(m->adr_type() == mach->adr_type(),"matcher should not change adr type")
kvn
parents:
247
diff
changeset
|
4550 case NarrowOop: |
6848
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6735
diff
changeset
|
4551 case NarrowKlass: |
0 | 4552 case Bottom: // Ye Olde Default |
4553 return Type::BOTTOM; | |
4554 case Top: | |
4555 return this; | |
4556 | |
4557 default: // All else is a mistake | |
4558 typerr(t); | |
4559 | |
4560 case AnyPtr: { // Meeting to AnyPtrs | |
4561 // Found an AnyPtr type vs self-KlassPtr type | |
4562 const TypePtr *tp = t->is_ptr(); | |
4563 int offset = meet_offset(tp->offset()); | |
4564 PTR ptr = meet_ptr(tp->ptr()); | |
4565 switch (tp->ptr()) { | |
4566 case TopPTR: | |
4567 return this; | |
4568 case Null: | |
4569 if( ptr == Null ) return TypePtr::make( AnyPtr, ptr, offset ); | |
4570 case AnyNull: | |
4571 return make( ptr, klass(), offset ); | |
4572 case BotPTR: | |
4573 case NotNull: | |
4574 return TypePtr::make(AnyPtr, ptr, offset); | |
4575 default: typerr(t); | |
4576 } | |
4577 } | |
4578 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6198
diff
changeset
|
4579 case RawPtr: |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6198
diff
changeset
|
4580 case MetadataPtr: |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6198
diff
changeset
|
4581 case OopPtr: |
0 | 4582 case AryPtr: // Meet with AryPtr |
4583 case InstPtr: // Meet with InstPtr | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6198
diff
changeset
|
4584 return TypePtr::BOTTOM; |
0 | 4585 |
4586 // | |
4587 // A-top } | |
4588 // / | \ } Tops | |
4589 // B-top A-any C-top } | |
4590 // | / | \ | } Any-nulls | |
4591 // B-any | C-any } | |
4592 // | | | | |
4593 // B-con A-con C-con } constants; not comparable across classes | |
4594 // | | | | |
4595 // B-not | C-not } | |
4596 // | \ | / | } not-nulls | |
4597 // B-bot A-not C-bot } | |
4598 // \ | / } Bottoms | |
4599 // A-bot } | |
4600 // | |
4601 | |
4602 case KlassPtr: { // Meet two KlassPtr types | |
4603 const TypeKlassPtr *tkls = t->is_klassptr(); | |
4604 int off = meet_offset(tkls->offset()); | |
4605 PTR ptr = meet_ptr(tkls->ptr()); | |
4606 | |
4607 // Check for easy case; klasses are equal (and perhaps not loaded!) | |
4608 // If we have constants, then we created oops so classes are loaded | |
4609 // and we can handle the constants further down. This case handles | |
4610 // not-loaded classes | |
4611 if( ptr != Constant && tkls->klass()->equals(klass()) ) { | |
4612 return make( ptr, klass(), off ); | |
4613 } | |
4614 | |
4615 // Classes require inspection in the Java klass hierarchy. Must be loaded. | |
4616 ciKlass* tkls_klass = tkls->klass(); | |
4617 ciKlass* this_klass = this->klass(); | |
4618 assert( tkls_klass->is_loaded(), "This class should have been loaded."); | |
4619 assert( this_klass->is_loaded(), "This class should have been loaded."); | |
4620 | |
4621 // If 'this' type is above the centerline and is a superclass of the | |
4622 // other, we can treat 'this' as having the same type as the other. | |
4623 if ((above_centerline(this->ptr())) && | |
4624 tkls_klass->is_subtype_of(this_klass)) { | |
4625 this_klass = tkls_klass; | |
4626 } | |
4627 // If 'tinst' type is above the centerline and is a superclass of the | |
4628 // other, we can treat 'tinst' as having the same type as the other. | |
4629 if ((above_centerline(tkls->ptr())) && | |
4630 this_klass->is_subtype_of(tkls_klass)) { | |
4631 tkls_klass = this_klass; | |
4632 } | |
4633 | |
4634 // Check for classes now being equal | |
4635 if (tkls_klass->equals(this_klass)) { | |
4636 // If the klasses are equal, the constants may still differ. Fall to | |
4637 // NotNull if they do (neither constant is NULL; that is a special case | |
4638 // handled elsewhere). | |
4639 if( ptr == Constant ) { | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6198
diff
changeset
|
4640 if (this->_ptr == Constant && tkls->_ptr == Constant && |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6198
diff
changeset
|
4641 this->klass()->equals(tkls->klass())); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6198
diff
changeset
|
4642 else if (above_centerline(this->ptr())); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6198
diff
changeset
|
4643 else if (above_centerline(tkls->ptr())); |
0 | 4644 else |
4645 ptr = NotNull; | |
4646 } | |
4647 return make( ptr, this_klass, off ); | |
4648 } // Else classes are not equal | |
4649 | |
4650 // Since klasses are different, we require the LCA in the Java | |
4651 // class hierarchy - which means we have to fall to at least NotNull. | |
4652 if( ptr == TopPTR || ptr == AnyNull || ptr == Constant ) | |
4653 ptr = NotNull; | |
4654 // Now we find the LCA of Java classes | |
4655 ciKlass* k = this_klass->least_common_ancestor(tkls_klass); | |
4656 return make( ptr, k, off ); | |
4657 } // End of case KlassPtr | |
4658 | |
4659 } // End of switch | |
4660 return this; // Return the double constant | |
4661 } | |
4662 | |
4663 //------------------------------xdual------------------------------------------ | |
4664 // Dual: compute field-by-field dual | |
4665 const Type *TypeKlassPtr::xdual() const { | |
4666 return new TypeKlassPtr( dual_ptr(), klass(), dual_offset() ); | |
4667 } | |
4668 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6198
diff
changeset
|
4669 //------------------------------get_con---------------------------------------- |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6198
diff
changeset
|
4670 intptr_t TypeKlassPtr::get_con() const { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6198
diff
changeset
|
4671 assert( _ptr == Null || _ptr == Constant, "" ); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6198
diff
changeset
|
4672 assert( _offset >= 0, "" ); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6198
diff
changeset
|
4673 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6198
diff
changeset
|
4674 if (_offset != 0) { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6198
diff
changeset
|
4675 // 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
|
4676 // 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
|
4677 // 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
|
4678 // 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
|
4679 // 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
|
4680 // 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
|
4681 // 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
|
4682 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
|
4683 ShouldNotReachHere(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6198
diff
changeset
|
4684 } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6198
diff
changeset
|
4685 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6198
diff
changeset
|
4686 return (intptr_t)klass()->constant_encoding(); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6198
diff
changeset
|
4687 } |
0 | 4688 //------------------------------dump2------------------------------------------ |
4689 // Dump Klass Type | |
4690 #ifndef PRODUCT | |
4691 void TypeKlassPtr::dump2( Dict & d, uint depth, outputStream *st ) const { | |
4692 switch( _ptr ) { | |
4693 case Constant: | |
4694 st->print("precise "); | |
4695 case NotNull: | |
4696 { | |
4697 const char *name = klass()->name()->as_utf8(); | |
4698 if( name ) { | |
4699 st->print("klass %s: " INTPTR_FORMAT, name, klass()); | |
4700 } else { | |
4701 ShouldNotReachHere(); | |
4702 } | |
4703 } | |
4704 case BotPTR: | |
4705 if( !WizardMode && !Verbose && !_klass_is_exact ) break; | |
4706 case TopPTR: | |
4707 case AnyNull: | |
4708 st->print(":%s", ptr_msg[_ptr]); | |
4709 if( _klass_is_exact ) st->print(":exact"); | |
4710 break; | |
4711 } | |
4712 | |
4713 if( _offset ) { // Dump offset, if any | |
4714 if( _offset == OffsetBot ) { st->print("+any"); } | |
4715 else if( _offset == OffsetTop ) { st->print("+unknown"); } | |
4716 else { st->print("+%d", _offset); } | |
4717 } | |
4718 | |
4719 st->print(" *"); | |
4720 } | |
4721 #endif | |
4722 | |
4723 | |
4724 | |
4725 //============================================================================= | |
4726 // Convenience common pre-built types. | |
4727 | |
4728 //------------------------------make------------------------------------------- | |
4729 const TypeFunc *TypeFunc::make( const TypeTuple *domain, const TypeTuple *range ) { | |
4730 return (TypeFunc*)(new TypeFunc(domain,range))->hashcons(); | |
4731 } | |
4732 | |
4733 //------------------------------make------------------------------------------- | |
4734 const TypeFunc *TypeFunc::make(ciMethod* method) { | |
4735 Compile* C = Compile::current(); | |
4736 const TypeFunc* tf = C->last_tf(method); // check cache | |
4737 if (tf != NULL) return tf; // The hit rate here is almost 50%. | |
4738 const TypeTuple *domain; | |
1137
97125851f396
6829187: compiler optimizations required for JSR 292
twisti
parents:
1009
diff
changeset
|
4739 if (method->is_static()) { |
0 | 4740 domain = TypeTuple::make_domain(NULL, method->signature()); |
4741 } else { | |
4742 domain = TypeTuple::make_domain(method->holder(), method->signature()); | |
4743 } | |
4744 const TypeTuple *range = TypeTuple::make_range(method->signature()); | |
4745 tf = TypeFunc::make(domain, range); | |
4746 C->set_last_tf(method, tf); // fill cache | |
4747 return tf; | |
4748 } | |
4749 | |
4750 //------------------------------meet------------------------------------------- | |
4751 // Compute the MEET of two types. It returns a new Type object. | |
4752 const Type *TypeFunc::xmeet( const Type *t ) const { | |
4753 // Perform a fast test for common case; meeting the same types together. | |
4754 if( this == t ) return this; // Meeting same type-rep? | |
4755 | |
4756 // Current "this->_base" is Func | |
4757 switch (t->base()) { // switch on original type | |
4758 | |
4759 case Bottom: // Ye Olde Default | |
4760 return t; | |
4761 | |
4762 default: // All else is a mistake | |
4763 typerr(t); | |
4764 | |
4765 case Top: | |
4766 break; | |
4767 } | |
4768 return this; // Return the double constant | |
4769 } | |
4770 | |
4771 //------------------------------xdual------------------------------------------ | |
4772 // Dual: compute field-by-field dual | |
4773 const Type *TypeFunc::xdual() const { | |
4774 return this; | |
4775 } | |
4776 | |
4777 //------------------------------eq--------------------------------------------- | |
4778 // Structural equality check for Type representations | |
4779 bool TypeFunc::eq( const Type *t ) const { | |
4780 const TypeFunc *a = (const TypeFunc*)t; | |
4781 return _domain == a->_domain && | |
4782 _range == a->_range; | |
4783 } | |
4784 | |
4785 //------------------------------hash------------------------------------------- | |
4786 // Type-specific hashing function. | |
4787 int TypeFunc::hash(void) const { | |
4788 return (intptr_t)_domain + (intptr_t)_range; | |
4789 } | |
4790 | |
4791 //------------------------------dump2------------------------------------------ | |
4792 // Dump Function Type | |
4793 #ifndef PRODUCT | |
4794 void TypeFunc::dump2( Dict &d, uint depth, outputStream *st ) const { | |
4795 if( _range->_cnt <= Parms ) | |
4796 st->print("void"); | |
4797 else { | |
4798 uint i; | |
4799 for (i = Parms; i < _range->_cnt-1; i++) { | |
4800 _range->field_at(i)->dump2(d,depth,st); | |
4801 st->print("/"); | |
4802 } | |
4803 _range->field_at(i)->dump2(d,depth,st); | |
4804 } | |
4805 st->print(" "); | |
4806 st->print("( "); | |
4807 if( !depth || d[this] ) { // Check for recursive dump | |
4808 st->print("...)"); | |
4809 return; | |
4810 } | |
4811 d.Insert((void*)this,(void*)this); // Stop recursion | |
4812 if (Parms < _domain->_cnt) | |
4813 _domain->field_at(Parms)->dump2(d,depth-1,st); | |
4814 for (uint i = Parms+1; i < _domain->_cnt; i++) { | |
4815 st->print(", "); | |
4816 _domain->field_at(i)->dump2(d,depth-1,st); | |
4817 } | |
4818 st->print(" )"); | |
4819 } | |
4820 #endif | |
4821 | |
4822 //------------------------------singleton-------------------------------------- | |
4823 // TRUE if Type is a singleton type, FALSE otherwise. Singletons are simple | |
4824 // constants (Ldi nodes). Singletons are integer, float or double constants | |
4825 // or a single symbol. | |
4826 bool TypeFunc::singleton(void) const { | |
4827 return false; // Never a singleton | |
4828 } | |
4829 | |
4830 bool TypeFunc::empty(void) const { | |
4831 return false; // Never empty | |
4832 } | |
4833 | |
4834 | |
4835 BasicType TypeFunc::return_type() const{ | |
4836 if (range()->cnt() == TypeFunc::Parms) { | |
4837 return T_VOID; | |
4838 } | |
4839 return range()->field_at(TypeFunc::Parms)->basic_type(); | |
4840 } |