373 size_t buffered_offset = buffered_address_to_offset((address)buffered_addr);
374 BitMap::idx_t idx = bit_idx_for_buffer_offset(buffered_offset);
375 oopmap->set_bit(idx);
376 }
377
378 template <typename T> void AOTStreamedHeapWriter::map_oop_field_in_buffer(oop obj, T* field_addr_in_buffer, CHeapBitMap* oopmap) {
379 if (obj == nullptr) {
380 store_oop_in_buffer(field_addr_in_buffer, 0);
381 } else {
382 int dfs_index = *_dfs_order_table->get(obj);
383 store_oop_in_buffer(field_addr_in_buffer, dfs_index);
384 }
385
386 mark_oop_pointer<T>(field_addr_in_buffer, oopmap);
387 }
388
389 void AOTStreamedHeapWriter::update_header_for_buffered_addr(address buffered_addr, oop src_obj, Klass* src_klass) {
390 assert(UseCompressedClassPointers, "Archived heap only supported for compressed klasses");
391 narrowKlass nk = ArchiveBuilder::current()->get_requested_narrow_klass(src_klass);
392
393 markWord mw = markWord::prototype();
394 oopDesc* fake_oop = (oopDesc*)buffered_addr;
395
396 // We need to retain the identity_hash, because it may have been used by some hashtables
397 // in the shared heap. This also has the side effect of pre-initializing the
398 // identity_hash for all shared objects, so they are less likely to be written
399 // into during run time, increasing the potential of memory sharing.
400 if (src_obj != nullptr) {
401 intptr_t src_hash = src_obj->identity_hash();
402 mw = mw.copy_set_hash(src_hash);
403 }
404
405 if (is_interned_string(src_obj)) {
406 // Mark the mark word of interned string so the loader knows to link these to
407 // the string table at runtime.
408 mw = mw.set_marked();
409 }
410
411 if (UseCompactObjectHeaders) {
412 fake_oop->set_mark(mw.set_narrow_klass(nk));
413 } else {
414 fake_oop->set_mark(mw);
415 fake_oop->set_narrow_klass(nk);
416 }
417 }
418
419 class AOTStreamedHeapWriter::EmbeddedOopMapper: public BasicOopIterateClosure {
420 oop _src_obj;
|
373 size_t buffered_offset = buffered_address_to_offset((address)buffered_addr);
374 BitMap::idx_t idx = bit_idx_for_buffer_offset(buffered_offset);
375 oopmap->set_bit(idx);
376 }
377
378 template <typename T> void AOTStreamedHeapWriter::map_oop_field_in_buffer(oop obj, T* field_addr_in_buffer, CHeapBitMap* oopmap) {
379 if (obj == nullptr) {
380 store_oop_in_buffer(field_addr_in_buffer, 0);
381 } else {
382 int dfs_index = *_dfs_order_table->get(obj);
383 store_oop_in_buffer(field_addr_in_buffer, dfs_index);
384 }
385
386 mark_oop_pointer<T>(field_addr_in_buffer, oopmap);
387 }
388
389 void AOTStreamedHeapWriter::update_header_for_buffered_addr(address buffered_addr, oop src_obj, Klass* src_klass) {
390 assert(UseCompressedClassPointers, "Archived heap only supported for compressed klasses");
391 narrowKlass nk = ArchiveBuilder::current()->get_requested_narrow_klass(src_klass);
392
393 markWord mw = Arguments::enable_preview() ? src_klass->prototype_header() : markWord::prototype();
394 oopDesc* fake_oop = (oopDesc*)buffered_addr;
395
396 // We need to retain the identity_hash, because it may have been used by some hashtables
397 // in the shared heap. This also has the side effect of pre-initializing the
398 // identity_hash for all shared objects, so they are less likely to be written
399 // into during run time, increasing the potential of memory sharing.
400 if (src_obj != nullptr && !src_klass->is_inline_klass()) {
401 intptr_t src_hash = src_obj->identity_hash();
402 mw = mw.copy_set_hash(src_hash);
403 }
404
405 if (is_interned_string(src_obj)) {
406 // Mark the mark word of interned string so the loader knows to link these to
407 // the string table at runtime.
408 mw = mw.set_marked();
409 }
410
411 if (UseCompactObjectHeaders) {
412 fake_oop->set_mark(mw.set_narrow_klass(nk));
413 } else {
414 fake_oop->set_mark(mw);
415 fake_oop->set_narrow_klass(nk);
416 }
417 }
418
419 class AOTStreamedHeapWriter::EmbeddedOopMapper: public BasicOopIterateClosure {
420 oop _src_obj;
|