Skip to content

Conversation

@rwestrel
Copy link
Contributor

@rwestrel rwestrel commented Nov 14, 2023

In the test case:

lateInlined1() and lateInlined2() are inlined incrementally
because they are invoked wih a method handle which is known constant
only after igvn. For the failure to reproduce, lateInlined2() must
be inlined after lateInlined1() which depends on igvn processing
order (that's why the test needs StressIGVN). lateInlined1() has 2
virtual calls that are inlined with bimorphic inlining. At each call
site, exception state is merged from A.m() and B.m(), the 2
methods that are inlined. c is casted to non null in A.m(). At the
first call site, c is live and merging the exception states causes
the creation of a Phi for c that merges c and the cast to non
null of c. At the second call site, c is not live so it's ignored
when merging exception states. When the exception states for the 2
call sites are combined, the region that merges the states at the
first call site is extended to have 4 inputs but the Phi for c at
the first call site is left with 2 inputs. When lateInlined2() is
inlined, it records a replaced node for a cast of c to non null. On
completion of incremental inlining, that replaced nodes is "applied".
In the process, the dead Phi for c created at the previous
incremental inline is found and because it has less inputs that its
region, the crash occurs.

The fix I propose is to simply ignore phi nodes that don't have the
same number of inputs as their region because they can only be a dead
Phi.


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issue

  • JDK-8319764: C2 compilation asserts during incremental inlining because Phi input is out of bounds (Bug - P3)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 16648

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

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/16648.diff

Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Nov 14, 2023

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

@rwestrel rwestrel marked this pull request as draft November 14, 2023 08:58
@openjdk
Copy link

openjdk bot commented Nov 14, 2023

@rwestrel The following label will be automatically applied to this pull request:

  • hotspot-compiler

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command.

@openjdk openjdk bot added the hotspot-compiler hotspot-compiler-dev@openjdk.org label Nov 14, 2023
@rwestrel rwestrel changed the title ;; This buffer is for text that is not saved, and for Lisp evaluation. 8319764: C2 compilation asserts during incremental inlining because Phi input is out of bounds Nov 14, 2023
@rwestrel rwestrel marked this pull request as ready for review November 14, 2023 09:04
@openjdk openjdk bot added the rfr Pull request is ready for review label Nov 14, 2023
@mlbridge
Copy link

mlbridge bot commented Nov 14, 2023

Webrevs

* @run main/othervm -XX:-TieredCompilation -XX:-BackgroundCompilation -XX:CompileCommand=dontinline,TestLateInlineReplacedNodesExceptionPath::notInlined
* -XX:+StressIGVN -XX:StressSeed=1246687813 TestLateInlineReplacedNodesExceptionPath
* @run main/othervm -XX:-TieredCompilation -XX:-BackgroundCompilation -XX:CompileCommand=dontinline,TestLateInlineReplacedNodesExceptionPath::notInlined
* -XX:+StressIGVN TestLateInlineReplacedNodesExceptionPath
Copy link
Member

Choose a reason for hiding this comment

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

VM option 'StressIGVN' is diagnostic and must be enabled via -XX:+UnlockDiagnosticVMOptions.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for looking at this. Fixed in the new commit.

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.

Looks reasonable to me. Could you elaborate on why this wasn't an issue before JDK-8312980?

@openjdk
Copy link

openjdk bot commented Nov 15, 2023

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

8319764: C2 compilation asserts during incremental inlining because Phi input is out of bounds

Reviewed-by: thartmann, chagedorn

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 94 new commits pushed to the master branch:

  • 6868b37: 8318826: C2: "Bad graph detected in build_loop_late" with incremental inlining
  • 1d96886: 8319531: FileServerHandler::discardRequestBody could be improved
  • 73e19f6: 8319825: jdk.net/jdk.net.ExtendedSocketOptions::IP_DONTFRAGMENT is missing @SInCE 19
  • faeea07: 8319747: galoisCounterMode_AESCrypt stack walking broken
  • b4c2d1c: 8319542: Fix boundaries of region to be tested with os::is_readable_range
  • c36ec2c: 8316653: Large NMethodSizeLimit triggers assert during C1 code buffer allocation
  • 2db9ea9: 8317723: C2: CountedLoopEndNodes and Zero Trip Guards are wrongly treated as Runtime Predicate
  • eaa4417: 8319301: Static analysis warnings after JDK-8318016
  • 3452210: 8283140: Remove unused encoding classes/operands from x86_64.ad
  • f0b7eb5: 8304020: Speed up test/jdk/java/util/zip/ZipFile/TestTooManyEntries.java and clarify its purpose
  • ... and 84 more: https://git.openjdk.org/jdk/compare/7c7f8ea30da7fe552bcd4f2b593fa9aad27dcdb4...master

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.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Nov 15, 2023
Comment on lines 160 to 161
if (in != nullptr && !in->is_top()) {
if (is_dominator(ctl, in)) {
Copy link
Member

@TobiHartmann TobiHartmann Nov 15, 2023

Choose a reason for hiding this comment

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

Ifs can be merged.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done in new commit.

Copy link
Member

@chhagedorn chhagedorn left a comment

Choose a reason for hiding this comment

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

That looks reasonable to me, too!

* bug 8319764
* @summary C2 compilation asserts during incremental inlining because Phi input is out of bounds
* @run main/othervm -XX:-TieredCompilation -XX:-BackgroundCompilation -XX:CompileCommand=dontinline,TestLateInlineReplacedNodesExceptionPath::notInlined
* -XX:+UnlockDiagnosticVMOptions -XX:+StressIGVN -XX:StressSeed=1246687813 TestLateInlineReplacedNodesExceptionPath
Copy link
Member

Choose a reason for hiding this comment

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

Since StressIGVN is C2 specific, you should add a @requires vm.compiler2.enabled.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done in new commit.

if (is_dominator(ctl, in)) {
valid_control.set(in->_idx);
collect_nodes_to_clone(stack, to_fix);
if (n->req() == region->req()) { // dead phi?
Copy link
Member

Choose a reason for hiding this comment

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

Maybe you can change this comment to "ignore dead phis".

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done in new commit.

@rwestrel
Copy link
Contributor Author

Looks reasonable to me. Could you elaborate on why this wasn't an issue before JDK-8312980?

Logic was quite different: it would go over the phi inputs looking for one that was of interest and then only looked at the region's input for that phi input so a phi with fewer inputs than the region wasn't an issue.

rwestrel and others added 2 commits November 15, 2023 17:05
…esExceptionPath.java

Co-authored-by: Christian Hagedorn <christian.hagedorn@oracle.com>
@rwestrel
Copy link
Contributor Author

That looks reasonable to me, too!

Thanks for reviewing and making suggestions.

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.

Thanks for the explanation. Looks good.

Copy link
Member

@chhagedorn chhagedorn left a comment

Choose a reason for hiding this comment

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

Still looks good

…esExceptionPath.java

Co-authored-by: Christian Hagedorn <christian.hagedorn@oracle.com>
@rwestrel
Copy link
Contributor Author

@TobiHartmann @chhagedorn thanks for the reviews.

@rwestrel
Copy link
Contributor Author

/integrate

@openjdk
Copy link

openjdk bot commented Nov 16, 2023

Going to push as commit f33c874.
Since your change was applied there have been 94 commits pushed to the master branch:

  • 6868b37: 8318826: C2: "Bad graph detected in build_loop_late" with incremental inlining
  • 1d96886: 8319531: FileServerHandler::discardRequestBody could be improved
  • 73e19f6: 8319825: jdk.net/jdk.net.ExtendedSocketOptions::IP_DONTFRAGMENT is missing @SInCE 19
  • faeea07: 8319747: galoisCounterMode_AESCrypt stack walking broken
  • b4c2d1c: 8319542: Fix boundaries of region to be tested with os::is_readable_range
  • c36ec2c: 8316653: Large NMethodSizeLimit triggers assert during C1 code buffer allocation
  • 2db9ea9: 8317723: C2: CountedLoopEndNodes and Zero Trip Guards are wrongly treated as Runtime Predicate
  • eaa4417: 8319301: Static analysis warnings after JDK-8318016
  • 3452210: 8283140: Remove unused encoding classes/operands from x86_64.ad
  • f0b7eb5: 8304020: Speed up test/jdk/java/util/zip/ZipFile/TestTooManyEntries.java and clarify its purpose
  • ... and 84 more: https://git.openjdk.org/jdk/compare/7c7f8ea30da7fe552bcd4f2b593fa9aad27dcdb4...master

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Nov 16, 2023
@openjdk openjdk bot closed this Nov 16, 2023
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Nov 16, 2023
@openjdk
Copy link

openjdk bot commented Nov 16, 2023

@rwestrel Pushed as commit f33c874.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

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

Labels

hotspot-compiler hotspot-compiler-dev@openjdk.org integrated Pull request has been integrated

Development

Successfully merging this pull request may close these issues.

3 participants