< prev index next >

src/hotspot/share/cds/archiveHeapWriter.cpp

Print this page
*** 203,12 ***
  
    HeapWord* mem = offset_to_buffered_address<HeapWord*>(_buffer_used);
    memset(mem, 0, byte_size);
    {
      // 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);
    }
--- 203,17 ---
  
    HeapWord* mem = offset_to_buffered_address<HeapWord*>(_buffer_used);
    memset(mem, 0, byte_size);
    {
      // This is copied from MemAllocator::finish
!     if (UseCompactObjectHeaders) {
!       narrowKlass nk = ArchiveBuilder::current()->get_requested_narrow_klass(k);
+       oopDesc::release_set_mark(mem, markWord::prototype().set_narrow_klass(nk));
+     } else {
+       oopDesc::set_mark(mem, markWord::prototype());
+       oopDesc::release_set_klass(mem, k);
+     }
    }
    {
      // This is copied from ObjArrayAllocator::initialize
      arrayOopDesc::set_length(mem, length);
    }

*** 325,13 ***
  HeapWord* ArchiveHeapWriter::init_filler_array_at_buffer_top(int array_length, size_t fill_bytes) {
    assert(UseCompressedClassPointers, "Archived heap only supported for compressed klasses");
    Klass* oak = Universe::objectArrayKlass(); // already relocated to point to archived klass
    HeapWord* mem = offset_to_buffered_address<HeapWord*>(_buffer_used);
    memset(mem, 0, fill_bytes);
-   oopDesc::set_mark(mem, markWord::prototype());
    narrowKlass nk = ArchiveBuilder::current()->get_requested_narrow_klass(oak);
!   cast_to_oop(mem)->set_narrow_klass(nk);
    arrayOopDesc::set_length(mem, array_length);
    return mem;
  }
  
  void ArchiveHeapWriter::maybe_fill_gc_region_gap(size_t required_byte_size) {
--- 330,17 ---
  HeapWord* ArchiveHeapWriter::init_filler_array_at_buffer_top(int array_length, size_t fill_bytes) {
    assert(UseCompressedClassPointers, "Archived heap only supported for compressed klasses");
    Klass* oak = Universe::objectArrayKlass(); // already relocated to point to archived klass
    HeapWord* mem = offset_to_buffered_address<HeapWord*>(_buffer_used);
    memset(mem, 0, fill_bytes);
    narrowKlass nk = ArchiveBuilder::current()->get_requested_narrow_klass(oak);
!   if (UseCompactObjectHeaders) {
+     oopDesc::release_set_mark(mem, markWord::prototype().set_narrow_klass(nk));
+   } else {
+     oopDesc::set_mark(mem, markWord::prototype());
+     cast_to_oop(mem)->set_narrow_klass(nk);
+   }
    arrayOopDesc::set_length(mem, array_length);
    return mem;
  }
  
  void ArchiveHeapWriter::maybe_fill_gc_region_gap(size_t required_byte_size) {

*** 527,17 ***
    assert(UseCompressedClassPointers, "Archived heap only supported for compressed klasses");
    narrowKlass nk = ArchiveBuilder::current()->get_requested_narrow_klass(src_klass);
    address buffered_addr = requested_addr_to_buffered_addr(cast_from_oop<address>(requested_obj));
  
    oop fake_oop = cast_to_oop(buffered_addr);
!   fake_oop->set_narrow_klass(nk);
  
    // We need to retain the identity_hash, because it may have been used by some hashtables
    // in the shared heap.
    if (src_obj != nullptr && !src_obj->fast_no_hash_check()) {
      intptr_t src_hash = src_obj->identity_hash();
!     fake_oop->set_mark(markWord::prototype().copy_set_hash(src_hash));
      assert(fake_oop->mark().is_unlocked(), "sanity");
  
      DEBUG_ONLY(intptr_t archived_hash = fake_oop->identity_hash());
      assert(src_hash == archived_hash, "Different hash codes: original " INTPTR_FORMAT ", archived " INTPTR_FORMAT, src_hash, archived_hash);
    }
--- 536,25 ---
    assert(UseCompressedClassPointers, "Archived heap only supported for compressed klasses");
    narrowKlass nk = ArchiveBuilder::current()->get_requested_narrow_klass(src_klass);
    address buffered_addr = requested_addr_to_buffered_addr(cast_from_oop<address>(requested_obj));
  
    oop fake_oop = cast_to_oop(buffered_addr);
!   if (UseCompactObjectHeaders) {
+     fake_oop->set_mark(markWord::prototype().set_narrow_klass(nk));
+   } else {
+     fake_oop->set_narrow_klass(nk);
+   }
  
    // We need to retain the identity_hash, because it may have been used by some hashtables
    // in the shared heap.
    if (src_obj != nullptr && !src_obj->fast_no_hash_check()) {
      intptr_t src_hash = src_obj->identity_hash();
!     if (UseCompactObjectHeaders) {
+       fake_oop->set_mark(markWord::prototype().set_narrow_klass(nk).copy_set_hash(src_hash));
+     } else {
+       fake_oop->set_mark(markWord::prototype().copy_set_hash(src_hash));
+     }
      assert(fake_oop->mark().is_unlocked(), "sanity");
  
      DEBUG_ONLY(intptr_t archived_hash = fake_oop->identity_hash());
      assert(src_hash == archived_hash, "Different hash codes: original " INTPTR_FORMAT ", archived " INTPTR_FORMAT, src_hash, archived_hash);
    }
< prev index next >