< prev index next >

src/hotspot/share/cds/archiveHeapWriter.cpp

Print this page

509   // Mark the pointer in the oopmap
510   T* region_bottom = (T*)requested_region_bottom;
511   assert(request_p >= region_bottom, "must be");
512   BitMap::idx_t idx = request_p - region_bottom;
513   assert(idx < oopmap->size(), "overflow");
514   oopmap->set_bit(idx);
515 }
516 
517 void ArchiveHeapWriter::update_header_for_requested_obj(oop requested_obj, oop src_obj,  Klass* src_klass) {
518   assert(UseCompressedClassPointers, "Archived heap only supported for compressed klasses");
519   narrowKlass nk = ArchiveBuilder::current()->get_requested_narrow_klass(src_klass);
520   address buffered_addr = requested_addr_to_buffered_addr(cast_from_oop<address>(requested_obj));
521 
522   oop fake_oop = cast_to_oop(buffered_addr);
523   fake_oop->set_narrow_klass(nk);
524 
525   // We need to retain the identity_hash, because it may have been used by some hashtables
526   // in the shared heap. This also has the side effect of pre-initializing the
527   // identity_hash for all shared objects, so they are less likely to be written
528   // into during run time, increasing the potential of memory sharing.
529   if (src_obj != nullptr) {
530     intptr_t src_hash = src_obj->identity_hash();
531     fake_oop->set_mark(markWord::prototype().copy_set_hash(src_hash));
532     assert(fake_oop->mark().is_unlocked(), "sanity");
533 
534     DEBUG_ONLY(intptr_t archived_hash = fake_oop->identity_hash());
535     assert(src_hash == archived_hash, "Different hash codes: original " INTPTR_FORMAT ", archived " INTPTR_FORMAT, src_hash, archived_hash);
536   }
537 }
538 
539 // Relocate an element in the buffered copy of HeapShared::roots()
540 template <typename T> void ArchiveHeapWriter::relocate_root_at(oop requested_roots, int index, CHeapBitMap* oopmap) {
541   size_t offset = (size_t)((objArrayOop)requested_roots)->obj_at_offset<T>(index);
542   relocate_field_in_buffer<T>((T*)(buffered_heap_roots_addr() + offset), oopmap);
543 }
544 
545 class ArchiveHeapWriter::EmbeddedOopRelocator: public BasicOopIterateClosure {
546   oop _src_obj;
547   address _buffered_obj;
548   CHeapBitMap* _oopmap;
549 
550 public:
551   EmbeddedOopRelocator(oop src_obj, address buffered_obj, CHeapBitMap* oopmap) :

509   // Mark the pointer in the oopmap
510   T* region_bottom = (T*)requested_region_bottom;
511   assert(request_p >= region_bottom, "must be");
512   BitMap::idx_t idx = request_p - region_bottom;
513   assert(idx < oopmap->size(), "overflow");
514   oopmap->set_bit(idx);
515 }
516 
517 void ArchiveHeapWriter::update_header_for_requested_obj(oop requested_obj, oop src_obj,  Klass* src_klass) {
518   assert(UseCompressedClassPointers, "Archived heap only supported for compressed klasses");
519   narrowKlass nk = ArchiveBuilder::current()->get_requested_narrow_klass(src_klass);
520   address buffered_addr = requested_addr_to_buffered_addr(cast_from_oop<address>(requested_obj));
521 
522   oop fake_oop = cast_to_oop(buffered_addr);
523   fake_oop->set_narrow_klass(nk);
524 
525   // We need to retain the identity_hash, because it may have been used by some hashtables
526   // in the shared heap. This also has the side effect of pre-initializing the
527   // identity_hash for all shared objects, so they are less likely to be written
528   // into during run time, increasing the potential of memory sharing.
529   if (src_obj != nullptr && (!(EnableValhalla && src_obj->mark().is_inline_type()))) {
530     intptr_t src_hash = src_obj->identity_hash();
531     fake_oop->set_mark(src_klass->prototype_header().copy_set_hash(src_hash));
532     assert(fake_oop->mark().is_unlocked(), "sanity");
533 
534     DEBUG_ONLY(intptr_t archived_hash = fake_oop->identity_hash());
535     assert(src_hash == archived_hash, "Different hash codes: original " INTPTR_FORMAT ", archived " INTPTR_FORMAT, src_hash, archived_hash);
536   }
537 }
538 
539 // Relocate an element in the buffered copy of HeapShared::roots()
540 template <typename T> void ArchiveHeapWriter::relocate_root_at(oop requested_roots, int index, CHeapBitMap* oopmap) {
541   size_t offset = (size_t)((objArrayOop)requested_roots)->obj_at_offset<T>(index);
542   relocate_field_in_buffer<T>((T*)(buffered_heap_roots_addr() + offset), oopmap);
543 }
544 
545 class ArchiveHeapWriter::EmbeddedOopRelocator: public BasicOopIterateClosure {
546   oop _src_obj;
547   address _buffered_obj;
548   CHeapBitMap* _oopmap;
549 
550 public:
551   EmbeddedOopRelocator(oop src_obj, address buffered_obj, CHeapBitMap* oopmap) :
< prev index next >