author | dnsimon |
Fri, 22 Dec 2017 18:34:36 +0100 | |
changeset 48480 | 614068b0ddd7 |
parent 47793 | 3dcd54513db1 |
child 48826 | c4d9d1b08e2e |
permissions | -rw-r--r-- |
43972 | 1 |
/* |
47668 | 2 |
* Copyright (c) 2011, 2017, 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 |
||
24 |
package jdk.vm.ci.hotspot; |
|
25 |
||
26 |
import static jdk.vm.ci.common.InitTimer.timer; |
|
27 |
import static jdk.vm.ci.hotspot.HotSpotJVMCIRuntime.runtime; |
|
28 |
||
29 |
import java.lang.reflect.Executable; |
|
30 |
||
31 |
import jdk.vm.ci.code.BytecodeFrame; |
|
32 |
import jdk.vm.ci.code.InstalledCode; |
|
33 |
import jdk.vm.ci.code.InvalidInstalledCodeException; |
|
34 |
import jdk.vm.ci.code.TargetDescription; |
|
35 |
import jdk.vm.ci.common.InitTimer; |
|
36 |
import jdk.vm.ci.common.JVMCIError; |
|
37 |
import jdk.vm.ci.meta.JavaType; |
|
38 |
import jdk.vm.ci.meta.ResolvedJavaMethod; |
|
39 |
import jdk.vm.ci.meta.ResolvedJavaType; |
|
40 |
||
41 |
/** |
|
42 |
* Calls from Java into HotSpot. The behavior of all the methods in this class that take a native |
|
43 |
* pointer as an argument (e.g., {@link #getSymbol(long)}) is undefined if the argument does not |
|
44 |
* denote a valid native object. |
|
45 |
*/ |
|
46 |
final class CompilerToVM { |
|
47 |
/** |
|
48 |
* Initializes the native part of the JVMCI runtime. |
|
49 |
*/ |
|
50 |
private static native void registerNatives(); |
|
51 |
||
52 |
static { |
|
53 |
initialize(); |
|
54 |
} |
|
55 |
||
56 |
@SuppressWarnings("try") |
|
57 |
private static void initialize() { |
|
58 |
try (InitTimer t = timer("CompilerToVM.registerNatives")) { |
|
59 |
registerNatives(); |
|
60 |
} |
|
61 |
} |
|
62 |
||
63 |
/** |
|
64 |
* Gets the {@link CompilerToVM} instance associated with the singleton |
|
65 |
* {@link HotSpotJVMCIRuntime} instance. |
|
66 |
*/ |
|
67 |
public static CompilerToVM compilerToVM() { |
|
68 |
return runtime().getCompilerToVM(); |
|
69 |
} |
|
70 |
||
71 |
/** |
|
72 |
* Copies the original bytecode of {@code method} into a new byte array and returns it. |
|
73 |
* |
|
74 |
* @return a new byte array containing the original bytecode of {@code method} |
|
75 |
*/ |
|
76 |
native byte[] getBytecode(HotSpotResolvedJavaMethodImpl method); |
|
77 |
||
78 |
/** |
|
79 |
* Gets the number of entries in {@code method}'s exception handler table or 0 if it has no |
|
80 |
* exception handler table. |
|
81 |
*/ |
|
82 |
native int getExceptionTableLength(HotSpotResolvedJavaMethodImpl method); |
|
83 |
||
84 |
/** |
|
85 |
* Gets the address of the first entry in {@code method}'s exception handler table. |
|
86 |
* |
|
87 |
* Each entry is a native object described by these fields: |
|
88 |
* |
|
89 |
* <ul> |
|
90 |
* <li>{@link HotSpotVMConfig#exceptionTableElementSize}</li> |
|
91 |
* <li>{@link HotSpotVMConfig#exceptionTableElementStartPcOffset}</li> |
|
92 |
* <li>{@link HotSpotVMConfig#exceptionTableElementEndPcOffset}</li> |
|
93 |
* <li>{@link HotSpotVMConfig#exceptionTableElementHandlerPcOffset}</li> |
|
94 |
* <li>{@link HotSpotVMConfig#exceptionTableElementCatchTypeIndexOffset} |
|
95 |
* </ul> |
|
96 |
* |
|
97 |
* @return 0 if {@code method} has no exception handlers (i.e. |
|
98 |
* {@code getExceptionTableLength(method) == 0}) |
|
99 |
*/ |
|
100 |
native long getExceptionTableStart(HotSpotResolvedJavaMethodImpl method); |
|
101 |
||
102 |
/** |
|
103 |
* Determines whether {@code method} is currently compilable by the JVMCI compiler being used by |
|
104 |
* the VM. This can return false if JVMCI compilation failed earlier for {@code method}, a |
|
105 |
* breakpoint is currently set in {@code method} or {@code method} contains other bytecode |
|
106 |
* features that require special handling by the VM. |
|
107 |
*/ |
|
108 |
native boolean isCompilable(HotSpotResolvedJavaMethodImpl method); |
|
109 |
||
110 |
/** |
|
111 |
* Determines if {@code method} is targeted by a VM directive (e.g., |
|
112 |
* {@code -XX:CompileCommand=dontinline,<pattern>}) or annotation (e.g., |
|
113 |
* {@code jdk.internal.vm.annotation.DontInline}) that specifies it should not be inlined. |
|
114 |
*/ |
|
115 |
native boolean hasNeverInlineDirective(HotSpotResolvedJavaMethodImpl method); |
|
116 |
||
117 |
/** |
|
118 |
* Determines if {@code method} should be inlined at any cost. This could be because: |
|
119 |
* <ul> |
|
120 |
* <li>a CompileOracle directive may forces inlining of this methods</li> |
|
121 |
* <li>an annotation forces inlining of this method</li> |
|
122 |
* </ul> |
|
123 |
*/ |
|
124 |
native boolean shouldInlineMethod(HotSpotResolvedJavaMethodImpl method); |
|
125 |
||
126 |
/** |
|
127 |
* Used to implement {@link ResolvedJavaType#findUniqueConcreteMethod(ResolvedJavaMethod)}. |
|
128 |
* |
|
129 |
* @param method the method on which to base the search |
|
130 |
* @param actualHolderType the best known type of receiver |
|
131 |
* @return the method result or 0 is there is no unique concrete method for {@code method} |
|
132 |
*/ |
|
133 |
native HotSpotResolvedJavaMethodImpl findUniqueConcreteMethod(HotSpotResolvedObjectTypeImpl actualHolderType, HotSpotResolvedJavaMethodImpl method); |
|
134 |
||
135 |
/** |
|
136 |
* Gets the implementor for the interface class {@code type}. |
|
137 |
* |
|
48480
614068b0ddd7
8193930: [JVMCI] calling ResolvedTypeType.getClassInitializer on an array type crashes
dnsimon
parents:
47793
diff
changeset
|
138 |
* @return the implementor if there is a single implementor, {@code null} if there is no |
614068b0ddd7
8193930: [JVMCI] calling ResolvedTypeType.getClassInitializer on an array type crashes
dnsimon
parents:
47793
diff
changeset
|
139 |
* implementor, or {@code type} itself if there is more than one implementor |
614068b0ddd7
8193930: [JVMCI] calling ResolvedTypeType.getClassInitializer on an array type crashes
dnsimon
parents:
47793
diff
changeset
|
140 |
* @throws IllegalArgumentException if type is not an interface type |
43972 | 141 |
*/ |
142 |
native HotSpotResolvedObjectTypeImpl getImplementor(HotSpotResolvedObjectTypeImpl type); |
|
143 |
||
144 |
/** |
|
145 |
* Determines if {@code method} is ignored by security stack walks. |
|
146 |
*/ |
|
147 |
native boolean methodIsIgnoredBySecurityStackWalk(HotSpotResolvedJavaMethodImpl method); |
|
148 |
||
149 |
/** |
|
150 |
* Converts a name to a type. |
|
151 |
* |
|
152 |
* @param name a well formed Java type in {@linkplain JavaType#getName() internal} format |
|
153 |
* @param accessingClass the context of resolution (must not be null) |
|
154 |
* @param resolve force resolution to a {@link ResolvedJavaType}. If true, this method will |
|
155 |
* either return a {@link ResolvedJavaType} or throw an exception |
|
156 |
* @return the type for {@code name} or 0 if resolution failed and {@code resolve == false} |
|
46972
3e88de95fccf
8186459: [JVMCI] ClassNotFoundException thrown by CompilerToVM.lookupType() should be converted to a LinkageError
dnsimon
parents:
46632
diff
changeset
|
157 |
* @throws ClassNotFoundException if {@code resolve == true} and the resolution failed |
43972 | 158 |
*/ |
46972
3e88de95fccf
8186459: [JVMCI] ClassNotFoundException thrown by CompilerToVM.lookupType() should be converted to a LinkageError
dnsimon
parents:
46632
diff
changeset
|
159 |
native HotSpotResolvedObjectTypeImpl lookupType(String name, Class<?> accessingClass, boolean resolve) throws ClassNotFoundException; |
43972 | 160 |
|
161 |
/** |
|
162 |
* Resolves the entry at index {@code cpi} in {@code constantPool} to an object. |
|
163 |
* |
|
164 |
* The behavior of this method is undefined if {@code cpi} does not denote one of the following |
|
165 |
* entry types: {@code JVM_CONSTANT_MethodHandle}, {@code JVM_CONSTANT_MethodHandleInError}, |
|
166 |
* {@code JVM_CONSTANT_MethodType} and {@code JVM_CONSTANT_MethodTypeInError}. |
|
167 |
*/ |
|
168 |
native Object resolveConstantInPool(HotSpotConstantPool constantPool, int cpi); |
|
169 |
||
170 |
/** |
|
171 |
* Resolves the entry at index {@code cpi} in {@code constantPool} to an object, looking in the |
|
172 |
* constant pool cache first. |
|
173 |
* |
|
174 |
* The behavior of this method is undefined if {@code cpi} does not denote a |
|
175 |
* {@code JVM_CONSTANT_String} entry. |
|
176 |
*/ |
|
177 |
native Object resolvePossiblyCachedConstantInPool(HotSpotConstantPool constantPool, int cpi); |
|
178 |
||
179 |
/** |
|
180 |
* Gets the {@code JVM_CONSTANT_NameAndType} index from the entry at index {@code cpi} in |
|
181 |
* {@code constantPool}. |
|
182 |
* |
|
183 |
* The behavior of this method is undefined if {@code cpi} does not denote an entry containing a |
|
184 |
* {@code JVM_CONSTANT_NameAndType} index. |
|
185 |
*/ |
|
186 |
native int lookupNameAndTypeRefIndexInPool(HotSpotConstantPool constantPool, int cpi); |
|
187 |
||
188 |
/** |
|
189 |
* Gets the name of the {@code JVM_CONSTANT_NameAndType} entry referenced by another entry |
|
190 |
* denoted by {@code which} in {@code constantPool}. |
|
191 |
* |
|
192 |
* The behavior of this method is undefined if {@code which} does not denote a entry that |
|
193 |
* references a {@code JVM_CONSTANT_NameAndType} entry. |
|
194 |
*/ |
|
195 |
native String lookupNameInPool(HotSpotConstantPool constantPool, int which); |
|
196 |
||
197 |
/** |
|
198 |
* Gets the signature of the {@code JVM_CONSTANT_NameAndType} entry referenced by another entry |
|
199 |
* denoted by {@code which} in {@code constantPool}. |
|
200 |
* |
|
201 |
* The behavior of this method is undefined if {@code which} does not denote a entry that |
|
202 |
* references a {@code JVM_CONSTANT_NameAndType} entry. |
|
203 |
*/ |
|
204 |
native String lookupSignatureInPool(HotSpotConstantPool constantPool, int which); |
|
205 |
||
206 |
/** |
|
207 |
* Gets the {@code JVM_CONSTANT_Class} index from the entry at index {@code cpi} in |
|
208 |
* {@code constantPool}. |
|
209 |
* |
|
210 |
* The behavior of this method is undefined if {@code cpi} does not denote an entry containing a |
|
211 |
* {@code JVM_CONSTANT_Class} index. |
|
212 |
*/ |
|
213 |
native int lookupKlassRefIndexInPool(HotSpotConstantPool constantPool, int cpi); |
|
214 |
||
215 |
/** |
|
216 |
* Looks up a class denoted by the {@code JVM_CONSTANT_Class} entry at index {@code cpi} in |
|
217 |
* {@code constantPool}. This method does not perform any resolution. |
|
218 |
* |
|
219 |
* The behavior of this method is undefined if {@code cpi} does not denote a |
|
220 |
* {@code JVM_CONSTANT_Class} entry. |
|
221 |
* |
|
222 |
* @return the resolved class entry or a String otherwise |
|
223 |
*/ |
|
224 |
native Object lookupKlassInPool(HotSpotConstantPool constantPool, int cpi); |
|
225 |
||
226 |
/** |
|
227 |
* Looks up a method denoted by the entry at index {@code cpi} in {@code constantPool}. This |
|
228 |
* method does not perform any resolution. |
|
229 |
* |
|
230 |
* The behavior of this method is undefined if {@code cpi} does not denote an entry representing |
|
231 |
* a method. |
|
232 |
* |
|
233 |
* @param opcode the opcode of the instruction for which the lookup is being performed or |
|
234 |
* {@code -1}. If non-negative, then resolution checks specific to the bytecode it |
|
235 |
* denotes are performed if the method is already resolved. Should any of these |
|
236 |
* checks fail, 0 is returned. |
|
237 |
* @return the resolved method entry, 0 otherwise |
|
238 |
*/ |
|
239 |
native HotSpotResolvedJavaMethodImpl lookupMethodInPool(HotSpotConstantPool constantPool, int cpi, byte opcode); |
|
240 |
||
241 |
/** |
|
242 |
* Ensures that the type referenced by the specified {@code JVM_CONSTANT_InvokeDynamic} entry at |
|
243 |
* index {@code cpi} in {@code constantPool} is loaded and initialized. |
|
244 |
* |
|
245 |
* The behavior of this method is undefined if {@code cpi} does not denote a |
|
246 |
* {@code JVM_CONSTANT_InvokeDynamic} entry. |
|
247 |
*/ |
|
248 |
native void resolveInvokeDynamicInPool(HotSpotConstantPool constantPool, int cpi); |
|
249 |
||
250 |
/** |
|
251 |
* If {@code cpi} denotes an entry representing a |
|
252 |
* <a href="https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-2.html#jvms-2.9">signature |
|
253 |
* polymorphic</a> method, this method ensures that the type referenced by the entry is loaded |
|
254 |
* and initialized. It {@code cpi} does not denote a signature polymorphic method, this method |
|
255 |
* does nothing. |
|
256 |
*/ |
|
257 |
native void resolveInvokeHandleInPool(HotSpotConstantPool constantPool, int cpi); |
|
258 |
||
259 |
/** |
|
48480
614068b0ddd7
8193930: [JVMCI] calling ResolvedTypeType.getClassInitializer on an array type crashes
dnsimon
parents:
47793
diff
changeset
|
260 |
* If {@code cpi} denotes an entry representing a resolved dynamic adapter (see |
614068b0ddd7
8193930: [JVMCI] calling ResolvedTypeType.getClassInitializer on an array type crashes
dnsimon
parents:
47793
diff
changeset
|
261 |
* {@code resolveInvokeDynamicInPool} and {@code resolveInvokeHandleInPool}), return the opcode |
614068b0ddd7
8193930: [JVMCI] calling ResolvedTypeType.getClassInitializer on an array type crashes
dnsimon
parents:
47793
diff
changeset
|
262 |
* of the instruction for which the resolution was performed ({@code invokedynamic} or |
614068b0ddd7
8193930: [JVMCI] calling ResolvedTypeType.getClassInitializer on an array type crashes
dnsimon
parents:
47793
diff
changeset
|
263 |
* {@code invokevirtual}}, or {@code -1} otherwise. |
47668 | 264 |
*/ |
265 |
native int isResolvedInvokeHandleInPool(HotSpotConstantPool constantPool, int cpi); |
|
266 |
||
267 |
/** |
|
43972 | 268 |
* Gets the list of type names (in the format of {@link JavaType#getName()}) denoting the |
269 |
* classes that define signature polymorphic methods. |
|
270 |
*/ |
|
271 |
native String[] getSignaturePolymorphicHolders(); |
|
272 |
||
273 |
/** |
|
274 |
* Gets the resolved type denoted by the entry at index {@code cpi} in {@code constantPool}. |
|
275 |
* |
|
276 |
* The behavior of this method is undefined if {@code cpi} does not denote an entry representing |
|
277 |
* a class. |
|
278 |
* |
|
279 |
* @throws LinkageError if resolution failed |
|
280 |
*/ |
|
281 |
native HotSpotResolvedObjectTypeImpl resolveTypeInPool(HotSpotConstantPool constantPool, int cpi) throws LinkageError; |
|
282 |
||
283 |
/** |
|
284 |
* Looks up and attempts to resolve the {@code JVM_CONSTANT_Field} entry for at index |
|
285 |
* {@code cpi} in {@code constantPool}. For some opcodes, checks are performed that require the |
|
286 |
* {@code method} that contains {@code opcode} to be specified. The values returned in |
|
287 |
* {@code info} are: |
|
288 |
* |
|
289 |
* <pre> |
|
290 |
* [ flags, // fieldDescriptor::access_flags() |
|
291 |
* offset, // fieldDescriptor::offset() |
|
292 |
* index // fieldDescriptor::index() |
|
293 |
* ] |
|
294 |
* </pre> |
|
295 |
* |
|
296 |
* The behavior of this method is undefined if {@code cpi} does not denote a |
|
297 |
* {@code JVM_CONSTANT_Field} entry. |
|
298 |
* |
|
299 |
* @param info an array in which the details of the field are returned |
|
300 |
* @return the type defining the field if resolution is successful, 0 otherwise |
|
301 |
*/ |
|
302 |
native HotSpotResolvedObjectTypeImpl resolveFieldInPool(HotSpotConstantPool constantPool, int cpi, HotSpotResolvedJavaMethodImpl method, byte opcode, int[] info); |
|
303 |
||
304 |
/** |
|
305 |
* Converts {@code cpci} from an index into the cache for {@code constantPool} to an index |
|
306 |
* directly into {@code constantPool}. |
|
307 |
* |
|
308 |
* The behavior of this method is undefined if {@code ccpi} is an invalid constant pool cache |
|
309 |
* index. |
|
310 |
*/ |
|
311 |
native int constantPoolRemapInstructionOperandFromCache(HotSpotConstantPool constantPool, int cpci); |
|
312 |
||
313 |
/** |
|
314 |
* Gets the appendix object (if any) associated with the entry at index {@code cpi} in |
|
315 |
* {@code constantPool}. |
|
316 |
*/ |
|
317 |
native Object lookupAppendixInPool(HotSpotConstantPool constantPool, int cpi); |
|
318 |
||
319 |
/** |
|
320 |
* Installs the result of a compilation into the code cache. |
|
321 |
* |
|
322 |
* @param target the target where this code should be installed |
|
323 |
* @param compiledCode the result of a compilation |
|
324 |
* @param code the details of the installed CodeBlob are written to this object |
|
325 |
* @return the outcome of the installation which will be one of |
|
326 |
* {@link HotSpotVMConfig#codeInstallResultOk}, |
|
327 |
* {@link HotSpotVMConfig#codeInstallResultCacheFull}, |
|
328 |
* {@link HotSpotVMConfig#codeInstallResultCodeTooLarge}, |
|
329 |
* {@link HotSpotVMConfig#codeInstallResultDependenciesFailed} or |
|
330 |
* {@link HotSpotVMConfig#codeInstallResultDependenciesInvalid}. |
|
331 |
* @throws JVMCIError if there is something wrong with the compiled code or the associated |
|
332 |
* metadata. |
|
333 |
*/ |
|
334 |
native int installCode(TargetDescription target, HotSpotCompiledCode compiledCode, InstalledCode code, HotSpotSpeculationLog speculationLog); |
|
335 |
||
336 |
/** |
|
337 |
* Generates the VM metadata for some compiled code and copies them into {@code metaData}. This |
|
338 |
* method does not install anything into the code cache. |
|
339 |
* |
|
340 |
* @param target the target where this code would be installed |
|
341 |
* @param compiledCode the result of a compilation |
|
342 |
* @param metaData the metadata is written to this object |
|
343 |
* @return the outcome of the installation which will be one of |
|
344 |
* {@link HotSpotVMConfig#codeInstallResultOk}, |
|
345 |
* {@link HotSpotVMConfig#codeInstallResultCacheFull}, |
|
346 |
* {@link HotSpotVMConfig#codeInstallResultCodeTooLarge}, |
|
347 |
* {@link HotSpotVMConfig#codeInstallResultDependenciesFailed} or |
|
348 |
* {@link HotSpotVMConfig#codeInstallResultDependenciesInvalid}. |
|
349 |
* @throws JVMCIError if there is something wrong with the compiled code or the metadata |
|
350 |
*/ |
|
351 |
native int getMetadata(TargetDescription target, HotSpotCompiledCode compiledCode, HotSpotMetaData metaData); |
|
352 |
||
353 |
/** |
|
354 |
* Resets all compilation statistics. |
|
355 |
*/ |
|
356 |
native void resetCompilationStatistics(); |
|
357 |
||
358 |
/** |
|
359 |
* Reads the database of VM info. The return value encodes the info in a nested object array |
|
360 |
* that is described by the pseudo Java object {@code info} below: |
|
361 |
* |
|
362 |
* <pre> |
|
363 |
* info = [ |
|
364 |
* VMField[] vmFields, |
|
365 |
* [String name, Long size, ...] vmTypeSizes, |
|
366 |
* [String name, Long value, ...] vmConstants, |
|
367 |
* [String name, Long value, ...] vmAddresses, |
|
368 |
* VMFlag[] vmFlags |
|
369 |
* VMIntrinsicMethod[] vmIntrinsics |
|
370 |
* ] |
|
371 |
* </pre> |
|
372 |
* |
|
373 |
* @return VM info as encoded above |
|
374 |
*/ |
|
375 |
native Object[] readConfiguration(); |
|
376 |
||
377 |
/** |
|
378 |
* Resolves the implementation of {@code method} for virtual dispatches on objects of dynamic |
|
379 |
* type {@code exactReceiver}. This resolution process only searches "up" the class hierarchy of |
|
380 |
* {@code exactReceiver}. |
|
381 |
* |
|
382 |
* @param caller the caller or context type used to perform access checks |
|
383 |
* @return the link-time resolved method (might be abstract) or {@code null} if it is either a |
|
384 |
* signature polymorphic method or can not be linked. |
|
385 |
*/ |
|
386 |
native HotSpotResolvedJavaMethodImpl resolveMethod(HotSpotResolvedObjectTypeImpl exactReceiver, HotSpotResolvedJavaMethodImpl method, HotSpotResolvedObjectTypeImpl caller); |
|
387 |
||
388 |
/** |
|
389 |
* Gets the static initializer of {@code type}. |
|
390 |
* |
|
48480
614068b0ddd7
8193930: [JVMCI] calling ResolvedTypeType.getClassInitializer on an array type crashes
dnsimon
parents:
47793
diff
changeset
|
391 |
* @return {@code null} if {@code type} has no static initializer |
43972 | 392 |
*/ |
393 |
native HotSpotResolvedJavaMethodImpl getClassInitializer(HotSpotResolvedObjectTypeImpl type); |
|
394 |
||
395 |
/** |
|
396 |
* Determines if {@code type} or any of its currently loaded subclasses overrides |
|
397 |
* {@code Object.finalize()}. |
|
398 |
*/ |
|
399 |
native boolean hasFinalizableSubclass(HotSpotResolvedObjectTypeImpl type); |
|
400 |
||
401 |
/** |
|
402 |
* Gets the method corresponding to {@code executable}. |
|
403 |
*/ |
|
404 |
native HotSpotResolvedJavaMethodImpl asResolvedJavaMethod(Executable executable); |
|
405 |
||
406 |
/** |
|
407 |
* Gets the maximum absolute offset of a PC relative call to {@code address} from any position |
|
408 |
* in the code cache. |
|
409 |
* |
|
410 |
* @param address an address that may be called from any code in the code cache |
|
411 |
* @return -1 if {@code address == 0} |
|
412 |
*/ |
|
413 |
native long getMaxCallTargetOffset(long address); |
|
414 |
||
415 |
/** |
|
416 |
* Gets a textual disassembly of {@code codeBlob}. |
|
417 |
* |
|
418 |
* @return a non-zero length string containing a disassembly of {@code codeBlob} or null if |
|
419 |
* {@code codeBlob} could not be disassembled for some reason |
|
420 |
*/ |
|
421 |
// The HotSpot disassembler seems not to be thread safe so it's better to synchronize its usage |
|
422 |
synchronized native String disassembleCodeBlob(InstalledCode installedCode); |
|
423 |
||
424 |
/** |
|
425 |
* Gets a stack trace element for {@code method} at bytecode index {@code bci}. |
|
426 |
*/ |
|
427 |
native StackTraceElement getStackTraceElement(HotSpotResolvedJavaMethodImpl method, int bci); |
|
428 |
||
429 |
/** |
|
430 |
* Executes some {@code installedCode} with arguments {@code args}. |
|
431 |
* |
|
432 |
* @return the result of executing {@code installedCode} |
|
433 |
* @throws InvalidInstalledCodeException if {@code installedCode} has been invalidated |
|
434 |
*/ |
|
435 |
native Object executeInstalledCode(Object[] args, InstalledCode installedCode) throws InvalidInstalledCodeException; |
|
436 |
||
437 |
/** |
|
438 |
* Gets the line number table for {@code method}. The line number table is encoded as (bci, |
|
439 |
* source line number) pairs. |
|
440 |
* |
|
441 |
* @return the line number table for {@code method} or null if it doesn't have one |
|
442 |
*/ |
|
443 |
native long[] getLineNumberTable(HotSpotResolvedJavaMethodImpl method); |
|
444 |
||
445 |
/** |
|
446 |
* Gets the number of entries in the local variable table for {@code method}. |
|
447 |
* |
|
448 |
* @return the number of entries in the local variable table for {@code method} |
|
449 |
*/ |
|
450 |
native int getLocalVariableTableLength(HotSpotResolvedJavaMethodImpl method); |
|
451 |
||
452 |
/** |
|
453 |
* Gets the address of the first entry in the local variable table for {@code method}. |
|
454 |
* |
|
455 |
* Each entry is a native object described by these fields: |
|
456 |
* |
|
457 |
* <ul> |
|
458 |
* <li>{@link HotSpotVMConfig#localVariableTableElementSize}</li> |
|
459 |
* <li>{@link HotSpotVMConfig#localVariableTableElementLengthOffset}</li> |
|
460 |
* <li>{@link HotSpotVMConfig#localVariableTableElementNameCpIndexOffset}</li> |
|
461 |
* <li>{@link HotSpotVMConfig#localVariableTableElementDescriptorCpIndexOffset}</li> |
|
462 |
* <li>{@link HotSpotVMConfig#localVariableTableElementSlotOffset} |
|
463 |
* <li>{@link HotSpotVMConfig#localVariableTableElementStartBciOffset} |
|
464 |
* </ul> |
|
465 |
* |
|
466 |
* @return 0 if {@code method} does not have a local variable table |
|
467 |
*/ |
|
468 |
native long getLocalVariableTableStart(HotSpotResolvedJavaMethodImpl method); |
|
469 |
||
470 |
/** |
|
48480
614068b0ddd7
8193930: [JVMCI] calling ResolvedTypeType.getClassInitializer on an array type crashes
dnsimon
parents:
47793
diff
changeset
|
471 |
* Sets flags on {@code method} indicating that it should never be inlined or compiled by the |
614068b0ddd7
8193930: [JVMCI] calling ResolvedTypeType.getClassInitializer on an array type crashes
dnsimon
parents:
47793
diff
changeset
|
472 |
* VM. |
43972 | 473 |
*/ |
47793
3dcd54513db1
8186478: [JVMCI] rename HotSpotResolvedJavaMethod#setNotInlineableOrCompileable
dnsimon
parents:
47668
diff
changeset
|
474 |
native void setNotInlinableOrCompilable(HotSpotResolvedJavaMethodImpl method); |
43972 | 475 |
|
476 |
/** |
|
477 |
* Invalidates the profiling information for {@code method} and (re)initializes it such that |
|
478 |
* profiling restarts upon its next invocation. |
|
479 |
*/ |
|
480 |
native void reprofile(HotSpotResolvedJavaMethodImpl method); |
|
481 |
||
482 |
/** |
|
483 |
* Invalidates {@code installedCode} such that {@link InvalidInstalledCodeException} will be |
|
484 |
* raised the next time {@code installedCode} is executed. |
|
485 |
*/ |
|
486 |
native void invalidateInstalledCode(InstalledCode installedCode); |
|
487 |
||
488 |
/** |
|
489 |
* Collects the current values of all JVMCI benchmark counters, summed up over all threads. |
|
490 |
*/ |
|
491 |
native long[] collectCounters(); |
|
492 |
||
493 |
/** |
|
494 |
* Determines if {@code metaspaceMethodData} is mature. |
|
495 |
*/ |
|
496 |
native boolean isMature(long metaspaceMethodData); |
|
497 |
||
498 |
/** |
|
499 |
* Generate a unique id to identify the result of the compile. |
|
500 |
*/ |
|
501 |
native int allocateCompileId(HotSpotResolvedJavaMethodImpl method, int entryBCI); |
|
502 |
||
503 |
/** |
|
504 |
* Determines if {@code method} has OSR compiled code identified by {@code entryBCI} for |
|
505 |
* compilation level {@code level}. |
|
506 |
*/ |
|
507 |
native boolean hasCompiledCodeForOSR(HotSpotResolvedJavaMethodImpl method, int entryBCI, int level); |
|
508 |
||
509 |
/** |
|
510 |
* Gets the value of {@code metaspaceSymbol} as a String. |
|
511 |
*/ |
|
512 |
native String getSymbol(long metaspaceSymbol); |
|
513 |
||
514 |
/** |
|
515 |
* Looks for the next Java stack frame matching an entry in {@code methods}. |
|
516 |
* |
|
517 |
* @param frame the starting point of the search, where {@code null} refers to the topmost frame |
|
518 |
* @param methods the methods to look for, where {@code null} means that any frame is returned |
|
519 |
* @return the frame, or {@code null} if the end of the stack was reached during the search |
|
520 |
*/ |
|
521 |
native HotSpotStackFrameReference getNextStackFrame(HotSpotStackFrameReference frame, ResolvedJavaMethod[] methods, int initialSkip); |
|
522 |
||
523 |
/** |
|
524 |
* Materializes all virtual objects within {@code stackFrame} and updates its locals. |
|
525 |
* |
|
526 |
* @param invalidate if {@code true}, the compiled method for the stack frame will be |
|
527 |
* invalidated |
|
528 |
*/ |
|
529 |
native void materializeVirtualObjects(HotSpotStackFrameReference stackFrame, boolean invalidate); |
|
530 |
||
531 |
/** |
|
532 |
* Gets the v-table index for interface method {@code method} in the receiver {@code type} or |
|
533 |
* {@link HotSpotVMConfig#invalidVtableIndex} if {@code method} is not in {@code type}'s |
|
534 |
* v-table. |
|
535 |
* |
|
536 |
* @throws InternalError if {@code type} is an interface or {@code method} is not held by an |
|
537 |
* interface or class represented by {@code type} is not initialized |
|
538 |
*/ |
|
539 |
native int getVtableIndexForInterfaceMethod(HotSpotResolvedObjectTypeImpl type, HotSpotResolvedJavaMethodImpl method); |
|
540 |
||
541 |
/** |
|
542 |
* Determines if debug info should also be emitted at non-safepoint locations. |
|
543 |
*/ |
|
544 |
native boolean shouldDebugNonSafepoints(); |
|
545 |
||
546 |
/** |
|
547 |
* Writes {@code length} bytes from {@code bytes} starting at offset {@code offset} to the |
|
548 |
* HotSpot's log stream. |
|
549 |
* |
|
550 |
* @exception NullPointerException if {@code bytes == null} |
|
551 |
* @exception IndexOutOfBoundsException if copying would cause access of data outside array |
|
552 |
* bounds |
|
553 |
*/ |
|
554 |
native void writeDebugOutput(byte[] bytes, int offset, int length); |
|
555 |
||
556 |
/** |
|
557 |
* Flush HotSpot's log stream. |
|
558 |
*/ |
|
559 |
native void flushDebugOutput(); |
|
560 |
||
561 |
/** |
|
562 |
* Read a HotSpot Method* value from the memory location described by {@code base} plus |
|
563 |
* {@code displacement} and return the {@link HotSpotResolvedJavaMethodImpl} wrapping it. This |
|
564 |
* method does no checking that the memory location actually contains a valid pointer and may |
|
565 |
* crash the VM if an invalid location is provided. If the {@code base} is null then |
|
566 |
* {@code displacement} is used by itself. If {@code base} is a |
|
567 |
* {@link HotSpotResolvedJavaMethodImpl}, {@link HotSpotConstantPool} or |
|
568 |
* {@link HotSpotResolvedObjectTypeImpl} then the metaspace pointer is fetched from that object |
|
569 |
* and added to {@code displacement}. Any other non-null object type causes an |
|
570 |
* {@link IllegalArgumentException} to be thrown. |
|
571 |
* |
|
572 |
* @param base an object to read from or null |
|
573 |
* @param displacement |
|
574 |
* @return null or the resolved method for this location |
|
575 |
*/ |
|
576 |
native HotSpotResolvedJavaMethodImpl getResolvedJavaMethod(Object base, long displacement); |
|
577 |
||
578 |
/** |
|
579 |
* Gets the {@code ConstantPool*} associated with {@code object} and returns a |
|
580 |
* {@link HotSpotConstantPool} wrapping it. |
|
581 |
* |
|
582 |
* @param object a {@link HotSpotResolvedJavaMethodImpl} or |
|
583 |
* {@link HotSpotResolvedObjectTypeImpl} object |
|
584 |
* @return a {@link HotSpotConstantPool} wrapping the {@code ConstantPool*} associated with |
|
585 |
* {@code object} |
|
586 |
* @throws NullPointerException if {@code object == null} |
|
587 |
* @throws IllegalArgumentException if {@code object} is neither a |
|
588 |
* {@link HotSpotResolvedJavaMethodImpl} nor a {@link HotSpotResolvedObjectTypeImpl} |
|
589 |
*/ |
|
590 |
native HotSpotConstantPool getConstantPool(Object object); |
|
591 |
||
592 |
/** |
|
593 |
* Read a HotSpot Klass* value from the memory location described by {@code base} plus |
|
594 |
* {@code displacement} and return the {@link HotSpotResolvedObjectTypeImpl} wrapping it. This |
|
595 |
* method does no checking that the memory location actually contains a valid pointer and may |
|
596 |
* crash the VM if an invalid location is provided. If the {@code base} is null then |
|
597 |
* {@code displacement} is used by itself. If {@code base} is a |
|
598 |
* {@link HotSpotResolvedJavaMethodImpl}, {@link HotSpotConstantPool} or |
|
599 |
* {@link HotSpotResolvedObjectTypeImpl} then the metaspace pointer is fetched from that object |
|
600 |
* and added to {@code displacement}. Any other non-null object type causes an |
|
601 |
* {@link IllegalArgumentException} to be thrown. |
|
602 |
* |
|
603 |
* @param base an object to read from or null |
|
604 |
* @param displacement |
|
605 |
* @param compressed true if the location contains a compressed Klass* |
|
606 |
* @return null or the resolved method for this location |
|
607 |
*/ |
|
608 |
native HotSpotResolvedObjectTypeImpl getResolvedJavaType(Object base, long displacement, boolean compressed); |
|
609 |
||
610 |
/** |
|
611 |
* Return the size of the HotSpot ProfileData* pointed at by {@code position}. If |
|
612 |
* {@code position} is outside the space of the MethodData then an |
|
613 |
* {@link IllegalArgumentException} is thrown. A {@code position} inside the MethodData but that |
|
614 |
* isn't pointing at a valid ProfileData will crash the VM. |
|
615 |
* |
|
616 |
* @param metaspaceMethodData |
|
617 |
* @param position |
|
618 |
* @return the size of the ProfileData item pointed at by {@code position} |
|
619 |
* @throws IllegalArgumentException if an out of range position is given |
|
620 |
*/ |
|
621 |
native int methodDataProfileDataSize(long metaspaceMethodData, int position); |
|
622 |
||
623 |
/** |
|
624 |
* Gets the fingerprint for a given Klass* |
|
625 |
* |
|
626 |
* @param metaspaceKlass |
|
627 |
* @return the value of the fingerprint (zero for arrays and synthetic classes). |
|
628 |
*/ |
|
629 |
native long getFingerprint(long metaspaceKlass); |
|
630 |
||
631 |
/** |
|
632 |
* Return the amount of native stack required for the interpreter frames represented by |
|
633 |
* {@code frame}. This is used when emitting the stack banging code to ensure that there is |
|
634 |
* enough space for the frames during deoptimization. |
|
635 |
* |
|
636 |
* @param frame |
|
637 |
* @return the number of bytes required for deoptimization of this frame state |
|
638 |
*/ |
|
639 |
native int interpreterFrameSize(BytecodeFrame frame); |
|
640 |
||
641 |
/** |
|
642 |
* Invokes non-public method {@code java.lang.invoke.LambdaForm.compileToBytecode()} on |
|
643 |
* {@code lambdaForm} (which must be a {@code java.lang.invoke.LambdaForm} instance). |
|
644 |
*/ |
|
645 |
native void compileToBytecode(Object lambdaForm); |
|
646 |
||
647 |
/** |
|
648 |
* Gets the value of the VM flag named {@code name}. |
|
649 |
* |
|
650 |
* @param name name of a VM option |
|
651 |
* @return {@code this} if the named VM option doesn't exist, a {@link String} or {@code null} |
|
652 |
* if its type is {@code ccstr} or {@code ccstrlist}, a {@link Double} if its type is |
|
653 |
* {@code double}, a {@link Boolean} if its type is {@code bool} otherwise a |
|
654 |
* {@link Long} |
|
655 |
*/ |
|
656 |
native Object getFlagValue(String name); |
|
45626
c4ea64135530
8182310: [AOT][JVMCI] Get host class of VM anonymous class
dnsimon
parents:
43972
diff
changeset
|
657 |
|
c4ea64135530
8182310: [AOT][JVMCI] Get host class of VM anonymous class
dnsimon
parents:
43972
diff
changeset
|
658 |
/** |
c4ea64135530
8182310: [AOT][JVMCI] Get host class of VM anonymous class
dnsimon
parents:
43972
diff
changeset
|
659 |
* Gets the host class for {@code type}. |
c4ea64135530
8182310: [AOT][JVMCI] Get host class of VM anonymous class
dnsimon
parents:
43972
diff
changeset
|
660 |
*/ |
c4ea64135530
8182310: [AOT][JVMCI] Get host class of VM anonymous class
dnsimon
parents:
43972
diff
changeset
|
661 |
native HotSpotResolvedObjectTypeImpl getHostClass(HotSpotResolvedObjectTypeImpl type); |
43972 | 662 |
} |