Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 4 additions & 10 deletions compiler/docs/ReplayCompilation.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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,
Expand All @@ -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;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand All @@ -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()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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.
Expand Down