From 9e94b42cb2f1b7678cd1599670137c93d881d92d Mon Sep 17 00:00:00 2001 From: Doug Simon Date: Tue, 8 Oct 2024 10:01:24 +0200 Subject: [PATCH] tmp --- .../hotspot/HotSpotGraalCompilerFactory.java | 4 ++-- .../replacements/InvocationPluginHelper.java | 13 ------------- .../compiler/replacements/ReplacementsImpl.java | 4 +++- .../compiler/serviceprovider/GraalServices.java | 8 ++++---- 4 files changed, 9 insertions(+), 20 deletions(-) diff --git a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/HotSpotGraalCompilerFactory.java b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/HotSpotGraalCompilerFactory.java index 6baea8aa5ca1..1873b603297a 100644 --- a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/HotSpotGraalCompilerFactory.java +++ b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/HotSpotGraalCompilerFactory.java @@ -167,8 +167,8 @@ static class Options { @Override public HotSpotGraalCompiler createCompiler(JVMCIRuntime runtime) { if (inImageBuildtimeCode() && inImageRuntimeCode()) { - // A number of guards in the compiler assume the invariant that - // at most one of these conditions is true so best to check it. + // A bunch of code assumes that at most one of these conditions + // is true so that invariant is verified here. throw new GraalError("Invariant violation: inImageBuildtimeCode && inImageRuntimeCode must not both be true"); } HotSpotJVMCIRuntime hsRuntime = (HotSpotJVMCIRuntime) runtime; diff --git a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/replacements/InvocationPluginHelper.java b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/replacements/InvocationPluginHelper.java index 6b13ce79166c..8e5647349964 100644 --- a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/replacements/InvocationPluginHelper.java +++ b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/replacements/InvocationPluginHelper.java @@ -24,11 +24,8 @@ */ package jdk.graal.compiler.replacements; -import static org.graalvm.nativeimage.ImageInfo.inImageBuildtimeCode; - import java.util.ArrayList; -import jdk.graal.compiler.api.replacements.Snippet; import jdk.graal.compiler.core.common.calc.CanonicalCondition; import jdk.graal.compiler.core.common.calc.Condition; import jdk.graal.compiler.core.common.type.Stamp; @@ -324,16 +321,6 @@ public ResolvedJavaField getField(ResolvedJavaType type, String fieldName) { throw new GraalError("missing field " + fieldName + " in type " + type); } - /** - * Gets the offset of a field. Normally InvocationPlugins are run in the target VM so nothing - * special needs to be done to handle these offsets but if a {@link Snippet} even triggers a - * plugin that uses a field offset them some extra machinery will be needed to delay the lookup. - */ - public ValueNode getFieldOffset(ResolvedJavaType type, String fieldName) { - GraalError.guarantee(!inImageBuildtimeCode() || !b.parsingIntrinsic(), "these values must be deferred in substitutions and snippets"); - return ConstantNode.forInt(getField(type, fieldName).getOffset()); - } - /** * Performs a range check for an intrinsic. This is a range check that represents a hard error * in the intrinsic so it's permissible to throw an exception directly for this case. diff --git a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/replacements/ReplacementsImpl.java b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/replacements/ReplacementsImpl.java index ad0b07a19d10..040c7608c51b 100644 --- a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/replacements/ReplacementsImpl.java +++ b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/replacements/ReplacementsImpl.java @@ -38,6 +38,7 @@ import java.util.concurrent.ConcurrentMap; import java.util.concurrent.atomic.AtomicInteger; +import jdk.graal.compiler.serviceprovider.GraalServices; import org.graalvm.collections.EconomicMap; import org.graalvm.collections.Equivalence; import org.graalvm.collections.Pair; @@ -478,13 +479,14 @@ static class EncodedIntrinsicContext extends IntrinsicContext { @Override public boolean isDeferredInvoke(StateSplit stateSplit) { - if (inImageRuntimeCode()) { + if (GraalServices.isInLibgraal()) { throw GraalError.shouldNotReachHere("unused in libgraal"); // ExcludeFromJacocoGeneratedReport } if (stateSplit instanceof Invoke) { Invoke invoke = (Invoke) stateSplit; ResolvedJavaMethod method = invoke.callTarget().targetMethod(); if (method == null) { + Runtime.version(); return false; } if (method.getAnnotation(Fold.class) != null) { diff --git a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/serviceprovider/GraalServices.java b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/serviceprovider/GraalServices.java index 225e78fadce2..11d29d4422a5 100644 --- a/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/serviceprovider/GraalServices.java +++ b/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/serviceprovider/GraalServices.java @@ -54,8 +54,8 @@ public final class GraalServices { /** * Returns true if (at the time of the call) code is executing in the context of building - * libgraal. Note that this is more specific than {@link ImageInfo#inImageBuildtimeCode()} which - * will return true when building any native image, not just libgraal. + * libgraal. Note that this is more specific than {@link ImageInfo#inImageBuildtimeCode()}. The + * latter will return true when building any native image, not just libgraal. */ public static boolean isBuildingLibgraal() { // Note that IS_BUILDING_NATIVE_IMAGE is true when in libgraal runtime @@ -64,8 +64,8 @@ public static boolean isBuildingLibgraal() { /** * Returns true if (at the time of the call) code is executing in the context of executing - * libgraal. Note that this is more specific than {@link ImageInfo#inImageRuntimeCode()} which - * will return true when executing any native image, not just libgraal. + * libgraal. Note that this is more specific than {@link ImageInfo#inImageRuntimeCode()}. The + * latter will return true when executing any native image, not just libgraal. */ public static boolean isInLibgraal() { return Services.IS_IN_NATIVE_IMAGE;