< prev index next >

src/hotspot/share/cds/heapShared.cpp

Print this page
*** 57,10 ***
--- 57,11 ---
  #include "runtime/fieldDescriptor.inline.hpp"
  #include "runtime/globals_extension.hpp"
  #include "runtime/init.hpp"
  #include "runtime/java.hpp"
  #include "runtime/javaCalls.hpp"
+ #include "runtime/safepoint.hpp"
  #include "runtime/safepointVerifiers.hpp"
  #include "utilities/bitMap.inline.hpp"
  #include "utilities/copy.hpp"
  #if INCLUDE_G1GC
  #include "gc/g1/g1CollectedHeap.hpp"

*** 295,11 ***
      // We need to retain the identity_hash, because it may have been used by some hashtables
      // in the shared heap. This also has the side effect of pre-initializing the
      // identity_hash for all shared objects, so they are less likely to be written
      // into during run time, increasing the potential of memory sharing.
      int hash_original = obj->identity_hash();
!     archived_oop->set_mark(markWord::prototype().copy_set_hash(hash_original));
      assert(archived_oop->mark().is_unlocked(), "sanity");
  
      DEBUG_ONLY(int hash_archived = archived_oop->identity_hash());
      assert(hash_original == hash_archived, "Different hash codes: original %x, archived %x", hash_original, hash_archived);
  
--- 296,18 ---
      // We need to retain the identity_hash, because it may have been used by some hashtables
      // in the shared heap. This also has the side effect of pre-initializing the
      // identity_hash for all shared objects, so they are less likely to be written
      // into during run time, increasing the potential of memory sharing.
      int hash_original = obj->identity_hash();
! 
+     assert(SafepointSynchronize::is_at_safepoint(), "resolving displaced headers only at safepoint");
+     markWord mark = obj->mark();
+     if (mark.has_displaced_mark_helper()) {
+       mark = mark.displaced_mark_helper();
+     }
+     narrowKlass nklass = mark.narrow_klass();
+     archived_oop->set_mark(markWord::prototype().copy_set_hash(hash_original) LP64_ONLY(.set_narrow_klass(nklass)));
      assert(archived_oop->mark().is_unlocked(), "sanity");
  
      DEBUG_ONLY(int hash_archived = archived_oop->identity_hash());
      assert(hash_original == hash_archived, "Different hash codes: original %x, archived %x", hash_original, hash_archived);
  

*** 434,11 ***
    HeapWord* mem = G1CollectedHeap::heap()->archive_mem_allocate(size);
  
    memset(mem, 0, size * BytesPerWord);
    {
      // This is copied from MemAllocator::finish
!     oopDesc::set_mark(mem, markWord::prototype());
      oopDesc::release_set_klass(mem, k);
    }
    {
      // This is copied from ObjArrayAllocator::initialize
      arrayOopDesc::set_length(mem, length);
--- 442,11 ---
    HeapWord* mem = G1CollectedHeap::heap()->archive_mem_allocate(size);
  
    memset(mem, 0, size * BytesPerWord);
    {
      // This is copied from MemAllocator::finish
!     oopDesc::set_mark(mem, k->prototype_header());
      oopDesc::release_set_klass(mem, k);
    }
    {
      // This is copied from ObjArrayAllocator::initialize
      arrayOopDesc::set_length(mem, length);
< prev index next >