< prev index next >

src/hotspot/share/cds/archiveHeapWriter.cpp

Print this page

411   // Mark the pointer in the oopmap
412   T* region_bottom = (T*)requested_region_bottom;
413   assert(request_p >= region_bottom, "must be");
414   BitMap::idx_t idx = request_p - region_bottom;
415   assert(idx < oopmap->size(), "overflow");
416   oopmap->set_bit(idx);
417 }
418 
419 void ArchiveHeapWriter::update_header_for_requested_obj(oop requested_obj, oop src_obj,  Klass* src_klass) {
420   assert(UseCompressedClassPointers, "Archived heap only supported for compressed klasses");
421   narrowKlass nk = ArchiveBuilder::current()->get_requested_narrow_klass(src_klass);
422   address buffered_addr = requested_addr_to_buffered_addr(cast_from_oop<address>(requested_obj));
423 
424   oop fake_oop = cast_to_oop(buffered_addr);
425   fake_oop->set_narrow_klass(nk);
426 
427   // We need to retain the identity_hash, because it may have been used by some hashtables
428   // in the shared heap. This also has the side effect of pre-initializing the
429   // identity_hash for all shared objects, so they are less likely to be written
430   // into during run time, increasing the potential of memory sharing.
431   if (src_obj != nullptr) {
432     int src_hash = src_obj->identity_hash();
433     fake_oop->set_mark(markWord::prototype().copy_set_hash(src_hash));
434     assert(fake_oop->mark().is_unlocked(), "sanity");
435 
436     DEBUG_ONLY(int archived_hash = fake_oop->identity_hash());
437     assert(src_hash == archived_hash, "Different hash codes: original %x, archived %x", src_hash, archived_hash);
438   }
439 }
440 
441 // Relocate an element in the buffered copy of HeapShared::roots()
442 template <typename T> void ArchiveHeapWriter::relocate_root_at(oop requested_roots, int index, CHeapBitMap* oopmap) {
443   size_t offset = (size_t)((objArrayOop)requested_roots)->obj_at_offset<T>(index);
444   relocate_field_in_buffer<T>((T*)(buffered_heap_roots_addr() + offset), oopmap);
445 }
446 
447 class ArchiveHeapWriter::EmbeddedOopRelocator: public BasicOopIterateClosure {
448   oop _src_obj;
449   address _buffered_obj;
450   CHeapBitMap* _oopmap;
451 
452 public:
453   EmbeddedOopRelocator(oop src_obj, address buffered_obj, CHeapBitMap* oopmap) :

411   // Mark the pointer in the oopmap
412   T* region_bottom = (T*)requested_region_bottom;
413   assert(request_p >= region_bottom, "must be");
414   BitMap::idx_t idx = request_p - region_bottom;
415   assert(idx < oopmap->size(), "overflow");
416   oopmap->set_bit(idx);
417 }
418 
419 void ArchiveHeapWriter::update_header_for_requested_obj(oop requested_obj, oop src_obj,  Klass* src_klass) {
420   assert(UseCompressedClassPointers, "Archived heap only supported for compressed klasses");
421   narrowKlass nk = ArchiveBuilder::current()->get_requested_narrow_klass(src_klass);
422   address buffered_addr = requested_addr_to_buffered_addr(cast_from_oop<address>(requested_obj));
423 
424   oop fake_oop = cast_to_oop(buffered_addr);
425   fake_oop->set_narrow_klass(nk);
426 
427   // We need to retain the identity_hash, because it may have been used by some hashtables
428   // in the shared heap. This also has the side effect of pre-initializing the
429   // identity_hash for all shared objects, so they are less likely to be written
430   // into during run time, increasing the potential of memory sharing.
431   if (src_obj != nullptr && (!(EnableValhalla && src_obj->mark().is_inline_type()))) {
432     int src_hash = src_obj->identity_hash();
433     fake_oop->set_mark(src_klass->prototype_header().copy_set_hash(src_hash));
434     assert(fake_oop->mark().is_unlocked(), "sanity");
435 
436     DEBUG_ONLY(int archived_hash = fake_oop->identity_hash());
437     assert(src_hash == archived_hash, "Different hash codes: original %x, archived %x", src_hash, archived_hash);
438   }
439 }
440 
441 // Relocate an element in the buffered copy of HeapShared::roots()
442 template <typename T> void ArchiveHeapWriter::relocate_root_at(oop requested_roots, int index, CHeapBitMap* oopmap) {
443   size_t offset = (size_t)((objArrayOop)requested_roots)->obj_at_offset<T>(index);
444   relocate_field_in_buffer<T>((T*)(buffered_heap_roots_addr() + offset), oopmap);
445 }
446 
447 class ArchiveHeapWriter::EmbeddedOopRelocator: public BasicOopIterateClosure {
448   oop _src_obj;
449   address _buffered_obj;
450   CHeapBitMap* _oopmap;
451 
452 public:
453   EmbeddedOopRelocator(oop src_obj, address buffered_obj, CHeapBitMap* oopmap) :
< prev index next >