< prev index next > src/hotspot/share/cds/aotStreamedHeapWriter.cpp
Print this page
return !Klass::layout_helper_is_array(lh);
}
size_t AOTStreamedHeapWriter::copy_one_source_obj_to_buffer(oop src_obj) {
+ size_t old_size = src_obj->size();
+ size_t size = src_obj->copy_size_cds(old_size, src_obj->mark());
if (needs_explicit_size(src_obj)) {
// Explicitly write object size for more complex objects, to avoid having to
// pretend the buffer objects are objects when loading the objects, in order
// to read the size. Most of the time, the layout helper of the class is enough.
- write<size_t>(src_obj->size());
+ write<size_t>(size);
}
- size_t byte_size = src_obj->size() * HeapWordSize;
+ size_t byte_size = size * HeapWordSize;
assert(byte_size > 0, "no zero-size objects");
size_t new_used = _buffer_used + byte_size;
assert(new_used > _buffer_used, "no wrap around");
address from = cast_from_oop<address>(src_obj);
address to = offset_to_buffered_address<address>(_buffer_used);
assert(is_object_aligned(_buffer_used), "sanity");
assert(is_object_aligned(byte_size), "sanity");
- memcpy(to, from, byte_size);
+ memcpy(to, from, MIN2(size, old_size) * HeapWordSize);
if (java_lang_Module::is_instance(src_obj)) {
// These native pointers will be restored explicitly at run time.
Modules::check_archived_module_oop(src_obj);
update_buffered_object_field<ModuleEntry*>(to, java_lang_Module::module_entry_offset(), nullptr);
// We need to retain the identity_hash, because it may have been used by some hashtables
// in the shared heap. This also has the side effect of pre-initializing the
// identity_hash for all shared objects, so they are less likely to be written
// into during run time, increasing the potential of memory sharing.
if (src_obj != nullptr) {
- intptr_t src_hash = src_obj->identity_hash();
- mw = mw.copy_set_hash(src_hash);
+ if (UseCompactObjectHeaders) {
+ mw = mw.copy_hashctrl_from(src_obj->mark());
+ if (mw.is_hashed_not_expanded()) {
+ mw = fake_oop->initialize_hash_if_necessary(src_obj, src_klass, mw);
+ } else if (mw.is_not_hashed_expanded()) {
+ // If a scratch mirror class has not been hashed until now, then reset its
+ // hash bits to initial state.
+ mw = mw.set_not_hashed_not_expanded();
+ }
+ } else {
+ intptr_t src_hash = src_obj->identity_hash();
+ mw = mw.copy_set_hash(src_hash);
+ }
}
if (is_interned_string(src_obj)) {
// Mark the mark word of interned string so the loader knows to link these to
// the string table at runtime.
oop src_obj = AOTStreamedHeapWriter::buffered_offset_to_source_obj(buffered_offset);
assert(src_obj != nullptr, "why is this null?");
oopDesc* raw_oop = (oopDesc*)buffered_addr;
Klass* klass = src_obj->klass();
size_t size = src_obj->size();
+ size = src_obj->copy_size_cds(size, src_obj->mark());
intptr_t target_location = (intptr_t)buffered_offset;
uint32_t narrow_location = checked_cast<uint32_t>(dfs_index);
address requested_addr = (address)buffered_offset;
< prev index next >