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