Skip to content

Commit 2eeda64

Browse files
committed
8325132: CDS: Make sure the ArchiveRelocationMode is always printed in the log
Reviewed-by: shade, iklam
1 parent 50ac24e commit 2eeda64

File tree

4 files changed

+18
-8
lines changed

4 files changed

+18
-8
lines changed

src/hotspot/share/cds/metaspaceShared.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1134,6 +1134,8 @@ void MetaspaceShared::initialize_runtime_shared_and_meta_spaces() {
11341134
log_info(cds)("Core region alignment: %zu", static_mapinfo->core_region_alignment());
11351135
dynamic_mapinfo = open_dynamic_archive();
11361136

1137+
log_info(cds)("ArchiveRelocationMode: %d", ArchiveRelocationMode);
1138+
11371139
// First try to map at the requested address
11381140
result = map_archives(static_mapinfo, dynamic_mapinfo, true);
11391141
if (result == MAP_ARCHIVE_MMAP_FAILURE) {

test/hotspot/jtreg/runtime/cds/appcds/ArchiveRelocationTest.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ static void test(boolean run_reloc) throws Exception {
6161

6262
String appJar = ClassFileInstaller.getJarPath("hello.jar");
6363
String mainClass = "Hello";
64-
String forceRelocation = "-XX:ArchiveRelocationMode=1";
65-
String runRelocArg = run_reloc ? forceRelocation : "-showversion";
64+
String maybeRelocation = "-XX:ArchiveRelocationMode=0";
65+
String runRelocArg = run_reloc ? "-showversion" : maybeRelocation;
6666
String logArg = "-Xlog:cds=debug,cds+reloc=debug,cds+heap";
6767
String unlockArg = "-XX:+UnlockDiagnosticVMOptions";
6868
String nmtArg = "-XX:NativeMemoryTracking=detail";
@@ -75,7 +75,10 @@ static void test(boolean run_reloc) throws Exception {
7575
TestCommon.run("-cp", appJar, unlockArg, runRelocArg, logArg, mainClass)
7676
.assertNormalExit(output -> {
7777
if (run_reloc) {
78-
output.shouldContain("Try to map archive(s) at an alternative address");
78+
output.shouldContain("ArchiveRelocationMode == 1: always map archive(s) at an alternative address")
79+
.shouldContain("Try to map archive(s) at an alternative address");
80+
} else {
81+
output.shouldContain("ArchiveRelocationMode: 0");
7982
}
8083
});
8184
}

test/hotspot/jtreg/runtime/cds/appcds/TestSerialGCWithCDS.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,14 +128,14 @@ static void test(boolean dumpWithSerial, boolean execWithSerial, boolean useSmal
128128
"Hello");
129129
out.shouldNotContain(errMsg);
130130

131-
System.out.println("2. Exec with " + execGC + " and test ArchiveRelocationMode");
131+
System.out.println("2. Exec with " + execGC + " and test ArchiveRelocationMode=0");
132132
out = TestCommon.exec(helloJar,
133133
execGC,
134134
small1,
135135
small2,
136136
coops,
137137
"-Xlog:cds,cds+heap",
138-
"-XX:ArchiveRelocationMode=1", // always relocate shared metadata
138+
"-XX:ArchiveRelocationMode=0", // may relocate shared metadata
139139
"Hello");
140140
out.shouldNotContain(errMsg);
141141

test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/DynamicArchiveRelocationTest.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,16 +79,17 @@ static void doTest() throws Exception {
7979

8080
String appJar = ClassFileInstaller.getJarPath("hello.jar");
8181
String mainClass = "Hello";
82-
String forceRelocation = "-XX:ArchiveRelocationMode=1";
83-
String dumpTopRelocArg = dump_top_reloc ? forceRelocation : "-showversion";
84-
String runRelocArg = run_reloc ? forceRelocation : "-showversion";
82+
String maybeRelocation = "-XX:ArchiveRelocationMode=0";
83+
String dumpTopRelocArg = dump_top_reloc ? "-showversion" : maybeRelocation;
84+
String runRelocArg = run_reloc ? "-showversion" : maybeRelocation;
8585
String logArg = "-Xlog:cds=debug,cds+reloc=debug";
8686

8787
String baseArchiveName = getNewArchiveName("base");
8888
String topArchiveName = getNewArchiveName("top");
8989

9090
String runtimeMsg = "Try to map archive(s) at an alternative address";
9191
String unlockArg = "-XX:+UnlockDiagnosticVMOptions";
92+
String relocationModeMsg = "ArchiveRelocationMode: 0";
9293

9394
// (1) Dump base archive (static)
9495

@@ -105,6 +106,8 @@ static void doTest() throws Exception {
105106
.assertNormalExit(output -> {
106107
if (dump_top_reloc) {
107108
output.shouldContain(runtimeMsg);
109+
} else {
110+
output.shouldContain(relocationModeMsg);
108111
}
109112
});
110113

@@ -116,6 +119,8 @@ static void doTest() throws Exception {
116119
.assertNormalExit(output -> {
117120
if (run_reloc) {
118121
output.shouldContain(runtimeMsg);
122+
} else {
123+
output.shouldContain(relocationModeMsg);
119124
}
120125
});
121126
}

0 commit comments

Comments
 (0)