Skip to content

Commit

Permalink
[GR-58919] Fix Truffle host inlining may peek into native calls and f…
Browse files Browse the repository at this point in the history
…ail.

PullRequest: graal/19020
  • Loading branch information
chumer committed Oct 21, 2024
2 parents 191353e + 6af3d09 commit d5fd699
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ public void test() {
runTest("testThrow");
runTest("testRangeCheck");
runTest("testImplicitCast");
runTest("testNativeCall");
}

@SuppressWarnings("try")
Expand Down Expand Up @@ -963,6 +964,22 @@ static int testImplicitCast(int value) {
return (int) MyTypesGen.asImplicitDouble(0, value);
}

@BytecodeInterpreterSwitch
@ExpectNotInlined(name = {"nativeCall"}, count = {1})
static int testNativeCall(int value) {
if (value == 42) {
// we do not call nativeCall directly to trigger the peek deopt logic in host inlining
peekNativeCall();
}
return 42;
}

static void peekNativeCall() {
nativeCall();
}

static native void nativeCall();

static int testIndirectIntrinsicsImpl(A a) {
return a.intrinsic(); // inlined and intrinsic
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -603,6 +603,10 @@ private BackPropagation peekPropagatesDeoptOrUnwind(InliningPhaseContext context
return BackPropagation.NOTHING;
}

if (!method.hasBytecodes() || method.isNative()) {
return BackPropagation.NOTHING;
}

StructuredGraph graph = lookupGraph(context, callerInvoke, method);
FixedNode current = graph.start();
while (current instanceof FixedWithNextNode) {
Expand Down

0 comments on commit d5fd699

Please sign in to comment.