--- old/src/hotspot/share/classfile/javaClasses.cpp 2018-03-19 13:56:08.918252192 +0100 +++ new/src/hotspot/share/classfile/javaClasses.cpp 2018-03-19 13:56:08.710252199 +0100 @@ -1866,12 +1866,7 @@ oop java_lang_Throwable::unassigned_stacktrace() { InstanceKlass* ik = SystemDictionary::Throwable_klass(); - address addr = ik->static_field_addr(static_unassigned_stacktrace_offset); - if (UseCompressedOops) { - return oopDesc::load_decode_heap_oop((narrowOop *)addr); - } else { - return oopDesc::load_decode_heap_oop((oop*)addr); - } + return ik->static_oop_field(static_unassigned_stacktrace_offset); } oop java_lang_Throwable::backtrace(oop throwable) { @@ -4130,15 +4125,10 @@ int java_lang_System::out_offset_in_bytes() { return static_out_offset; } int java_lang_System::err_offset_in_bytes() { return static_err_offset; } - bool java_lang_System::has_security_manager() { InstanceKlass* ik = SystemDictionary::System_klass(); - address addr = ik->static_field_addr(static_security_offset); - if (UseCompressedOops) { - return oopDesc::load_decode_heap_oop((narrowOop *)addr) != NULL; - } else { - return oopDesc::load_decode_heap_oop((oop*)addr) != NULL; - } + oop obj = ik->static_oop_field(static_security_offset); + return obj != NULL; } int java_lang_Class::_klass_offset; --- old/src/hotspot/share/oops/instanceKlass.cpp 2018-03-19 13:56:09.342252177 +0100 +++ new/src/hotspot/share/oops/instanceKlass.cpp 2018-03-19 13:56:09.138252184 +0100 @@ -52,6 +52,7 @@ #include "memory/metaspaceShared.hpp" #include "memory/oopFactory.hpp" #include "memory/resourceArea.hpp" +#include "oops/access.inline.hpp" #include "oops/fieldStreams.hpp" #include "oops/instanceClassLoaderKlass.hpp" #include "oops/instanceKlass.inline.hpp" @@ -2257,9 +2258,14 @@ address InstanceKlass::static_field_addr(int offset) { assert(offset >= InstanceMirrorKlass::offset_of_static_fields(), "has already been adjusted"); - return (address)(offset + cast_from_oop(java_mirror())); + oop mirror = Access<>::resolve(java_mirror()); + return (address)(offset + cast_from_oop(mirror)); } +oop InstanceKlass::static_oop_field(int offset) { + assert(offset >= InstanceMirrorKlass::offset_of_static_fields(), "has already been adjusted"); + return HeapAccess<>::oop_load((HeapWord*)static_field_addr(offset)); +} const char* InstanceKlass::signature_name() const { int hash_len = 0; --- old/src/hotspot/share/oops/instanceKlass.hpp 2018-03-19 13:56:09.738252164 +0100 +++ new/src/hotspot/share/oops/instanceKlass.hpp 2018-03-19 13:56:09.530252171 +0100 @@ -1071,6 +1071,7 @@ int itable_offset_in_words() const { return start_of_itable() - (intptr_t*)this; } address static_field_addr(int offset); + oop static_oop_field(int offset); OopMapBlock* start_of_nonstatic_oop_maps() const { return (OopMapBlock*)(start_of_itable() + itable_length());