--- old/src/share/vm/prims/jvm.cpp 2017-04-25 16:45:41.559172874 +0200 +++ new/src/share/vm/prims/jvm.cpp 2017-04-25 16:45:41.411172879 +0200 @@ -34,7 +34,6 @@ #include "classfile/stringTable.hpp" #include "classfile/systemDictionary.hpp" #include "classfile/vmSymbols.hpp" -#include "gc/shared/barrierSet.inline.hpp" #include "gc/shared/collectedHeap.inline.hpp" #include "interpreter/bytecode.hpp" #include "memory/oopFactory.hpp" @@ -53,6 +52,7 @@ #include "prims/nativeLookup.hpp" #include "prims/privilegedStack.hpp" #include "prims/stackwalk.hpp" +#include "runtime/access.inline.hpp" #include "runtime/arguments.hpp" #include "runtime/atomic.hpp" #include "runtime/handles.inline.hpp" @@ -652,25 +652,7 @@ new_obj_oop = CollectedHeap::obj_allocate(klass, size, CHECK_NULL); } - // 4839641 (4840070): We must do an oop-atomic copy, because if another thread - // is modifying a reference field in the clonee, a non-oop-atomic copy might - // be suspended in the middle of copying the pointer and end up with parts - // of two different pointers in the field. Subsequent dereferences will crash. - // 4846409: an oop-copy of objects with long or double fields or arrays of same - // won't copy the longs/doubles atomically in 32-bit vm's, so we copy jlongs instead - // of oops. We know objects are aligned on a minimum of an jlong boundary. - // The same is true of StubRoutines::object_copy and the various oop_copy - // variants, and of the code generated by the inline_native_clone intrinsic. - assert(MinObjAlignmentInBytes >= BytesPerLong, "objects misaligned"); - Copy::conjoint_jlongs_atomic((jlong*)obj(), (jlong*)new_obj_oop, - (size_t)align_object_size(size) / HeapWordsPerLong); - // Clear the header - new_obj_oop->init_mark(); - - // Store check (mark entire object and let gc sort it out) - BarrierSet* bs = Universe::heap()->barrier_set(); - assert(bs->has_write_region_opt(), "Barrier set does not have write_region"); - bs->write_region(MemRegion((HeapWord*)new_obj_oop, size)); + HeapAccess<>::clone(obj(), new_obj_oop, size); Handle new_obj(THREAD, new_obj_oop); // Special handling for MemberNames. Since they contain Method* metadata, they