Skip to content

Commit

Permalink
make use of Platforms annotation to mark hosted-only code
Browse files Browse the repository at this point in the history
  • Loading branch information
dougxc committed Oct 9, 2024
1 parent 7f59adb commit f1c6e66
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@
import jdk.vm.ci.meta.MetaAccessProvider;
import jdk.vm.ci.meta.ResolvedJavaMethod;
import jdk.vm.ci.meta.ResolvedJavaType;
import org.graalvm.nativeimage.Platform;
import org.graalvm.nativeimage.Platforms;

/**
* Filters certain method substitutions based on whether there is underlying hardware support for
Expand Down Expand Up @@ -274,6 +276,7 @@ public <T> T getInjectedArgument(Class<T> capability) {
return super.getInjectedArgument(capability);
}

@Platforms(Platform.HOSTED_ONLY.class)
public ResolvedJavaMethod findSnippetMethod(ResolvedJavaMethod thisMethod) {
if (snippetEncoder == null) {
throw new GraalError("findSnippetMethod called before initialization of Replacements");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,16 @@
import jdk.vm.ci.hotspot.HotSpotJVMCIBackendFactory;
import jdk.vm.ci.hotspot.HotSpotJVMCIRuntime;
import jdk.vm.ci.services.JVMCIServiceLocator;
import org.graalvm.nativeimage.Platform;
import org.graalvm.nativeimage.Platforms;

/**
* This class is used at image build-time when a libgraal image gets built. Its static methods are
* called from {@code com.oracle.svm.graal.hotspot.libgraal.LibGraalFeature} before static analysis.
* These methods ensure the static field state of Graal and JVMCI classes loaded by the
* LibGraalClassLoader is set up correctly for getting built into libgraal.
*/
@Platforms(Platform.HOSTED_ONLY.class)
public class BuildTime {

private static final String VALID_LOADER_NAME = "LibGraalClassLoader";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
import com.oracle.truffle.compiler.hotspot.libgraal.TruffleFromLibGraal.Id;
import jdk.graal.compiler.truffle.host.TruffleHostEnvironment;
import org.graalvm.nativeimage.ImageInfo;
import org.graalvm.nativeimage.Platform;
import org.graalvm.nativeimage.Platforms;

import java.lang.invoke.MethodHandle;
import java.lang.invoke.MethodHandles;
Expand All @@ -45,6 +47,7 @@
/**
* Class used to initialize the Truffle extensions to the Graal compiler in the image build time.
*/
@Platforms(Platform.HOSTED_ONLY.class)
public class BuildTime {

private static Lookup hostLookup;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@
import jdk.vm.ci.runtime.JVMCI;
import jdk.vm.ci.services.Services;
import org.graalvm.nativeimage.ImageInfo;
import org.graalvm.nativeimage.Platform;
import org.graalvm.nativeimage.Platforms;

/**
* Interface to functionality that abstracts over which JDK version Graal is running on.
Expand Down Expand Up @@ -75,6 +77,7 @@ public static boolean isInLibgraal() {
*/
private static Map<Class<?>, List<?>> libgraalServices;

@Platforms(Platform.HOSTED_ONLY.class)
@ExcludeFromJacocoGeneratedReport("only called when building libgraal")
public static void setLibgraalServices(Map<Class<?>, List<?>> services) {
GraalError.guarantee(libgraalServices == null, "Libgraal services must be set exactly once");
Expand Down

0 comments on commit f1c6e66

Please sign in to comment.