From e416945dc59c982794c1467b38a5bf8dadff1bb9 Mon Sep 17 00:00:00 2001 From: Andrej Pecimuth Date: Fri, 10 Oct 2025 12:27:32 +0200 Subject: [PATCH] Enable replay launcher by default. --- compiler/docs/ReplayCompilation.md | 14 ++++---------- .../compiler/libgraal/LibGraalEntryPoints.java | 14 +------------- .../replaycomp/test/ReplayCompilationLauncher.java | 9 +-------- .../replaycomp/ReplayCompilationProxies.java | 2 -- .../replaycomp/ReplayCompilationRunner.java | 3 --- .../replaycomp/ReplayCompilationSupport.java | 11 ----------- 6 files changed, 6 insertions(+), 47 deletions(-) diff --git a/compiler/docs/ReplayCompilation.md b/compiler/docs/ReplayCompilation.md index 66ad033ad9d7..d14552005741 100644 --- a/compiler/docs/ReplayCompilation.md +++ b/compiler/docs/ReplayCompilation.md @@ -65,18 +65,12 @@ Any `-ea`, `-esa`, and `-X` arguments from the command line are passed to the JV Jargraal can replay both jargraal and libgraal compilations. Libgraal can replay only libgraal compilations. -It is necessary to explicitly enable the replay launcher entry point when building libgraal using the VM argument -`-Ddebug.jdk.graal.enableReplayLauncher=true`. - -```shell -EXTRA_IMAGE_BUILDER_ARGUMENTS=-Ddebug.jdk.graal.enableReplayLauncher=true mx --env libgraal build -``` - -When the `--libgraal` argument is passed to `mx replaycomp`, the previously built libgraal native library is loaded, and -the native launcher is invoked instead of the Java launcher. With the below command, all replay related processing -(including JSON parsing) is performed by libgraal code. +To replay on libgraal, build libgraal first. Then, pass the `--libgraal` argument to `mx replaycomp`, which invokes the +native launcher. With the below commands, all replay related processing (including JSON parsing) is performed by +libgraal code. ```shell +mx -p ../vm --env libgraal build mx replaycomp --libgraal ./replay-files ``` diff --git a/compiler/src/jdk.graal.compiler.libgraal/src/jdk/graal/compiler/libgraal/LibGraalEntryPoints.java b/compiler/src/jdk.graal.compiler.libgraal/src/jdk/graal/compiler/libgraal/LibGraalEntryPoints.java index 30680f01da9f..b167022861a9 100644 --- a/compiler/src/jdk.graal.compiler.libgraal/src/jdk/graal/compiler/libgraal/LibGraalEntryPoints.java +++ b/compiler/src/jdk.graal.compiler.libgraal/src/jdk/graal/compiler/libgraal/LibGraalEntryPoints.java @@ -31,7 +31,6 @@ import java.io.PrintStream; import java.util.Arrays; import java.util.Map; -import java.util.function.BooleanSupplier; import org.graalvm.collections.EconomicMap; import org.graalvm.jniutils.JNI.JNIEnv; @@ -54,7 +53,6 @@ import jdk.graal.compiler.hotspot.HotSpotGraalServices; import jdk.graal.compiler.hotspot.ProfileReplaySupport; import jdk.graal.compiler.hotspot.replaycomp.ReplayCompilationRunner; -import jdk.graal.compiler.hotspot.replaycomp.ReplayCompilationSupport; import jdk.graal.compiler.options.OptionDescriptors; import jdk.graal.compiler.options.OptionKey; import jdk.graal.compiler.options.OptionValues; @@ -301,7 +299,7 @@ private static long hashConstantOopFields(JNIEnv jniEnv, * @return the exit status of the replay compilation launcher */ @SuppressWarnings({"unused", "try"}) - @CEntryPoint(name = "Java_jdk_graal_compiler_hotspot_replaycomp_test_ReplayCompilationLauncher_runInLibgraal", include = LibGraalReplayLauncherEnabled.class) + @CEntryPoint(name = "Java_jdk_graal_compiler_hotspot_replaycomp_test_ReplayCompilationLauncher_runInLibgraal", include = LibGraalFeature.IsEnabled.class) private static int replayCompilation(JNIEnv jniEnv, PointerBase jclass, @IsolateThreadContext long isolateThread, @@ -322,14 +320,4 @@ private static int replayCompilation(JNIEnv jniEnv, LibGraalSupportImpl.doReferenceHandling(); } } - - /** - * Controls whether the replay launcher entry point should be included in libgraal. - */ - private static final class LibGraalReplayLauncherEnabled implements BooleanSupplier { - @Override - public boolean getAsBoolean() { - return new LibGraalFeature.IsEnabled().getAsBoolean() && ReplayCompilationSupport.ENABLE_REPLAY_LAUNCHER; - } - } } diff --git a/compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/hotspot/replaycomp/test/ReplayCompilationLauncher.java b/compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/hotspot/replaycomp/test/ReplayCompilationLauncher.java index 42680566b949..5731c0c55a64 100644 --- a/compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/hotspot/replaycomp/test/ReplayCompilationLauncher.java +++ b/compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/hotspot/replaycomp/test/ReplayCompilationLauncher.java @@ -31,7 +31,6 @@ import jdk.graal.compiler.api.test.ModuleSupport; import jdk.graal.compiler.hotspot.replaycomp.ReplayCompilationRunner; -import jdk.graal.compiler.hotspot.replaycomp.ReplayCompilationSupport; import jdk.graal.compiler.hotspot.test.LibGraalCompilationDriver; /** @@ -55,13 +54,7 @@ public class ReplayCompilationLauncher { public static void main(String[] args) { if (LibGraal.isAvailable()) { - try { - LibGraal.registerNativeMethods(ReplayCompilationLauncher.class); - } catch (Error error) { - System.err.printf("The replay launcher entry point could not be linked. Build libgraal with -D%s=true as an extra image builder option to enable the launcher.%n", - ReplayCompilationSupport.ENABLE_REPLAY_LAUNCHER_PROP); - throw error; - } + LibGraal.registerNativeMethods(ReplayCompilationLauncher.class); StringBuilder argString = new StringBuilder(); for (String arg : args) { if (!argString.isEmpty()) { diff --git a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/replaycomp/ReplayCompilationProxies.java b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/replaycomp/ReplayCompilationProxies.java index 673234c0b777..dfd41e874266 100644 --- a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/replaycomp/ReplayCompilationProxies.java +++ b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/replaycomp/ReplayCompilationProxies.java @@ -35,7 +35,6 @@ import org.graalvm.collections.EconomicMap; import org.graalvm.collections.Equivalence; -import jdk.graal.compiler.core.common.LibGraalSupport; import jdk.graal.compiler.debug.DebugCloseable; import jdk.graal.compiler.debug.DebugContext; import jdk.graal.compiler.debug.GlobalMetrics; @@ -77,7 +76,6 @@ * * @see ReplayCompilationSupport */ -@LibGraalSupport.HostedOnly(unlessTrue = ReplayCompilationSupport.ENABLE_REPLAY_LAUNCHER_PROP) public class ReplayCompilationProxies implements CompilationProxies { public static class Options { // @formatter:off diff --git a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/replaycomp/ReplayCompilationRunner.java b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/replaycomp/ReplayCompilationRunner.java index 28c0ca445ef5..86863a22901c 100644 --- a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/replaycomp/ReplayCompilationRunner.java +++ b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/replaycomp/ReplayCompilationRunner.java @@ -66,15 +66,12 @@ import jdk.vm.ci.hotspot.HotSpotCompilationRequest; import jdk.vm.ci.hotspot.HotSpotJVMCIRuntime; -//JaCoCo Exclude - /** * The entry point for running replay compilations in jargraal and libgraal. * * @see ReplayCompilationSupport * @see CompilerInterfaceDeclarations */ -@LibGraalSupport.HostedOnly(unlessTrue = ReplayCompilationSupport.ENABLE_REPLAY_LAUNCHER_PROP) public class ReplayCompilationRunner { /** * The exit status of a replay compilation run. diff --git a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/replaycomp/ReplayCompilationSupport.java b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/replaycomp/ReplayCompilationSupport.java index 564687fbdbef..ae3fa84b0a8f 100644 --- a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/replaycomp/ReplayCompilationSupport.java +++ b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/replaycomp/ReplayCompilationSupport.java @@ -47,7 +47,6 @@ import jdk.graal.compiler.options.OptionValues; import jdk.graal.compiler.printer.CanonicalStringGraphPrinter; import jdk.graal.compiler.replacements.SnippetTemplate; -import jdk.graal.compiler.serviceprovider.GraalServices; import jdk.graal.compiler.util.json.JsonWriter; import jdk.vm.ci.hotspot.HotSpotCompilationRequest; import jdk.vm.ci.hotspot.HotSpotJVMCIRuntime; @@ -104,16 +103,6 @@ * replay is close to the code compiled during recording. */ public final class ReplayCompilationSupport { - /** - * Libgraal build-time system property name for enabling the replay compilation launcher. - */ - public static final String ENABLE_REPLAY_LAUNCHER_PROP = "debug.jdk.graal.enableReplayLauncher"; - - /** - * Whether the replay compilation launcher is enabled in libgraal. - */ - public static final boolean ENABLE_REPLAY_LAUNCHER = Boolean.parseBoolean(GraalServices.getSavedProperty(ENABLE_REPLAY_LAUNCHER_PROP)); - /** * Checks whether the given method's compilation should be recorded according to the given * options.