8381871: GenShen: ShenandoahGCHeuristics flag not reset after ignoring non-adaptive value

Reviewed-by: xpeng, kdnilsen, ysr, serb, wkemper
This commit is contained in:
Patrick Fontanilla 2026-04-15 19:02:28 +00:00 committed by Sergey Bylokhov
parent 29434cc651
commit 5acbf8baea
2 changed files with 85 additions and 0 deletions

View File

@ -200,6 +200,7 @@ void ShenandoahArguments::initialize() {
&& strcmp(ShenandoahGCHeuristics, "adaptive") != 0) {
log_warning(gc)("Ignoring -XX:ShenandoahGCHeuristics input: %s, because generational shenandoah only"
" supports adaptive heuristics", ShenandoahGCHeuristics);
FLAG_SET_ERGO(ShenandoahGCHeuristics, "adaptive");
}
FullGCForwarding::initialize_flags(MaxHeapSize);

View File

@ -0,0 +1,84 @@
/*
* Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*
*/
/*
* @test id=generational
* @bug 8381871
* @summary Test that ShenandoahGCHeuristics is always adaptive in generational mode
* @requires vm.gc.Shenandoah
* @library /test/lib
* @run driver TestGenerationalHeuristics
*/
import jdk.test.lib.process.ProcessTools;
import jdk.test.lib.process.OutputAnalyzer;
public class TestGenerationalHeuristics {
public static void main(String[] args) throws Exception {
{
OutputAnalyzer output = ProcessTools.executeLimitedTestJava(
"-XX:+UseShenandoahGC",
"-XX:ShenandoahGCMode=generational",
"-XX:ShenandoahGCHeuristics=adaptive",
"-XX:+PrintFlagsFinal",
"-version");
output.shouldMatch("ShenandoahGCHeuristics(.*)= adaptive ");
output.shouldHaveExitValue(0);
}
{
OutputAnalyzer output = ProcessTools.executeLimitedTestJava(
"-XX:+UseShenandoahGC",
"-XX:ShenandoahGCMode=generational",
"-XX:ShenandoahGCHeuristics=static",
"-XX:+PrintFlagsFinal",
"-version");
output.shouldMatch("ShenandoahGCHeuristics(.*)= adaptive ");
output.shouldHaveExitValue(0);
}
{
OutputAnalyzer output = ProcessTools.executeLimitedTestJava(
"-XX:+UseShenandoahGC",
"-XX:ShenandoahGCMode=generational",
"-XX:ShenandoahGCHeuristics=aggressive",
"-XX:+PrintFlagsFinal",
"-version");
output.shouldMatch("ShenandoahGCHeuristics(.*)= adaptive ");
output.shouldHaveExitValue(0);
}
{
OutputAnalyzer output = ProcessTools.executeLimitedTestJava(
"-XX:+UseShenandoahGC",
"-XX:ShenandoahGCMode=generational",
"-XX:ShenandoahGCHeuristics=compact",
"-XX:+PrintFlagsFinal",
"-version");
output.shouldMatch("ShenandoahGCHeuristics(.*)= adaptive ");
output.shouldHaveExitValue(0);
}
}
}