From e4076b09dff90701a3f192d3eefba27d35c260d6 Mon Sep 17 00:00:00 2001 From: Daniel Skantz Date: Mon, 20 Apr 2026 06:38:10 +0000 Subject: [PATCH] 8375905: Add a missing bailout check in PhaseCFG::schedule_late and a test to exercise more bailout code paths Reviewed-by: dfenacci, chagedorn, rcastanedalo --- src/hotspot/share/opto/gcm.cpp | 3 ++ .../compiler/debug/TestStressBailout.java | 28 +++++++++++++------ 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/src/hotspot/share/opto/gcm.cpp b/src/hotspot/share/opto/gcm.cpp index e3d3108a22e..ce1ea8a59e2 100644 --- a/src/hotspot/share/opto/gcm.cpp +++ b/src/hotspot/share/opto/gcm.cpp @@ -1743,6 +1743,9 @@ void PhaseCFG::schedule_late(VectorSet &visited, Node_Stack &stack) { // are needed make sure that after placement in a block we don't // need any new precedence edges. verify_anti_dependences(late, self); + if (C->failing()) { + return; + } } #endif } // Loop until all nodes have been visited diff --git a/test/hotspot/jtreg/compiler/debug/TestStressBailout.java b/test/hotspot/jtreg/compiler/debug/TestStressBailout.java index 68610576a39..f79cb679c41 100644 --- a/test/hotspot/jtreg/compiler/debug/TestStressBailout.java +++ b/test/hotspot/jtreg/compiler/debug/TestStressBailout.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 2026, Oracle and/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 @@ -24,6 +24,7 @@ package compiler.debug; import java.util.Random; +import java.util.stream.Stream; import jdk.test.lib.process.OutputAnalyzer; import jdk.test.lib.process.ProcessTools; @@ -36,24 +37,33 @@ import jdk.test.lib.Utils; * @requires vm.debug == true & vm.compiler2.enabled & (vm.opt.AbortVMOnCompilationFailure == "null" | !vm.opt.AbortVMOnCompilationFailure) * @summary Basic tests for bailout stress flag. * @library /test/lib / - * @run driver compiler.debug.TestStressBailout + * @run main compiler.debug.TestStressBailout + */ + +/* + * @test + * @key stress randomness + * @bug 8375905 + * @requires vm.debug == true & vm.compiler2.enabled & (vm.opt.AbortVMOnCompilationFailure == "null" | !vm.opt.AbortVMOnCompilationFailure) + * @summary Additional crashes revealed by diagnostic code run during VerifyIterativeGVN + * @library /test/lib / + * @run main compiler.debug.TestStressBailout -XX:VerifyIterativeGVN=1111 */ public class TestStressBailout { - static void runTest(int invprob) throws Exception { - String[] procArgs = {"-Xcomp", "-XX:-TieredCompilation", "-XX:+StressBailout", - "-XX:StressBailoutMean=" + invprob, "-version"}; - ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder(procArgs); + static void runTest(int invprob, Stream vmArgs) throws Exception { + Stream procArgs = Stream.of("-Xcomp", "-XX:-TieredCompilation", "-XX:+StressBailout", "-XX:StressBailoutMean=" + invprob, "-version"); + ProcessBuilder pb = ProcessTools.createTestJavaProcessBuilder(Stream.concat(vmArgs, procArgs).toArray(x -> new String[x])); OutputAnalyzer out = new OutputAnalyzer(pb.start()); out.shouldHaveExitValue(0); } - public static void main(String[] args) throws Exception { + public static void main(String[] vmArgs) throws Exception { Random r = Utils.getRandomInstance(); // Likely bail out on -version, for some low Mean value. - runTest(r.nextInt(1, 10)); + runTest(r.nextInt(1, 10), Stream.of(vmArgs)); // Higher value - runTest(r.nextInt(10, 1_000_000)); + runTest(r.nextInt(10, 1_000_000), Stream.of(vmArgs)); } }