< prev index next >

src/hotspot/share/cds/aotStreamedHeapWriter.cpp

Print this page

354   // Mark the pointer in the oopmap
355   size_t buffered_offset = buffered_address_to_offset((address)buffered_addr);
356   BitMap::idx_t idx = bit_idx_for_buffer_offset(buffered_offset);
357   oopmap->set_bit(idx);
358 }
359 
360 template <typename T> void AOTStreamedHeapWriter::map_oop_field_in_buffer(oop obj, T* field_addr_in_buffer, CHeapBitMap* oopmap) {
361   if (obj == nullptr) {
362     store_oop_in_buffer(field_addr_in_buffer, 0);
363   } else {
364     int dfs_index = *_dfs_order_table->get(obj);
365     store_oop_in_buffer(field_addr_in_buffer, dfs_index);
366   }
367 
368   mark_oop_pointer<T>(field_addr_in_buffer, oopmap);
369 }
370 
371 void AOTStreamedHeapWriter::update_header_for_buffered_addr(address buffered_addr, oop src_obj,  Klass* src_klass) {
372   narrowKlass nk = ArchiveBuilder::current()->get_requested_narrow_klass(src_klass);
373 
374   markWord mw = markWord::prototype();
375   oopDesc* fake_oop = (oopDesc*)buffered_addr;
376 
377   // We need to retain the identity_hash, because it may have been used by some hashtables
378   // in the shared heap. This also has the side effect of pre-initializing the
379   // identity_hash for all shared objects, so they are less likely to be written
380   // into during run time, increasing the potential of memory sharing.
381   if (src_obj != nullptr) {
382     intptr_t src_hash = src_obj->identity_hash();
383     mw = mw.copy_set_hash(src_hash);
384   }
385 
386   if (HeapShared::is_interned_string(src_obj)) {
387     // Mark the mark word of interned string so the loader knows to link these to
388     // the string table at runtime.
389     mw = mw.set_marked();
390   }
391 
392   if (UseCompactObjectHeaders) {
393     fake_oop->set_mark(mw.set_narrow_klass(nk));
394   } else {
395     fake_oop->set_mark(mw);
396     fake_oop->set_narrow_klass(nk);
397   }
398 }
399 
400 class AOTStreamedHeapWriter::EmbeddedOopMapper: public BasicOopIterateClosure {
401   oop _src_obj;

354   // Mark the pointer in the oopmap
355   size_t buffered_offset = buffered_address_to_offset((address)buffered_addr);
356   BitMap::idx_t idx = bit_idx_for_buffer_offset(buffered_offset);
357   oopmap->set_bit(idx);
358 }
359 
360 template <typename T> void AOTStreamedHeapWriter::map_oop_field_in_buffer(oop obj, T* field_addr_in_buffer, CHeapBitMap* oopmap) {
361   if (obj == nullptr) {
362     store_oop_in_buffer(field_addr_in_buffer, 0);
363   } else {
364     int dfs_index = *_dfs_order_table->get(obj);
365     store_oop_in_buffer(field_addr_in_buffer, dfs_index);
366   }
367 
368   mark_oop_pointer<T>(field_addr_in_buffer, oopmap);
369 }
370 
371 void AOTStreamedHeapWriter::update_header_for_buffered_addr(address buffered_addr, oop src_obj,  Klass* src_klass) {
372   narrowKlass nk = ArchiveBuilder::current()->get_requested_narrow_klass(src_klass);
373 
374   markWord mw = Arguments::enable_preview() ? src_klass->prototype_header() : markWord::prototype();
375   oopDesc* fake_oop = (oopDesc*)buffered_addr;
376 
377   // We need to retain the identity_hash, because it may have been used by some hashtables
378   // in the shared heap. This also has the side effect of pre-initializing the
379   // identity_hash for all shared objects, so they are less likely to be written
380   // into during run time, increasing the potential of memory sharing.
381   if (src_obj != nullptr && !src_klass->is_inline_klass()) {
382     intptr_t src_hash = src_obj->identity_hash();
383     mw = mw.copy_set_hash(src_hash);
384   }
385 
386   if (HeapShared::is_interned_string(src_obj)) {
387     // Mark the mark word of interned string so the loader knows to link these to
388     // the string table at runtime.
389     mw = mw.set_marked();
390   }
391 
392   if (UseCompactObjectHeaders) {
393     fake_oop->set_mark(mw.set_narrow_klass(nk));
394   } else {
395     fake_oop->set_mark(mw);
396     fake_oop->set_narrow_klass(nk);
397   }
398 }
399 
400 class AOTStreamedHeapWriter::EmbeddedOopMapper: public BasicOopIterateClosure {
401   oop _src_obj;
< prev index next >