diff --git a/src/hotspot/share/cds/archiveHeapWriter.cpp b/src/hotspot/share/cds/archiveHeapWriter.cpp index 710e693bfdb..a55325978de 100644 --- a/src/hotspot/share/cds/archiveHeapWriter.cpp +++ b/src/hotspot/share/cds/archiveHeapWriter.cpp @@ -558,9 +558,12 @@ void ArchiveHeapWriter::update_header_for_requested_obj(oop requested_obj, oop s oop fake_oop = cast_to_oop(buffered_addr); fake_oop->set_narrow_klass(nk); + if (src_obj == nullptr) { + return; + } // We need to retain the identity_hash, because it may have been used by some hashtables // in the shared heap. - if (src_obj != nullptr && !src_obj->fast_no_hash_check()) { + if (!src_obj->fast_no_hash_check()) { intptr_t src_hash = src_obj->identity_hash(); fake_oop->set_mark(markWord::prototype().copy_set_hash(src_hash)); assert(fake_oop->mark().is_unlocked(), "sanity"); @@ -568,6 +571,8 @@ void ArchiveHeapWriter::update_header_for_requested_obj(oop requested_obj, oop s DEBUG_ONLY(intptr_t archived_hash = fake_oop->identity_hash()); assert(src_hash == archived_hash, "Different hash codes: original " INTPTR_FORMAT ", archived " INTPTR_FORMAT, src_hash, archived_hash); } + // Strip age bits. + fake_oop->set_mark(fake_oop->mark().set_age(0)); } class ArchiveHeapWriter::EmbeddedOopRelocator: public BasicOopIterateClosure { diff --git a/test/hotspot/jtreg/runtime/cds/DeterministicDump.java b/test/hotspot/jtreg/runtime/cds/DeterministicDump.java index cc8d8c2b1dd..6b6431c0e5e 100644 --- a/test/hotspot/jtreg/runtime/cds/DeterministicDump.java +++ b/test/hotspot/jtreg/runtime/cds/DeterministicDump.java @@ -50,8 +50,10 @@ public class DeterministicDump { public static void doTest(boolean compressed) throws Exception { ArrayList baseArgs = new ArrayList<>(); - // Use the same heap size as make/Images.gmk + // Try to reduce indeterminism of GC heap sizing and evacuation. baseArgs.add("-Xmx128M"); + baseArgs.add("-Xms128M"); + baseArgs.add("-Xmn120M"); if (Platform.is64bit()) { // This option is available only on 64-bit. @@ -80,7 +82,7 @@ public class DeterministicDump { String mapName = logName + ".map"; CDSOptions opts = (new CDSOptions()) .addPrefix("-Xint") // Override any -Xmixed/-Xcomp flags from jtreg -vmoptions - .addPrefix("-Xlog:cds=debug") + .addPrefix("-Xlog:cds=debug,gc=debug") .addPrefix("-Xlog:cds+map*=trace:file=" + mapName + ":none:filesize=0") .setArchiveName(archiveName) .addSuffix(args)