Skip to content

Commit

Permalink
* fix heap size for test
Browse files Browse the repository at this point in the history
* testing some changes, reproduction

* clean up test
  • Loading branch information
tschatzl committed Oct 30, 2024
1 parent cc7c398 commit ccbb180
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/hotspot/share/cds/archiveBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1206,6 +1206,7 @@ class ArchiveBuilder::CDSMapLogger : AllStatic {
ArchiveBuilder* builder = ArchiveBuilder::current();
Klass* requested_klass = builder->to_requested(builder->get_buffered_addr(source_klass));

st.print(" - markword: "); source_oop->mark().print_on(&st); st.cr();
st.print(" - klass: ");
source_klass->print_value_on(&st);
st.print(" " PTR_FORMAT, p2i(requested_klass));
Expand Down
7 changes: 6 additions & 1 deletion src/hotspot/share/cds/archiveHeapWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -558,16 +558,21 @@ 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");

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 {
Expand Down
12 changes: 8 additions & 4 deletions test/hotspot/jtreg/runtime/cds/DeterministicDump.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,21 @@ public static void main(String[] args) throws Exception {
public static void doTest(boolean compressed) throws Exception {
ArrayList<String> 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("-Xmn128M");
baseArgs.add("-XX:ParallelGCThreads=1");
baseArgs.add("-XX:-ResizeTLAB");
baseArgs.add("-XX:-ResizePLAB");

if (Platform.is64bit()) {
// This option is available only on 64-bit.
String sign = (compressed) ? "+" : "-";
baseArgs.add("-XX:" + sign + "UseCompressedOops");
}

String baseArchive = dump(baseArgs);

// (1) Dump with the same args. Should produce the same archive.
String baseArchive2 = dump(baseArgs);
compare(baseArchive, baseArchive2);
Expand All @@ -80,7 +84,7 @@ static String dump(ArrayList<String> args, String... more) throws Exception {
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)
Expand Down

0 comments on commit ccbb180

Please sign in to comment.