|
100 | 100 | import java.util.function.ToLongFunction;
|
101 | 101 | import java.util.function.UnaryOperator;
|
102 | 102 |
|
103 |
| -import jdk.graal.compiler.phases.common.InsertGuardFencesPhase; |
104 | 103 | import org.graalvm.collections.Pair;
|
105 | 104 | import org.graalvm.nativeimage.AnnotationAccess;
|
106 | 105 | import org.graalvm.nativeimage.ImageSingletons;
|
|
141 | 140 | import com.oracle.svm.truffle.api.SubstrateTruffleRuntime;
|
142 | 141 | import com.oracle.svm.truffle.api.SubstrateTruffleUniverseFactory;
|
143 | 142 | import com.oracle.svm.util.LogUtils;
|
| 143 | +import com.oracle.svm.util.ReflectionUtil; |
144 | 144 | import com.oracle.svm.util.StringUtil;
|
145 | 145 | import com.oracle.truffle.api.CompilerAsserts;
|
146 | 146 | import com.oracle.truffle.api.CompilerDirectives;
|
|
150 | 150 | import com.oracle.truffle.api.frame.Frame;
|
151 | 151 | import com.oracle.truffle.api.nodes.BytecodeOSRNode;
|
152 | 152 | import com.oracle.truffle.api.nodes.ExplodeLoop;
|
| 153 | +import com.oracle.truffle.api.nodes.RootNode; |
| 154 | +import com.oracle.truffle.runtime.OptimizedCallTarget; |
153 | 155 | import com.oracle.truffle.runtime.TruffleCallBoundary;
|
154 | 156 |
|
155 | 157 | import jdk.graal.compiler.core.phases.HighTier;
|
|
164 | 166 | import jdk.graal.compiler.options.Option;
|
165 | 167 | import jdk.graal.compiler.options.OptionValues;
|
166 | 168 | import jdk.graal.compiler.phases.common.CanonicalizerPhase;
|
| 169 | +import jdk.graal.compiler.phases.common.InsertGuardFencesPhase; |
167 | 170 | import jdk.graal.compiler.phases.tiers.Suites;
|
168 | 171 | import jdk.graal.compiler.phases.util.Providers;
|
169 | 172 | import jdk.graal.compiler.truffle.KnownTruffleTypes;
|
@@ -409,12 +412,16 @@ public void beforeAnalysis(BeforeAnalysisAccess access) {
|
409 | 412 | }
|
410 | 413 |
|
411 | 414 | /*
|
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. |
416 | 421 | */
|
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); |
418 | 425 |
|
419 | 426 | /*
|
420 | 427 | * This effectively initializes the Truffle fallback engine which does all the system
|
|
0 commit comments