< prev index next >

src/hotspot/share/cds/archiveHeapWriter.cpp

Print this page

546   T* region_bottom = (T*)requested_region_bottom;
547   assert(request_p >= region_bottom, "must be");
548   BitMap::idx_t idx = request_p - region_bottom;
549   assert(idx < oopmap->size(), "overflow");
550   oopmap->set_bit(idx);
551 }
552 
553 void ArchiveHeapWriter::update_header_for_requested_obj(oop requested_obj, oop src_obj,  Klass* src_klass) {
554   assert(UseCompressedClassPointers, "Archived heap only supported for compressed klasses");
555   narrowKlass nk = ArchiveBuilder::current()->get_requested_narrow_klass(src_klass);
556   address buffered_addr = requested_addr_to_buffered_addr(cast_from_oop<address>(requested_obj));
557 
558   oop fake_oop = cast_to_oop(buffered_addr);
559   fake_oop->set_narrow_klass(nk);
560 
561   if (src_obj == nullptr) {
562     return;
563   }
564   // We need to retain the identity_hash, because it may have been used by some hashtables
565   // in the shared heap.
566   if (!src_obj->fast_no_hash_check()) {
567     intptr_t src_hash = src_obj->identity_hash();
568     fake_oop->set_mark(markWord::prototype().copy_set_hash(src_hash));
569     assert(fake_oop->mark().is_unlocked(), "sanity");
570 
571     DEBUG_ONLY(intptr_t archived_hash = fake_oop->identity_hash());
572     assert(src_hash == archived_hash, "Different hash codes: original " INTPTR_FORMAT ", archived " INTPTR_FORMAT, src_hash, archived_hash);
573   }
574   // Strip age bits.
575   fake_oop->set_mark(fake_oop->mark().set_age(0));
576 }
577 
578 class ArchiveHeapWriter::EmbeddedOopRelocator: public BasicOopIterateClosure {
579   oop _src_obj;
580   address _buffered_obj;
581   CHeapBitMap* _oopmap;
582 
583 public:
584   EmbeddedOopRelocator(oop src_obj, address buffered_obj, CHeapBitMap* oopmap) :
585     _src_obj(src_obj), _buffered_obj(buffered_obj), _oopmap(oopmap) {}
586 
587   void do_oop(narrowOop *p) { EmbeddedOopRelocator::do_oop_work(p); }
588   void do_oop(      oop *p) { EmbeddedOopRelocator::do_oop_work(p); }

546   T* region_bottom = (T*)requested_region_bottom;
547   assert(request_p >= region_bottom, "must be");
548   BitMap::idx_t idx = request_p - region_bottom;
549   assert(idx < oopmap->size(), "overflow");
550   oopmap->set_bit(idx);
551 }
552 
553 void ArchiveHeapWriter::update_header_for_requested_obj(oop requested_obj, oop src_obj,  Klass* src_klass) {
554   assert(UseCompressedClassPointers, "Archived heap only supported for compressed klasses");
555   narrowKlass nk = ArchiveBuilder::current()->get_requested_narrow_klass(src_klass);
556   address buffered_addr = requested_addr_to_buffered_addr(cast_from_oop<address>(requested_obj));
557 
558   oop fake_oop = cast_to_oop(buffered_addr);
559   fake_oop->set_narrow_klass(nk);
560 
561   if (src_obj == nullptr) {
562     return;
563   }
564   // We need to retain the identity_hash, because it may have been used by some hashtables
565   // in the shared heap.
566   if (!src_obj->fast_no_hash_check() && (!(EnableValhalla && src_obj->mark().is_inline_type()))) {
567     intptr_t src_hash = src_obj->identity_hash();
568     fake_oop->set_mark(src_klass->prototype_header().copy_set_hash(src_hash));
569     assert(fake_oop->mark().is_unlocked(), "sanity");
570 
571     DEBUG_ONLY(intptr_t archived_hash = fake_oop->identity_hash());
572     assert(src_hash == archived_hash, "Different hash codes: original " INTPTR_FORMAT ", archived " INTPTR_FORMAT, src_hash, archived_hash);
573   }
574   // Strip age bits.
575   fake_oop->set_mark(fake_oop->mark().set_age(0));
576 }
577 
578 class ArchiveHeapWriter::EmbeddedOopRelocator: public BasicOopIterateClosure {
579   oop _src_obj;
580   address _buffered_obj;
581   CHeapBitMap* _oopmap;
582 
583 public:
584   EmbeddedOopRelocator(oop src_obj, address buffered_obj, CHeapBitMap* oopmap) :
585     _src_obj(src_obj), _buffered_obj(buffered_obj), _oopmap(oopmap) {}
586 
587   void do_oop(narrowOop *p) { EmbeddedOopRelocator::do_oop_work(p); }
588   void do_oop(      oop *p) { EmbeddedOopRelocator::do_oop_work(p); }
< prev index next >