Skip to content

Commit

Permalink
8341553: Remove UseCompactObjectHeaders extra CDS archives
Browse files Browse the repository at this point in the history
  • Loading branch information
calvinccheung committed Nov 12, 2024
1 parent a4e2c20 commit 85bfbba
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 5 deletions.
9 changes: 6 additions & 3 deletions make/autoconf/jdk-options.m4
Original file line number Diff line number Diff line change
Expand Up @@ -705,9 +705,9 @@ AC_DEFUN([JDKOPT_ENABLE_DISABLE_CDS_ARCHIVE],
#
AC_DEFUN([JDKOPT_ENABLE_DISABLE_CDS_ARCHIVE_COH],
[
UTIL_ARG_ENABLE(NAME: cds-archive-coh, DEFAULT: auto, RESULT: BUILD_CDS_ARCHIVE_COH,
UTIL_ARG_ENABLE(NAME: cds-archive-coh, DEFAULT: false, RESULT: BUILD_CDS_ARCHIVE_COH,
DESC: [enable generation of default CDS archives for compact object headers (requires --enable-cds-archive)],
DEFAULT_DESC: [auto],
DEFAULT_DESC: [false],
CHECKING_MSG: [if default CDS archives for compact object headers should be generated],
CHECK_AVAILABLE: [
AC_MSG_CHECKING([if CDS archive with compact object headers is available])
Expand All @@ -722,9 +722,12 @@ AC_DEFUN([JDKOPT_ENABLE_DISABLE_CDS_ARCHIVE_COH],
test "x$OPENJDK_TARGET_CPU" != "xs390x"; then
AC_MSG_RESULT([no (compact object headers not supported for this platform)])
AVAILABLE=false
else
elif test "x$enable_cds_archive_coh" = "xyes"; then
AC_MSG_RESULT([yes])
AVAILABLE=true
else
AC_MSG_RESULT([yes])
AVAILABLE=false
fi
])
AC_SUBST(BUILD_CDS_ARCHIVE_COH)
Expand Down
50 changes: 48 additions & 2 deletions test/hotspot/jtreg/runtime/cds/TestDefaultArchiveLoading.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,51 @@
* @run driver TestDefaultArchiveLoading coops_coh
*/

import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import jdk.test.lib.Platform;
import jdk.test.lib.process.OutputAnalyzer;
import jdk.test.lib.process.ProcessTools;
import jtreg.SkippedException;

public class TestDefaultArchiveLoading {

private static String archiveName(String archiveSuffix) {
return "classes" + archiveSuffix + ".jsa";
}

private static Path archivePath(String archiveSuffix) {
return Paths.get(System.getProperty("java.home"), "lib",
"server", archiveName(archiveSuffix));
}

// Returns false if the COH archive already exists.
private static boolean createCOHArchive(char coops, char coh,
String archiveSuffix) throws Exception {
Path archive= archivePath(archiveSuffix);
if (Files.exists(archive)) {
return false;
}

ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(
"-XX:+UnlockExperimentalVMOptions",
"-XX:" + coh + "UseCompactObjectHeaders",
"-XX:" + coops + "UseCompressedOops",
"-Xlog:cds",
"-Xshare:dump");

OutputAnalyzer output = new OutputAnalyzer(pb.start());
output.shouldHaveExitValue(0)
.shouldContain(archiveName(archiveSuffix));
return true;
}

private static void deleteArchive(String archiveSuffix) throws Exception {
Path archive= archivePath(archiveSuffix);
Files.deleteIfExists(archive);
System.out.println("Deleted archive: " + archive.toString());
}

public static void main(String[] args) throws Exception {

if (args.length != 1) {
Expand All @@ -80,6 +119,7 @@ public static void main(String[] args) throws Exception {

String archiveSuffix;
char coh, coops;
boolean needsCleanup = false;;

switch (args[0]) {
case "nocoops_nocoh":
Expand All @@ -90,6 +130,7 @@ public static void main(String[] args) throws Exception {
coops = '-';
coh = '+';
archiveSuffix = "_nocoops_coh";
needsCleanup = createCOHArchive(coops, coh, archiveSuffix);
break;
case "coops_nocoh":
coops = '+';
Expand All @@ -99,6 +140,7 @@ public static void main(String[] args) throws Exception {
case "coops_coh":
coh = coops = '+';
archiveSuffix = "_coh";
needsCleanup = createCOHArchive(coops, coh, archiveSuffix);
break;
default: throw new RuntimeException("Invalid argument " + args[0]);
}
Expand All @@ -114,7 +156,11 @@ public static void main(String[] args) throws Exception {
OutputAnalyzer output = new OutputAnalyzer(pb.start());
output.shouldHaveExitValue(0);

output.shouldContain("classes" + archiveSuffix + ".jsa");
output.shouldContain(archiveName(archiveSuffix));

if (needsCleanup) {
deleteArchive(archiveSuffix);
}

}
}

0 comments on commit 85bfbba

Please sign in to comment.