349 static int _##name##_offset; \ |
350 static int _##name##_offset; \ |
350 static type name() { \ |
351 static type name() { \ |
351 assert(klassName::klass() != NULL && klassName::klass()->is_linked(), "Class not yet linked: " #klassName); \ |
352 assert(klassName::klass() != NULL && klassName::klass()->is_linked(), "Class not yet linked: " #klassName); \ |
352 InstanceKlass* ik = klassName::klass(); \ |
353 InstanceKlass* ik = klassName::klass(); \ |
353 address addr = ik->static_field_addr(_##name##_offset - InstanceMirrorKlass::offset_of_static_fields()); \ |
354 address addr = ik->static_field_addr(_##name##_offset - InstanceMirrorKlass::offset_of_static_fields()); \ |
354 if (UseCompressedOops) { \ |
355 oop result = HeapAccess<>::oop_load((HeapWord*)addr); \ |
355 return (type) oopDesc::load_decode_heap_oop((narrowOop *)addr); \ |
356 return type(result); \ |
356 } else { \ |
|
357 return (type) oopDesc::load_decode_heap_oop((oop*)addr); \ |
|
358 } \ |
|
359 } \ |
357 } \ |
360 static void set_##name(type x) { \ |
358 static void set_##name(type x) { \ |
361 assert(klassName::klass() != NULL && klassName::klass()->is_linked(), "Class not yet linked: " #klassName); \ |
359 assert(klassName::klass() != NULL && klassName::klass()->is_linked(), "Class not yet linked: " #klassName); \ |
362 assert(klassName::klass() != NULL, "Class not yet loaded: " #klassName); \ |
360 assert(klassName::klass() != NULL, "Class not yet loaded: " #klassName); \ |
363 InstanceKlass* ik = klassName::klass(); \ |
361 InstanceKlass* ik = klassName::klass(); \ |
364 address addr = ik->static_field_addr(_##name##_offset - InstanceMirrorKlass::offset_of_static_fields()); \ |
362 address addr = ik->static_field_addr(_##name##_offset - InstanceMirrorKlass::offset_of_static_fields()); \ |
365 if (UseCompressedOops) { \ |
363 HeapAccess<>::oop_store((HeapWord*)addr, x); \ |
366 oop_store((narrowOop *)addr, x); \ |
|
367 } else { \ |
|
368 oop_store((oop*)addr, x); \ |
|
369 } \ |
|
370 } |
364 } |
371 #define STATIC_PRIMITIVE_FIELD(klassName, name, jtypename) \ |
365 #define STATIC_PRIMITIVE_FIELD(klassName, name, jtypename) \ |
372 static int _##name##_offset; \ |
366 static int _##name##_offset; \ |
373 static jtypename name() { \ |
367 static jtypename name() { \ |
374 assert(klassName::klass() != NULL && klassName::klass()->is_linked(), "Class not yet linked: " #klassName); \ |
368 assert(klassName::klass() != NULL && klassName::klass()->is_linked(), "Class not yet linked: " #klassName); \ |
375 InstanceKlass* ik = klassName::klass(); \ |
369 InstanceKlass* ik = klassName::klass(); \ |
376 address addr = ik->static_field_addr(_##name##_offset - InstanceMirrorKlass::offset_of_static_fields()); \ |
370 address addr = ik->static_field_addr(_##name##_offset - InstanceMirrorKlass::offset_of_static_fields()); \ |
377 return *((jtypename *)addr); \ |
371 return HeapAccess<>::load((jtypename*)addr); \ |
378 } \ |
372 } \ |
379 static void set_##name(jtypename x) { \ |
373 static void set_##name(jtypename x) { \ |
380 assert(klassName::klass() != NULL && klassName::klass()->is_linked(), "Class not yet linked: " #klassName); \ |
374 assert(klassName::klass() != NULL && klassName::klass()->is_linked(), "Class not yet linked: " #klassName); \ |
381 InstanceKlass* ik = klassName::klass(); \ |
375 InstanceKlass* ik = klassName::klass(); \ |
382 address addr = ik->static_field_addr(_##name##_offset - InstanceMirrorKlass::offset_of_static_fields()); \ |
376 address addr = ik->static_field_addr(_##name##_offset - InstanceMirrorKlass::offset_of_static_fields()); \ |
383 *((jtypename *)addr) = x; \ |
377 HeapAccess<>::store((jtypename*)addr, x); \ |
384 } |
378 } |
385 |
379 |
386 #define STATIC_INT_FIELD(klassName, name) STATIC_PRIMITIVE_FIELD(klassName, name, jint) |
380 #define STATIC_INT_FIELD(klassName, name) STATIC_PRIMITIVE_FIELD(klassName, name, jint) |
387 #define STATIC_BOOLEAN_FIELD(klassName, name) STATIC_PRIMITIVE_FIELD(klassName, name, jboolean) |
381 #define STATIC_BOOLEAN_FIELD(klassName, name) STATIC_PRIMITIVE_FIELD(klassName, name, jboolean) |
388 |
382 |