src/hotspot/share/prims/jvm.cpp
changeset 47998 fb0275c320a0
parent 47765 b7c7428eaab9
child 48027 ddbcfca4d51d
child 48105 8d15b1369c7a
equal deleted inserted replaced
47997:55c43e677ded 47998:fb0275c320a0
    33 #include "classfile/modules.hpp"
    33 #include "classfile/modules.hpp"
    34 #include "classfile/packageEntry.hpp"
    34 #include "classfile/packageEntry.hpp"
    35 #include "classfile/stringTable.hpp"
    35 #include "classfile/stringTable.hpp"
    36 #include "classfile/systemDictionary.hpp"
    36 #include "classfile/systemDictionary.hpp"
    37 #include "classfile/vmSymbols.hpp"
    37 #include "classfile/vmSymbols.hpp"
    38 #include "gc/shared/barrierSet.inline.hpp"
       
    39 #include "gc/shared/collectedHeap.inline.hpp"
    38 #include "gc/shared/collectedHeap.inline.hpp"
    40 #include "interpreter/bytecode.hpp"
    39 #include "interpreter/bytecode.hpp"
    41 #include "memory/oopFactory.hpp"
    40 #include "memory/oopFactory.hpp"
    42 #include "memory/resourceArea.hpp"
    41 #include "memory/resourceArea.hpp"
    43 #include "memory/universe.inline.hpp"
    42 #include "memory/universe.inline.hpp"
       
    43 #include "oops/access.inline.hpp"
    44 #include "oops/fieldStreams.hpp"
    44 #include "oops/fieldStreams.hpp"
    45 #include "oops/instanceKlass.hpp"
    45 #include "oops/instanceKlass.hpp"
    46 #include "oops/method.hpp"
    46 #include "oops/method.hpp"
    47 #include "oops/objArrayKlass.hpp"
    47 #include "oops/objArrayKlass.hpp"
    48 #include "oops/objArrayOop.inline.hpp"
    48 #include "oops/objArrayOop.inline.hpp"
   650     new_obj_oop = CollectedHeap::array_allocate(klass, size, length, CHECK_NULL);
   650     new_obj_oop = CollectedHeap::array_allocate(klass, size, length, CHECK_NULL);
   651   } else {
   651   } else {
   652     new_obj_oop = CollectedHeap::obj_allocate(klass, size, CHECK_NULL);
   652     new_obj_oop = CollectedHeap::obj_allocate(klass, size, CHECK_NULL);
   653   }
   653   }
   654 
   654 
   655   // 4839641 (4840070): We must do an oop-atomic copy, because if another thread
   655   HeapAccess<>::clone(obj(), new_obj_oop, size);
   656   // is modifying a reference field in the clonee, a non-oop-atomic copy might
       
   657   // be suspended in the middle of copying the pointer and end up with parts
       
   658   // of two different pointers in the field.  Subsequent dereferences will crash.
       
   659   // 4846409: an oop-copy of objects with long or double fields or arrays of same
       
   660   // won't copy the longs/doubles atomically in 32-bit vm's, so we copy jlongs instead
       
   661   // of oops.  We know objects are aligned on a minimum of an jlong boundary.
       
   662   // The same is true of StubRoutines::object_copy and the various oop_copy
       
   663   // variants, and of the code generated by the inline_native_clone intrinsic.
       
   664   assert(MinObjAlignmentInBytes >= BytesPerLong, "objects misaligned");
       
   665   Copy::conjoint_jlongs_atomic((jlong*)obj(), (jlong*)new_obj_oop,
       
   666                                align_object_size(size) / HeapWordsPerLong);
       
   667   // Clear the header
       
   668   new_obj_oop->init_mark();
       
   669 
       
   670   // Store check (mark entire object and let gc sort it out)
       
   671   BarrierSet* bs = Universe::heap()->barrier_set();
       
   672   bs->write_region(MemRegion((HeapWord*)new_obj_oop, size));
       
   673 
   656 
   674   Handle new_obj(THREAD, new_obj_oop);
   657   Handle new_obj(THREAD, new_obj_oop);
   675   // Caution: this involves a java upcall, so the clone should be
   658   // Caution: this involves a java upcall, so the clone should be
   676   // "gc-robust" by this stage.
   659   // "gc-robust" by this stage.
   677   if (klass->has_finalizer()) {
   660   if (klass->has_finalizer()) {