Skip to content

Commit

Permalink
tmp
Browse files Browse the repository at this point in the history
  • Loading branch information
dougxc committed Oct 9, 2024
1 parent f1c6e66 commit 9e94b42
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
Expand Down

0 comments on commit 9e94b42

Please sign in to comment.