Mercurial > hg > graal-jvmci-8
comparison src/share/vm/jvmci/jvmciJavaAccess.hpp @ 22454:76af33d4d504
Make jvmci redefinition safe
author | Tom Rodriguez <tom.rodriguez@oracle.com> |
---|---|
date | Fri, 21 Aug 2015 11:57:29 -0700 |
parents | 7b4a47fcc4c0 |
children | 3fb432661d59 |
comparison
equal
deleted
inserted
replaced
22453:d6bbd5d8d81e | 22454:76af33d4d504 |
---|---|
45 * static void set_index(jobject obj, jint x); | 45 * static void set_index(jobject obj, jint x); |
46 * }; | 46 * }; |
47 * | 47 * |
48 */ | 48 */ |
49 | 49 |
50 #define 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_int_field, static_boolean_field) \ | 50 #define 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) \ |
51 start_class(HotSpotResolvedObjectTypeImpl) \ | 51 start_class(HotSpotResolvedObjectTypeImpl) \ |
52 oop_field(HotSpotResolvedObjectTypeImpl, javaClass, "Ljava/lang/Class;") \ | 52 oop_field(HotSpotResolvedObjectTypeImpl, javaClass, "Ljava/lang/Class;") \ |
53 end_class \ | 53 end_class \ |
54 start_class(HotSpotResolvedJavaMethodImpl) \ | 54 start_class(HotSpotResolvedJavaMethodImpl) \ |
55 long_field(HotSpotResolvedJavaMethodImpl, metaspaceMethod) \ | 55 long_field(HotSpotResolvedJavaMethodImpl, metaspaceMethod) \ |
92 int_field(HotSpotCompiledNmethod, entryBCI) \ | 92 int_field(HotSpotCompiledNmethod, entryBCI) \ |
93 int_field(HotSpotCompiledNmethod, id) \ | 93 int_field(HotSpotCompiledNmethod, id) \ |
94 long_field(HotSpotCompiledNmethod, jvmciEnv) \ | 94 long_field(HotSpotCompiledNmethod, jvmciEnv) \ |
95 boolean_field(HotSpotCompiledNmethod, hasUnsafeAccess) \ | 95 boolean_field(HotSpotCompiledNmethod, hasUnsafeAccess) \ |
96 end_class \ | 96 end_class \ |
97 start_class(HotSpotJVMCIMetaAccessContext) \ | |
98 static_objArrayOop_field(HotSpotJVMCIMetaAccessContext, allContexts, "[Ljava/lang/ref/WeakReference;") \ | |
99 objArrayOop_field(HotSpotJVMCIMetaAccessContext, metadataRoots, "[Ljava/lang/Object;") \ | |
100 end_class \ | |
97 start_class(HotSpotForeignCallTarget) \ | 101 start_class(HotSpotForeignCallTarget) \ |
98 long_field(HotSpotForeignCallTarget, address) \ | 102 long_field(HotSpotForeignCallTarget, address) \ |
99 end_class \ | 103 end_class \ |
100 start_class(Assumptions_NoFinalizableSubclass) \ | 104 start_class(Assumptions_NoFinalizableSubclass) \ |
101 oop_field(Assumptions_NoFinalizableSubclass, receiverType, "Ljdk/internal/jvmci/meta/ResolvedJavaType;") \ | 105 oop_field(Assumptions_NoFinalizableSubclass, receiverType, "Ljdk/internal/jvmci/meta/ResolvedJavaType;") \ |
251 start_class(HotSpotStackFrameReference) \ | 255 start_class(HotSpotStackFrameReference) \ |
252 oop_field(HotSpotStackFrameReference, compilerToVM, "Ljdk/internal/jvmci/hotspot/CompilerToVM;") \ | 256 oop_field(HotSpotStackFrameReference, compilerToVM, "Ljdk/internal/jvmci/hotspot/CompilerToVM;") \ |
253 long_field(HotSpotStackFrameReference, stackPointer) \ | 257 long_field(HotSpotStackFrameReference, stackPointer) \ |
254 int_field(HotSpotStackFrameReference, frameNumber) \ | 258 int_field(HotSpotStackFrameReference, frameNumber) \ |
255 int_field(HotSpotStackFrameReference, bci) \ | 259 int_field(HotSpotStackFrameReference, bci) \ |
256 long_field(HotSpotStackFrameReference, metaspaceMethod) \ | 260 oop_field(HotSpotStackFrameReference, method, "Ljdk/internal/jvmci/hotspot/HotSpotResolvedJavaMethod;") \ |
257 objArrayOop_field(HotSpotStackFrameReference, locals, "[Ljava/lang/Object;") \ | 261 objArrayOop_field(HotSpotStackFrameReference, locals, "[Ljava/lang/Object;") \ |
258 typeArrayOop_field(HotSpotStackFrameReference, localIsVirtual, "[Z") \ | 262 typeArrayOop_field(HotSpotStackFrameReference, localIsVirtual, "[Z") \ |
259 end_class | 263 end_class \ |
260 \ | 264 start_class(HotSpotConstantPool) \ |
265 long_field(HotSpotConstantPool, metaspaceConstantPool) \ | |
266 end_class \ | |
261 /* end*/ | 267 /* end*/ |
262 | 268 |
263 #define START_CLASS(name) \ | 269 #define START_CLASS(name) \ |
264 class name : AllStatic { \ | 270 class name : AllStatic { \ |
265 private: \ | 271 private: \ |
266 friend class JVMCICompiler; \ | 272 friend class JVMCICompiler; \ |
267 static void check(oop obj, const char* field_name) { \ | 273 static void check(oop obj, const char* field_name, int offset) { \ |
268 assert(obj != NULL, err_msg("NULL field access of %s.%s", #name, field_name)); \ | 274 assert(obj != NULL, err_msg("NULL field access of %s.%s", #name, field_name)); \ |
269 assert(obj->is_a(SystemDictionary::name##_klass()), "wrong class, " #name " expected"); \ | 275 assert(obj->is_a(SystemDictionary::name##_klass()), err_msg("wrong class, " #name " expected, found %s", obj->klass()->external_name())); \ |
276 assert(offset != 0, "must be valid offset"); \ | |
270 } \ | 277 } \ |
271 static void compute_offsets(); \ | 278 static void compute_offsets(); \ |
272 public: \ | 279 public: \ |
273 static Klass* klass() { return SystemDictionary::name##_klass(); } | 280 static Klass* klass() { return SystemDictionary::name##_klass(); } |
274 | 281 |
275 #define END_CLASS }; | 282 #define END_CLASS }; |
276 | 283 |
277 #define FIELD(name, type, accessor, cast) \ | 284 #define FIELD(name, type, accessor, cast) \ |
278 static int _##name##_offset; \ | 285 static int _##name##_offset; \ |
279 static type name(oop obj) { check(obj, #name); return cast obj->accessor(_##name##_offset); } \ | 286 static type name(oop obj) { check(obj, #name, _##name##_offset); return cast obj->accessor(_##name##_offset); } \ |
280 static type name(Handle& obj) { check(obj(), #name); return cast obj->accessor(_##name##_offset); } \ | 287 static type name(Handle& obj) { check(obj(), #name, _##name##_offset); return cast obj->accessor(_##name##_offset); } \ |
281 static type name(jobject obj) { check(JNIHandles::resolve(obj), #name); return cast JNIHandles::resolve(obj)->accessor(_##name##_offset); } \ | 288 static type name(jobject obj) { check(JNIHandles::resolve(obj), #name, _##name##_offset); return cast JNIHandles::resolve(obj)->accessor(_##name##_offset); } \ |
282 static void set_##name(oop obj, type x) { check(obj, #name); obj->accessor##_put(_##name##_offset, x); } \ | 289 static void set_##name(oop obj, type x) { check(obj, #name, _##name##_offset); obj->accessor##_put(_##name##_offset, x); } \ |
283 static void set_##name(Handle& obj, type x) { check(obj(), #name); obj->accessor##_put(_##name##_offset, x); } \ | 290 static void set_##name(Handle& obj, type x) { check(obj(), #name, _##name##_offset); obj->accessor##_put(_##name##_offset, x); } \ |
284 static void set_##name(jobject obj, type x) { check(JNIHandles::resolve(obj), #name); JNIHandles::resolve(obj)->accessor##_put(_##name##_offset, x); } | 291 static void set_##name(jobject obj, type x) { check(JNIHandles::resolve(obj), #name, _##name##_offset); JNIHandles::resolve(obj)->accessor##_put(_##name##_offset, x); } |
285 | 292 |
286 #define EMPTY_CAST | 293 #define EMPTY_CAST |
287 #define CHAR_FIELD(klass, name) FIELD(name, jchar, char_field, EMPTY_CAST) | 294 #define CHAR_FIELD(klass, name) FIELD(name, jchar, char_field, EMPTY_CAST) |
288 #define INT_FIELD(klass, name) FIELD(name, jint, int_field, EMPTY_CAST) | 295 #define INT_FIELD(klass, name) FIELD(name, jint, int_field, EMPTY_CAST) |
289 #define BOOLEAN_FIELD(klass, name) FIELD(name, jboolean, bool_field, EMPTY_CAST) | 296 #define BOOLEAN_FIELD(klass, name) FIELD(name, jboolean, bool_field, EMPTY_CAST) |
290 #define LONG_FIELD(klass, name) FIELD(name, jlong, long_field, EMPTY_CAST) | 297 #define LONG_FIELD(klass, name) FIELD(name, jlong, long_field, EMPTY_CAST) |
291 #define FLOAT_FIELD(klass, name) FIELD(name, jfloat, float_field, EMPTY_CAST) | 298 #define FLOAT_FIELD(klass, name) FIELD(name, jfloat, float_field, EMPTY_CAST) |
292 #define OOP_FIELD(klass, name, signature) FIELD(name, oop, obj_field, EMPTY_CAST) | 299 #define OOP_FIELD(klass, name, signature) FIELD(name, oop, obj_field, EMPTY_CAST) |
293 #define OBJARRAYOOP_FIELD(klass, name, signature) FIELD(name, objArrayOop, obj_field, (objArrayOop)) | 300 #define OBJARRAYOOP_FIELD(klass, name, signature) FIELD(name, objArrayOop, obj_field, (objArrayOop)) |
294 #define TYPEARRAYOOP_FIELD(klass, name, signature) FIELD(name, typeArrayOop, obj_field, (typeArrayOop)) | 301 #define TYPEARRAYOOP_FIELD(klass, name, signature) FIELD(name, typeArrayOop, obj_field, (typeArrayOop)) |
295 #define STATIC_OOP_FIELD(klassName, name, signature) \ | 302 #define STATIC_OOP_FIELD(klassName, name, signature) STATIC_OOPISH_FIELD(klassName, name, oop, signature) |
303 #define STATIC_OBJARRAYOOP_FIELD(klassName, name, signature) STATIC_OOPISH_FIELD(klassName, name, objArrayOop, signature) | |
304 #define STATIC_OOPISH_FIELD(klassName, name, type, signature) \ | |
296 static int _##name##_offset; \ | 305 static int _##name##_offset; \ |
297 static oop name() { \ | 306 static type name() { \ |
298 InstanceKlass* ik = InstanceKlass::cast(klassName::klass()); \ | 307 InstanceKlass* ik = InstanceKlass::cast(klassName::klass()); \ |
299 address addr = ik->static_field_addr(_##name##_offset - InstanceMirrorKlass::offset_of_static_fields()); \ | 308 address addr = ik->static_field_addr(_##name##_offset - InstanceMirrorKlass::offset_of_static_fields()); \ |
300 if (UseCompressedOops) { \ | 309 if (UseCompressedOops) { \ |
301 return oopDesc::load_decode_heap_oop((narrowOop *)addr); \ | 310 return (type) oopDesc::load_decode_heap_oop((narrowOop *)addr); \ |
302 } else { \ | 311 } else { \ |
303 return oopDesc::load_decode_heap_oop((oop*)addr); \ | 312 return (type) oopDesc::load_decode_heap_oop((oop*)addr); \ |
304 } \ | 313 } \ |
305 } \ | 314 } \ |
306 static void set_##name(oop x) { \ | 315 static void set_##name(type x) { \ |
307 InstanceKlass* ik = InstanceKlass::cast(klassName::klass()); \ | 316 InstanceKlass* ik = InstanceKlass::cast(klassName::klass()); \ |
308 address addr = ik->static_field_addr(_##name##_offset - InstanceMirrorKlass::offset_of_static_fields()); \ | 317 address addr = ik->static_field_addr(_##name##_offset - InstanceMirrorKlass::offset_of_static_fields()); \ |
309 if (UseCompressedOops) { \ | 318 if (UseCompressedOops) { \ |
310 oop_store((narrowOop *)addr, x); \ | 319 oop_store((narrowOop *)addr, x); \ |
311 } else { \ | 320 } else { \ |
326 } | 335 } |
327 | 336 |
328 #define STATIC_INT_FIELD(klassName, name) STATIC_PRIMITIVE_FIELD(klassName, name, jint) | 337 #define STATIC_INT_FIELD(klassName, name) STATIC_PRIMITIVE_FIELD(klassName, name, jint) |
329 #define STATIC_BOOLEAN_FIELD(klassName, name) STATIC_PRIMITIVE_FIELD(klassName, name, jboolean) | 338 #define STATIC_BOOLEAN_FIELD(klassName, name) STATIC_PRIMITIVE_FIELD(klassName, name, jboolean) |
330 | 339 |
331 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_INT_FIELD, STATIC_BOOLEAN_FIELD) | 340 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) |
332 #undef START_CLASS | 341 #undef START_CLASS |
333 #undef END_CLASS | 342 #undef END_CLASS |
334 #undef FIELD | 343 #undef FIELD |
335 #undef CHAR_FIELD | 344 #undef CHAR_FIELD |
336 #undef INT_FIELD | 345 #undef INT_FIELD |
338 #undef LONG_FIELD | 347 #undef LONG_FIELD |
339 #undef FLOAT_FIELD | 348 #undef FLOAT_FIELD |
340 #undef OOP_FIELD | 349 #undef OOP_FIELD |
341 #undef TYPEARRAYOOP_FIELD | 350 #undef TYPEARRAYOOP_FIELD |
342 #undef OBJARRAYOOP_FIELD | 351 #undef OBJARRAYOOP_FIELD |
352 #undef STATIC_OOPISH_FIELD | |
343 #undef STATIC_OOP_FIELD | 353 #undef STATIC_OOP_FIELD |
354 #undef STATIC_OBJARRAYOOP_FIELD | |
344 #undef STATIC_INT_FIELD | 355 #undef STATIC_INT_FIELD |
345 #undef STATIC_BOOLEAN_FIELD | 356 #undef STATIC_BOOLEAN_FIELD |
346 #undef EMPTY_CAST | 357 #undef EMPTY_CAST |
347 | 358 |
348 void compute_offset(int &dest_offset, Klass* klass, const char* name, const char* signature, bool static_field); | 359 void compute_offset(int &dest_offset, Klass* klass, const char* name, const char* signature, bool static_field); |