valhalla icon indicating copy to clipboard operation
valhalla copied to clipboard

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

Open merykitty opened this issue 9 months ago • 6 comments
trafficstars

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

  • [x] 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

merykitty avatar Feb 12 '25 16:02 merykitty

:wave: 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.

bridgekeeper[bot] avatar Feb 12 '25 16:02 bridgekeeper[bot]

@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:

  • 4d262327f1c2d0b4a1bb583f5b9eb3db9c224ea8: Merge jdk
  • a637ccf2fead25ea6a06ad6bd65e92b8694ee11c: 8349851: RISC-V: Call VM leaf can use movptr2
  • adc3f53d2403cd414a91e71c079b4108b2346da0: 8349787: java/lang/Thread/virtual/ThreadPollOnYield.java#default passes unexpectedly without libVThreadPinner.so
  • 55097dd4cbb5d691c12cb0247d66dce593759d59: 8344802: Crash in StubRoutines::verify_mxcsr with -XX:+EnableX86ECoreOpts and -Xcheck:jni
  • b8576eb48e6aae96f9bad1caeedaeb4b5b675e34: 6562489: Font-Renderer should ignore invisible characters \u2062 and \u2063
  • 7a0832f5487cb7586131f6c4e0b90300f6de5dec: 8349934: Wrong file regex for copyright header format check in .jcheck/conf
  • 2a5d1da3355a4df3109ec42646b5b0cf088b4c2a: 8349571: Remove JavaThreadFactory interface from SA
  • 74e458bad6ba6e8aa85e0950119963a6f6cb2c03: 8349684: Remove SA core file tests from problem list for macosx-x64
  • ba28119642a7cfa850707a01ce8e589c3a80d416: 8348427: DeferredLintHandler API should use JCTree instead of DiagnosticPosition
  • c5ac3c4f11e777b24d597deec522c9df09750f59: 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).

openjdk[bot] avatar Feb 12 '25 16:02 openjdk[bot]

Webrevs

mlbridge[bot] avatar Feb 12 '25 16:02 mlbridge[bot]

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?

dean-long avatar Feb 18 '25 18:02 dean-long

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.

TobiHartmann avatar Feb 18 '25 18:02 TobiHartmann

@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!

bridgekeeper[bot] avatar Mar 25 '25 13:03 bridgekeeper[bot]

@merykitty This pull request has been inactive for more than 8 weeks and will now be automatically closed. If you would like to continue working on this pull request in the future, feel free to reopen it! This can be done using the /open pull request command.

bridgekeeper[bot] avatar Apr 22 '25 20:04 bridgekeeper[bot]