1/*
2 * Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved.
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#ifndef SHARE_JVMCI_JVMCIJAVACLASSES_HPP
25#define SHARE_JVMCI_JVMCIJAVACLASSES_HPP
26
27#include "classfile/vmSymbols.hpp"
28#include "jvmci/jvmciExceptions.hpp"
29#include "jvmci/jvmciObject.hpp"
30#include "runtime/jniHandles.hpp"
31
32/*
33 * This macro defines the structure of the JVMCI classes accessed from VM code. It is used to
34 * generate accessors similar to javaClasses.hpp, but with specializations for HotSpot and JNI based
35 * access.
36 *
37 * HotSpotJVMCI: This class contains accessors based on the VM internal
38 * interface to Java. It is used for JVMCI Java code executing on the HotSpot heap.
39 *
40 * JNIJVMCI: This class contains JNI based accessors and is used for JVMCI
41 * Java code executing in the JVMCI shared library.
42 */
43
44#define JVMCI_CLASSES_DO(start_class, \
45 end_class, \
46 char_field, \
47 int_field, \
48 boolean_field, \
49 long_field, \
50 float_field, \
51 object_field, \
52 primarray_field, \
53 objectarray_field, \
54 static_object_field, \
55 static_objectarray_field, \
56 static_int_field, \
57 static_boolean_field, \
58 jvmci_method, \
59 jvmci_constructor) \
60 start_class(Services, jdk_vm_ci_services_Services) \
61 jvmci_method(CallStaticVoidMethod, GetStaticMethodID, call_static, void, Services, initializeSavedProperties, byte_array_void_signature, (JVMCIObject serializedProperties)) \
62 end_class \
63 start_class(Architecture, jdk_vm_ci_code_Architecture) \
64 object_field(Architecture, wordKind, "Ljdk/vm/ci/meta/PlatformKind;") \
65 end_class \
66 start_class(TargetDescription, jdk_vm_ci_code_TargetDescription) \
67 object_field(TargetDescription, arch, "Ljdk/vm/ci/code/Architecture;") \
68 end_class \
69 start_class(HotSpotResolvedObjectTypeImpl, jdk_vm_ci_hotspot_HotSpotResolvedObjectTypeImpl) \
70 long_field(HotSpotResolvedObjectTypeImpl, metadataPointer) \
71 end_class \
72 start_class(HotSpotResolvedPrimitiveType, jdk_vm_ci_hotspot_HotSpotResolvedPrimitiveType) \
73 object_field(HotSpotResolvedPrimitiveType, mirror, "Ljdk/vm/ci/hotspot/HotSpotObjectConstantImpl;") \
74 object_field(HotSpotResolvedPrimitiveType, kind, "Ljdk/vm/ci/meta/JavaKind;") \
75 static_objectarray_field(HotSpotResolvedPrimitiveType, primitives, "[Ljdk/vm/ci/hotspot/HotSpotResolvedPrimitiveType;") \
76 end_class \
77 start_class(HotSpotResolvedJavaFieldImpl, jdk_vm_ci_hotspot_HotSpotResolvedJavaFieldImpl) \
78 object_field(HotSpotResolvedJavaFieldImpl, type, "Ljdk/vm/ci/meta/JavaType;") \
79 object_field(HotSpotResolvedJavaFieldImpl, holder, "Ljdk/vm/ci/hotspot/HotSpotResolvedObjectTypeImpl;") \
80 int_field(HotSpotResolvedJavaFieldImpl, offset) \
81 int_field(HotSpotResolvedJavaFieldImpl, modifiers) \
82 end_class \
83 start_class(HotSpotResolvedJavaMethodImpl, jdk_vm_ci_hotspot_HotSpotResolvedJavaMethodImpl) \
84 long_field(HotSpotResolvedJavaMethodImpl, metadataHandle) \
85 end_class \
86 start_class(InstalledCode, jdk_vm_ci_code_InstalledCode) \
87 long_field(InstalledCode, address) \
88 long_field(InstalledCode, entryPoint) \
89 long_field(InstalledCode, version) \
90 object_field(InstalledCode, name, "Ljava/lang/String;") \
91 end_class \
92 start_class(HotSpotInstalledCode, jdk_vm_ci_hotspot_HotSpotInstalledCode) \
93 int_field(HotSpotInstalledCode, size) \
94 long_field(HotSpotInstalledCode, codeStart) \
95 int_field(HotSpotInstalledCode, codeSize) \
96 end_class \
97 start_class(HotSpotNmethod, jdk_vm_ci_hotspot_HotSpotNmethod) \
98 boolean_field(HotSpotNmethod, isDefault) \
99 long_field(HotSpotNmethod, compileIdSnapshot) \
100 object_field(HotSpotNmethod, method, "Ljdk/vm/ci/hotspot/HotSpotResolvedJavaMethodImpl;") \
101 jvmci_constructor(HotSpotNmethod, "(Ljdk/vm/ci/hotspot/HotSpotResolvedJavaMethodImpl;Ljava/lang/String;ZJ)V") \
102 end_class \
103 start_class(HotSpotCompiledCode, jdk_vm_ci_hotspot_HotSpotCompiledCode) \
104 object_field(HotSpotCompiledCode, name, "Ljava/lang/String;") \
105 primarray_field(HotSpotCompiledCode, targetCode, "[B") \
106 int_field(HotSpotCompiledCode, targetCodeSize) \
107 objectarray_field(HotSpotCompiledCode, sites, "[Ljdk/vm/ci/code/site/Site;") \
108 objectarray_field(HotSpotCompiledCode, assumptions, "[Ljdk/vm/ci/meta/Assumptions$Assumption;") \
109 objectarray_field(HotSpotCompiledCode, methods, "[Ljdk/vm/ci/meta/ResolvedJavaMethod;") \
110 objectarray_field(HotSpotCompiledCode, comments, "[Ljdk/vm/ci/hotspot/HotSpotCompiledCode$Comment;") \
111 primarray_field(HotSpotCompiledCode, dataSection, "[B") \
112 int_field(HotSpotCompiledCode, dataSectionAlignment) \
113 objectarray_field(HotSpotCompiledCode, dataSectionPatches, "[Ljdk/vm/ci/code/site/DataPatch;") \
114 boolean_field(HotSpotCompiledCode, isImmutablePIC) \
115 int_field(HotSpotCompiledCode, totalFrameSize) \
116 object_field(HotSpotCompiledCode, deoptRescueSlot, "Ljdk/vm/ci/code/StackSlot;") \
117 end_class \
118 start_class(HotSpotCompiledCode_Comment, jdk_vm_ci_hotspot_HotSpotCompiledCode_Comment) \
119 object_field(HotSpotCompiledCode_Comment, text, "Ljava/lang/String;") \
120 int_field(HotSpotCompiledCode_Comment, pcOffset) \
121 end_class \
122 start_class(HotSpotCompiledNmethod, jdk_vm_ci_hotspot_HotSpotCompiledNmethod) \
123 object_field(HotSpotCompiledNmethod, method, "Ljdk/vm/ci/hotspot/HotSpotResolvedJavaMethod;") \
124 object_field(HotSpotCompiledNmethod, installationFailureMessage, "Ljava/lang/String;") \
125 int_field(HotSpotCompiledNmethod, entryBCI) \
126 int_field(HotSpotCompiledNmethod, id) \
127 long_field(HotSpotCompiledNmethod, compileState) \
128 boolean_field(HotSpotCompiledNmethod, hasUnsafeAccess) \
129 end_class \
130 start_class(HotSpotForeignCallTarget, jdk_vm_ci_hotspot_HotSpotForeignCallTarget) \
131 long_field(HotSpotForeignCallTarget, address) \
132 end_class \
133 start_class(VMField, jdk_vm_ci_hotspot_VMField) \
134 object_field(VMField, name, "Ljava/lang/String;") \
135 object_field(VMField, type, "Ljava/lang/String;") \
136 long_field(VMField, offset) \
137 long_field(VMField, address) \
138 object_field(VMField, value, "Ljava/lang/Object;") \
139 jvmci_constructor(VMField, "(Ljava/lang/String;Ljava/lang/String;JJLjava/lang/Object;)V") \
140 end_class \
141 start_class(VMFlag, jdk_vm_ci_hotspot_VMFlag) \
142 object_field(VMFlag, name, "Ljava/lang/String;") \
143 object_field(VMFlag, type, "Ljava/lang/String;") \
144 object_field(VMFlag, value, "Ljava/lang/Object;") \
145 jvmci_constructor(VMFlag, "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Object;)V") \
146 end_class \
147 start_class(VMIntrinsicMethod, jdk_vm_ci_hotspot_VMIntrinsicMethod) \
148 object_field(VMIntrinsicMethod, declaringClass, "Ljava/lang/String;") \
149 object_field(VMIntrinsicMethod, name, "Ljava/lang/String;") \
150 object_field(VMIntrinsicMethod, descriptor, "Ljava/lang/String;") \
151 int_field(VMIntrinsicMethod, id) \
152 jvmci_constructor(VMIntrinsicMethod, "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;I)V") \
153 end_class \
154 start_class(Assumptions_NoFinalizableSubclass, jdk_vm_ci_meta_Assumptions_NoFinalizableSubclass) \
155 object_field(Assumptions_NoFinalizableSubclass, receiverType, "Ljdk/vm/ci/meta/ResolvedJavaType;") \
156 end_class \
157 start_class(Assumptions_ConcreteSubtype, jdk_vm_ci_meta_Assumptions_ConcreteSubtype) \
158 object_field(Assumptions_ConcreteSubtype, context, "Ljdk/vm/ci/meta/ResolvedJavaType;") \
159 object_field(Assumptions_ConcreteSubtype, subtype, "Ljdk/vm/ci/meta/ResolvedJavaType;") \
160 end_class \
161 start_class(Assumptions_LeafType, jdk_vm_ci_meta_Assumptions_LeafType) \
162 object_field(Assumptions_LeafType, context, "Ljdk/vm/ci/meta/ResolvedJavaType;") \
163 end_class \
164 start_class(Assumptions_ConcreteMethod, jdk_vm_ci_meta_Assumptions_ConcreteMethod) \
165 object_field(Assumptions_ConcreteMethod, method, "Ljdk/vm/ci/meta/ResolvedJavaMethod;") \
166 object_field(Assumptions_ConcreteMethod, context, "Ljdk/vm/ci/meta/ResolvedJavaType;") \
167 object_field(Assumptions_ConcreteMethod, impl, "Ljdk/vm/ci/meta/ResolvedJavaMethod;") \
168 end_class \
169 start_class(Assumptions_CallSiteTargetValue, jdk_vm_ci_meta_Assumptions_CallSiteTargetValue) \
170 object_field(Assumptions_CallSiteTargetValue, callSite, "Ljdk/vm/ci/meta/JavaConstant;") \
171 object_field(Assumptions_CallSiteTargetValue, methodHandle, "Ljdk/vm/ci/meta/JavaConstant;") \
172 end_class \
173 start_class(site_Site, jdk_vm_ci_code_site_Site) \
174 int_field(site_Site, pcOffset) \
175 end_class \
176 start_class(site_Call, jdk_vm_ci_code_site_Call) \
177 object_field(site_Call, target, "Ljdk/vm/ci/meta/InvokeTarget;") \
178 end_class \
179 start_class(site_DataPatch, jdk_vm_ci_code_site_DataPatch) \
180 object_field(site_DataPatch, reference, "Ljdk/vm/ci/code/site/Reference;") \
181 end_class \
182 start_class(site_ConstantReference, jdk_vm_ci_code_site_ConstantReference) \
183 object_field(site_ConstantReference, constant, "Ljdk/vm/ci/meta/VMConstant;") \
184 end_class \
185 start_class(site_DataSectionReference, jdk_vm_ci_code_site_DataSectionReference) \
186 int_field(site_DataSectionReference, offset) \
187 end_class \
188 start_class(site_InfopointReason, jdk_vm_ci_code_site_InfopointReason) \
189 static_object_field(site_InfopointReason, SAFEPOINT, "Ljdk/vm/ci/code/site/InfopointReason;") \
190 static_object_field(site_InfopointReason, CALL, "Ljdk/vm/ci/code/site/InfopointReason;") \
191 static_object_field(site_InfopointReason, IMPLICIT_EXCEPTION, "Ljdk/vm/ci/code/site/InfopointReason;") \
192 end_class \
193 start_class(site_Infopoint, jdk_vm_ci_code_site_Infopoint) \
194 object_field(site_Infopoint, debugInfo, "Ljdk/vm/ci/code/DebugInfo;") \
195 object_field(site_Infopoint, reason, "Ljdk/vm/ci/code/site/InfopointReason;") \
196 end_class \
197 start_class(site_ExceptionHandler, jdk_vm_ci_code_site_ExceptionHandler) \
198 int_field(site_ExceptionHandler, handlerPos) \
199 end_class \
200 start_class(site_Mark, jdk_vm_ci_code_site_Mark) \
201 object_field(site_Mark, id, "Ljava/lang/Object;") \
202 end_class \
203 start_class(HotSpotCompilationRequestResult, jdk_vm_ci_hotspot_HotSpotCompilationRequestResult) \
204 object_field(HotSpotCompilationRequestResult, failureMessage, "Ljava/lang/String;") \
205 boolean_field(HotSpotCompilationRequestResult, retry) \
206 int_field(HotSpotCompilationRequestResult, inlinedBytecodes) \
207 end_class \
208 start_class(DebugInfo, jdk_vm_ci_code_DebugInfo) \
209 object_field(DebugInfo, bytecodePosition, "Ljdk/vm/ci/code/BytecodePosition;") \
210 object_field(DebugInfo, referenceMap, "Ljdk/vm/ci/code/ReferenceMap;") \
211 object_field(DebugInfo, calleeSaveInfo, "Ljdk/vm/ci/code/RegisterSaveLayout;") \
212 objectarray_field(DebugInfo, virtualObjectMapping, "[Ljdk/vm/ci/code/VirtualObject;") \
213 end_class \
214 start_class(HotSpotReferenceMap, jdk_vm_ci_hotspot_HotSpotReferenceMap) \
215 objectarray_field(HotSpotReferenceMap, objects, "[Ljdk/vm/ci/code/Location;") \
216 objectarray_field(HotSpotReferenceMap, derivedBase, "[Ljdk/vm/ci/code/Location;") \
217 primarray_field(HotSpotReferenceMap, sizeInBytes, "[I") \
218 int_field(HotSpotReferenceMap, maxRegisterSize) \
219 end_class \
220 start_class(RegisterSaveLayout, jdk_vm_ci_code_RegisterSaveLayout) \
221 objectarray_field(RegisterSaveLayout, registers, "[Ljdk/vm/ci/code/Register;") \
222 primarray_field(RegisterSaveLayout, slots, "[I") \
223 end_class \
224 start_class(BytecodeFrame, jdk_vm_ci_code_BytecodeFrame) \
225 objectarray_field(BytecodeFrame, values, "[Ljdk/vm/ci/meta/JavaValue;") \
226 objectarray_field(BytecodeFrame, slotKinds, "[Ljdk/vm/ci/meta/JavaKind;") \
227 int_field(BytecodeFrame, numLocals) \
228 int_field(BytecodeFrame, numStack) \
229 int_field(BytecodeFrame, numLocks) \
230 boolean_field(BytecodeFrame, rethrowException) \
231 boolean_field(BytecodeFrame, duringCall) \
232 static_int_field(BytecodeFrame, UNKNOWN_BCI) \
233 static_int_field(BytecodeFrame, UNWIND_BCI) \
234 static_int_field(BytecodeFrame, BEFORE_BCI) \
235 static_int_field(BytecodeFrame, AFTER_BCI) \
236 static_int_field(BytecodeFrame, AFTER_EXCEPTION_BCI) \
237 static_int_field(BytecodeFrame, INVALID_FRAMESTATE_BCI) \
238 end_class \
239 start_class(BytecodePosition, jdk_vm_ci_code_BytecodePosition) \
240 object_field(BytecodePosition, caller, "Ljdk/vm/ci/code/BytecodePosition;") \
241 object_field(BytecodePosition, method, "Ljdk/vm/ci/meta/ResolvedJavaMethod;") \
242 int_field(BytecodePosition, bci) \
243 end_class \
244 start_class(JavaConstant, jdk_vm_ci_meta_JavaConstant) \
245 static_object_field(JavaConstant, NULL_POINTER, "Ljdk/vm/ci/meta/JavaConstant;") \
246 jvmci_method(CallStaticObjectMethod, GetStaticMethodID, call_static, JVMCIObject, JavaConstant, forFloat, forFloat_signature, (JVMCIObject kind, jlong value, JVMCI_TRAPS)) \
247 jvmci_method(CallStaticObjectMethod, GetStaticMethodID, call_static, JVMCIObject, JavaConstant, forDouble, forDouble_signature, (JVMCIObject kind, jlong value, JVMCI_TRAPS)) \
248 end_class \
249 start_class(ResolvedJavaMethod, jdk_vm_ci_meta_ResolvedJavaMethod) \
250 end_class \
251 start_class(PrimitiveConstant, jdk_vm_ci_meta_PrimitiveConstant) \
252 object_field(PrimitiveConstant, kind, "Ljdk/vm/ci/meta/JavaKind;") \
253 long_field(PrimitiveConstant, primitive) \
254 jvmci_method(CallStaticObjectMethod, GetStaticMethodID, call_static, JVMCIObject, PrimitiveConstant, forTypeChar, forTypeChar_signature, (JVMCIObject kind, jlong value, JVMCI_TRAPS)) \
255 end_class \
256 start_class(RawConstant, jdk_vm_ci_meta_RawConstant) \
257 end_class \
258 start_class(NullConstant, jdk_vm_ci_meta_NullConstant) \
259 end_class \
260 start_class(HotSpotCompressedNullConstant, jdk_vm_ci_hotspot_HotSpotCompressedNullConstant) \
261 end_class \
262 start_class(HotSpotObjectConstantImpl, jdk_vm_ci_hotspot_HotSpotObjectConstantImpl) \
263 boolean_field(HotSpotObjectConstantImpl, compressed) \
264 end_class \
265 start_class(DirectHotSpotObjectConstantImpl, jdk_vm_ci_hotspot_DirectHotSpotObjectConstantImpl) \
266 object_field(DirectHotSpotObjectConstantImpl, object, "Ljava/lang/Object;") \
267 jvmci_constructor(DirectHotSpotObjectConstantImpl, "(Ljava/lang/Object;Z)V") \
268 end_class \
269 start_class(IndirectHotSpotObjectConstantImpl, jdk_vm_ci_hotspot_IndirectHotSpotObjectConstantImpl) \
270 long_field(IndirectHotSpotObjectConstantImpl, objectHandle) \
271 jvmci_constructor(IndirectHotSpotObjectConstantImpl, "(JZZ)V") \
272 end_class \
273 start_class(HotSpotMetaspaceConstantImpl, jdk_vm_ci_hotspot_HotSpotMetaspaceConstantImpl) \
274 object_field(HotSpotMetaspaceConstantImpl, metaspaceObject, "Ljdk/vm/ci/hotspot/MetaspaceObject;") \
275 boolean_field(HotSpotMetaspaceConstantImpl, compressed) \
276 end_class \
277 start_class(HotSpotSentinelConstant, jdk_vm_ci_hotspot_HotSpotSentinelConstant) \
278 end_class \
279 start_class(JavaKind, jdk_vm_ci_meta_JavaKind) \
280 char_field(JavaKind, typeChar) \
281 static_object_field(JavaKind, Boolean, "Ljdk/vm/ci/meta/JavaKind;") \
282 static_object_field(JavaKind, Byte, "Ljdk/vm/ci/meta/JavaKind;") \
283 static_object_field(JavaKind, Char, "Ljdk/vm/ci/meta/JavaKind;") \
284 static_object_field(JavaKind, Short, "Ljdk/vm/ci/meta/JavaKind;") \
285 static_object_field(JavaKind, Int, "Ljdk/vm/ci/meta/JavaKind;") \
286 static_object_field(JavaKind, Long, "Ljdk/vm/ci/meta/JavaKind;") \
287 end_class \
288 start_class(ValueKind, jdk_vm_ci_meta_ValueKind) \
289 object_field(ValueKind, platformKind, "Ljdk/vm/ci/meta/PlatformKind;") \
290 end_class \
291 start_class(Value, jdk_vm_ci_meta_Value) \
292 object_field(Value, valueKind, "Ljdk/vm/ci/meta/ValueKind;") \
293 static_object_field(Value, ILLEGAL, "Ljdk/vm/ci/meta/AllocatableValue;") \
294 end_class \
295 start_class(RegisterValue, jdk_vm_ci_code_RegisterValue) \
296 object_field(RegisterValue, reg, "Ljdk/vm/ci/code/Register;") \
297 end_class \
298 start_class(code_Location, jdk_vm_ci_code_Location) \
299 object_field(code_Location, reg, "Ljdk/vm/ci/code/Register;") \
300 int_field(code_Location, offset) \
301 end_class \
302 start_class(code_Register, jdk_vm_ci_code_Register) \
303 int_field(code_Register, number) \
304 int_field(code_Register, encoding) \
305 end_class \
306 start_class(StackSlot, jdk_vm_ci_code_StackSlot) \
307 int_field(StackSlot, offset) \
308 boolean_field(StackSlot, addFrameSize) \
309 end_class \
310 start_class(VirtualObject, jdk_vm_ci_code_VirtualObject) \
311 int_field(VirtualObject, id) \
312 boolean_field(VirtualObject, isAutoBox) \
313 object_field(VirtualObject, type, "Ljdk/vm/ci/meta/ResolvedJavaType;") \
314 objectarray_field(VirtualObject, values, "[Ljdk/vm/ci/meta/JavaValue;") \
315 objectarray_field(VirtualObject, slotKinds, "[Ljdk/vm/ci/meta/JavaKind;") \
316 end_class \
317 start_class(StackLockValue, jdk_vm_ci_code_StackLockValue) \
318 object_field(StackLockValue, owner, "Ljdk/vm/ci/meta/JavaValue;") \
319 object_field(StackLockValue, slot, "Ljdk/vm/ci/meta/AllocatableValue;") \
320 boolean_field(StackLockValue, eliminated) \
321 end_class \
322 start_class(HotSpotStackFrameReference, jdk_vm_ci_hotspot_HotSpotStackFrameReference) \
323 object_field(HotSpotStackFrameReference, compilerToVM, "Ljdk/vm/ci/hotspot/CompilerToVM;") \
324 boolean_field(HotSpotStackFrameReference, objectsMaterialized) \
325 long_field(HotSpotStackFrameReference, stackPointer) \
326 int_field(HotSpotStackFrameReference, frameNumber) \
327 int_field(HotSpotStackFrameReference, bci) \
328 object_field(HotSpotStackFrameReference, method, "Ljdk/vm/ci/hotspot/HotSpotResolvedJavaMethod;") \
329 objectarray_field(HotSpotStackFrameReference, locals, "[Ljava/lang/Object;") \
330 primarray_field(HotSpotStackFrameReference, localIsVirtual, "[Z") \
331 end_class \
332 start_class(HotSpotMetaData, jdk_vm_ci_hotspot_HotSpotMetaData) \
333 primarray_field(HotSpotMetaData, pcDescBytes, "[B") \
334 primarray_field(HotSpotMetaData, scopesDescBytes, "[B") \
335 primarray_field(HotSpotMetaData, relocBytes, "[B") \
336 primarray_field(HotSpotMetaData, exceptionBytes, "[B") \
337 primarray_field(HotSpotMetaData, implicitExceptionBytes, "[B") \
338 primarray_field(HotSpotMetaData, oopMaps, "[B") \
339 object_field(HotSpotMetaData, metadata, "[Ljava/lang/Object;") \
340 end_class \
341 start_class(HotSpotConstantPool, jdk_vm_ci_hotspot_HotSpotConstantPool) \
342 long_field(HotSpotConstantPool, metadataHandle) \
343 end_class \
344 start_class(HotSpotJVMCIRuntime, jdk_vm_ci_hotspot_HotSpotJVMCIRuntime) \
345 objectarray_field(HotSpotJVMCIRuntime, excludeFromJVMCICompilation, "[Ljava/lang/Module;") \
346 jvmci_method(CallNonvirtualObjectMethod, GetMethodID, call_special, JVMCIObject, HotSpotJVMCIRuntime, compileMethod, compileMethod_signature, (JVMCIObject runtime, JVMCIObject method, int entry_bci, jlong env, int id)) \
347 jvmci_method(CallStaticObjectMethod, GetStaticMethodID, call_static, JVMCIObject, HotSpotJVMCIRuntime, encodeThrowable, encodeThrowable_signature, (JVMCIObject throwable)) \
348 jvmci_method(CallStaticObjectMethod, GetStaticMethodID, call_static, JVMCIObject, HotSpotJVMCIRuntime, decodeThrowable, decodeThrowable_signature, (JVMCIObject encodedThrowable)) \
349 jvmci_method(CallNonvirtualVoidMethod, GetMethodID, call_special, void, HotSpotJVMCIRuntime, bootstrapFinished, void_method_signature, (JVMCIObject runtime, JVMCI_TRAPS)) \
350 jvmci_method(CallNonvirtualVoidMethod, GetMethodID, call_special, void, HotSpotJVMCIRuntime, shutdown, void_method_signature, (JVMCIObject runtime)) \
351 jvmci_method(CallStaticObjectMethod, GetStaticMethodID, call_static, JVMCIObject, HotSpotJVMCIRuntime, runtime, runtime_signature, (JVMCI_TRAPS)) \
352 jvmci_method(CallObjectMethod, GetMethodID, call_virtual, JVMCIObject, HotSpotJVMCIRuntime, getCompiler, getCompiler_signature, (JVMCIObject runtime, JVMCI_TRAPS)) \
353 jvmci_method(CallStaticObjectMethod, GetStaticMethodID, call_static, JVMCIObject, HotSpotJVMCIRuntime, callToString, callToString_signature, (JVMCIObject object, JVMCI_TRAPS)) \
354 end_class \
355 start_class(JVMCIError, jdk_vm_ci_common_JVMCIError) \
356 jvmci_constructor(JVMCIError, "(Ljava/lang/String;)V") \
357 end_class \
358 start_class(InspectedFrameVisitor, jdk_vm_ci_code_stack_InspectedFrameVisitor) \
359 end_class \
360 start_class(JVMCI, jdk_vm_ci_runtime_JVMCI) \
361 jvmci_method(CallStaticObjectMethod, GetStaticMethodID, call_static, JVMCIObject, JVMCI, getRuntime, getRuntime_signature, (JVMCI_TRAPS)) \
362 jvmci_method(CallStaticObjectMethod, GetStaticMethodID, call_static, JVMCIObject, JVMCI, initializeRuntime, initializeRuntime_signature, (JVMCI_TRAPS)) \
363 end_class \
364 start_class(Object, java_lang_Object) \
365 end_class \
366 start_class(String, java_lang_String) \
367 end_class \
368 start_class(Class, java_lang_Class) \
369 jvmci_method(CallObjectMethod, GetMethodID, call_virtual, JVMCIObject, Class, getName, void_string_signature, (JVMCI_TRAPS)) \
370 end_class \
371 start_class(ArrayIndexOutOfBoundsException, java_lang_ArrayIndexOutOfBoundsException) \
372 jvmci_constructor(ArrayIndexOutOfBoundsException, "(Ljava/lang/String;)V") \
373 end_class \
374 start_class(IllegalStateException, java_lang_IllegalStateException) \
375 jvmci_constructor(IllegalStateException, "(Ljava/lang/String;)V") \
376 end_class \
377 start_class(NullPointerException, java_lang_NullPointerException) \
378 jvmci_constructor(NullPointerException, "(Ljava/lang/String;)V") \
379 end_class \
380 start_class(IllegalArgumentException, java_lang_IllegalArgumentException) \
381 jvmci_constructor(IllegalArgumentException, "(Ljava/lang/String;)V") \
382 end_class \
383 start_class(InternalError, java_lang_InternalError) \
384 jvmci_constructor(InternalError, "(Ljava/lang/String;)V") \
385 end_class \
386 start_class(ClassNotFoundException, java_lang_ClassNotFoundException) \
387 jvmci_constructor(ClassNotFoundException, "(Ljava/lang/String;)V") \
388 end_class \
389 start_class(InvalidInstalledCodeException, jdk_vm_ci_code_InvalidInstalledCodeException) \
390 jvmci_constructor(InvalidInstalledCodeException, "(Ljava/lang/String;)V") \
391 end_class \
392 start_class(UnsatisfiedLinkError, java_lang_UnsatisfiedLinkError) \
393 jvmci_constructor(UnsatisfiedLinkError, "(Ljava/lang/String;)V") \
394 end_class \
395 start_class(UnsupportedOperationException, java_lang_UnsupportedOperationException) \
396 jvmci_constructor(UnsupportedOperationException, "(Ljava/lang/String;)V") \
397 end_class \
398 start_class(StackTraceElement, java_lang_StackTraceElement) \
399 object_field(StackTraceElement, declaringClass, "Ljava/lang/String;") \
400 object_field(StackTraceElement, methodName, "Ljava/lang/String;") \
401 object_field(StackTraceElement, fileName, "Ljava/lang/String;") \
402 int_field(StackTraceElement, lineNumber) \
403 jvmci_constructor(StackTraceElement, "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;I)V") \
404 end_class \
405 start_class(Throwable, java_lang_Throwable) \
406 object_field(Throwable, detailMessage, "Ljava/lang/String;") \
407 end_class \
408 /* end*/
409
410class JVMCICompiler;
411class JVMCIEnv;
412
413#define START_CLASS(simpleClassName, fullClassName) \
414 class simpleClassName { \
415 friend class JVMCIEnv; \
416 static void initialize(JVMCI_TRAPS); \
417 static bool is_instance(JVMCIEnv* jvmciEnv, JVMCIObject object); \
418
419#define END_CLASS };
420
421#define EMPTY_CAST
422#define CHAR_FIELD(simpleClassName, name) FIELD(simpleClassName, name, jchar)
423#define INT_FIELD(simpleClassName, name) FIELD(simpleClassName, name, jint)
424#define BOOLEAN_FIELD(simpleClassName, name) FIELD(simpleClassName, name, jboolean)
425#define LONG_FIELD(simpleClassName, name) FIELD(simpleClassName, name, jlong)
426#define FLOAT_FIELD(simpleClassName, name) FIELD(simpleClassName, name, jfloat)
427
428#define OBJECT_FIELD(simpleClassName, name, signature) OOPISH_FIELD(simpleClassName, name, JVMCIObject, oop)
429#define OBJECTARRAY_FIELD(simpleClassName, name, signature) OOPISH_FIELD(simpleClassName, name, JVMCIObjectArray, objArrayOop)
430#define PRIMARRAY_FIELD(simpleClassName, name, signature) OOPISH_FIELD(simpleClassName, name, JVMCIPrimitiveArray, typeArrayOop)
431
432#define STATIC_INT_FIELD(simpleClassName, name) STATIC_FIELD(simpleClassName, name, jint)
433#define STATIC_BOOLEAN_FIELD(simpleClassName, name) STATIC_FIELD(simpleClassName, name, jboolean)
434#define STATIC_OBJECT_FIELD(simpleClassName, name, signature) STATIC_OOPISH_FIELD(simpleClassName, name, JVMCIObject, oop)
435#define STATIC_OBJECTARRAY_FIELD(simpleClassName, name, signature) STATIC_OOPISH_FIELD(simpleClassName, name, JVMCIObjectArray, objArrayOop)
436
437#define HS_START_CLASS(simpleClassName, fullClassName) \
438 START_CLASS(simpleClassName, fullClassName) \
439 friend class HotSpotJVMCI; \
440 private: \
441 static void check(oop obj, const char* field_name, int offset); \
442 static InstanceKlass* _klass; \
443 public: \
444 static InstanceKlass* klass() { assert(_klass != NULL, "uninit"); return _klass; } \
445 static Symbol* symbol() { return vmSymbols::fullClassName(); }
446
447#define FIELD(simpleClassName, name, type) \
448 private: \
449 static int _##name##_offset; \
450 public: \
451 static type get_ ## name(JVMCIEnv* env, JVMCIObject obj) { return name(env, resolve(obj)); } \
452 static void set_ ## name(JVMCIEnv* env, JVMCIObject obj, type x) { set_ ## name(env, resolve(obj), x); } \
453 static type name(JVMCIEnv* env, oop obj); \
454 static void set_ ## name(JVMCIEnv* env, oop obj, type x);
455
456#define OOPISH_FIELD(simpleClassName, name, type, hstype) \
457 private: \
458 static int _##name##_offset; \
459 public: \
460 static type get_ ## name(JVMCIEnv* env, JVMCIObject obj) { return (type) wrap(name(env, resolve(obj))); } \
461 static void set_ ## name(JVMCIEnv* env, JVMCIObject obj, type x) { set_ ## name(env, resolve(obj), (hstype) resolve(x)); } \
462 static hstype name(JVMCIEnv* env, oop obj); \
463 static void set_ ## name(JVMCIEnv* env, oop obj, hstype x);
464
465#define STATIC_FIELD(simpleClassName, name, type) \
466 private: \
467 static int _##name##_offset; \
468 public: \
469 static type get_ ## name(JVMCIEnv* env); \
470 static void set_ ## name(JVMCIEnv* env, type x);
471
472#define STATIC_OOPISH_FIELD(simpleClassName, name, type, hstype) \
473 private: \
474 static int _##name##_offset; \
475 public: \
476 static type get_ ## name(JVMCIEnv* env) { return (type) wrap(name(env)); } \
477 static void set_ ## name(JVMCIEnv* env, type x) { set_ ## name(env, (hstype) resolve(x)); } \
478 static hstype name(JVMCIEnv* env); \
479 static void set_ ## name(JVMCIEnv* env, hstype hstype);
480
481#define METHOD(jniCallType, jniGetMethod, hsCallType, returnType, simpleClassName, methodName, signatureSymbolName, args)
482#define CONSTRUCTOR(className, signature)
483
484/**
485 * VM internal interface to Java classes, methods and objects. For example:
486 *
487 * class HotSpotJVMCI {
488 * ...
489 * class Architecture {
490 * static void initialize(JVMCIEnv* env);
491 * static bool is_instance(JVMCIEnv* env, JVMCIObject object);
492 * private:
493 * static void check(oop obj, const char *field_name, int offset);
494 * public:
495 * static InstanceKlass *klass() { ... }
496 * static Symbol *symbol() { return vmSymbols::jdk_vm_ci_code_Architecture(); }
497 * private:
498 * static int _wordKind_offset;
499 * public:
500 * static JVMCIObject get_wordKind(JVMCIEnv *env, JVMCIObject obj) { ... }
501 * static void set_wordKind(JVMCIEnv *env, JVMCIObject obj, JVMCIObject x) { ... }
502 * static oop wordKind(JVMCIEnv *env, oop obj);
503 * static void set_wordKind(JVMCIEnv *env, oop obj, oop x);
504 * }
505 * ...
506 * };
507 */
508class HotSpotJVMCI {
509 friend class JVMCIEnv;
510
511 public:
512
513 static oop resolve(JVMCIObject obj);
514
515 static arrayOop resolve(JVMCIArray obj);
516 static objArrayOop resolve(JVMCIObjectArray obj);
517 static typeArrayOop resolve(JVMCIPrimitiveArray obj);
518
519 static JVMCIObject wrap(jobject obj) { return JVMCIObject(obj, true); }
520 static JVMCIObject wrap(oop obj);
521
522 static inline Method* asMethod(JVMCIEnv* env, oop jvmci_method) {
523 return *(Method**) HotSpotResolvedJavaMethodImpl::metadataHandle(env, jvmci_method);
524 }
525 static inline ConstantPool* asConstantPool(JVMCIEnv* env, oop jvmci_constant_pool) {
526 return *(ConstantPool**) HotSpotConstantPool::metadataHandle(env, jvmci_constant_pool);
527 }
528 static inline Klass* asKlass(JVMCIEnv* env, oop jvmci_type) {
529 return (Klass*) HotSpotResolvedObjectTypeImpl::metadataPointer(env, jvmci_type);
530 }
531
532 static void compute_offsets(TRAPS);
533 static void compute_offset(int &dest_offset, Klass* klass, const char* name, const char* signature, bool static_field, TRAPS);
534
535 JVMCI_CLASSES_DO(HS_START_CLASS, END_CLASS, CHAR_FIELD, INT_FIELD, BOOLEAN_FIELD, LONG_FIELD, FLOAT_FIELD, OBJECT_FIELD, PRIMARRAY_FIELD, OBJECTARRAY_FIELD, STATIC_OBJECT_FIELD, STATIC_OBJECTARRAY_FIELD, STATIC_INT_FIELD, STATIC_BOOLEAN_FIELD, METHOD, CONSTRUCTOR)
536};
537
538#undef HS_START_CLASS
539
540#define JNI_START_CLASS(simpleClassName, fullClassName) \
541 START_CLASS(simpleClassName, fullClassName) \
542 friend class JNIJVMCI; \
543 private: \
544 static void check(JVMCIEnv* jvmciEnv, JVMCIObject obj, const char* field_name, jfieldID offset); \
545 static jclass _class; \
546public: \
547 static jclass clazz() { assert(_class != NULL, #fullClassName " uninitialized"); return _class; } \
548 static jclass fullClassName ##_class() { assert(_class != NULL, "uninit"); return _class; }
549
550#undef METHOD
551#undef CONSTRUCTOR
552#undef FIELD
553#undef OOPISH_FIELD
554#undef STATIC_FIELD
555#undef STATIC_OOPISH_FIELD
556
557#define FIELD(simpleClassName, name, type) \
558 private: \
559 static jfieldID _##name##_field_id; \
560 public: \
561 static type get_ ## name(JVMCIEnv* jvmciEnv, JVMCIObject obj); \
562 static void set_ ## name(JVMCIEnv* jvmciEnv, JVMCIObject obj, type x);
563
564#define OOPISH_FIELD(simpleClassName, name, type, hstype) \
565 FIELD(simpleClassName, name, type)
566
567#define STATIC_FIELD(simpleClassName, name, type) \
568 private: \
569 static jfieldID _##name##_field_id; \
570 public: \
571 static type get_ ## name(JVMCIEnv* jvmciEnv); \
572 static void set_ ## name(JVMCIEnv* jvmciEnv, type x);
573
574#define STATIC_OOPISH_FIELD(simpleClassName, name, type, hstype) \
575 STATIC_FIELD(simpleClassName, name, type)
576
577#define METHOD(jniCallType, jniGetMethod, hsCallType, returnType, className, methodName, signatureSymbolName, args) \
578 public: \
579 static jmethodID methodName##_method() { return _##methodName##_method; } \
580 private: \
581 static jmethodID _##methodName##_method;
582
583#define CONSTRUCTOR(className, signature) \
584 public: \
585 static jmethodID constructor() { return _constructor; } \
586 private: \
587 static jmethodID _constructor;
588
589/**
590 * JNI based interface to Java classes, methods and objects. For example:
591 *
592 * class JNIJVMCI {
593 * ...
594 * class Architecture {
595 * static void initialize(JVMCIEnv* env);
596 * static bool is_instance(JVMCIEnv* env, JVMCIObject object);
597 * private:
598 * static void check(oop obj, const char *field_name, int offset);
599 * static jclass _class;
600 * public:
601 * static jclass clazz() { return _class; }
602 * static jclass jdk_vm_ci_code_Architecture_class() { return _class; }
603 * private:
604 * static jfieldID _wordKind_field_id;
605 * public:
606 * static JVMCIObject get_wordKind(JVMCIEnv *env, JVMCIObject obj) { ... }
607 * static void set_wordKind(JVMCIEnv *env, JVMCIObject obj, JVMCIObject x) { ... }
608 * }
609 * ...
610 * };
611 */
612class JNIJVMCI {
613 friend class JVMCIEnv;
614
615 static jclass _byte_array;
616 static jclass _box_classes[T_CONFLICT+1];
617 static jfieldID _box_fields[T_CONFLICT+1];
618 static jmethodID _box_constructors[T_CONFLICT+1];
619 static jmethodID _Class_getName_method;
620
621 static jmethodID _HotSpotResolvedJavaMethodImpl_fromMetaspace_method;
622 static jmethodID _HotSpotConstantPool_fromMetaspace_method;
623 static jmethodID _HotSpotResolvedObjectTypeImpl_fromMetaspace_method;
624 static jmethodID _HotSpotResolvedPrimitiveType_fromMetaspace_method;
625
626 public:
627 static jmethodID Class_getName_method() { return _Class_getName_method; }
628
629 static jclass byte_array() { assert(_byte_array != NULL, "uninit"); return _byte_array; }
630
631 static jclass box_class(BasicType type) { assert(_box_classes[type]!= NULL, "uninit"); return _box_classes[type]; }
632 static jfieldID box_field(BasicType type) { assert(_box_fields[type]!= NULL, "uninit"); return _box_fields[type]; }
633 static jmethodID box_constructor(BasicType type) { assert(_box_constructors[type]!= NULL, "uninit"); return _box_constructors[type]; }
634
635 static jmethodID HotSpotResolvedJavaMethodImpl_fromMetaspace_method() { assert(_HotSpotResolvedJavaMethodImpl_fromMetaspace_method != NULL, "uninit"); return _HotSpotResolvedJavaMethodImpl_fromMetaspace_method; }
636 static jmethodID HotSpotConstantPool_fromMetaspace_method() { assert(_HotSpotConstantPool_fromMetaspace_method != NULL, "uninit"); return _HotSpotConstantPool_fromMetaspace_method; }
637 static jmethodID HotSpotResolvedObjectTypeImpl_fromMetaspace_method() { assert(_HotSpotResolvedObjectTypeImpl_fromMetaspace_method != NULL, "uninit"); return _HotSpotResolvedObjectTypeImpl_fromMetaspace_method; }
638 static jmethodID HotSpotResolvedPrimitiveType_fromMetaspace_method() { assert(_HotSpotResolvedPrimitiveType_fromMetaspace_method != NULL, "uninit"); return _HotSpotResolvedPrimitiveType_fromMetaspace_method; }
639
640 static void initialize_ids(JNIEnv* env);
641 static void initialize_field_id(JNIEnv* env, jfieldID &dest_offset, jclass klass, const char* klass_name, const char* name, const char* signature, bool static_field);
642
643 static jobject resolve_handle(JVMCIObject obj) { return obj.as_jobject(); }
644 static JVMCIObject wrap(jobject obj) { return JVMCIObject(obj, false); }
645
646 JVMCI_CLASSES_DO(JNI_START_CLASS, END_CLASS, CHAR_FIELD, INT_FIELD, BOOLEAN_FIELD, LONG_FIELD, FLOAT_FIELD, OBJECT_FIELD, PRIMARRAY_FIELD, OBJECTARRAY_FIELD, STATIC_OBJECT_FIELD, STATIC_OBJECTARRAY_FIELD, STATIC_INT_FIELD, STATIC_BOOLEAN_FIELD, METHOD, CONSTRUCTOR)
647};
648
649#undef JNI_START_CLASS
650#undef START_CLASS
651#undef END_CLASS
652#undef METHOD
653#undef CONSTRUCTOR
654#undef FIELD
655#undef CHAR_FIELD
656#undef INT_FIELD
657#undef BOOLEAN_FIELD
658#undef LONG_FIELD
659#undef FLOAT_FIELD
660#undef OBJECT_FIELD
661#undef PRIMARRAY_FIELD
662#undef OBJECTARRAY_FIELD
663#undef FIELD
664#undef OOPISH_FIELD
665#undef STATIC_FIELD
666#undef STATIC_OOPISH_FIELD
667#undef STATIC_FIELD
668#undef STATIC_OBJECT_FIELD
669#undef STATIC_OBJECTARRAY_FIELD
670#undef STATIC_INT_FIELD
671#undef STATIC_BOOLEAN_FIELD
672#undef STATIC_PRIMITIVE_FIELD
673#undef EMPTY_CAST
674
675#endif // SHARE_JVMCI_JVMCIJAVACLASSES_HPP
676