21 * questions. |
21 * questions. |
22 */ |
22 */ |
23 |
23 |
24 #include "precompiled.hpp" |
24 #include "precompiled.hpp" |
25 #include "classfile/symbolTable.hpp" |
25 #include "classfile/symbolTable.hpp" |
|
26 #include "interpreter/linkResolver.hpp" |
|
27 #include "jvmci/jniAccessMark.inline.hpp" |
26 #include "jvmci/jvmciJavaClasses.hpp" |
28 #include "jvmci/jvmciJavaClasses.hpp" |
|
29 #include "jvmci/jvmciRuntime.hpp" |
27 #include "memory/resourceArea.hpp" |
30 #include "memory/resourceArea.hpp" |
28 #include "oops/oop.inline.hpp" |
|
29 #include "runtime/jniHandles.inline.hpp" |
31 #include "runtime/jniHandles.inline.hpp" |
30 #include "runtime/fieldDescriptor.inline.hpp" |
32 #include "runtime/fieldDescriptor.inline.hpp" |
31 |
33 |
32 |
34 // ------------------------------------------------------------------ |
33 // This macro expands for non-inline functions, in class declarations. |
35 |
34 |
36 oop HotSpotJVMCI::resolve(JVMCIObject obj) { |
35 #define START_CLASS(name) \ |
37 return JNIHandles::resolve(obj.as_jobject()); |
36 void name::check(oop obj, const char* field_name, int offset) { \ |
38 } |
37 assert(obj != NULL, "NULL field access of %s.%s", #name, field_name); \ |
39 |
38 assert(obj->is_a(SystemDictionary::name##_klass()), "wrong class, " #name " expected, found %s", obj->klass()->external_name()); \ |
40 arrayOop HotSpotJVMCI::resolve(JVMCIArray obj) { |
39 assert(offset != 0, "must be valid offset"); \ |
41 return (arrayOop) JNIHandles::resolve(obj.as_jobject()); |
|
42 } |
|
43 |
|
44 objArrayOop HotSpotJVMCI::resolve(JVMCIObjectArray obj) { |
|
45 return (objArrayOop) JNIHandles::resolve(obj.as_jobject()); |
|
46 } |
|
47 |
|
48 typeArrayOop HotSpotJVMCI::resolve(JVMCIPrimitiveArray obj) { |
|
49 return (typeArrayOop) JNIHandles::resolve(obj.as_jobject()); |
|
50 } |
|
51 |
|
52 JVMCIObject HotSpotJVMCI::wrap(oop obj) { |
|
53 assert(Thread::current()->is_Java_thread(), "must be"); |
|
54 return JVMCIObject(JNIHandles::make_local(obj), true); |
|
55 } |
|
56 |
|
57 /** |
|
58 * Computes the field offset of a static or instance field. |
|
59 * It looks up the name and signature symbols without creating new ones; |
|
60 * all the symbols of these classes need to be already loaded. |
|
61 */ |
|
62 void HotSpotJVMCI::compute_offset(int &dest_offset, Klass* klass, const char* name, const char* signature, bool static_field, TRAPS) { |
|
63 InstanceKlass* ik = InstanceKlass::cast(klass); |
|
64 Symbol* name_symbol = SymbolTable::probe(name, (int)strlen(name)); |
|
65 Symbol* signature_symbol = SymbolTable::probe(signature, (int)strlen(signature)); |
|
66 if (name_symbol == NULL || signature_symbol == NULL) { |
|
67 #ifndef PRODUCT |
|
68 ik->print_on(tty); |
|
69 #endif |
|
70 fatal("symbol with name %s and signature %s was not found in symbol table (klass=%s)", name, signature, klass->name()->as_C_string()); |
|
71 } |
|
72 |
|
73 fieldDescriptor fd; |
|
74 if (!ik->find_field(name_symbol, signature_symbol, &fd)) { |
|
75 ResourceMark rm; |
|
76 fatal("Could not find field %s.%s with signature %s", ik->external_name(), name, signature); |
|
77 } |
|
78 guarantee(fd.is_static() == static_field, "static/instance mismatch"); |
|
79 dest_offset = fd.offset(); |
|
80 assert(dest_offset != 0, "must be valid offset"); |
|
81 if (static_field) { |
|
82 // Must ensure classes for static fields are initialized as the |
|
83 // accessor itself does not include a class initialization check. |
|
84 ik->initialize(CHECK); |
|
85 } |
|
86 } |
|
87 |
|
88 #ifndef PRODUCT |
|
89 static void check_resolve_method(const char* call_type, Klass* resolved_klass, Symbol* method_name, Symbol* method_signature, TRAPS) { |
|
90 methodHandle method; |
|
91 LinkInfo link_info(resolved_klass, method_name, method_signature, NULL, LinkInfo::skip_access_check); |
|
92 if (strcmp(call_type, "call_static") == 0) { |
|
93 method = LinkResolver::resolve_static_call_or_null(link_info); |
|
94 } else if (strcmp(call_type, "call_virtual") == 0) { |
|
95 method = LinkResolver::resolve_virtual_call_or_null(resolved_klass, link_info); |
|
96 } else if (strcmp(call_type, "call_special") == 0) { |
|
97 method = LinkResolver::resolve_special_call_or_null(link_info); |
|
98 } else { |
|
99 fatal("Unknown or unsupported call type: %s", call_type); |
|
100 } |
|
101 if (method.is_null()) { |
|
102 fatal("Could not resolve %s.%s%s", resolved_klass->external_name(), method_name->as_C_string(), method_signature->as_C_string()); |
|
103 } |
|
104 } |
|
105 #endif |
|
106 |
|
107 jclass JNIJVMCI::_box_classes[T_CONFLICT+1]; |
|
108 jclass JNIJVMCI::_byte_array; |
|
109 jfieldID JNIJVMCI::_box_fields[T_CONFLICT+1]; |
|
110 jmethodID JNIJVMCI::_box_constructors[T_CONFLICT+1]; |
|
111 jmethodID JNIJVMCI::_Class_getName_method; |
|
112 |
|
113 jmethodID JNIJVMCI::_HotSpotResolvedJavaMethodImpl_fromMetaspace_method; |
|
114 jmethodID JNIJVMCI::_HotSpotConstantPool_fromMetaspace_method; |
|
115 jmethodID JNIJVMCI::_HotSpotResolvedObjectTypeImpl_fromMetaspace_method; |
|
116 jmethodID JNIJVMCI::_HotSpotResolvedPrimitiveType_fromMetaspace_method; |
|
117 |
|
118 #define START_CLASS(className, fullClassName) { \ |
|
119 Klass* k = SystemDictionary::resolve_or_fail(vmSymbols::fullClassName(), true, CHECK); \ |
|
120 className::_klass = InstanceKlass::cast(k); \ |
|
121 className::_klass->initialize(CHECK); |
|
122 |
|
123 #define END_CLASS } |
|
124 |
|
125 #define FIELD(className, name, signature, static_field) compute_offset(className::_##name##_offset, className::_klass, #name, signature, static_field, CHECK); |
|
126 #define CHAR_FIELD(className, name) FIELD(className, name, "C", false) |
|
127 #define INT_FIELD(className, name) FIELD(className, name, "I", false) |
|
128 #define BOOLEAN_FIELD(className, name) FIELD(className, name, "Z", false) |
|
129 #define LONG_FIELD(className, name) FIELD(className, name, "J", false) |
|
130 #define FLOAT_FIELD(className, name) FIELD(className, name, "F", false) |
|
131 #define OBJECT_FIELD(className, name, signature) FIELD(className, name, signature, false) |
|
132 #define STATIC_OBJECT_FIELD(className, name, signature) FIELD(className, name, signature, true) |
|
133 #define STATIC_INT_FIELD(className, name) FIELD(className, name, "I", true) |
|
134 #define STATIC_BOOLEAN_FIELD(className, name) FIELD(className, name, "Z", true) |
|
135 #ifdef PRODUCT |
|
136 #define METHOD(jniCallType, jniGetMethod, hsCallType, returnType, className, methodName, signatureSymbolName, args) |
|
137 #define CONSTRUCTOR(className, signature) |
|
138 #else |
|
139 #define METHOD(jniCallType, jniGetMethod, hsCallType, returnType, className, methodName, signatureSymbolName, args) \ |
|
140 check_resolve_method(#hsCallType, k, vmSymbols::methodName##_name(), vmSymbols::signatureSymbolName(), CHECK); |
|
141 #define CONSTRUCTOR(className, signature) { \ |
|
142 TempNewSymbol sig = SymbolTable::new_symbol(signature, CHECK); \ |
|
143 check_resolve_method("call_special", k, vmSymbols::object_initializer_name(), sig, CHECK); \ |
|
144 } |
|
145 #endif |
|
146 /** |
|
147 * Computes and initializes the offsets used by HotSpotJVMCI. |
|
148 */ |
|
149 void HotSpotJVMCI::compute_offsets(TRAPS) { |
|
150 JVMCI_CLASSES_DO(START_CLASS, END_CLASS, CHAR_FIELD, INT_FIELD, BOOLEAN_FIELD, LONG_FIELD, FLOAT_FIELD, OBJECT_FIELD, OBJECT_FIELD, OBJECT_FIELD, STATIC_OBJECT_FIELD, STATIC_OBJECT_FIELD, STATIC_INT_FIELD, STATIC_BOOLEAN_FIELD, METHOD, CONSTRUCTOR) |
|
151 } |
|
152 |
|
153 #undef START_CLASS |
|
154 #undef END_CLASS |
|
155 #undef METHOD |
|
156 #undef CONSTRUCTOR |
|
157 #undef FIELD |
|
158 #undef CHAR_FIELD |
|
159 #undef INT_FIELD |
|
160 #undef BOOLEAN_FIELD |
|
161 #undef LONG_FIELD |
|
162 #undef FLOAT_FIELD |
|
163 #undef OBJECT_FIELD |
|
164 #undef PRIMARRAY_FIELD |
|
165 #undef OBJECTARRAY_FIELD |
|
166 #undef STATIC_FIELD |
|
167 #undef STATIC_OBJECT_FIELD |
|
168 #undef STATIC_OBJECTARRAY_FIELD |
|
169 #undef STATIC_INT_FIELD |
|
170 #undef STATIC_BOOLEAN_FIELD |
|
171 #undef EMPTY_CAST |
|
172 |
|
173 // ------------------------------------------------------------------ |
|
174 |
|
175 #define START_CLASS(className, fullClassName) \ |
|
176 void HotSpotJVMCI::className::initialize(JVMCI_TRAPS) { \ |
|
177 Thread* THREAD = Thread::current(); \ |
|
178 className::klass()->initialize(CHECK); \ |
|
179 } \ |
|
180 bool HotSpotJVMCI::className::is_instance(JVMCIEnv* env, JVMCIObject object) { \ |
|
181 return resolve(object)->is_a(className::klass()); \ |
|
182 } \ |
|
183 void HotSpotJVMCI::className::check(oop obj, const char* field_name, int offset) { \ |
|
184 assert(obj != NULL, "NULL field access of %s.%s", #className, field_name); \ |
|
185 assert(obj->is_a(className::klass()), "wrong class, " #className " expected, found %s", obj->klass()->external_name()); \ |
|
186 assert(offset != 0, "must be valid offset"); \ |
|
187 } \ |
|
188 InstanceKlass* HotSpotJVMCI::className::_klass = NULL; |
|
189 |
|
190 #define END_CLASS |
|
191 |
|
192 #define FIELD(className, name, type, accessor, cast) \ |
|
193 type HotSpotJVMCI::className::name(JVMCIEnv* env, oop obj) { className::check(obj, #name, className::_##name##_offset); return cast obj->accessor(className::_##name##_offset); } \ |
|
194 void HotSpotJVMCI::className::set_##name(JVMCIEnv* env, oop obj, type x) { className::check(obj, #name, className::_##name##_offset); obj->accessor##_put(className::_##name##_offset, x); } |
|
195 |
|
196 #define EMPTY_CAST |
|
197 #define CHAR_FIELD(className, name) FIELD(className, name, jchar, char_field, EMPTY_CAST) |
|
198 #define INT_FIELD(className, name) FIELD(className, name, jint, int_field, EMPTY_CAST) |
|
199 #define BOOLEAN_FIELD(className, name) FIELD(className, name, jboolean, bool_field, EMPTY_CAST) |
|
200 #define LONG_FIELD(className, name) FIELD(className, name, jlong, long_field, EMPTY_CAST) |
|
201 #define FLOAT_FIELD(className, name) FIELD(className, name, jfloat, float_field, EMPTY_CAST) |
|
202 |
|
203 #define OBJECT_FIELD(className, name, signature) FIELD(className, name, oop, obj_field, EMPTY_CAST) |
|
204 #define OBJECTARRAY_FIELD(className, name, signature) FIELD(className, name, objArrayOop, obj_field, (objArrayOop)) |
|
205 #define PRIMARRAY_FIELD(className, name, signature) FIELD(className, name, typeArrayOop, obj_field, (typeArrayOop)) |
|
206 #define STATIC_OBJECT_FIELD(className, name, signature) STATIC_OOPISH_FIELD(className, name, oop) |
|
207 #define STATIC_OBJECTARRAY_FIELD(className, name, signature) STATIC_OOPISH_FIELD(className, name, objArrayOop) |
|
208 #define STATIC_OOPISH_FIELD(className, name, type) \ |
|
209 type HotSpotJVMCI::className::name(JVMCIEnv* env) { \ |
|
210 assert(className::klass() != NULL && className::klass()->is_linked(), "Class not yet linked: " #className); \ |
|
211 InstanceKlass* ik = className::klass(); \ |
|
212 oop base = ik->static_field_base_raw(); \ |
|
213 oop result = HeapAccess<>::oop_load_at(base, className::_##name##_offset); \ |
|
214 return type(result); \ |
|
215 } \ |
|
216 void HotSpotJVMCI::className::set_##name(JVMCIEnv* env, type x) { \ |
|
217 assert(className::klass() != NULL && className::klass()->is_linked(), "Class not yet linked: " #className); \ |
|
218 assert(className::klass() != NULL, "Class not yet loaded: " #className); \ |
|
219 InstanceKlass* ik = className::klass(); \ |
|
220 oop base = ik->static_field_base_raw(); \ |
|
221 HeapAccess<>::oop_store_at(base, className::_##name##_offset, x); \ |
40 } |
222 } |
|
223 #define STATIC_PRIMITIVE_FIELD(className, name, jtypename) \ |
|
224 jtypename HotSpotJVMCI::className::get_##name(JVMCIEnv* env) { \ |
|
225 assert(className::klass() != NULL && className::klass()->is_linked(), "Class not yet linked: " #className); \ |
|
226 InstanceKlass* ik = className::klass(); \ |
|
227 oop base = ik->static_field_base_raw(); \ |
|
228 return HeapAccess<>::load_at(base, className::_##name##_offset); \ |
|
229 } \ |
|
230 void HotSpotJVMCI::className::set_##name(JVMCIEnv* env, jtypename x) { \ |
|
231 assert(className::klass() != NULL && className::klass()->is_linked(), "Class not yet linked: " #className); \ |
|
232 InstanceKlass* ik = className::klass(); \ |
|
233 oop base = ik->static_field_base_raw(); \ |
|
234 HeapAccess<>::store_at(base, _##name##_offset, x); \ |
|
235 } |
|
236 |
|
237 #define STATIC_INT_FIELD(className, name) STATIC_PRIMITIVE_FIELD(className, name, jint) |
|
238 #define STATIC_BOOLEAN_FIELD(className, name) STATIC_PRIMITIVE_FIELD(className, name, jboolean) |
|
239 #define METHOD(jniCallType, jniGetMethod, hsCallType, returnType, className, methodName, signatureSymbolName, args) |
|
240 #define CONSTRUCTOR(className, signature) |
|
241 |
|
242 /** |
|
243 * Generates the method and field definitions for the classes in HotSpotJVMCI. For example: |
|
244 * |
|
245 * void HotSpotJVMCI::Architecture::initialize(JVMCIEnv* env) { ... } |
|
246 * bool HotSpotJVMCI::Architecture::is_instance(JVMCIEnv* env, JVMCIObject object) { ... } |
|
247 * void HotSpotJVMCI::Architecture::check(oop obj, const char* field_name, int offset) { ... } |
|
248 * oop HotSpotJVMCI::Architecture::wordKind(JVMCIEnv* env, oop obj) { ... } |
|
249 * void HotSpotJVMCI::Architecture::set_wordKind(JVMCIEnv* env, oop obj, oop x) { ... } |
|
250 * |
|
251 * InstanceKlass *HotSpotJVMCI::Architecture::_klass = NULL; |
|
252 */ |
|
253 JVMCI_CLASSES_DO(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) |
|
254 |
|
255 #undef START_CLASS |
|
256 #undef END_CLASS |
|
257 #undef METHOD |
|
258 #undef CONSTRUCTOR |
|
259 #undef FIELD |
|
260 #undef CHAR_FIELD |
|
261 #undef INT_FIELD |
|
262 #undef BOOLEAN_FIELD |
|
263 #undef LONG_FIELD |
|
264 #undef FLOAT_FIELD |
|
265 #undef OBJECT_FIELD |
|
266 #undef PRIMARRAY_FIELD |
|
267 #undef OBJECTARRAY_FIELD |
|
268 #undef STATIC_OOPISH_FIELD |
|
269 #undef STATIC_OBJECT_FIELD |
|
270 #undef STATIC_OBJECTARRAY_FIELD |
|
271 #undef STATIC_INT_FIELD |
|
272 #undef STATIC_BOOLEAN_FIELD |
|
273 #undef STATIC_PRIMITIVE_FIELD |
|
274 #undef EMPTY_CAST |
|
275 |
|
276 /** |
|
277 * Initializes the JNI id of a field. As per the JNI specification, |
|
278 * this ensures the declaring class is initialized. |
|
279 */ |
|
280 void JNIJVMCI::initialize_field_id(JNIEnv* env, jfieldID &fieldid, jclass clazz, const char* class_name, const char* name, const char* signature, bool static_field) { |
|
281 if (JVMCILibDumpJNIConfig != NULL) { |
|
282 fileStream* st = JVMCIGlobals::get_jni_config_file(); |
|
283 st->print_cr("field %s %s %s", class_name, name, signature); |
|
284 return; |
|
285 } |
|
286 if (env->ExceptionCheck()) { |
|
287 return; |
|
288 } |
|
289 if (static_field) { |
|
290 // Class initialization barrier |
|
291 fieldid = env->GetStaticFieldID(clazz, name, signature); |
|
292 } else { |
|
293 // Class initialization barrier |
|
294 fieldid = env->GetFieldID(clazz, name, signature); |
|
295 } |
|
296 |
|
297 if (env->ExceptionCheck()) { |
|
298 env->ExceptionDescribe(); |
|
299 env->ExceptionClear(); |
|
300 ResourceMark rm; |
|
301 Thread* THREAD = Thread::current(); |
|
302 fatal("Could not find field %s.%s with signature %s", class_name, name, signature); |
|
303 } |
|
304 } |
|
305 |
|
306 #define START_CLASS(className, fullClassName) { \ |
|
307 current_class_name = vmSymbols::fullClassName()->as_C_string(); \ |
|
308 if (JVMCILibDumpJNIConfig != NULL) { \ |
|
309 fileStream* st = JVMCIGlobals::get_jni_config_file(); \ |
|
310 st->print_cr("class %s", current_class_name); \ |
|
311 } else { \ |
|
312 jclass k = env->FindClass(current_class_name); \ |
|
313 JVMCI_EXCEPTION_CHECK(env, "FindClass(%s)", current_class_name); \ |
|
314 assert(k != NULL, #fullClassName " not initialized"); \ |
|
315 className::_class = (jclass) env->NewGlobalRef(k); \ |
|
316 } |
|
317 |
|
318 #define END_CLASS current_class_name = NULL; } |
|
319 |
|
320 #define FIELD(className, name, signature, static_field) initialize_field_id(env, className::_##name##_field_id, className::_class, current_class_name, #name, signature, static_field); |
|
321 #define CHAR_FIELD(className, name) FIELD(className, name, "C", false) |
|
322 #define INT_FIELD(className, name) FIELD(className, name, "I", false) |
|
323 #define BOOLEAN_FIELD(className, name) FIELD(className, name, "Z", false) |
|
324 #define LONG_FIELD(className, name) FIELD(className, name, "J", false) |
|
325 #define FLOAT_FIELD(className, name) FIELD(className, name, "F", false) |
|
326 #define OBJECT_FIELD(className, name, signature) FIELD(className, name, signature, false) |
|
327 #define STATIC_OBJECT_FIELD(className, name, signature) FIELD(className, name, signature, true) |
|
328 #define STATIC_INT_FIELD(className, name) FIELD(className, name, "I", true) |
|
329 #define STATIC_BOOLEAN_FIELD(className, name) FIELD(className, name, "Z", true) |
|
330 |
|
331 #define GET_JNI_METHOD(jniGetMethod, dst, clazz, methodName, signature) \ |
|
332 if (JVMCILibDumpJNIConfig != NULL) { \ |
|
333 fileStream* st = JVMCIGlobals::get_jni_config_file(); \ |
|
334 st->print_cr("method %s %s %s", current_class_name, methodName, signature); \ |
|
335 } else { \ |
|
336 dst = env->jniGetMethod(clazz, methodName, signature); \ |
|
337 JVMCI_EXCEPTION_CHECK(env, #jniGetMethod "(%s.%s%s)", current_class_name, methodName, signature); \ |
|
338 assert(dst != NULL, "uninitialized"); \ |
|
339 } |
|
340 |
|
341 #define GET_JNI_CONSTRUCTOR(clazz, signature) \ |
|
342 GET_JNI_METHOD(GetMethodID, JNIJVMCI::clazz::_constructor, clazz::_class, "<init>", signature) \ |
|
343 |
|
344 #define METHOD(jniCallType, jniGetMethod, hsCallType, returnType, className, methodName, signatureSymbolName, args) \ |
|
345 GET_JNI_METHOD(jniGetMethod, \ |
|
346 className::_##methodName##_method, \ |
|
347 className::clazz(), \ |
|
348 vmSymbols::methodName##_name()->as_C_string(), \ |
|
349 vmSymbols::signatureSymbolName()->as_C_string()) |
|
350 |
|
351 #define CONSTRUCTOR(className, signature) \ |
|
352 GET_JNI_CONSTRUCTOR(className, signature) |
|
353 |
|
354 extern "C" { |
|
355 void JNICALL JVM_RegisterJVMCINatives(JNIEnv *env, jclass compilerToVMClass); |
|
356 jobject JNICALL JVM_GetJVMCIRuntime(JNIEnv *env, jclass c); |
|
357 } |
|
358 |
|
359 #define IN_CLASS(fullClassName) current_class_name = vmSymbols::fullClassName()->as_C_string() |
|
360 /** |
|
361 * Initializes the JNI method and field ids used in JNIJVMCI. |
|
362 */ |
|
363 void JNIJVMCI::initialize_ids(JNIEnv* env) { |
|
364 ResourceMark rm; |
|
365 const char* current_class_name = NULL; |
|
366 JVMCI_CLASSES_DO(START_CLASS, END_CLASS, CHAR_FIELD, INT_FIELD, BOOLEAN_FIELD, LONG_FIELD, FLOAT_FIELD, OBJECT_FIELD, OBJECT_FIELD, OBJECT_FIELD, STATIC_OBJECT_FIELD, STATIC_OBJECT_FIELD, STATIC_INT_FIELD, STATIC_BOOLEAN_FIELD, METHOD, CONSTRUCTOR) |
|
367 |
|
368 IN_CLASS(java_lang_Class); |
|
369 GET_JNI_METHOD(GetMethodID, _Class_getName_method, Class::_class, "getName", "()Ljava/lang/String;"); |
|
370 |
|
371 IN_CLASS(jdk_vm_ci_hotspot_HotSpotResolvedPrimitiveType); |
|
372 GET_JNI_METHOD(GetStaticMethodID, _HotSpotResolvedPrimitiveType_fromMetaspace_method, HotSpotResolvedPrimitiveType::_class, |
|
373 vmSymbols::fromMetaspace_name()->as_C_string(), |
|
374 vmSymbols::primitive_fromMetaspace_signature()->as_C_string()); |
|
375 IN_CLASS(jdk_vm_ci_hotspot_HotSpotResolvedObjectTypeImpl); |
|
376 GET_JNI_METHOD(GetStaticMethodID, _HotSpotResolvedObjectTypeImpl_fromMetaspace_method, HotSpotResolvedObjectTypeImpl::_class, |
|
377 vmSymbols::fromMetaspace_name()->as_C_string(), |
|
378 vmSymbols::klass_fromMetaspace_signature()->as_C_string()); |
|
379 IN_CLASS(jdk_vm_ci_hotspot_HotSpotConstantPool); |
|
380 GET_JNI_METHOD(GetStaticMethodID, _HotSpotConstantPool_fromMetaspace_method, HotSpotConstantPool::_class, |
|
381 vmSymbols::fromMetaspace_name()->as_C_string(), |
|
382 vmSymbols::constantPool_fromMetaspace_signature()->as_C_string()); |
|
383 IN_CLASS(jdk_vm_ci_hotspot_HotSpotResolvedJavaMethodImpl); |
|
384 GET_JNI_METHOD(GetStaticMethodID, _HotSpotResolvedJavaMethodImpl_fromMetaspace_method, HotSpotResolvedJavaMethodImpl::_class, |
|
385 vmSymbols::fromMetaspace_name()->as_C_string(), |
|
386 vmSymbols::method_fromMetaspace_signature()->as_C_string()); |
|
387 |
|
388 #define BOX_CLASSES(generate) \ |
|
389 generate(Boolean, T_BOOLEAN, Z) \ |
|
390 generate(Byte, T_BYTE, B) \ |
|
391 generate(Character, T_CHAR, C) \ |
|
392 generate(Short, T_SHORT, S) \ |
|
393 generate(Integer, T_INT, I) \ |
|
394 generate(Long, T_LONG, J) \ |
|
395 generate(Float, T_FLOAT, F) \ |
|
396 generate(Double, T_DOUBLE, D) \ |
|
397 |
|
398 #define DO_BOX_CLASS(klass, basicType, type) \ |
|
399 current_class_name = "java/lang/" #klass; \ |
|
400 if (JVMCILibDumpJNIConfig == NULL) { \ |
|
401 _box_classes[basicType] = env->FindClass("java/lang/" #klass); \ |
|
402 JVMCI_EXCEPTION_CHECK(env, "FindClass(%s)", #klass); \ |
|
403 _box_classes[basicType] = (jclass) env->NewGlobalRef(_box_classes[basicType]); \ |
|
404 assert(_box_classes[basicType] != NULL, "uninitialized"); \ |
|
405 _box_fields[basicType] = env->GetFieldID(_box_classes[basicType], "value", #type); \ |
|
406 JVMCI_EXCEPTION_CHECK(env, "GetFieldID(%s, value, %s)", #klass, #type); \ |
|
407 GET_JNI_METHOD(GetMethodID, _box_constructors[basicType], _box_classes[basicType], "<init>", "(" #type ")V"); \ |
|
408 } else { \ |
|
409 fileStream* st = JVMCIGlobals::get_jni_config_file(); \ |
|
410 st->print_cr("field %s value %s", current_class_name, #type); \ |
|
411 st->print_cr("method %s <init> (%s)V", current_class_name, #type); \ |
|
412 } |
|
413 |
|
414 BOX_CLASSES(DO_BOX_CLASS); |
|
415 |
|
416 if (JVMCILibDumpJNIConfig == NULL) { |
|
417 _byte_array = env->FindClass("[B"); |
|
418 JVMCI_EXCEPTION_CHECK(env, "FindClass([B)"); |
|
419 _byte_array = (jclass) env->NewGlobalRef(_byte_array); |
|
420 assert(_byte_array != NULL, "uninitialized"); |
|
421 } else { |
|
422 fileStream* st = JVMCIGlobals::get_jni_config_file(); |
|
423 st->print_cr("class [B"); |
|
424 } |
|
425 |
|
426 #define DUMP_ALL_NATIVE_METHODS(class_symbol) do { \ |
|
427 current_class_name = class_symbol->as_C_string(); \ |
|
428 Klass* k = SystemDictionary::resolve_or_fail(class_symbol, true, CHECK_EXIT); \ |
|
429 InstanceKlass* iklass = InstanceKlass::cast(k); \ |
|
430 Array<Method*>* methods = iklass->methods(); \ |
|
431 for (int i = 0; i < methods->length(); i++) { \ |
|
432 Method* m = methods->at(i); \ |
|
433 if (m->is_native()) { \ |
|
434 st->print_cr("method %s %s %s", current_class_name, m->name()->as_C_string(), m->signature()->as_C_string()); \ |
|
435 } \ |
|
436 } \ |
|
437 } while(0) |
|
438 |
|
439 if (JVMCILibDumpJNIConfig != NULL) { |
|
440 Thread* THREAD = Thread::current(); |
|
441 fileStream* st = JVMCIGlobals::get_jni_config_file(); |
|
442 |
|
443 DUMP_ALL_NATIVE_METHODS(vmSymbols::jdk_vm_ci_hotspot_CompilerToVM()); |
|
444 |
|
445 st->flush(); |
|
446 tty->print_cr("Dumped JVMCI shared library JNI configuration to %s", JVMCILibDumpJNIConfig); |
|
447 vm_exit(0); |
|
448 } |
|
449 |
|
450 #undef DUMP_ALL_NATIVE_METHODS |
|
451 #undef DO_BOX_CLASS |
|
452 #undef BOX_CLASSES |
|
453 #undef IN_CLASS |
|
454 |
|
455 #define CC (char*) /*cast a literal from (const char*)*/ |
|
456 #define FN_PTR(f) CAST_FROM_FN_PTR(void*, &(f)) |
|
457 |
|
458 if (env != JavaThread::current()->jni_environment()) { |
|
459 jclass clazz = env->FindClass("jdk/vm/ci/hotspot/CompilerToVM"); |
|
460 if (env->ExceptionCheck()) { |
|
461 env->ExceptionDescribe(); |
|
462 guarantee(false, "Could not find class jdk/vm/ci/hotspot/CompilerToVM"); |
|
463 } |
|
464 JNINativeMethod CompilerToVM_native_methods[] = { |
|
465 { CC"registerNatives", CC"()V", FN_PTR(JVM_RegisterJVMCINatives) }, |
|
466 }; |
|
467 env->RegisterNatives(clazz, CompilerToVM_native_methods, 1); |
|
468 if (env->ExceptionCheck()) { |
|
469 env->ExceptionDescribe(); |
|
470 guarantee(false, ""); |
|
471 } |
|
472 |
|
473 JNINativeMethod JVMCI_native_methods[] = { |
|
474 { CC"initializeRuntime", CC"()Ljdk/vm/ci/runtime/JVMCIRuntime;", FN_PTR(JVM_GetJVMCIRuntime) }, |
|
475 }; |
|
476 env->RegisterNatives(JVMCI::clazz(), JVMCI_native_methods, 1); |
|
477 if (env->ExceptionCheck()) { |
|
478 env->ExceptionDescribe(); |
|
479 guarantee(false, ""); |
|
480 } |
|
481 } |
|
482 } |
|
483 |
|
484 #undef METHOD |
|
485 #undef CONSTRUCTOR |
|
486 #undef FIELD2 |
|
487 |
|
488 #define EMPTY0 |
|
489 #define EMPTY1(x) |
|
490 #define EMPTY2(x,y) |
|
491 #define FIELD3(className, name, sig) FIELD2(className, name) |
|
492 #define FIELD2(className, name) \ |
|
493 jfieldID JNIJVMCI::className::_##name##_field_id = 0; \ |
|
494 int HotSpotJVMCI::className::_##name##_offset = 0; |
|
495 #define METHOD(jniCallType, jniGetMethod, hsCallType, returnType, className, methodName, signatureSymbolName, args) |
|
496 #define CONSTRUCTOR(className, signature) |
|
497 |
|
498 // Generates the definitions of static fields used by the accessors. For example: |
|
499 // jfieldID JNIJVMCI::Architecture::_wordKind_field_id = 0; |
|
500 // jfieldID HotSpotJVMCI::Architecture::_wordKind_offset = 0; |
|
501 JVMCI_CLASSES_DO(EMPTY2, EMPTY0, FIELD2, FIELD2, FIELD2, FIELD2, FIELD2, FIELD3, FIELD3, FIELD3, FIELD3, FIELD3, FIELD2, FIELD2, METHOD, CONSTRUCTOR) |
|
502 |
|
503 #undef START_CLASS |
|
504 #undef END_CLASS |
|
505 #undef METHOD |
|
506 #undef CONSTRUCTOR |
|
507 #undef FIELD |
|
508 #undef CHAR_FIELD |
|
509 #undef INT_FIELD |
|
510 #undef BOOLEAN_FIELD |
|
511 #undef LONG_FIELD |
|
512 #undef FLOAT_FIELD |
|
513 #undef OBJECT_FIELD |
|
514 #undef PRIMARRAY_FIELD |
|
515 #undef OBJECTARRAY_FIELD |
|
516 #undef STATIC_FIELD |
|
517 #undef STATIC_OBJECT_FIELD |
|
518 #undef STATIC_OBJECTARRAY_FIELD |
|
519 #undef STATIC_INT_FIELD |
|
520 #undef STATIC_BOOLEAN_FIELD |
|
521 #undef EMPTY_CAST |
|
522 |
|
523 |
|
524 #define START_CLASS(className, fullClassName) \ |
|
525 void JNIJVMCI::className::initialize(JVMCI_TRAPS) { \ |
|
526 /* should already be initialized */ \ |
|
527 } \ |
|
528 bool JNIJVMCI::className::is_instance(JVMCIEnv* jvmciEnv, JVMCIObject object) { \ |
|
529 JNIAccessMark jni(jvmciEnv); \ |
|
530 return jni()->IsInstanceOf(object.as_jobject(), className::clazz()) != 0; \ |
|
531 } \ |
|
532 void JNIJVMCI::className::check(JVMCIEnv* jvmciEnv, JVMCIObject obj, const char* field_name, jfieldID offset) { \ |
|
533 assert(obj.is_non_null(), "NULL field access of %s.%s", #className, field_name); \ |
|
534 assert(jvmciEnv->isa_##className(obj), "wrong class, " #className " expected, found %s", jvmciEnv->klass_name(obj)); \ |
|
535 assert(offset != 0, "must be valid offset"); \ |
|
536 } \ |
|
537 jclass JNIJVMCI::className::_class = NULL; |
41 |
538 |
42 #define END_CLASS |
539 #define END_CLASS |
43 |
540 |
44 #define FIELD(klass, name, type, accessor, cast) \ |
541 #define FIELD(className, name, type, accessor, cast) \ |
45 type klass::name(jobject obj) { check(JNIHandles::resolve(obj), #name, _##name##_offset); return cast JNIHandles::resolve(obj)->accessor(_##name##_offset); } \ |
542 type JNIJVMCI::className::get_##name(JVMCIEnv* jvmciEnv, JVMCIObject obj) { \ |
46 void klass::set_##name(jobject obj, type x) { check(JNIHandles::resolve(obj), #name, _##name##_offset); JNIHandles::resolve(obj)->accessor##_put(_##name##_offset, x); } |
543 className::check(jvmciEnv, obj, #name, className::_##name##_field_id); \ |
|
544 JNIAccessMark jni(jvmciEnv); \ |
|
545 return cast jni()->Get##accessor##Field(resolve_handle(obj), className::_##name##_field_id); \ |
|
546 } \ |
|
547 void JNIJVMCI::className::set_##name(JVMCIEnv* jvmciEnv, JVMCIObject obj, type x) { \ |
|
548 className::check(jvmciEnv, obj, #name, className::_##name##_field_id); \ |
|
549 JNIAccessMark jni(jvmciEnv); \ |
|
550 jni()->Set##accessor##Field(resolve_handle(obj), className::_##name##_field_id, x); \ |
|
551 } \ |
47 |
552 |
48 #define EMPTY_CAST |
553 #define EMPTY_CAST |
49 #define CHAR_FIELD(klass, name) FIELD(klass, name, jchar, char_field, EMPTY_CAST) |
554 #define CHAR_FIELD(className, name) FIELD(className, name, jchar, Char, EMPTY_CAST) |
50 #define INT_FIELD(klass, name) FIELD(klass, name, jint, int_field, EMPTY_CAST) |
555 #define INT_FIELD(className, name) FIELD(className, name, jint, Int, EMPTY_CAST) |
51 #define BOOLEAN_FIELD(klass, name) FIELD(klass, name, jboolean, bool_field, EMPTY_CAST) |
556 #define BOOLEAN_FIELD(className, name) FIELD(className, name, jboolean, Boolean, EMPTY_CAST) |
52 #define LONG_FIELD(klass, name) FIELD(klass, name, jlong, long_field, EMPTY_CAST) |
557 #define LONG_FIELD(className, name) FIELD(className, name, jlong, Long, EMPTY_CAST) |
53 #define FLOAT_FIELD(klass, name) FIELD(klass, name, jfloat, float_field, EMPTY_CAST) |
558 #define FLOAT_FIELD(className, name) FIELD(className, name, jfloat, Float, EMPTY_CAST) |
54 #define OOP_FIELD(klass, name, signature) FIELD(klass, name, oop, obj_field, EMPTY_CAST) |
559 |
55 #define OBJARRAYOOP_FIELD(klass, name, signature) FIELD(klass, name, objArrayOop, obj_field, (objArrayOop)) |
560 #define OBJECT_FIELD(className, name, signature) OOPISH_FIELD(className, name, JVMCIObject, Object, EMPTY_CAST) |
56 #define TYPEARRAYOOP_FIELD(klass, name, signature) FIELD(klass, name, typeArrayOop, obj_field, (typeArrayOop)) |
561 #define OBJECTARRAY_FIELD(className, name, signature) OOPISH_FIELD(className, name, JVMCIObjectArray, Object, (JVMCIObjectArray)) |
57 #define STATIC_OOP_FIELD(klassName, name, signature) STATIC_OOPISH_FIELD(klassName, name, oop, signature) |
562 #define PRIMARRAY_FIELD(className, name, signature) OOPISH_FIELD(className, name, JVMCIPrimitiveArray, Object, (JVMCIPrimitiveArray)) |
58 #define STATIC_OBJARRAYOOP_FIELD(klassName, name, signature) STATIC_OOPISH_FIELD(klassName, name, objArrayOop, signature) |
563 |
59 #define STATIC_OOPISH_FIELD(klassName, name, type, signature) \ |
564 #define STATIC_OBJECT_FIELD(className, name, signature) STATIC_OOPISH_FIELD(className, name, JVMCIObject, Object, (JVMCIObject)) |
60 type klassName::name() { \ |
565 #define STATIC_OBJECTARRAY_FIELD(className, name, signature) STATIC_OOPISH_FIELD(className, name, JVMCIObjectArray, Object, (JVMCIObjectArray)) |
61 assert(klassName::klass() != NULL && klassName::klass()->is_linked(), "Class not yet linked: " #klassName); \ |
566 |
62 InstanceKlass* ik = klassName::klass(); \ |
567 #define OOPISH_FIELD(className, name, type, accessor, cast) \ |
63 oop base = ik->static_field_base_raw(); \ |
568 type JNIJVMCI::className::get_##name(JVMCIEnv* jvmciEnv, JVMCIObject obj) { \ |
64 oop result = HeapAccess<>::oop_load_at(base, _##name##_offset); \ |
569 className::check(jvmciEnv, obj, #name, className::_##name##_field_id); \ |
65 return type(result); \ |
570 JNIAccessMark jni(jvmciEnv); \ |
66 } \ |
571 return cast wrap(jni()->Get##accessor##Field(resolve_handle(obj), className::_##name##_field_id)); \ |
67 void klassName::set_##name(type x) { \ |
572 } \ |
68 assert(klassName::klass() != NULL && klassName::klass()->is_linked(), "Class not yet linked: " #klassName); \ |
573 void JNIJVMCI::className::set_##name(JVMCIEnv* jvmciEnv, JVMCIObject obj, type x) { \ |
69 assert(klassName::klass() != NULL, "Class not yet loaded: " #klassName); \ |
574 className::check(jvmciEnv, obj, #name, className::_##name##_field_id); \ |
70 InstanceKlass* ik = klassName::klass(); \ |
575 JNIAccessMark jni(jvmciEnv); \ |
71 oop base = ik->static_field_base_raw(); \ |
576 jni()->Set##accessor##Field(resolve_handle(obj), className::_##name##_field_id, resolve_handle(x)); \ |
72 HeapAccess<>::oop_store_at(base, _##name##_offset, x); \ |
577 } |
73 } |
578 |
74 #define STATIC_PRIMITIVE_FIELD(klassName, name, jtypename) \ |
579 #define STATIC_OOPISH_FIELD(className, name, type, accessor, cast) \ |
75 jtypename klassName::name() { \ |
580 type JNIJVMCI::className::get_##name(JVMCIEnv* jvmciEnv) { \ |
76 assert(klassName::klass() != NULL && klassName::klass()->is_linked(), "Class not yet linked: " #klassName); \ |
581 JNIAccessMark jni(jvmciEnv); \ |
77 InstanceKlass* ik = klassName::klass(); \ |
582 return cast wrap(jni()->GetStatic##accessor##Field(className::clazz(), className::_##name##_field_id)); \ |
78 oop base = ik->static_field_base_raw(); \ |
583 } \ |
79 return HeapAccess<>::load_at(base, _##name##_offset); \ |
584 void JNIJVMCI::className::set_##name(JVMCIEnv* jvmciEnv, type x) { \ |
80 } \ |
585 JNIAccessMark jni(jvmciEnv); \ |
81 void klassName::set_##name(jtypename x) { \ |
586 jni()->SetStatic##accessor##Field(className::clazz(), className::_##name##_field_id, resolve_handle(x)); \ |
82 assert(klassName::klass() != NULL && klassName::klass()->is_linked(), "Class not yet linked: " #klassName); \ |
587 } |
83 InstanceKlass* ik = klassName::klass(); \ |
588 |
84 oop base = ik->static_field_base_raw(); \ |
589 #define STATIC_PRIMITIVE_FIELD(className, name, type, accessor, cast) \ |
85 HeapAccess<>::store_at(base, _##name##_offset, x); \ |
590 type JNIJVMCI::className::get_##name(JVMCIEnv* jvmciEnv) { \ |
86 } |
591 JNIAccessMark jni(jvmciEnv); \ |
87 |
592 return cast jni()->GetStatic##accessor##Field(className::clazz(), className::_##name##_field_id); \ |
88 #define STATIC_INT_FIELD(klassName, name) STATIC_PRIMITIVE_FIELD(klassName, name, jint) |
593 } \ |
89 #define STATIC_BOOLEAN_FIELD(klassName, name) STATIC_PRIMITIVE_FIELD(klassName, name, jboolean) |
594 void JNIJVMCI::className::set_##name(JVMCIEnv* jvmciEnv, type x) { \ |
90 |
595 JNIAccessMark jni(jvmciEnv); \ |
91 COMPILER_CLASSES_DO(START_CLASS, END_CLASS, CHAR_FIELD, INT_FIELD, BOOLEAN_FIELD, LONG_FIELD, FLOAT_FIELD, OOP_FIELD, TYPEARRAYOOP_FIELD, OBJARRAYOOP_FIELD, STATIC_OOP_FIELD, STATIC_OBJARRAYOOP_FIELD, STATIC_INT_FIELD, STATIC_BOOLEAN_FIELD) |
596 jni()->SetStatic##accessor##Field(className::clazz(), className::_##name##_field_id, x); \ |
|
597 } |
|
598 |
|
599 #define STATIC_INT_FIELD(className, name) STATIC_PRIMITIVE_FIELD(className, name, jint, Int, EMPTY_CAST) |
|
600 #define STATIC_BOOLEAN_FIELD(className, name) STATIC_PRIMITIVE_FIELD(className, name, jboolean, Boolean, EMPTY_CAST) |
|
601 #define METHOD(jniCallType, jniGetMethod, hsCallType, returnType, className, methodName, signatureSymbolName, args) \ |
|
602 jmethodID JNIJVMCI::className::_##methodName##_method; |
|
603 |
|
604 #define CONSTRUCTOR(className, signature) \ |
|
605 jmethodID JNIJVMCI::className::_constructor; |
|
606 |
|
607 /** |
|
608 * Generates the method definitions for the classes in HotSpotJVMCI. |
|
609 */ |
|
610 JVMCI_CLASSES_DO(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) |
|
611 |
|
612 #undef METHOD |
|
613 #undef CONSTRUCTOR |
92 #undef START_CLASS |
614 #undef START_CLASS |
93 #undef END_CLASS |
615 #undef END_CLASS |
94 #undef FIELD |
616 #undef FIELD |
95 #undef CHAR_FIELD |
617 #undef CHAR_FIELD |
96 #undef INT_FIELD |
618 #undef INT_FIELD |
97 #undef BOOLEAN_FIELD |
619 #undef BOOLEAN_FIELD |
98 #undef LONG_FIELD |
620 #undef LONG_FIELD |
99 #undef FLOAT_FIELD |
621 #undef FLOAT_FIELD |
100 #undef OOP_FIELD |
622 #undef OBJECT_FIELD |
101 #undef TYPEARRAYOOP_FIELD |
623 #undef PRIMARRAY_FIELD |
102 #undef OBJARRAYOOP_FIELD |
624 #undef OBJECTARRAY_FIELD |
103 #undef STATIC_OOPISH_FIELD |
625 #undef STATIC_OOPISH_FIELD |
104 #undef STATIC_OOP_FIELD |
626 #undef STATIC_OBJECT_FIELD |
105 #undef STATIC_OBJARRAYOOP_FIELD |
627 #undef STATIC_OBJECTARRAY_FIELD |
106 #undef STATIC_INT_FIELD |
628 #undef STATIC_INT_FIELD |
107 #undef STATIC_BOOLEAN_FIELD |
629 #undef STATIC_BOOLEAN_FIELD |
108 #undef STATIC_PRIMITIVE_FIELD |
630 #undef STATIC_PRIMITIVE_FIELD |
|
631 #undef OOPISH_FIELD |
109 #undef EMPTY_CAST |
632 #undef EMPTY_CAST |
110 |
|
111 // This function is similar to javaClasses.cpp, it computes the field offset of a (static or instance) field. |
|
112 // It looks up the name and signature symbols without creating new ones, all the symbols of these classes need to be already loaded. |
|
113 |
|
114 void compute_offset(int &dest_offset, Klass* klass, const char* name, const char* signature, bool static_field, TRAPS) { |
|
115 InstanceKlass* ik = InstanceKlass::cast(klass); |
|
116 Symbol* name_symbol = SymbolTable::probe(name, (int)strlen(name)); |
|
117 Symbol* signature_symbol = SymbolTable::probe(signature, (int)strlen(signature)); |
|
118 if (name_symbol == NULL || signature_symbol == NULL) { |
|
119 #ifndef PRODUCT |
|
120 ik->print_on(tty); |
|
121 #endif |
|
122 fatal("symbol with name %s and signature %s was not found in symbol table (klass=%s)", name, signature, klass->name()->as_C_string()); |
|
123 } |
|
124 |
|
125 fieldDescriptor fd; |
|
126 if (!ik->find_field(name_symbol, signature_symbol, &fd)) { |
|
127 ResourceMark rm; |
|
128 fatal("Invalid layout of %s %s at %s", name_symbol->as_C_string(), signature_symbol->as_C_string(), ik->external_name()); |
|
129 } |
|
130 guarantee(fd.is_static() == static_field, "static/instance mismatch"); |
|
131 dest_offset = fd.offset(); |
|
132 assert(dest_offset != 0, "must be valid offset"); |
|
133 if (static_field) { |
|
134 // Must ensure classes for static fields are initialized as the |
|
135 // accessor itself does not include a class initialization check. |
|
136 ik->initialize(CHECK); |
|
137 } |
|
138 } |
|
139 |
|
140 // This piece of macro magic creates the contents of the jvmci_compute_offsets method that initializes the field indices of all the access classes. |
|
141 |
|
142 #define START_CLASS(name) { Klass* k = SystemDictionary::name##_klass(); assert(k != NULL, "Could not find class " #name ""); |
|
143 |
|
144 #define END_CLASS } |
|
145 |
|
146 #define FIELD(klass, name, signature, static_field) compute_offset(klass::_##name##_offset, k, #name, signature, static_field, CHECK); |
|
147 #define CHAR_FIELD(klass, name) FIELD(klass, name, "C", false) |
|
148 #define INT_FIELD(klass, name) FIELD(klass, name, "I", false) |
|
149 #define BOOLEAN_FIELD(klass, name) FIELD(klass, name, "Z", false) |
|
150 #define LONG_FIELD(klass, name) FIELD(klass, name, "J", false) |
|
151 #define FLOAT_FIELD(klass, name) FIELD(klass, name, "F", false) |
|
152 #define OOP_FIELD(klass, name, signature) FIELD(klass, name, signature, false) |
|
153 #define STATIC_OOP_FIELD(klass, name, signature) FIELD(klass, name, signature, true) |
|
154 #define STATIC_INT_FIELD(klass, name) FIELD(klass, name, "I", true) |
|
155 #define STATIC_BOOLEAN_FIELD(klass, name) FIELD(klass, name, "Z", true) |
|
156 |
|
157 |
|
158 void JVMCIJavaClasses::compute_offsets(TRAPS) { |
|
159 COMPILER_CLASSES_DO(START_CLASS, END_CLASS, CHAR_FIELD, INT_FIELD, BOOLEAN_FIELD, LONG_FIELD, FLOAT_FIELD, OOP_FIELD, OOP_FIELD, OOP_FIELD, STATIC_OOP_FIELD, STATIC_OOP_FIELD, STATIC_INT_FIELD, STATIC_BOOLEAN_FIELD) |
|
160 } |
|
161 |
|
162 #define EMPTY0 |
|
163 #define EMPTY1(x) |
|
164 #define EMPTY2(x,y) |
|
165 #define FIELD2(klass, name) int klass::_##name##_offset = 0; |
|
166 #define FIELD3(klass, name, sig) FIELD2(klass, name) |
|
167 |
|
168 COMPILER_CLASSES_DO(EMPTY1, EMPTY0, FIELD2, FIELD2, FIELD2, FIELD2, FIELD2, FIELD3, FIELD3, FIELD3, FIELD3, FIELD3, FIELD2, FIELD2) |
|
169 |
|