Mercurial > hg > graal-jvmci-8
comparison src/share/vm/graal/graalJavaAccess.hpp @ 21113:0cf5897db25a
Better assertion message for NULL deference in graalJavaAccess
author | Tom Rodriguez <tom.rodriguez@oracle.com> |
---|---|
date | Wed, 22 Apr 2015 16:42:05 -0700 |
parents | 92fc95e8667d |
children | 5cbaf1e9ff2e 1da7aef31a08 |
comparison
equal
deleted
inserted
replaced
21112:f01ebceea995 | 21113:0cf5897db25a |
---|---|
271 | 271 |
272 #define START_CLASS(name) \ | 272 #define START_CLASS(name) \ |
273 class name : AllStatic { \ | 273 class name : AllStatic { \ |
274 private: \ | 274 private: \ |
275 friend class GraalCompiler; \ | 275 friend class GraalCompiler; \ |
276 static void check(oop obj) { \ | 276 static void check(oop obj, const char* field_name) { \ |
277 assert(obj != NULL, "NULL field access of class " #name); \ | 277 assert(obj != NULL, err_msg("NULL field access of %s.%s", #name, field_name)); \ |
278 assert(obj->is_a(SystemDictionary::name##_klass()), "wrong class, " #name " expected"); \ | 278 assert(obj->is_a(SystemDictionary::name##_klass()), "wrong class, " #name " expected"); \ |
279 } \ | 279 } \ |
280 static void compute_offsets(); \ | 280 static void compute_offsets(); \ |
281 public: \ | 281 public: \ |
282 static Klass* klass() { return SystemDictionary::name##_klass(); } | 282 static Klass* klass() { return SystemDictionary::name##_klass(); } |
283 | 283 |
284 #define END_CLASS }; | 284 #define END_CLASS }; |
285 | 285 |
286 #define FIELD(name, type, accessor, cast) \ | 286 #define FIELD(name, type, accessor, cast) \ |
287 static int _##name##_offset; \ | 287 static int _##name##_offset; \ |
288 static type name(oop obj) { check(obj); return cast obj->accessor(_##name##_offset); } \ | 288 static type name(oop obj) { check(obj, #name); return cast obj->accessor(_##name##_offset); } \ |
289 static type name(Handle& obj) { check(obj()); return cast obj->accessor(_##name##_offset); } \ | 289 static type name(Handle& obj) { check(obj(), #name); return cast obj->accessor(_##name##_offset); } \ |
290 static type name(jobject obj) { check(JNIHandles::resolve(obj)); return cast JNIHandles::resolve(obj)->accessor(_##name##_offset); } \ | 290 static type name(jobject obj) { check(JNIHandles::resolve(obj), #name); return cast JNIHandles::resolve(obj)->accessor(_##name##_offset); } \ |
291 static void set_##name(oop obj, type x) { check(obj); obj->accessor##_put(_##name##_offset, x); } \ | 291 static void set_##name(oop obj, type x) { check(obj, #name); obj->accessor##_put(_##name##_offset, x); } \ |
292 static void set_##name(Handle& obj, type x) { check(obj()); obj->accessor##_put(_##name##_offset, x); } \ | 292 static void set_##name(Handle& obj, type x) { check(obj(), #name); obj->accessor##_put(_##name##_offset, x); } \ |
293 static void set_##name(jobject obj, type x) { check(JNIHandles::resolve(obj)); JNIHandles::resolve(obj)->accessor##_put(_##name##_offset, x); } | 293 static void set_##name(jobject obj, type x) { check(JNIHandles::resolve(obj), #name); JNIHandles::resolve(obj)->accessor##_put(_##name##_offset, x); } |
294 | 294 |
295 #define EMPTY_CAST | 295 #define EMPTY_CAST |
296 #define CHAR_FIELD(klass, name) FIELD(name, jchar, char_field, EMPTY_CAST) | 296 #define CHAR_FIELD(klass, name) FIELD(name, jchar, char_field, EMPTY_CAST) |
297 #define INT_FIELD(klass, name) FIELD(name, jint, int_field, EMPTY_CAST) | 297 #define INT_FIELD(klass, name) FIELD(name, jint, int_field, EMPTY_CAST) |
298 #define BOOLEAN_FIELD(klass, name) FIELD(name, jboolean, bool_field, EMPTY_CAST) | 298 #define BOOLEAN_FIELD(klass, name) FIELD(name, jboolean, bool_field, EMPTY_CAST) |