From f2b4e12afe67086a2ae08081fd545e5ce4d731fd Mon Sep 17 00:00:00 2001 From: Doug Simon Date: Tue, 18 Feb 2025 20:18:08 +0000 Subject: [PATCH] 8350263: JvmciNotifyBootstrapFinishedEventTest intermittently times out Reviewed-by: yzheng, never --- .../TestUncaughtErrorInCompileMethod.config | 2 +- .../TestUncaughtErrorInCompileMethod.java | 52 ++++++++++--------- ...mciNotifyBootstrapFinishedEventTest.config | 2 +- ...JvmciNotifyBootstrapFinishedEventTest.java | 31 ++++++----- 4 files changed, 48 insertions(+), 39 deletions(-) diff --git a/test/hotspot/jtreg/compiler/jvmci/TestUncaughtErrorInCompileMethod.config b/test/hotspot/jtreg/compiler/jvmci/TestUncaughtErrorInCompileMethod.config index 521c27977f2..f54fcb0b8dc 100644 --- a/test/hotspot/jtreg/compiler/jvmci/TestUncaughtErrorInCompileMethod.config +++ b/test/hotspot/jtreg/compiler/jvmci/TestUncaughtErrorInCompileMethod.config @@ -1 +1 @@ -compiler.jvmci.TestUncaughtErrorInCompileMethod +compiler.jvmci.TestUncaughtErrorInCompileMethod$Locator diff --git a/test/hotspot/jtreg/compiler/jvmci/TestUncaughtErrorInCompileMethod.java b/test/hotspot/jtreg/compiler/jvmci/TestUncaughtErrorInCompileMethod.java index 511e0c4b98c..49eae648bfc 100644 --- a/test/hotspot/jtreg/compiler/jvmci/TestUncaughtErrorInCompileMethod.java +++ b/test/hotspot/jtreg/compiler/jvmci/TestUncaughtErrorInCompileMethod.java @@ -56,7 +56,7 @@ import java.util.List; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; -public class TestUncaughtErrorInCompileMethod extends JVMCIServiceLocator { +public class TestUncaughtErrorInCompileMethod { static volatile boolean compilerCreationErrorOccurred; @@ -86,6 +86,7 @@ public class TestUncaughtErrorInCompileMethod extends JVMCIServiceLocator { ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( "-XX:+UnlockExperimentalVMOptions", "-XX:+UseJVMCICompiler", "-Djvmci.Compiler=ErrorCompiler", + "-XX:-UseJVMCINativeLibrary", "-XX:-TieredCompilation", "-XX:+PrintCompilation", "--add-exports=jdk.internal.vm.ci/jdk.vm.ci.services=ALL-UNNAMED", @@ -124,7 +125,7 @@ public class TestUncaughtErrorInCompileMethod extends JVMCIServiceLocator { // Check that hs-err contains the stack trace of the fatal exception (sample shown above) String[] stackTraceSubstrings = { - "at compiler.jvmci.TestUncaughtErrorInCompileMethod$1.createCompiler(TestUncaughtErrorInCompileMethod.java", + "at compiler.jvmci.TestUncaughtErrorInCompileMethod$Locator$1.createCompiler(TestUncaughtErrorInCompileMethod.java", "at jdk.internal.vm.ci/jdk.vm.ci.hotspot.HotSpotJVMCIRuntime.compileMethod(HotSpotJVMCIRuntime.java" }; for (String expect : stackTraceSubstrings) { @@ -172,31 +173,34 @@ public class TestUncaughtErrorInCompileMethod extends JVMCIServiceLocator { } } - @Override - public S getProvider(Class service) { - if (service == JVMCICompilerFactory.class) { - return service.cast(new JVMCICompilerFactory() { - final AtomicInteger counter = new AtomicInteger(); - @Override - public String getCompilerName() { - return "ErrorCompiler"; - } + public static class Locator extends JVMCIServiceLocator { - @Override - public JVMCICompiler createCompiler(JVMCIRuntime runtime) { - int attempt = counter.incrementAndGet(); - CompilerCreationError e = new CompilerCreationError(attempt); - e.printStackTrace(); - if (attempt >= 10) { - // Delay notifying the loop in main so that compilation failures - // have time to be reported by -XX:+PrintCompilation. - compilerCreationErrorOccurred = true; + @Override + public S getProvider(Class service) { + if (service == JVMCICompilerFactory.class) { + return service.cast(new JVMCICompilerFactory() { + final AtomicInteger counter = new AtomicInteger(); + @Override + public String getCompilerName() { + return "ErrorCompiler"; } - throw e; - } - }); + + @Override + public JVMCICompiler createCompiler(JVMCIRuntime runtime) { + int attempt = counter.incrementAndGet(); + CompilerCreationError e = new CompilerCreationError(attempt); + e.printStackTrace(); + if (attempt >= 10) { + // Delay notifying the loop in main so that compilation failures + // have time to be reported by -XX:+PrintCompilation. + compilerCreationErrorOccurred = true; + } + throw e; + } + }); + } + return null; } - return null; } /** diff --git a/test/hotspot/jtreg/compiler/jvmci/events/JvmciNotifyBootstrapFinishedEventTest.config b/test/hotspot/jtreg/compiler/jvmci/events/JvmciNotifyBootstrapFinishedEventTest.config index 19cd01ec1e1..709b87f94ef 100644 --- a/test/hotspot/jtreg/compiler/jvmci/events/JvmciNotifyBootstrapFinishedEventTest.config +++ b/test/hotspot/jtreg/compiler/jvmci/events/JvmciNotifyBootstrapFinishedEventTest.config @@ -1,2 +1,2 @@ -compiler.jvmci.events.JvmciNotifyBootstrapFinishedEventTest +compiler.jvmci.events.JvmciNotifyBootstrapFinishedEventTest$Locator compiler.jvmci.common.JVMCIHelpers diff --git a/test/hotspot/jtreg/compiler/jvmci/events/JvmciNotifyBootstrapFinishedEventTest.java b/test/hotspot/jtreg/compiler/jvmci/events/JvmciNotifyBootstrapFinishedEventTest.java index 6230dda8802..8d3b5fcce5b 100644 --- a/test/hotspot/jtreg/compiler/jvmci/events/JvmciNotifyBootstrapFinishedEventTest.java +++ b/test/hotspot/jtreg/compiler/jvmci/events/JvmciNotifyBootstrapFinishedEventTest.java @@ -62,29 +62,34 @@ import jdk.test.lib.Asserts; import jdk.vm.ci.services.JVMCIServiceLocator; import jdk.vm.ci.hotspot.HotSpotVMEventListener; -public class JvmciNotifyBootstrapFinishedEventTest extends JVMCIServiceLocator implements HotSpotVMEventListener { +public class JvmciNotifyBootstrapFinishedEventTest { private static final boolean BOOTSTRAP = Boolean .getBoolean("compiler.jvmci.events.JvmciNotifyBootstrapFinishedEventTest.bootstrap"); - private static volatile int gotBoostrapNotification = 0; + private static volatile int gotBootstrapNotification = 0; public static void main(String args[]) { if (BOOTSTRAP) { - Asserts.assertEQ(gotBoostrapNotification, 1, "Did not receive expected number of bootstrap events"); + Asserts.assertEQ(gotBootstrapNotification, 1, "Did not receive expected number of bootstrap events"); } else { - Asserts.assertEQ(gotBoostrapNotification, 0, "Got unexpected bootstrap event"); + Asserts.assertEQ(gotBootstrapNotification, 0, "Got unexpected bootstrap event"); } } - @Override - public S getProvider(Class service) { - if (service == HotSpotVMEventListener.class) { - return service.cast(this); + public static class Locator extends JVMCIServiceLocator implements HotSpotVMEventListener { + public Locator() { + Thread.dumpStack(); + } + @Override + public S getProvider(Class service) { + if (service == HotSpotVMEventListener.class) { + return service.cast(this); + } + return null; } - return null; - } - @Override - public void notifyBootstrapFinished() { - gotBoostrapNotification++; + @Override + public void notifyBootstrapFinished() { + gotBootstrapNotification++; + } } }