Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[GR-58919] Fix Truffle host inlining may peek into native calls and fail. #9909

Merged
merged 1 commit into from
Oct 22, 2024
Merged
Show file tree
Hide file tree
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 @@ -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