author | dlong |
Fri, 28 Jun 2019 16:50:14 -0400 | |
changeset 55532 | 6546a2ae6773 |
parent 54669 | ad45b3802d4e |
child 55534 | 5ce081828739 |
child 55579 | 4ce8e03602e1 |
permissions | -rw-r--r-- |
43972 | 1 |
/* |
54669
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
52645
diff
changeset
|
2 |
* Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved. |
43972 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. |
|
8 |
* |
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
13 |
* accompanied this code). |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License version |
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 |
* |
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
20 |
* or visit www.oracle.com if you need additional information or have any |
|
21 |
* questions. |
|
22 |
*/ |
|
23 |
package jdk.vm.ci.hotspot; |
|
24 |
||
25 |
import static java.util.Objects.requireNonNull; |
|
26 |
import static jdk.vm.ci.hotspot.CompilerToVM.compilerToVM; |
|
27 |
import static jdk.vm.ci.hotspot.HotSpotConstantPool.isSignaturePolymorphicHolder; |
|
28 |
import static jdk.vm.ci.hotspot.HotSpotJVMCIRuntime.runtime; |
|
29 |
import static jdk.vm.ci.hotspot.HotSpotModifiers.jvmClassModifiers; |
|
30 |
import static jdk.vm.ci.hotspot.HotSpotVMConfig.config; |
|
31 |
import static jdk.vm.ci.hotspot.UnsafeAccess.UNSAFE; |
|
32 |
||
33 |
import java.lang.annotation.Annotation; |
|
52645
74cf02d5f6e2
8213907: [JVMCI] avoid Class.getDeclared* methods when converting JVMCI objects to reflection objects
dnsimon
parents:
51444
diff
changeset
|
34 |
import java.lang.reflect.Field; |
43972 | 35 |
import java.lang.reflect.Modifier; |
36 |
import java.nio.ByteOrder; |
|
37 |
import java.util.HashMap; |
|
38 |
||
39 |
import jdk.vm.ci.common.JVMCIError; |
|
40 |
import jdk.vm.ci.meta.Assumptions.AssumptionResult; |
|
41 |
import jdk.vm.ci.meta.Assumptions.ConcreteMethod; |
|
42 |
import jdk.vm.ci.meta.Assumptions.ConcreteSubtype; |
|
43 |
import jdk.vm.ci.meta.Assumptions.LeafType; |
|
44 |
import jdk.vm.ci.meta.Assumptions.NoFinalizableSubclass; |
|
45 |
import jdk.vm.ci.meta.Constant; |
|
46 |
import jdk.vm.ci.meta.JavaConstant; |
|
47 |
import jdk.vm.ci.meta.JavaKind; |
|
48 |
import jdk.vm.ci.meta.JavaType; |
|
49 |
import jdk.vm.ci.meta.ResolvedJavaField; |
|
50 |
import jdk.vm.ci.meta.ResolvedJavaMethod; |
|
51 |
import jdk.vm.ci.meta.ResolvedJavaType; |
|
50858 | 52 |
import jdk.vm.ci.meta.UnresolvedJavaField; |
53 |
import jdk.vm.ci.meta.UnresolvedJavaType; |
|
43972 | 54 |
|
55 |
/** |
|
54669
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
52645
diff
changeset
|
56 |
* Implementation of {@link JavaType} for resolved non-primitive HotSpot classes. This class is not |
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
52645
diff
changeset
|
57 |
* an {@link MetaspaceHandleObject} because it doesn't have to be scanned for GC. It's liveness is |
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
52645
diff
changeset
|
58 |
* maintained by a reference to the {@link Class} instance. |
43972 | 59 |
*/ |
54669
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
52645
diff
changeset
|
60 |
final class HotSpotResolvedObjectTypeImpl extends HotSpotResolvedJavaType implements HotSpotResolvedObjectType, MetaspaceObject { |
43972 | 61 |
|
62 |
private static final HotSpotResolvedJavaField[] NO_FIELDS = new HotSpotResolvedJavaField[0]; |
|
63 |
private static final int METHOD_CACHE_ARRAY_CAPACITY = 8; |
|
64 |
||
65 |
/** |
|
66 |
* The Java class this type represents. |
|
67 |
*/ |
|
54669
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
52645
diff
changeset
|
68 |
private final long metadataPointer; |
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
52645
diff
changeset
|
69 |
|
43972 | 70 |
private HotSpotResolvedJavaMethodImpl[] methodCacheArray; |
71 |
private HashMap<Long, HotSpotResolvedJavaMethodImpl> methodCacheHashMap; |
|
54669
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
52645
diff
changeset
|
72 |
private volatile HotSpotResolvedJavaField[] instanceFields; |
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
52645
diff
changeset
|
73 |
private volatile HotSpotResolvedObjectTypeImpl[] interfaces; |
43972 | 74 |
private HotSpotConstantPool constantPool; |
75 |
private HotSpotResolvedObjectType arrayOfType; |
|
54669
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
52645
diff
changeset
|
76 |
private final JavaConstant mirror; |
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
52645
diff
changeset
|
77 |
private HotSpotResolvedObjectTypeImpl superClass; |
43972 | 78 |
|
79 |
/** |
|
54669
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
52645
diff
changeset
|
80 |
* Managed exclusively by {@link HotSpotJDKReflection#getField}. |
52645
74cf02d5f6e2
8213907: [JVMCI] avoid Class.getDeclared* methods when converting JVMCI objects to reflection objects
dnsimon
parents:
51444
diff
changeset
|
81 |
*/ |
74cf02d5f6e2
8213907: [JVMCI] avoid Class.getDeclared* methods when converting JVMCI objects to reflection objects
dnsimon
parents:
51444
diff
changeset
|
82 |
HashMap<HotSpotResolvedJavaFieldImpl, Field> reflectionFieldCache; |
74cf02d5f6e2
8213907: [JVMCI] avoid Class.getDeclared* methods when converting JVMCI objects to reflection objects
dnsimon
parents:
51444
diff
changeset
|
83 |
|
54669
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
52645
diff
changeset
|
84 |
static HotSpotResolvedObjectTypeImpl getJavaLangObject() { |
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
52645
diff
changeset
|
85 |
return runtime().getJavaLangObject(); |
43972 | 86 |
} |
87 |
||
88 |
/** |
|
54669
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
52645
diff
changeset
|
89 |
* Gets the JVMCI mirror from a HotSpot type. |
43972 | 90 |
* |
91 |
* Called from the VM. |
|
92 |
* |
|
54669
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
52645
diff
changeset
|
93 |
* @param klassPointer a native pointer to the Klass* |
43972 | 94 |
* @return the {@link ResolvedJavaType} corresponding to {@code javaClass} |
95 |
*/ |
|
96 |
@SuppressWarnings("unused") |
|
54669
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
52645
diff
changeset
|
97 |
@VMEntryPoint |
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
52645
diff
changeset
|
98 |
private static HotSpotResolvedObjectTypeImpl fromMetaspace(long klassPointer, String signature) { |
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
52645
diff
changeset
|
99 |
return runtime().fromMetaspace(klassPointer, signature); |
43972 | 100 |
} |
101 |
||
102 |
/** |
|
103 |
* Creates the JVMCI mirror for a {@link Class} object. |
|
104 |
* |
|
105 |
* <b>NOTE</b>: Creating an instance of this class does not install the mirror for the |
|
54669
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
52645
diff
changeset
|
106 |
* {@link Class} type. {@link #fromMetaspace} instead. |
43972 | 107 |
* </p> |
108 |
* |
|
54669
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
52645
diff
changeset
|
109 |
* @param metadataPointer the Klass* to create the mirror for |
43972 | 110 |
*/ |
54669
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
52645
diff
changeset
|
111 |
HotSpotResolvedObjectTypeImpl(long metadataPointer, String name) { |
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
52645
diff
changeset
|
112 |
super(name); |
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
52645
diff
changeset
|
113 |
this.metadataPointer = metadataPointer; |
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
52645
diff
changeset
|
114 |
this.mirror = runtime().compilerToVm.getJavaMirror(this); |
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
52645
diff
changeset
|
115 |
assert metadataPointer != 0; |
43972 | 116 |
assert getName().charAt(0) != '[' || isArray() : getName(); |
117 |
} |
|
118 |
||
119 |
/** |
|
120 |
* Gets the metaspace Klass for this type. |
|
121 |
*/ |
|
122 |
long getMetaspaceKlass() { |
|
54669
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
52645
diff
changeset
|
123 |
long metaspacePointer = getMetaspacePointer(); |
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
52645
diff
changeset
|
124 |
if (metaspacePointer == 0) { |
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
52645
diff
changeset
|
125 |
throw new NullPointerException("Klass* is null"); |
43972 | 126 |
} |
54669
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
52645
diff
changeset
|
127 |
return metaspacePointer; |
43972 | 128 |
} |
129 |
||
130 |
@Override |
|
131 |
public long getMetaspacePointer() { |
|
54669
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
52645
diff
changeset
|
132 |
return metadataPointer; |
43972 | 133 |
} |
134 |
||
135 |
@Override |
|
136 |
public int getModifiers() { |
|
137 |
if (isArray()) { |
|
138 |
return (getElementalType().getModifiers() & (Modifier.PUBLIC | Modifier.PRIVATE | Modifier.PROTECTED)) | Modifier.FINAL | Modifier.ABSTRACT; |
|
139 |
} else { |
|
140 |
return getAccessFlags() & jvmClassModifiers(); |
|
141 |
} |
|
142 |
} |
|
143 |
||
144 |
public int getAccessFlags() { |
|
145 |
HotSpotVMConfig config = config(); |
|
146 |
return UNSAFE.getInt(getMetaspaceKlass() + config.klassAccessFlagsOffset); |
|
147 |
} |
|
148 |
||
149 |
@Override |
|
150 |
public HotSpotResolvedObjectType getArrayClass() { |
|
151 |
if (arrayOfType == null) { |
|
54669
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
52645
diff
changeset
|
152 |
try { |
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
52645
diff
changeset
|
153 |
arrayOfType = (HotSpotResolvedObjectType) runtime().compilerToVm.lookupType("[" + getName(), this, true); |
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
52645
diff
changeset
|
154 |
} catch (ClassNotFoundException e) { |
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
52645
diff
changeset
|
155 |
throw new JVMCIError(e); |
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
52645
diff
changeset
|
156 |
} |
43972 | 157 |
} |
158 |
return arrayOfType; |
|
159 |
} |
|
160 |
||
161 |
@Override |
|
162 |
public ResolvedJavaType getComponentType() { |
|
54669
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
52645
diff
changeset
|
163 |
return runtime().compilerToVm.getComponentType(this); |
43972 | 164 |
} |
165 |
||
166 |
@Override |
|
167 |
public AssumptionResult<ResolvedJavaType> findLeafConcreteSubtype() { |
|
168 |
if (isLeaf()) { |
|
169 |
// No assumptions are required. |
|
170 |
return new AssumptionResult<>(this); |
|
171 |
} |
|
172 |
HotSpotVMConfig config = config(); |
|
173 |
if (isArray()) { |
|
174 |
ResolvedJavaType elementalType = getElementalType(); |
|
175 |
AssumptionResult<ResolvedJavaType> elementType = elementalType.findLeafConcreteSubtype(); |
|
176 |
if (elementType != null && elementType.getResult().equals(elementalType)) { |
|
177 |
/* |
|
178 |
* If the elementType is leaf then the array is leaf under the same assumptions but |
|
179 |
* only if the element type is exactly the leaf type. The element type can be |
|
180 |
* abstract even if there is only one implementor of the abstract type. |
|
181 |
*/ |
|
182 |
AssumptionResult<ResolvedJavaType> result = new AssumptionResult<>(this); |
|
183 |
result.add(elementType); |
|
184 |
return result; |
|
185 |
} |
|
186 |
return null; |
|
187 |
} else if (isInterface()) { |
|
188 |
HotSpotResolvedObjectTypeImpl implementor = getSingleImplementor(); |
|
189 |
/* |
|
190 |
* If the implementor field contains itself that indicates that the interface has more |
|
191 |
* than one implementors (see: InstanceKlass::add_implementor). |
|
192 |
*/ |
|
193 |
if (implementor == null || implementor.equals(this)) { |
|
194 |
return null; |
|
195 |
} |
|
196 |
||
197 |
assert !implementor.isInterface(); |
|
198 |
if (implementor.isAbstract() || !implementor.isLeafClass()) { |
|
199 |
AssumptionResult<ResolvedJavaType> leafConcreteSubtype = implementor.findLeafConcreteSubtype(); |
|
200 |
if (leafConcreteSubtype != null) { |
|
201 |
assert !leafConcreteSubtype.getResult().equals(implementor); |
|
202 |
AssumptionResult<ResolvedJavaType> newResult = new AssumptionResult<>(leafConcreteSubtype.getResult(), new ConcreteSubtype(this, implementor)); |
|
203 |
// Accumulate leaf assumptions and return the combined result. |
|
204 |
newResult.add(leafConcreteSubtype); |
|
205 |
return newResult; |
|
206 |
} |
|
207 |
return null; |
|
208 |
} |
|
209 |
return concreteSubtype(implementor); |
|
210 |
} else { |
|
211 |
HotSpotResolvedObjectTypeImpl type = this; |
|
212 |
while (type.isAbstract()) { |
|
213 |
HotSpotResolvedObjectTypeImpl subklass = type.getSubklass(); |
|
214 |
if (subklass == null || UNSAFE.getAddress(subklass.getMetaspaceKlass() + config.nextSiblingOffset) != 0) { |
|
215 |
return null; |
|
216 |
} |
|
217 |
type = subklass; |
|
218 |
} |
|
219 |
if (type.isAbstract() || type.isInterface() || !type.isLeafClass()) { |
|
220 |
return null; |
|
221 |
} |
|
222 |
if (this.isAbstract()) { |
|
223 |
return concreteSubtype(type); |
|
224 |
} else { |
|
225 |
assert this.equals(type); |
|
226 |
return new AssumptionResult<>(type, new LeafType(type)); |
|
227 |
} |
|
228 |
} |
|
229 |
} |
|
230 |
||
231 |
private AssumptionResult<ResolvedJavaType> concreteSubtype(HotSpotResolvedObjectTypeImpl type) { |
|
232 |
if (type.isLeaf()) { |
|
233 |
return new AssumptionResult<>(type, new ConcreteSubtype(this, type)); |
|
234 |
} else { |
|
235 |
return new AssumptionResult<>(type, new LeafType(type), new ConcreteSubtype(this, type)); |
|
236 |
} |
|
237 |
} |
|
238 |
||
239 |
/** |
|
240 |
* Returns if type {@code type} is a leaf class. This is the case if the |
|
241 |
* {@code Klass::_subklass} field of the underlying class is zero. |
|
242 |
* |
|
243 |
* @return true if the type is a leaf class |
|
244 |
*/ |
|
245 |
private boolean isLeafClass() { |
|
246 |
return UNSAFE.getLong(this.getMetaspaceKlass() + config().subklassOffset) == 0; |
|
247 |
} |
|
248 |
||
249 |
/** |
|
250 |
* Returns the {@code Klass::_subklass} field of the underlying metaspace klass for the given |
|
251 |
* type {@code type}. |
|
252 |
* |
|
253 |
* @return value of the subklass field as metaspace klass pointer |
|
254 |
*/ |
|
255 |
private HotSpotResolvedObjectTypeImpl getSubklass() { |
|
256 |
return compilerToVM().getResolvedJavaType(this, config().subklassOffset, false); |
|
257 |
} |
|
258 |
||
259 |
@Override |
|
260 |
public HotSpotResolvedObjectTypeImpl getSuperclass() { |
|
54669
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
52645
diff
changeset
|
261 |
if (isInterface()) { |
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
52645
diff
changeset
|
262 |
return null; |
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
52645
diff
changeset
|
263 |
} |
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
52645
diff
changeset
|
264 |
HotSpotResolvedObjectTypeImpl javaLangObject = runtime().getJavaLangObject(); |
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
52645
diff
changeset
|
265 |
if (this.equals(javaLangObject)) { |
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
52645
diff
changeset
|
266 |
return null; |
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
52645
diff
changeset
|
267 |
} |
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
52645
diff
changeset
|
268 |
if (isArray()) { |
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
52645
diff
changeset
|
269 |
return javaLangObject; |
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
52645
diff
changeset
|
270 |
} |
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
52645
diff
changeset
|
271 |
|
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
52645
diff
changeset
|
272 |
// Cache result of native call |
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
52645
diff
changeset
|
273 |
if (superClass == null) { |
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
52645
diff
changeset
|
274 |
superClass = compilerToVM().getResolvedJavaType(this, config().superOffset, false); |
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
52645
diff
changeset
|
275 |
} |
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
52645
diff
changeset
|
276 |
return superClass; |
43972 | 277 |
} |
278 |
||
279 |
@Override |
|
280 |
public HotSpotResolvedObjectTypeImpl[] getInterfaces() { |
|
281 |
if (interfaces == null) { |
|
54669
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
52645
diff
changeset
|
282 |
if (isArray()) { |
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
52645
diff
changeset
|
283 |
HotSpotResolvedObjectTypeImpl[] types = new HotSpotResolvedObjectTypeImpl[2]; |
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
52645
diff
changeset
|
284 |
types[0] = runtime().getJavaLangCloneable(); |
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
52645
diff
changeset
|
285 |
types[1] = runtime().getJavaLangSerializable(); |
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
52645
diff
changeset
|
286 |
this.interfaces = types; |
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
52645
diff
changeset
|
287 |
} else { |
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
52645
diff
changeset
|
288 |
interfaces = runtime().compilerToVm.getInterfaces(this); |
43972 | 289 |
} |
290 |
} |
|
291 |
return interfaces; |
|
292 |
} |
|
293 |
||
294 |
@Override |
|
295 |
public HotSpotResolvedObjectTypeImpl getSingleImplementor() { |
|
296 |
if (!isInterface()) { |
|
297 |
throw new JVMCIError("Cannot call getSingleImplementor() on a non-interface type: %s", this); |
|
298 |
} |
|
299 |
return compilerToVM().getImplementor(this); |
|
300 |
} |
|
301 |
||
50858 | 302 |
@Override |
43972 | 303 |
public HotSpotResolvedObjectTypeImpl getSupertype() { |
304 |
if (isArray()) { |
|
305 |
ResolvedJavaType componentType = getComponentType(); |
|
54669
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
52645
diff
changeset
|
306 |
if (componentType.equals(getJavaLangObject()) || componentType.isPrimitive()) { |
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
52645
diff
changeset
|
307 |
return getJavaLangObject(); |
43972 | 308 |
} |
54669
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
52645
diff
changeset
|
309 |
HotSpotResolvedObjectTypeImpl supertype = ((HotSpotResolvedObjectTypeImpl) componentType).getSupertype(); |
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
52645
diff
changeset
|
310 |
return (HotSpotResolvedObjectTypeImpl) supertype.getArrayClass(); |
43972 | 311 |
} |
312 |
if (isInterface()) { |
|
54669
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
52645
diff
changeset
|
313 |
return getJavaLangObject(); |
43972 | 314 |
} |
315 |
return getSuperclass(); |
|
316 |
} |
|
317 |
||
318 |
@Override |
|
319 |
public HotSpotResolvedObjectType findLeastCommonAncestor(ResolvedJavaType otherType) { |
|
320 |
if (otherType.isPrimitive()) { |
|
321 |
return null; |
|
322 |
} else { |
|
323 |
HotSpotResolvedObjectTypeImpl t1 = this; |
|
324 |
HotSpotResolvedObjectTypeImpl t2 = (HotSpotResolvedObjectTypeImpl) otherType; |
|
325 |
while (true) { |
|
326 |
if (t1.isAssignableFrom(t2)) { |
|
327 |
return t1; |
|
328 |
} |
|
329 |
if (t2.isAssignableFrom(t1)) { |
|
330 |
return t2; |
|
331 |
} |
|
332 |
t1 = t1.getSupertype(); |
|
333 |
t2 = t2.getSupertype(); |
|
334 |
} |
|
335 |
} |
|
336 |
} |
|
337 |
||
338 |
@Override |
|
339 |
public AssumptionResult<Boolean> hasFinalizableSubclass() { |
|
340 |
assert !isArray(); |
|
341 |
if (!compilerToVM().hasFinalizableSubclass(this)) { |
|
342 |
return new AssumptionResult<>(false, new NoFinalizableSubclass(this)); |
|
343 |
} |
|
344 |
return new AssumptionResult<>(true); |
|
345 |
} |
|
346 |
||
347 |
@Override |
|
348 |
public boolean hasFinalizer() { |
|
349 |
return (getAccessFlags() & config().jvmAccHasFinalizer) != 0; |
|
350 |
} |
|
351 |
||
352 |
@Override |
|
353 |
public boolean isArray() { |
|
54669
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
52645
diff
changeset
|
354 |
return layoutHelper() < config().klassLayoutHelperNeutralValue; |
43972 | 355 |
} |
356 |
||
357 |
@Override |
|
50858 | 358 |
public boolean isEnum() { |
54669
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
52645
diff
changeset
|
359 |
HotSpotResolvedObjectTypeImpl superclass = getSuperclass(); |
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
52645
diff
changeset
|
360 |
return superclass != null && superclass.equals(runtime().getJavaLangEnum()); |
50858 | 361 |
} |
362 |
||
363 |
@Override |
|
43972 | 364 |
public boolean isInitialized() { |
365 |
return isArray() ? true : getInitState() == config().instanceKlassStateFullyInitialized; |
|
366 |
} |
|
367 |
||
368 |
@Override |
|
369 |
public boolean isLinked() { |
|
370 |
return isArray() ? true : getInitState() >= config().instanceKlassStateLinked; |
|
371 |
} |
|
372 |
||
373 |
/** |
|
374 |
* Returns the value of the state field {@code InstanceKlass::_init_state} of the metaspace |
|
375 |
* klass. |
|
376 |
* |
|
377 |
* @return state field value of this type |
|
378 |
*/ |
|
379 |
private int getInitState() { |
|
380 |
assert !isArray() : "_init_state only exists in InstanceKlass"; |
|
381 |
return UNSAFE.getByte(getMetaspaceKlass() + config().instanceKlassInitStateOffset) & 0xFF; |
|
382 |
} |
|
383 |
||
384 |
@Override |
|
385 |
public void initialize() { |
|
386 |
if (!isInitialized()) { |
|
54669
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
52645
diff
changeset
|
387 |
runtime().compilerToVm.ensureInitialized(this); |
43972 | 388 |
assert isInitialized(); |
389 |
} |
|
390 |
} |
|
391 |
||
392 |
@Override |
|
393 |
public boolean isInstance(JavaConstant obj) { |
|
394 |
if (obj.getJavaKind() == JavaKind.Object && !obj.isNull()) { |
|
54669
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
52645
diff
changeset
|
395 |
return runtime().reflection.isInstance(this, (HotSpotObjectConstantImpl) obj); |
43972 | 396 |
} |
397 |
return false; |
|
398 |
} |
|
399 |
||
400 |
@Override |
|
401 |
public boolean isInstanceClass() { |
|
402 |
return !isArray() && !isInterface(); |
|
403 |
} |
|
404 |
||
405 |
@Override |
|
406 |
public boolean isInterface() { |
|
54669
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
52645
diff
changeset
|
407 |
return (getAccessFlags() & config().jvmAccInterface) != 0; |
43972 | 408 |
} |
409 |
||
410 |
@Override |
|
411 |
public boolean isAssignableFrom(ResolvedJavaType other) { |
|
412 |
assert other != null; |
|
413 |
if (other instanceof HotSpotResolvedObjectTypeImpl) { |
|
414 |
HotSpotResolvedObjectTypeImpl otherType = (HotSpotResolvedObjectTypeImpl) other; |
|
54669
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
52645
diff
changeset
|
415 |
return runtime().reflection.isAssignableFrom(this, otherType); |
43972 | 416 |
} |
417 |
return false; |
|
418 |
} |
|
419 |
||
420 |
@Override |
|
45626
c4ea64135530
8182310: [AOT][JVMCI] Get host class of VM anonymous class
dnsimon
parents:
44836
diff
changeset
|
421 |
public ResolvedJavaType getHostClass() { |
c4ea64135530
8182310: [AOT][JVMCI] Get host class of VM anonymous class
dnsimon
parents:
44836
diff
changeset
|
422 |
if (isArray()) { |
c4ea64135530
8182310: [AOT][JVMCI] Get host class of VM anonymous class
dnsimon
parents:
44836
diff
changeset
|
423 |
return null; |
c4ea64135530
8182310: [AOT][JVMCI] Get host class of VM anonymous class
dnsimon
parents:
44836
diff
changeset
|
424 |
} |
c4ea64135530
8182310: [AOT][JVMCI] Get host class of VM anonymous class
dnsimon
parents:
44836
diff
changeset
|
425 |
return compilerToVM().getHostClass(this); |
c4ea64135530
8182310: [AOT][JVMCI] Get host class of VM anonymous class
dnsimon
parents:
44836
diff
changeset
|
426 |
} |
c4ea64135530
8182310: [AOT][JVMCI] Get host class of VM anonymous class
dnsimon
parents:
44836
diff
changeset
|
427 |
|
c4ea64135530
8182310: [AOT][JVMCI] Get host class of VM anonymous class
dnsimon
parents:
44836
diff
changeset
|
428 |
@Override |
43972 | 429 |
public boolean isJavaLangObject() { |
54669
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
52645
diff
changeset
|
430 |
return getName().equals("Ljava/lang/Object;"); |
43972 | 431 |
} |
432 |
||
433 |
@Override |
|
434 |
public JavaKind getJavaKind() { |
|
435 |
return JavaKind.Object; |
|
436 |
} |
|
437 |
||
438 |
@Override |
|
439 |
public ResolvedJavaMethod resolveMethod(ResolvedJavaMethod method, ResolvedJavaType callerType) { |
|
440 |
assert !callerType.isArray(); |
|
441 |
if (isInterface()) { |
|
442 |
// Methods can only be resolved against concrete types |
|
443 |
return null; |
|
444 |
} |
|
445 |
if (method.isConcrete() && method.getDeclaringClass().equals(this) && method.isPublic() && !isSignaturePolymorphicHolder(method.getDeclaringClass())) { |
|
446 |
return method; |
|
447 |
} |
|
448 |
if (!method.getDeclaringClass().isAssignableFrom(this)) { |
|
449 |
return null; |
|
450 |
} |
|
451 |
HotSpotResolvedJavaMethodImpl hotSpotMethod = (HotSpotResolvedJavaMethodImpl) method; |
|
452 |
HotSpotResolvedObjectTypeImpl hotSpotCallerType = (HotSpotResolvedObjectTypeImpl) callerType; |
|
453 |
return compilerToVM().resolveMethod(this, hotSpotMethod, hotSpotCallerType); |
|
454 |
} |
|
455 |
||
50858 | 456 |
@Override |
43972 | 457 |
public HotSpotConstantPool getConstantPool() { |
458 |
if (constantPool == null || !isArray() && UNSAFE.getAddress(getMetaspaceKlass() + config().instanceKlassConstantsOffset) != constantPool.getMetaspaceConstantPool()) { |
|
459 |
/* |
|
460 |
* If the pointer to the ConstantPool has changed since this was last read refresh the |
|
461 |
* HotSpotConstantPool wrapper object. This ensures that uses of the constant pool are |
|
462 |
* operating on the latest one and that HotSpotResolvedJavaMethodImpls will be able to |
|
463 |
* use the shared copy instead of creating their own instance. |
|
464 |
*/ |
|
465 |
constantPool = compilerToVM().getConstantPool(this); |
|
466 |
} |
|
467 |
return constantPool; |
|
468 |
} |
|
469 |
||
470 |
/** |
|
471 |
* Gets the instance size of this type. If an instance of this type cannot be fast path |
|
472 |
* allocated, then the returned value is negative (its absolute value gives the size). Must not |
|
473 |
* be called if this is an array or interface type. |
|
474 |
*/ |
|
50858 | 475 |
@Override |
43972 | 476 |
public int instanceSize() { |
477 |
assert !isArray(); |
|
478 |
assert !isInterface(); |
|
479 |
||
480 |
HotSpotVMConfig config = config(); |
|
481 |
final int layoutHelper = layoutHelper(); |
|
482 |
assert layoutHelper > config.klassLayoutHelperNeutralValue : "must be instance"; |
|
483 |
||
484 |
// See: Klass::layout_helper_size_in_bytes |
|
485 |
int size = layoutHelper & ~config.klassLayoutHelperInstanceSlowPathBit; |
|
486 |
||
487 |
// See: Klass::layout_helper_needs_slow_path |
|
488 |
boolean needsSlowPath = (layoutHelper & config.klassLayoutHelperInstanceSlowPathBit) != 0; |
|
489 |
||
490 |
return needsSlowPath ? -size : size; |
|
491 |
} |
|
492 |
||
50858 | 493 |
@Override |
43972 | 494 |
public int layoutHelper() { |
495 |
HotSpotVMConfig config = config(); |
|
54669
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
52645
diff
changeset
|
496 |
assert getMetaspaceKlass() != 0 : getName(); |
43972 | 497 |
return UNSAFE.getInt(getMetaspaceKlass() + config.klassLayoutHelperOffset); |
498 |
} |
|
499 |
||
500 |
@Override |
|
501 |
public long getFingerprint() { |
|
502 |
return compilerToVM().getFingerprint(getMetaspaceKlass()); |
|
503 |
} |
|
504 |
||
54669
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
52645
diff
changeset
|
505 |
synchronized HotSpotResolvedJavaMethod createMethod(long metaspaceHandle) { |
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
52645
diff
changeset
|
506 |
long metaspaceMethod = UNSAFE.getLong(metaspaceHandle); |
43972 | 507 |
// Maintain cache as array. |
508 |
if (methodCacheArray == null) { |
|
509 |
methodCacheArray = new HotSpotResolvedJavaMethodImpl[METHOD_CACHE_ARRAY_CAPACITY]; |
|
510 |
} |
|
511 |
||
512 |
int i = 0; |
|
513 |
for (; i < methodCacheArray.length; ++i) { |
|
514 |
HotSpotResolvedJavaMethodImpl curMethod = methodCacheArray[i]; |
|
515 |
if (curMethod == null) { |
|
54669
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
52645
diff
changeset
|
516 |
HotSpotResolvedJavaMethodImpl newMethod = new HotSpotResolvedJavaMethodImpl(this, metaspaceHandle); |
43972 | 517 |
methodCacheArray[i] = newMethod; |
518 |
return newMethod; |
|
54669
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
52645
diff
changeset
|
519 |
} else if (curMethod.getMetaspaceMethod() == metaspaceMethod) { |
43972 | 520 |
return curMethod; |
521 |
} |
|
522 |
} |
|
523 |
||
524 |
// Fall-back to hash table. |
|
525 |
if (methodCacheHashMap == null) { |
|
526 |
methodCacheHashMap = new HashMap<>(); |
|
527 |
} |
|
528 |
||
529 |
HotSpotResolvedJavaMethodImpl lookupResult = methodCacheHashMap.get(metaspaceMethod); |
|
530 |
if (lookupResult == null) { |
|
54669
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
52645
diff
changeset
|
531 |
HotSpotResolvedJavaMethodImpl newMethod = new HotSpotResolvedJavaMethodImpl(this, metaspaceHandle); |
43972 | 532 |
methodCacheHashMap.put(metaspaceMethod, newMethod); |
533 |
return newMethod; |
|
534 |
} else { |
|
535 |
return lookupResult; |
|
536 |
} |
|
537 |
} |
|
538 |
||
50858 | 539 |
@Override |
43972 | 540 |
public int getVtableLength() { |
541 |
HotSpotVMConfig config = config(); |
|
542 |
if (isInterface() || isArray()) { |
|
543 |
/* Everything has the core vtable of java.lang.Object */ |
|
544 |
return config.baseVtableLength(); |
|
545 |
} |
|
546 |
int result = UNSAFE.getInt(getMetaspaceKlass() + config.klassVtableLengthOffset) / (config.vtableEntrySize / config.heapWordSize); |
|
547 |
assert result >= config.baseVtableLength() : UNSAFE.getInt(getMetaspaceKlass() + config.klassVtableLengthOffset) + " " + config.vtableEntrySize; |
|
548 |
return result; |
|
549 |
} |
|
550 |
||
47781
499bba56e938
8177397: [JVMCI] remove unnecessary synchronization
dnsimon
parents:
47668
diff
changeset
|
551 |
HotSpotResolvedJavaField createField(JavaType type, long offset, int rawFlags, int index) { |
43972 | 552 |
return new HotSpotResolvedJavaFieldImpl(this, type, offset, rawFlags, index); |
553 |
} |
|
554 |
||
555 |
@Override |
|
556 |
public AssumptionResult<ResolvedJavaMethod> findUniqueConcreteMethod(ResolvedJavaMethod method) { |
|
557 |
HotSpotResolvedJavaMethod hmethod = (HotSpotResolvedJavaMethod) method; |
|
558 |
HotSpotResolvedObjectType declaredHolder = hmethod.getDeclaringClass(); |
|
559 |
/* |
|
560 |
* Sometimes the receiver type in the graph hasn't stabilized to a subtype of declared |
|
561 |
* holder, usually because of phis, so make sure that the type is related to the declared |
|
562 |
* type before using it for lookup. Unlinked types should also be ignored because we can't |
|
563 |
* resolve the proper method to invoke. Generally unlinked types in invokes should result in |
|
564 |
* a deopt instead since they can't really be used if they aren't linked yet. |
|
565 |
*/ |
|
566 |
if (!declaredHolder.isAssignableFrom(this) || this.isArray() || this.equals(declaredHolder) || !isLinked() || isInterface()) { |
|
567 |
ResolvedJavaMethod result = hmethod.uniqueConcreteMethod(declaredHolder); |
|
568 |
if (result != null) { |
|
569 |
return new AssumptionResult<>(result, new ConcreteMethod(method, declaredHolder, result)); |
|
570 |
} |
|
571 |
return null; |
|
572 |
} |
|
573 |
/* |
|
574 |
* The holder may be a subtype of the declaredHolder so make sure to resolve the method to |
|
575 |
* the correct method for the subtype. |
|
576 |
*/ |
|
577 |
HotSpotResolvedJavaMethod resolvedMethod = (HotSpotResolvedJavaMethod) resolveMethod(hmethod, this); |
|
578 |
if (resolvedMethod == null) { |
|
579 |
// The type isn't known to implement the method. |
|
580 |
return null; |
|
581 |
} |
|
55532
6546a2ae6773
8226533: JVMCI: findUniqueConcreteMethod should handle statically bindable methods directly
dlong
parents:
54669
diff
changeset
|
582 |
if (resolvedMethod.canBeStaticallyBound()) { |
6546a2ae6773
8226533: JVMCI: findUniqueConcreteMethod should handle statically bindable methods directly
dlong
parents:
54669
diff
changeset
|
583 |
// No assumptions are required. |
6546a2ae6773
8226533: JVMCI: findUniqueConcreteMethod should handle statically bindable methods directly
dlong
parents:
54669
diff
changeset
|
584 |
return new AssumptionResult<>(resolvedMethod); |
6546a2ae6773
8226533: JVMCI: findUniqueConcreteMethod should handle statically bindable methods directly
dlong
parents:
54669
diff
changeset
|
585 |
} |
43972 | 586 |
|
587 |
ResolvedJavaMethod result = resolvedMethod.uniqueConcreteMethod(this); |
|
588 |
if (result != null) { |
|
589 |
return new AssumptionResult<>(result, new ConcreteMethod(method, this, result)); |
|
590 |
} |
|
591 |
return null; |
|
592 |
} |
|
593 |
||
594 |
FieldInfo createFieldInfo(int index) { |
|
595 |
return new FieldInfo(index); |
|
596 |
} |
|
597 |
||
54669
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
52645
diff
changeset
|
598 |
public void ensureInitialized() { |
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
52645
diff
changeset
|
599 |
runtime().compilerToVm.ensureInitialized(this); |
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
52645
diff
changeset
|
600 |
} |
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
52645
diff
changeset
|
601 |
|
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
52645
diff
changeset
|
602 |
@Override |
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
52645
diff
changeset
|
603 |
public boolean equals(Object obj) { |
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
52645
diff
changeset
|
604 |
if (obj == this) { |
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
52645
diff
changeset
|
605 |
return true; |
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
52645
diff
changeset
|
606 |
} |
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
52645
diff
changeset
|
607 |
if (!(obj instanceof HotSpotResolvedObjectTypeImpl)) { |
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
52645
diff
changeset
|
608 |
return false; |
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
52645
diff
changeset
|
609 |
} |
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
52645
diff
changeset
|
610 |
HotSpotResolvedObjectTypeImpl that = (HotSpotResolvedObjectTypeImpl) obj; |
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
52645
diff
changeset
|
611 |
return getMetaspaceKlass() == that.getMetaspaceKlass(); |
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
52645
diff
changeset
|
612 |
} |
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
52645
diff
changeset
|
613 |
|
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
52645
diff
changeset
|
614 |
@Override |
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
52645
diff
changeset
|
615 |
JavaConstant getJavaMirror() { |
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
52645
diff
changeset
|
616 |
return mirror; |
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
52645
diff
changeset
|
617 |
} |
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
52645
diff
changeset
|
618 |
|
43972 | 619 |
/** |
620 |
* This class represents the field information for one field contained in the fields array of an |
|
621 |
* {@code InstanceKlass}. The implementation is similar to the native {@code FieldInfo} class. |
|
622 |
*/ |
|
623 |
class FieldInfo { |
|
624 |
/** |
|
625 |
* Native pointer into the array of Java shorts. |
|
626 |
*/ |
|
627 |
private final long metaspaceData; |
|
628 |
||
629 |
/** |
|
630 |
* Creates a field info for the field in the fields array at index {@code index}. |
|
631 |
* |
|
632 |
* @param index index to the fields array |
|
633 |
*/ |
|
634 |
FieldInfo(int index) { |
|
635 |
HotSpotVMConfig config = config(); |
|
636 |
// Get Klass::_fields |
|
637 |
final long metaspaceFields = UNSAFE.getAddress(getMetaspaceKlass() + config.instanceKlassFieldsOffset); |
|
638 |
assert config.fieldInfoFieldSlots == 6 : "revisit the field parsing code"; |
|
639 |
int offset = config.fieldInfoFieldSlots * Short.BYTES * index; |
|
640 |
metaspaceData = metaspaceFields + config.arrayU2DataOffset + offset; |
|
641 |
} |
|
642 |
||
643 |
private int getAccessFlags() { |
|
644 |
return readFieldSlot(config().fieldInfoAccessFlagsOffset); |
|
645 |
} |
|
646 |
||
647 |
private int getNameIndex() { |
|
648 |
return readFieldSlot(config().fieldInfoNameIndexOffset); |
|
649 |
} |
|
650 |
||
651 |
private int getSignatureIndex() { |
|
652 |
return readFieldSlot(config().fieldInfoSignatureIndexOffset); |
|
653 |
} |
|
654 |
||
655 |
public int getOffset() { |
|
656 |
HotSpotVMConfig config = config(); |
|
657 |
final int lowPacked = readFieldSlot(config.fieldInfoLowPackedOffset); |
|
658 |
final int highPacked = readFieldSlot(config.fieldInfoHighPackedOffset); |
|
659 |
final int offset = ((highPacked << Short.SIZE) | lowPacked) >> config.fieldInfoTagSize; |
|
660 |
return offset; |
|
661 |
} |
|
662 |
||
663 |
/** |
|
664 |
* Helper method to read an entry (slot) from the field array. Currently field info is laid |
|
665 |
* on top an array of Java shorts. |
|
666 |
*/ |
|
667 |
private int readFieldSlot(int index) { |
|
668 |
int offset = Short.BYTES * index; |
|
669 |
return UNSAFE.getChar(metaspaceData + offset); |
|
670 |
} |
|
671 |
||
672 |
/** |
|
673 |
* Returns the name of this field as a {@link String}. If the field is an internal field the |
|
674 |
* name index is pointing into the vmSymbols table. |
|
675 |
*/ |
|
676 |
public String getName() { |
|
677 |
final int nameIndex = getNameIndex(); |
|
678 |
return isInternal() ? config().symbolAt(nameIndex) : getConstantPool().lookupUtf8(nameIndex); |
|
679 |
} |
|
680 |
||
681 |
/** |
|
682 |
* Returns the signature of this field as {@link String}. If the field is an internal field |
|
683 |
* the signature index is pointing into the vmSymbols table. |
|
684 |
*/ |
|
685 |
public String getSignature() { |
|
686 |
final int signatureIndex = getSignatureIndex(); |
|
687 |
return isInternal() ? config().symbolAt(signatureIndex) : getConstantPool().lookupUtf8(signatureIndex); |
|
688 |
} |
|
689 |
||
690 |
public JavaType getType() { |
|
691 |
String signature = getSignature(); |
|
692 |
return runtime().lookupType(signature, HotSpotResolvedObjectTypeImpl.this, false); |
|
693 |
} |
|
694 |
||
695 |
private boolean isInternal() { |
|
696 |
return (getAccessFlags() & config().jvmAccFieldInternal) != 0; |
|
697 |
} |
|
698 |
||
699 |
public boolean isStatic() { |
|
700 |
return Modifier.isStatic(getAccessFlags()); |
|
701 |
} |
|
702 |
||
703 |
public boolean hasGenericSignature() { |
|
704 |
return (getAccessFlags() & config().jvmAccFieldHasGenericSignature) != 0; |
|
705 |
} |
|
706 |
} |
|
707 |
||
708 |
@Override |
|
709 |
public ResolvedJavaField[] getInstanceFields(boolean includeSuperclasses) { |
|
710 |
if (instanceFields == null) { |
|
711 |
if (isArray() || isInterface()) { |
|
712 |
instanceFields = NO_FIELDS; |
|
713 |
} else { |
|
714 |
HotSpotResolvedJavaField[] prepend = NO_FIELDS; |
|
715 |
if (getSuperclass() != null) { |
|
716 |
prepend = (HotSpotResolvedJavaField[]) getSuperclass().getInstanceFields(true); |
|
717 |
} |
|
718 |
instanceFields = getFields(false, prepend); |
|
719 |
} |
|
720 |
} |
|
721 |
if (!includeSuperclasses && getSuperclass() != null) { |
|
722 |
int superClassFieldCount = getSuperclass().getInstanceFields(true).length; |
|
723 |
if (superClassFieldCount == instanceFields.length) { |
|
724 |
// This class does not have any instance fields of its own. |
|
725 |
return NO_FIELDS; |
|
726 |
} else if (superClassFieldCount != 0) { |
|
727 |
HotSpotResolvedJavaField[] result = new HotSpotResolvedJavaField[instanceFields.length - superClassFieldCount]; |
|
728 |
System.arraycopy(instanceFields, superClassFieldCount, result, 0, result.length); |
|
729 |
return result; |
|
730 |
} else { |
|
731 |
// The super classes of this class do not have any instance fields. |
|
732 |
} |
|
733 |
} |
|
734 |
return instanceFields; |
|
735 |
} |
|
736 |
||
737 |
@Override |
|
738 |
public ResolvedJavaField[] getStaticFields() { |
|
739 |
if (isArray()) { |
|
740 |
return new HotSpotResolvedJavaField[0]; |
|
741 |
} else { |
|
742 |
return getFields(true, NO_FIELDS); |
|
743 |
} |
|
744 |
} |
|
745 |
||
746 |
/** |
|
747 |
* Gets the instance or static fields of this class. |
|
748 |
* |
|
749 |
* @param retrieveStaticFields specifies whether to return instance or static fields |
|
750 |
* @param prepend an array to be prepended to the returned result |
|
751 |
*/ |
|
752 |
private HotSpotResolvedJavaField[] getFields(boolean retrieveStaticFields, HotSpotResolvedJavaField[] prepend) { |
|
753 |
HotSpotVMConfig config = config(); |
|
754 |
final long metaspaceFields = UNSAFE.getAddress(getMetaspaceKlass() + config.instanceKlassFieldsOffset); |
|
755 |
int metaspaceFieldsLength = UNSAFE.getInt(metaspaceFields + config.arrayU1LengthOffset); |
|
756 |
int resultCount = 0; |
|
757 |
int index = 0; |
|
758 |
for (int i = 0; i < metaspaceFieldsLength; i += config.fieldInfoFieldSlots, index++) { |
|
759 |
FieldInfo field = new FieldInfo(index); |
|
760 |
if (field.hasGenericSignature()) { |
|
761 |
metaspaceFieldsLength--; |
|
762 |
} |
|
763 |
||
764 |
if (field.isStatic() == retrieveStaticFields) { |
|
765 |
resultCount++; |
|
766 |
} |
|
767 |
} |
|
768 |
||
769 |
if (resultCount == 0) { |
|
770 |
return prepend; |
|
771 |
} |
|
772 |
||
773 |
int prependLength = prepend.length; |
|
774 |
resultCount += prependLength; |
|
775 |
||
776 |
HotSpotResolvedJavaField[] result = new HotSpotResolvedJavaField[resultCount]; |
|
777 |
if (prependLength != 0) { |
|
778 |
System.arraycopy(prepend, 0, result, 0, prependLength); |
|
779 |
} |
|
780 |
||
781 |
int resultIndex = prependLength; |
|
782 |
for (int i = 0; i < index; ++i) { |
|
783 |
FieldInfo field = new FieldInfo(i); |
|
784 |
if (field.isStatic() == retrieveStaticFields) { |
|
785 |
int offset = field.getOffset(); |
|
786 |
HotSpotResolvedJavaField resolvedJavaField = createField(field.getType(), offset, field.getAccessFlags(), i); |
|
787 |
||
788 |
// Make sure the result is sorted by offset. |
|
789 |
int j; |
|
50858 | 790 |
for (j = resultIndex - 1; j >= prependLength && result[j].getOffset() > offset; j--) { |
43972 | 791 |
result[j + 1] = result[j]; |
792 |
} |
|
793 |
result[j + 1] = resolvedJavaField; |
|
794 |
resultIndex++; |
|
795 |
} |
|
796 |
} |
|
797 |
||
798 |
return result; |
|
799 |
} |
|
800 |
||
801 |
@Override |
|
802 |
public String getSourceFileName() { |
|
803 |
HotSpotVMConfig config = config(); |
|
804 |
final int sourceFileNameIndex = UNSAFE.getChar(getMetaspaceKlass() + config.instanceKlassSourceFileNameIndexOffset); |
|
805 |
if (sourceFileNameIndex == 0) { |
|
806 |
return null; |
|
807 |
} |
|
808 |
return getConstantPool().lookupUtf8(sourceFileNameIndex); |
|
809 |
} |
|
810 |
||
811 |
@Override |
|
812 |
public Annotation[] getAnnotations() { |
|
54669
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
52645
diff
changeset
|
813 |
return runtime().reflection.getAnnotations(this); |
43972 | 814 |
} |
815 |
||
816 |
@Override |
|
817 |
public Annotation[] getDeclaredAnnotations() { |
|
54669
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
52645
diff
changeset
|
818 |
return runtime().reflection.getDeclaredAnnotations(this); |
43972 | 819 |
} |
820 |
||
821 |
@Override |
|
822 |
public <T extends Annotation> T getAnnotation(Class<T> annotationClass) { |
|
54669
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
52645
diff
changeset
|
823 |
return runtime().reflection.getAnnotation(this, annotationClass); |
43972 | 824 |
} |
825 |
||
826 |
/** |
|
827 |
* Performs a fast-path check that this type is resolved in the context of a given accessing |
|
828 |
* class. A negative result does not mean this type is not resolved with respect to |
|
829 |
* {@code accessingClass}. That can only be determined by |
|
830 |
* {@linkplain HotSpotJVMCIRuntime#lookupType(String, HotSpotResolvedObjectType, boolean) |
|
831 |
* re-resolving} the type. |
|
832 |
*/ |
|
50858 | 833 |
@Override |
43972 | 834 |
public boolean isDefinitelyResolvedWithRespectTo(ResolvedJavaType accessingClass) { |
835 |
assert accessingClass != null; |
|
836 |
ResolvedJavaType elementType = getElementalType(); |
|
837 |
if (elementType.isPrimitive()) { |
|
838 |
// Primitive type resolution is context free. |
|
839 |
return true; |
|
840 |
} |
|
841 |
if (elementType.getName().startsWith("Ljava/")) { |
|
842 |
// Classes in a java.* package can only be defined by the |
|
54669
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
52645
diff
changeset
|
843 |
// boot class loader. This is enforced by ClassLoader.preDefineClass() |
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
52645
diff
changeset
|
844 |
assert hasSameClassLoader(runtime().getJavaLangObject()); |
43972 | 845 |
return true; |
846 |
} |
|
54669
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
52645
diff
changeset
|
847 |
HotSpotResolvedObjectTypeImpl otherMirror = ((HotSpotResolvedObjectTypeImpl) accessingClass); |
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
52645
diff
changeset
|
848 |
return hasSameClassLoader(otherMirror); |
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
52645
diff
changeset
|
849 |
} |
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
52645
diff
changeset
|
850 |
|
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
52645
diff
changeset
|
851 |
private boolean hasSameClassLoader(HotSpotResolvedObjectTypeImpl otherMirror) { |
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
52645
diff
changeset
|
852 |
return UnsafeAccess.UNSAFE.getAddress(getMetaspaceKlass() + config().classLoaderDataOffset) == UnsafeAccess.UNSAFE.getAddress( |
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
52645
diff
changeset
|
853 |
otherMirror.getMetaspaceKlass() + config().classLoaderDataOffset); |
43972 | 854 |
} |
855 |
||
856 |
@Override |
|
857 |
public ResolvedJavaType resolve(ResolvedJavaType accessingClass) { |
|
858 |
if (isDefinitelyResolvedWithRespectTo(requireNonNull(accessingClass))) { |
|
859 |
return this; |
|
860 |
} |
|
861 |
HotSpotResolvedObjectTypeImpl accessingType = (HotSpotResolvedObjectTypeImpl) accessingClass; |
|
862 |
return (ResolvedJavaType) runtime().lookupType(getName(), accessingType, true); |
|
863 |
} |
|
864 |
||
865 |
/** |
|
866 |
* Gets the metaspace Klass boxed in a {@link JavaConstant}. |
|
867 |
*/ |
|
50858 | 868 |
@Override |
43972 | 869 |
public Constant klass() { |
870 |
return HotSpotMetaspaceConstantImpl.forMetaspaceObject(this, false); |
|
871 |
} |
|
872 |
||
50858 | 873 |
@Override |
43972 | 874 |
public boolean isPrimaryType() { |
875 |
return config().secondarySuperCacheOffset != superCheckOffset(); |
|
876 |
} |
|
877 |
||
50858 | 878 |
@Override |
43972 | 879 |
public int superCheckOffset() { |
880 |
HotSpotVMConfig config = config(); |
|
881 |
return UNSAFE.getInt(getMetaspaceKlass() + config.superCheckOffsetOffset); |
|
882 |
} |
|
883 |
||
50858 | 884 |
@Override |
43972 | 885 |
public long prototypeMarkWord() { |
886 |
HotSpotVMConfig config = config(); |
|
887 |
if (isArray()) { |
|
888 |
return config.arrayPrototypeMarkWord(); |
|
889 |
} else { |
|
890 |
return UNSAFE.getAddress(getMetaspaceKlass() + config.prototypeMarkWordOffset); |
|
891 |
} |
|
892 |
} |
|
893 |
||
894 |
@Override |
|
895 |
public ResolvedJavaField findInstanceFieldWithOffset(long offset, JavaKind expectedEntryKind) { |
|
896 |
ResolvedJavaField[] declaredFields = getInstanceFields(true); |
|
44517
63b463587198
8177673: [JVMCI] missing checks in HotSpotMemoryAccessProviderImpl can cause VM assertions to fail
dnsimon
parents:
43972
diff
changeset
|
897 |
return findFieldWithOffset(offset, expectedEntryKind, declaredFields); |
63b463587198
8177673: [JVMCI] missing checks in HotSpotMemoryAccessProviderImpl can cause VM assertions to fail
dnsimon
parents:
43972
diff
changeset
|
898 |
} |
63b463587198
8177673: [JVMCI] missing checks in HotSpotMemoryAccessProviderImpl can cause VM assertions to fail
dnsimon
parents:
43972
diff
changeset
|
899 |
|
63b463587198
8177673: [JVMCI] missing checks in HotSpotMemoryAccessProviderImpl can cause VM assertions to fail
dnsimon
parents:
43972
diff
changeset
|
900 |
public ResolvedJavaField findStaticFieldWithOffset(long offset, JavaKind expectedEntryKind) { |
63b463587198
8177673: [JVMCI] missing checks in HotSpotMemoryAccessProviderImpl can cause VM assertions to fail
dnsimon
parents:
43972
diff
changeset
|
901 |
ResolvedJavaField[] declaredFields = getStaticFields(); |
63b463587198
8177673: [JVMCI] missing checks in HotSpotMemoryAccessProviderImpl can cause VM assertions to fail
dnsimon
parents:
43972
diff
changeset
|
902 |
return findFieldWithOffset(offset, expectedEntryKind, declaredFields); |
63b463587198
8177673: [JVMCI] missing checks in HotSpotMemoryAccessProviderImpl can cause VM assertions to fail
dnsimon
parents:
43972
diff
changeset
|
903 |
} |
63b463587198
8177673: [JVMCI] missing checks in HotSpotMemoryAccessProviderImpl can cause VM assertions to fail
dnsimon
parents:
43972
diff
changeset
|
904 |
|
63b463587198
8177673: [JVMCI] missing checks in HotSpotMemoryAccessProviderImpl can cause VM assertions to fail
dnsimon
parents:
43972
diff
changeset
|
905 |
private static ResolvedJavaField findFieldWithOffset(long offset, JavaKind expectedEntryKind, ResolvedJavaField[] declaredFields) { |
43972 | 906 |
for (ResolvedJavaField field : declaredFields) { |
54669
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
52645
diff
changeset
|
907 |
long resolvedFieldOffset = field.getOffset(); |
43972 | 908 |
// @formatter:off |
54669
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
52645
diff
changeset
|
909 |
if (ByteOrder.nativeOrder() == ByteOrder.BIG_ENDIAN && |
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
52645
diff
changeset
|
910 |
expectedEntryKind.isPrimitive() && |
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
52645
diff
changeset
|
911 |
!expectedEntryKind.equals(JavaKind.Void) && |
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
52645
diff
changeset
|
912 |
field.getJavaKind().isPrimitive()) { |
43972 | 913 |
resolvedFieldOffset += |
54669
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
52645
diff
changeset
|
914 |
field.getJavaKind().getByteCount() - |
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
52645
diff
changeset
|
915 |
Math.min(field.getJavaKind().getByteCount(), 4 + expectedEntryKind.getByteCount()); |
43972 | 916 |
} |
917 |
if (resolvedFieldOffset == offset) { |
|
918 |
return field; |
|
919 |
} |
|
920 |
// @formatter:on |
|
921 |
} |
|
922 |
return null; |
|
923 |
} |
|
924 |
||
925 |
@Override |
|
926 |
public boolean isLocal() { |
|
54669
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
52645
diff
changeset
|
927 |
return runtime().reflection.isLocalClass(this); |
43972 | 928 |
} |
929 |
||
930 |
@Override |
|
931 |
public boolean isMember() { |
|
54669
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
52645
diff
changeset
|
932 |
return runtime().reflection.isMemberClass(this); |
43972 | 933 |
} |
934 |
||
935 |
@Override |
|
54669
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
52645
diff
changeset
|
936 |
public HotSpotResolvedObjectType getEnclosingType() { |
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
52645
diff
changeset
|
937 |
return runtime().reflection.getEnclosingClass(this); |
43972 | 938 |
} |
939 |
||
940 |
@Override |
|
941 |
public ResolvedJavaMethod[] getDeclaredConstructors() { |
|
54669
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
52645
diff
changeset
|
942 |
return runtime().compilerToVm.getDeclaredConstructors(this); |
43972 | 943 |
} |
944 |
||
945 |
@Override |
|
946 |
public ResolvedJavaMethod[] getDeclaredMethods() { |
|
54669
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
52645
diff
changeset
|
947 |
return runtime().compilerToVm.getDeclaredMethods(this); |
43972 | 948 |
} |
949 |
||
50858 | 950 |
@Override |
43972 | 951 |
public ResolvedJavaMethod getClassInitializer() { |
48480
614068b0ddd7
8193930: [JVMCI] calling ResolvedTypeType.getClassInitializer on an array type crashes
dnsimon
parents:
47781
diff
changeset
|
952 |
if (!isArray()) { |
614068b0ddd7
8193930: [JVMCI] calling ResolvedTypeType.getClassInitializer on an array type crashes
dnsimon
parents:
47781
diff
changeset
|
953 |
return compilerToVM().getClassInitializer(this); |
614068b0ddd7
8193930: [JVMCI] calling ResolvedTypeType.getClassInitializer on an array type crashes
dnsimon
parents:
47781
diff
changeset
|
954 |
} |
614068b0ddd7
8193930: [JVMCI] calling ResolvedTypeType.getClassInitializer on an array type crashes
dnsimon
parents:
47781
diff
changeset
|
955 |
return null; |
43972 | 956 |
} |
957 |
||
958 |
@Override |
|
959 |
public String toString() { |
|
960 |
return "HotSpotType<" + getName() + ", resolved>"; |
|
961 |
} |
|
962 |
||
963 |
@Override |
|
50858 | 964 |
public ResolvedJavaType lookupType(UnresolvedJavaType unresolvedJavaType, boolean resolve) { |
965 |
JavaType javaType = HotSpotJVMCIRuntime.runtime().lookupType(unresolvedJavaType.getName(), this, resolve); |
|
966 |
if (javaType instanceof ResolvedJavaType) { |
|
967 |
return (ResolvedJavaType) javaType; |
|
968 |
} |
|
969 |
return null; |
|
970 |
} |
|
971 |
||
972 |
@Override |
|
973 |
public ResolvedJavaField resolveField(UnresolvedJavaField unresolvedJavaField, ResolvedJavaType accessingClass) { |
|
974 |
for (ResolvedJavaField field : getInstanceFields(false)) { |
|
975 |
if (field.getName().equals(unresolvedJavaField.getName())) { |
|
976 |
return field; |
|
977 |
} |
|
978 |
} |
|
979 |
for (ResolvedJavaField field : getStaticFields()) { |
|
980 |
if (field.getName().equals(unresolvedJavaField.getName())) { |
|
981 |
return field; |
|
982 |
} |
|
983 |
} |
|
984 |
throw new InternalError(unresolvedJavaField.toString()); |
|
985 |
} |
|
986 |
||
987 |
@Override |
|
43972 | 988 |
public boolean isCloneableWithAllocation() { |
989 |
return (getAccessFlags() & config().jvmAccIsCloneableFast) != 0; |
|
990 |
} |
|
47668 | 991 |
|
54669
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
52645
diff
changeset
|
992 |
JavaConstant readFieldValue(HotSpotResolvedJavaField field, boolean isVolatile) { |
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
52645
diff
changeset
|
993 |
return runtime().reflection.readFieldValue(this, field, isVolatile); |
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
52645
diff
changeset
|
994 |
} |
ad45b3802d4e
8220623: [JVMCI] Update JVMCI to support JVMCI based Compiler compiled into shared library
kvn
parents:
52645
diff
changeset
|
995 |
|
47668 | 996 |
private int getMiscFlags() { |
997 |
return UNSAFE.getInt(getMetaspaceKlass() + config().instanceKlassMiscFlagsOffset); |
|
998 |
} |
|
999 |
||
51420
6bb7b8d0da76
8209535: [JVMCI] Do not swallow NoClassDefFoundError when converting JVMCI methods and fields to reflection objects
dnsimon
parents:
50858
diff
changeset
|
1000 |
@Override |
51444
3e5d28e6de32
8209301: JVM rename is_anonymous, host_klass to unsafe specific terminology ahead of Unsafe.defineAnonymousClass deprecation
lfoltan
parents:
51420
diff
changeset
|
1001 |
public boolean isUnsafeAnonymous() { |
3e5d28e6de32
8209301: JVM rename is_anonymous, host_klass to unsafe specific terminology ahead of Unsafe.defineAnonymousClass deprecation
lfoltan
parents:
51420
diff
changeset
|
1002 |
return (getMiscFlags() & config().instanceKlassMiscIsUnsafeAnonymous) != 0; |
47668 | 1003 |
} |
1004 |
||
43972 | 1005 |
} |