Skip to content

Commit 3b10843

Browse files
Automatic merge of master into galahad
2 parents df52c80 + cdd8e9f commit 3b10843

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

substratevm/src/com.oracle.svm.truffle/src/com/oracle/svm/truffle/TruffleFeature.java

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@
100100
import java.util.function.ToLongFunction;
101101
import java.util.function.UnaryOperator;
102102

103-
import jdk.graal.compiler.phases.common.InsertGuardFencesPhase;
104103
import org.graalvm.collections.Pair;
105104
import org.graalvm.nativeimage.AnnotationAccess;
106105
import org.graalvm.nativeimage.ImageSingletons;
@@ -141,6 +140,7 @@
141140
import com.oracle.svm.truffle.api.SubstrateTruffleRuntime;
142141
import com.oracle.svm.truffle.api.SubstrateTruffleUniverseFactory;
143142
import com.oracle.svm.util.LogUtils;
143+
import com.oracle.svm.util.ReflectionUtil;
144144
import com.oracle.svm.util.StringUtil;
145145
import com.oracle.truffle.api.CompilerAsserts;
146146
import com.oracle.truffle.api.CompilerDirectives;
@@ -150,6 +150,8 @@
150150
import com.oracle.truffle.api.frame.Frame;
151151
import com.oracle.truffle.api.nodes.BytecodeOSRNode;
152152
import com.oracle.truffle.api.nodes.ExplodeLoop;
153+
import com.oracle.truffle.api.nodes.RootNode;
154+
import com.oracle.truffle.runtime.OptimizedCallTarget;
153155
import com.oracle.truffle.runtime.TruffleCallBoundary;
154156

155157
import jdk.graal.compiler.core.phases.HighTier;
@@ -164,6 +166,7 @@
164166
import jdk.graal.compiler.options.Option;
165167
import jdk.graal.compiler.options.OptionValues;
166168
import jdk.graal.compiler.phases.common.CanonicalizerPhase;
169+
import jdk.graal.compiler.phases.common.InsertGuardFencesPhase;
167170
import jdk.graal.compiler.phases.tiers.Suites;
168171
import jdk.graal.compiler.phases.util.Providers;
169172
import jdk.graal.compiler.truffle.KnownTruffleTypes;
@@ -409,12 +412,16 @@ public void beforeAnalysis(BeforeAnalysisAccess access) {
409412
}
410413

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

419426
/*
420427
* This effectively initializes the Truffle fallback engine which does all the system

0 commit comments

Comments
 (0)