< prev index next > src/hotspot/share/cds/heapShared.cpp
Print this page
}
SystemDictionaryShared::update_archived_mirror_native_pointers();
}
unsigned HeapShared::oop_hash(oop const& p) {
- unsigned hash = (unsigned)p->identity_hash();
- return hash;
+ // We are at a safepoint, so the object won't move. It's OK to use its
+ // address as the hashcode.
+ // We can't use p->identity_hash() as it's not available for primitive oops.
+ assert_at_safepoint();
+ return (unsigned)(p2i(p) >> LogBytesPerWord);
}
static void reset_states(oop obj, TRAPS) {
Handle h_obj(THREAD, obj);
InstanceKlass* klass = InstanceKlass::cast(obj->klass());
//
// 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.
- int hash_original = obj->identity_hash();
- archived_oop->set_mark(markWord::prototype().copy_set_hash(hash_original));
- assert(archived_oop->mark().is_unlocked(), "sanity");
+ if (!(EnableValhalla && obj->mark().is_inline_type())) {
+ int hash_original = obj->identity_hash();
+ archived_oop->set_mark(archived_oop->klass()->prototype_header().copy_set_hash(hash_original));
+ assert(archived_oop->mark().is_unlocked(), "sanity");
- DEBUG_ONLY(int hash_archived = archived_oop->identity_hash());
- assert(hash_original == hash_archived, "Different hash codes: original %x, archived %x", hash_original, hash_archived);
+ DEBUG_ONLY(int hash_archived = archived_oop->identity_hash());
+ assert(hash_original == hash_archived, "Different hash codes: original %x, archived %x", hash_original, hash_archived);
+ }
ArchivedObjectCache* cache = archived_object_cache();
CachedOopInfo info = make_cached_oop_info(archived_oop);
cache->put(obj, info);
if (log_is_enabled(Debug, cds, heap)) {
HeapWord* mem = G1CollectedHeap::heap()->archive_mem_allocate(size);
memset(mem, 0, size * BytesPerWord);
{
// This is copied from MemAllocator::finish
- oopDesc::set_mark(mem, markWord::prototype());
+ oopDesc::set_mark(mem, k->prototype_header());
oopDesc::release_set_klass(mem, k);
}
{
// This is copied from ObjArrayAllocator::initialize
arrayOopDesc::set_length(mem, length);
< prev index next >