Skip to content

Commit d266ca9

Browse files
committed
8348752: Enable -XX:+AOTClassLinking by default when -XX:AOTMode is specified
Reviewed-by: shade, heidinga
1 parent cbc89a7 commit d266ca9

File tree

2 files changed

+33
-3
lines changed

2 files changed

+33
-3
lines changed

src/hotspot/share/cds/cdsConfig.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,11 @@ void CDSConfig::check_flag_aliases() {
419419
bool CDSConfig::check_vm_args_consistency(bool patch_mod_javabase, bool mode_flag_cmd_line) {
420420
check_flag_aliases();
421421

422+
if (!FLAG_IS_DEFAULT(AOTMode)) {
423+
// Using any form of the new AOTMode switch enables enhanced optimizations.
424+
FLAG_SET_ERGO_IF_DEFAULT(AOTClassLinking, true);
425+
}
426+
422427
if (AOTClassLinking) {
423428
// If AOTClassLinking is specified, enable all AOT optimizations by default.
424429
FLAG_SET_ERGO_IF_DEFAULT(AOTInvokeDynamicLinking, true);

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

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2024, 2025, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -59,7 +59,7 @@ static void positiveTests() throws Exception {
5959
out.shouldContain("Hello World");
6060
out.shouldHaveExitValue(0);
6161

62-
// (2) Assembly Phase
62+
// (2) Assembly Phase (AOTClassLinking unspecified -> should be enabled by default)
6363
pb = ProcessTools.createLimitedTestJavaProcessBuilder(
6464
"-XX:AOTMode=create",
6565
"-XX:AOTConfiguration=" + aotConfigFile,
@@ -77,6 +77,7 @@ static void positiveTests() throws Exception {
7777
"-Xlog:cds",
7878
"-cp", appJar, helloClass);
7979
out = CDSTestUtils.executeAndLog(pb, "prod");
80+
out.shouldContain("Using AOT-linked classes: true (static archive: has aot-linked classes)");
8081
out.shouldContain("Opened archive hello.aot.");
8182
out.shouldContain("Hello World");
8283
out.shouldHaveExitValue(0);
@@ -107,7 +108,7 @@ static void positiveTests() throws Exception {
107108
out.shouldContain("Hello World");
108109
out.shouldHaveExitValue(0);
109110

110-
// (5) AOTMode=on
111+
// (6) AOTMode=on
111112
pb = ProcessTools.createLimitedTestJavaProcessBuilder(
112113
"-XX:AOTCache=" + aotCacheFile,
113114
"--show-version",
@@ -119,6 +120,30 @@ static void positiveTests() throws Exception {
119120
out.shouldContain("Opened archive hello.aot.");
120121
out.shouldContain("Hello World");
121122
out.shouldHaveExitValue(0);
123+
124+
// (7) Assembly Phase with -XX:-AOTClassLinking
125+
pb = ProcessTools.createLimitedTestJavaProcessBuilder(
126+
"-XX:AOTMode=create",
127+
"-XX:-AOTClassLinking",
128+
"-XX:AOTConfiguration=" + aotConfigFile,
129+
"-XX:AOTCache=" + aotCacheFile,
130+
"-Xlog:cds",
131+
"-cp", appJar);
132+
out = CDSTestUtils.executeAndLog(pb, "asm");
133+
out.shouldContain("Dumping shared data to file:");
134+
out.shouldMatch("cds.*hello[.]aot");
135+
out.shouldHaveExitValue(0);
136+
137+
// (8) Production Run with AOTCache, which was created with -XX:-AOTClassLinking
138+
pb = ProcessTools.createLimitedTestJavaProcessBuilder(
139+
"-XX:AOTCache=" + aotCacheFile,
140+
"-Xlog:cds",
141+
"-cp", appJar, helloClass);
142+
out = CDSTestUtils.executeAndLog(pb, "prod");
143+
out.shouldContain("Using AOT-linked classes: false (static archive: no aot-linked classes)");
144+
out.shouldContain("Opened archive hello.aot.");
145+
out.shouldContain("Hello World");
146+
out.shouldHaveExitValue(0);
122147
}
123148

124149
static void negativeTests() throws Exception {

0 commit comments

Comments
 (0)