--- old/src/hotspot/share/oops/cpCache.cpp 2018-01-09 13:49:22.775913350 +0100 +++ new/src/hotspot/share/oops/cpCache.cpp 2018-01-09 13:49:22.463913361 +0100 @@ -33,6 +33,7 @@ #include "memory/metaspaceClosure.hpp" #include "memory/resourceArea.hpp" #include "memory/universe.inline.hpp" +#include "oops/access.inline.hpp" #include "oops/cpCache.hpp" #include "oops/objArrayOop.inline.hpp" #include "oops/oop.inline.hpp" @@ -753,13 +754,16 @@ #if INCLUDE_CDS_JAVA_HEAP oop ConstantPoolCache::archived_references() { - assert(UseSharedSpaces, "UseSharedSpaces expected."); - return oopDesc::decode_heap_oop(_archived_references); + // Loading an archive root forces the oop to become strongly reachable. + // For example, if it is loaded during concurrent marking in a SATB + // collector, it will be enqueued to the SATB queue, effectively + // shading the previously white object gray. + return RootAccess::oop_load(&_archived_references); } void ConstantPoolCache::set_archived_references(oop o) { assert(DumpSharedSpaces, "called only during runtime"); - _archived_references = oopDesc::encode_heap_oop(o); + RootAccess::oop_store(&_archived_references, o); } #endif