Skip to content

8349068: [lworld] C2 compilation fails with "not enough operands for reexecution" #1363

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

Open
wants to merge 1 commit into
base: lworld
Choose a base branch
from

Conversation

merykitty
Copy link
Member

@merykitty merykitty commented Feb 12, 2025

Hi,

The issue here is that GraphKit::make_runtime_call is often used to execute a bytecode. As a result, it expects that it may deoptimize and thus need to reexecute the current bytecode in the interpreter. This is the intention of the assert, to verify that we are having enough operands for reexecution of the bytecode. However, in the failing case, GraphKit::make_runtime_call is not used to execute the bytecode, but to handle the exceptions thrown by that bytecode. In this case, the bytecode itself has finished executing and must not be reexecuted, we can see that in Parse::catch_inline_exceptions:

// Oops, need to call into the VM to resolve the klasses at runtime.
// Note:  This call must not deoptimize, since it is not a real at this bci!
kill_dead_locals();

make_runtime_call(RC_NO_LEAF | RC_MUST_THROW,
                  OptoRuntime::rethrow_Type(),
                  OptoRuntime::rethrow_stub(),
                  nullptr, nullptr,
                  ex_node);

As a result, reexecution is impossible and we don't need to worry about the operand stack, I propose removing the assert as it seems to be the cleanest fix.

The reason this only fails on lworld is because here the execution of aastore involves a static Java call, resulting in a potential exception that needs catching.

Please share your thoughts, thanks a lot.


Progress

  • Change must not contain extraneous whitespace

Issue

  • JDK-8349068: [lworld] C2 compilation fails with "not enough operands for reexecution" (Bug - P4) ⚠️ Issue is not open.

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/valhalla.git pull/1363/head:pull/1363
$ git checkout pull/1363

Update a local copy of the PR:
$ git checkout pull/1363
$ git pull https://git.openjdk.org/valhalla.git pull/1363/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 1363

View PR using the GUI difftool:
$ git pr show -t 1363

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/valhalla/pull/1363.diff

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Feb 12, 2025

👋 Welcome back qamai! A progress list of the required criteria for merging this PR into lworld will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk
Copy link

openjdk bot commented Feb 12, 2025

@merykitty This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

8349068: [lworld] C2 compilation fails with "not enough operands for reexecution"

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 273 new commits pushed to the lworld branch:

  • 4d26232: Merge jdk
  • a637ccf: 8349851: RISC-V: Call VM leaf can use movptr2
  • adc3f53: 8349787: java/lang/Thread/virtual/ThreadPollOnYield.java#default passes unexpectedly without libVThreadPinner.so
  • 55097dd: 8344802: Crash in StubRoutines::verify_mxcsr with -XX:+EnableX86ECoreOpts and -Xcheck:jni
  • b8576eb: 6562489: Font-Renderer should ignore invisible characters \u2062 and \u2063
  • 7a0832f: 8349934: Wrong file regex for copyright header format check in .jcheck/conf
  • 2a5d1da: 8349571: Remove JavaThreadFactory interface from SA
  • 74e458b: 8349684: Remove SA core file tests from problem list for macosx-x64
  • ba28119: 8348427: DeferredLintHandler API should use JCTree instead of DiagnosticPosition
  • c5ac3c4: 8249831: Test sun/security/mscapi/nonUniqueAliases/NonUniqueAliases.java is marked with @ignore
  • ... and 263 more: https://git.openjdk.org/valhalla/compare/12e5ddae614f88ad9262cd73f06003b569495cc4...lworld

As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

As you do not have Committer status in this project an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@TobiHartmann) but any other Committer may sponsor as well.

➡️ To flag this PR as ready for integration with the above commit message, type /integrate in a new comment. (Afterwards, your sponsor types /sponsor in a new comment to perform the integration).

@mlbridge
Copy link

mlbridge bot commented Feb 12, 2025

Webrevs

Copy link
Member

@TobiHartmann TobiHartmann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix looks reasonable to me. Just wondering, as an alternative, could we weaken the assert by checking if the call is to OptoRuntime::rethrow_stub?

@dean-long
Copy link
Member

dean-long commented Feb 18, 2025

I disagree with removing the assert. It seems like we should be skipping this code if must_throw is set, and possibly even calling set_should_reexecute(false) instead. Also, should the fix be moved to jdk25 because of JDK-8350208?

@TobiHartmann
Copy link
Member

I just wanted to add the same comment. If this is indeed the same issue as JDK-8350208, the fix should be done in mainline and JDK-8349068 should be closed as duplicate.

@@ -938,7 +938,6 @@ void GraphKit::add_safepoint_edges(SafePointNode* call, bool must_throw) {
int inputs = 0, not_used; // initialized by GraphKit::compute_stack_effects()
assert(method() == youngest_jvms->method(), "sanity");
assert(compute_stack_effects(inputs, not_used), "unknown bytecode: %s", Bytecodes::name(java_bc()));
assert(out_jvms->sp() >= (uint)inputs, "not enough operands for reexecution");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removal of this assertion looks incorrect, given that stack holds the active expressions this sanity check ensures that required number of inputs needed to re-construction of interpreter frame are present.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will be fixed by JDK-8350208 in mainline.

@bridgekeeper
Copy link

bridgekeeper bot commented Mar 25, 2025

@merykitty This pull request has been inactive for more than 4 weeks and will be automatically closed if another 4 weeks passes without any activity. To avoid this, simply add a new comment to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

4 participants