Skip to content

Commit 6288d21

Browse files
committed
[GR-64178] Fix Truffle inInterpreter methods must be marked as opaque to avoid analysis strengthening which modifies the dominator tree needed during host inlining.
PullRequest: graal/20559
2 parents ba5de4d + 717e494 commit 6288d21

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@
145145
import com.oracle.truffle.api.CompilerAsserts;
146146
import com.oracle.truffle.api.CompilerDirectives;
147147
import com.oracle.truffle.api.CompilerDirectives.TruffleBoundary;
148+
import com.oracle.truffle.api.HostCompilerDirectives;
148149
import com.oracle.truffle.api.Truffle;
149150
import com.oracle.truffle.api.TruffleRuntime;
150151
import com.oracle.truffle.api.frame.Frame;
@@ -340,8 +341,17 @@ private boolean handleNeverPartOfCompilation(GraphBuilderContext b, ResolvedJava
340341

341342
@Override
342343
public void beforeAnalysis(BeforeAnalysisAccess access) {
343-
SubstrateTruffleRuntime truffleRuntime = (SubstrateTruffleRuntime) Truffle.getRuntime();
344344
BeforeAnalysisAccessImpl config = (BeforeAnalysisAccessImpl) access;
345+
/*
346+
* Both methods are needed in HostInliningPhase to not be optimized / strengthened. By
347+
* specifying them as opaque we make sure that the original dominator tree is preserved. If
348+
* we do not set these methods as opaque we might end up host inlining into paths that are
349+
* not designed for PE/HostInlining.
350+
*/
351+
config.registerOpaqueMethodReturn(ReflectionUtil.lookupMethod(CompilerDirectives.class, "inInterpreter"));
352+
config.registerOpaqueMethodReturn(ReflectionUtil.lookupMethod(HostCompilerDirectives.class, "inInterpreterFastPath"));
353+
354+
SubstrateTruffleRuntime truffleRuntime = (SubstrateTruffleRuntime) Truffle.getRuntime();
345355
TruffleHostEnvironment.overrideLookup(new SubstrateTruffleHostEnvironmentLookup(truffleRuntime, config.getMetaAccess()));
346356

347357
ImageSingletons.lookup(TruffleBaseFeature.class).setProfilingEnabled(truffleRuntime.isProfilingEnabled());

0 commit comments

Comments
 (0)