Skip to content
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@
import java.util.function.ToLongFunction;
import java.util.function.UnaryOperator;

import jdk.graal.compiler.phases.common.InsertGuardFencesPhase;
import org.graalvm.collections.Pair;
import org.graalvm.nativeimage.AnnotationAccess;
import org.graalvm.nativeimage.ImageSingletons;
Expand Down Expand Up @@ -141,6 +140,7 @@
import com.oracle.svm.truffle.api.SubstrateTruffleRuntime;
import com.oracle.svm.truffle.api.SubstrateTruffleUniverseFactory;
import com.oracle.svm.util.LogUtils;
import com.oracle.svm.util.ReflectionUtil;
import com.oracle.svm.util.StringUtil;
import com.oracle.truffle.api.CompilerAsserts;
import com.oracle.truffle.api.CompilerDirectives;
Expand All @@ -150,6 +150,8 @@
import com.oracle.truffle.api.frame.Frame;
import com.oracle.truffle.api.nodes.BytecodeOSRNode;
import com.oracle.truffle.api.nodes.ExplodeLoop;
import com.oracle.truffle.api.nodes.RootNode;
import com.oracle.truffle.runtime.OptimizedCallTarget;
import com.oracle.truffle.runtime.TruffleCallBoundary;

import jdk.graal.compiler.core.phases.HighTier;
Expand All @@ -164,6 +166,7 @@
import jdk.graal.compiler.options.Option;
import jdk.graal.compiler.options.OptionValues;
import jdk.graal.compiler.phases.common.CanonicalizerPhase;
import jdk.graal.compiler.phases.common.InsertGuardFencesPhase;
import jdk.graal.compiler.phases.tiers.Suites;
import jdk.graal.compiler.phases.util.Providers;
import jdk.graal.compiler.truffle.KnownTruffleTypes;
Expand Down Expand Up @@ -409,12 +412,16 @@ public void beforeAnalysis(BeforeAnalysisAccess access) {
}

/*
* The concrete subclass of OptimizedCallTarget needs to be registered as in heap for the
* forced compilation of frame methods to work. Forcing compilation of a method effectively
* adds it as a root and non-static root methods are only compiled if types implementing
* them or any of their subtypes are allocated.
* GR-57561: The constructor of the concrete subclass of OptimizedCallTarget needs to be
* seen by the analysis, otherwise the analysis will not see any writes to its fields
* (namely rootNode and engine), which will make a lot of Truffle code look unreachable.
* Since the createOptimizedCallTarget is a member method, we also need to ensure that an
* instance of TruffleSupport is always seen as instantiated, otherwise the method might not
* be considered reachable.
*/
config.registerAsInHeap(TruffleSupport.singleton().getOptimizedCallTargetClass(), "Concrete subclass of OptimizedCallTarget registered by " + TruffleFeature.class);
config.registerAsInHeap(TruffleSupport.singleton().getClass(), "Concrete subclass of TruffleSupport needs to be seen as instantiated, registered by " + TruffleFeature.class);
config.registerAsRoot(ReflectionUtil.lookupMethod(TruffleSupport.singleton().getClass(), "createOptimizedCallTarget", OptimizedCallTarget.class, RootNode.class), true,
"The constructor of the concrete subclass of OptimizedCallTarget needs to be seen by the analysis, registered by " + TruffleFeature.class);

/*
* This effectively initializes the Truffle fallback engine which does all the system
Expand Down