8350263: JvmciNotifyBootstrapFinishedEventTest intermittently times out

Reviewed-by: yzheng, never
This commit is contained in:
Doug Simon 2025-02-18 20:18:08 +00:00
parent 46d4a601e0
commit f2b4e12afe
4 changed files with 48 additions and 39 deletions

View File

@ -1 +1 @@
compiler.jvmci.TestUncaughtErrorInCompileMethod compiler.jvmci.TestUncaughtErrorInCompileMethod$Locator

View File

@ -56,7 +56,7 @@ import java.util.List;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
public class TestUncaughtErrorInCompileMethod extends JVMCIServiceLocator { public class TestUncaughtErrorInCompileMethod {
static volatile boolean compilerCreationErrorOccurred; static volatile boolean compilerCreationErrorOccurred;
@ -86,6 +86,7 @@ public class TestUncaughtErrorInCompileMethod extends JVMCIServiceLocator {
ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder( ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(
"-XX:+UnlockExperimentalVMOptions", "-XX:+UnlockExperimentalVMOptions",
"-XX:+UseJVMCICompiler", "-Djvmci.Compiler=ErrorCompiler", "-XX:+UseJVMCICompiler", "-Djvmci.Compiler=ErrorCompiler",
"-XX:-UseJVMCINativeLibrary",
"-XX:-TieredCompilation", "-XX:-TieredCompilation",
"-XX:+PrintCompilation", "-XX:+PrintCompilation",
"--add-exports=jdk.internal.vm.ci/jdk.vm.ci.services=ALL-UNNAMED", "--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) // Check that hs-err contains the stack trace of the fatal exception (sample shown above)
String[] stackTraceSubstrings = { 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" "at jdk.internal.vm.ci/jdk.vm.ci.hotspot.HotSpotJVMCIRuntime.compileMethod(HotSpotJVMCIRuntime.java"
}; };
for (String expect : stackTraceSubstrings) { for (String expect : stackTraceSubstrings) {
@ -172,31 +173,34 @@ public class TestUncaughtErrorInCompileMethod extends JVMCIServiceLocator {
} }
} }
@Override public static class Locator extends JVMCIServiceLocator {
public <S> S getProvider(Class<S> service) {
if (service == JVMCICompilerFactory.class) {
return service.cast(new JVMCICompilerFactory() {
final AtomicInteger counter = new AtomicInteger();
@Override
public String getCompilerName() {
return "ErrorCompiler";
}
@Override @Override
public JVMCICompiler createCompiler(JVMCIRuntime runtime) { public <S> S getProvider(Class<S> service) {
int attempt = counter.incrementAndGet(); if (service == JVMCICompilerFactory.class) {
CompilerCreationError e = new CompilerCreationError(attempt); return service.cast(new JVMCICompilerFactory() {
e.printStackTrace(); final AtomicInteger counter = new AtomicInteger();
if (attempt >= 10) { @Override
// Delay notifying the loop in main so that compilation failures public String getCompilerName() {
// have time to be reported by -XX:+PrintCompilation. return "ErrorCompiler";
compilerCreationErrorOccurred = true;
} }
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;
} }
/** /**

View File

@ -1,2 +1,2 @@
compiler.jvmci.events.JvmciNotifyBootstrapFinishedEventTest compiler.jvmci.events.JvmciNotifyBootstrapFinishedEventTest$Locator
compiler.jvmci.common.JVMCIHelpers compiler.jvmci.common.JVMCIHelpers

View File

@ -62,29 +62,34 @@ import jdk.test.lib.Asserts;
import jdk.vm.ci.services.JVMCIServiceLocator; import jdk.vm.ci.services.JVMCIServiceLocator;
import jdk.vm.ci.hotspot.HotSpotVMEventListener; import jdk.vm.ci.hotspot.HotSpotVMEventListener;
public class JvmciNotifyBootstrapFinishedEventTest extends JVMCIServiceLocator implements HotSpotVMEventListener { public class JvmciNotifyBootstrapFinishedEventTest {
private static final boolean BOOTSTRAP = Boolean private static final boolean BOOTSTRAP = Boolean
.getBoolean("compiler.jvmci.events.JvmciNotifyBootstrapFinishedEventTest.bootstrap"); .getBoolean("compiler.jvmci.events.JvmciNotifyBootstrapFinishedEventTest.bootstrap");
private static volatile int gotBoostrapNotification = 0; private static volatile int gotBootstrapNotification = 0;
public static void main(String args[]) { public static void main(String args[]) {
if (BOOTSTRAP) { 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 { } else {
Asserts.assertEQ(gotBoostrapNotification, 0, "Got unexpected bootstrap event"); Asserts.assertEQ(gotBootstrapNotification, 0, "Got unexpected bootstrap event");
} }
} }
@Override public static class Locator extends JVMCIServiceLocator implements HotSpotVMEventListener {
public <S> S getProvider(Class<S> service) { public Locator() {
if (service == HotSpotVMEventListener.class) { Thread.dumpStack();
return service.cast(this); }
@Override
public <S> S getProvider(Class<S> service) {
if (service == HotSpotVMEventListener.class) {
return service.cast(this);
}
return null;
} }
return null;
}
@Override @Override
public void notifyBootstrapFinished() { public void notifyBootstrapFinished() {
gotBoostrapNotification++; gotBootstrapNotification++;
}
} }
} }