Skip to content

8315088: C2: assert(wq.size() - before == EMPTY_LOOP_SIZE) failed: expect the EMPTY_LOOP_SIZE nodes of this body if empty#15520

Closed
rwestrel wants to merge 4 commits intoopenjdk:masterfrom
rwestrel:JDK-8315088
Closed

8315088: C2: assert(wq.size() - before == EMPTY_LOOP_SIZE) failed: expect the EMPTY_LOOP_SIZE nodes of this body if empty#15520
rwestrel wants to merge 4 commits intoopenjdk:masterfrom
rwestrel:JDK-8315088

Conversation

@rwestrel
Copy link
Contributor

@rwestrel rwestrel commented Aug 31, 2023

The assert fires in code that looks for counted loops that would be
empty if not part of a loop strip mining nest (that is some nodes in
the the loop body are kept alive because of the safepoint in the outer
loop, the loop would otherwise be empty). That logic starts by finding
the set of EMPTY_LOOP_SIZE nodes that are core to all counted loops
(exit test, iv phi etc) and store them in the empty_loop_nodes
list.

Finding the "core" nodes is performed by
IdealLoopTree::collect_loop_core_nodes. It enqueues the backedge of
the loop in empty_loop_nodes and then iteratively pushes inputs of
nodes in empty_loop_nodes that belongs to the loop until it can't
make progress. There should be EMPTY_LOOP_SIZE of those nodes.

It's possible that that 2 or more loops are involved in the process:
a node n in loop 1 could be kept alive by the safepoint of loop 2 so
loop 2 needs to be empty for n to become dead and possibly loop 1 to
be empty. When that happens while the logic is in the process of
determining if loop 1 is empty, it needs to also collect the
EMPTY_LOOP_SIZE nodes that make the "core" of loop 2. They are
enqueued to the empty_loop_nodes list too.

The failure happens when empty_loop_nodes already has the "core"
nodes of loop 1 and "core" nodes for loop 2 are collected. In the
processIdealLoopTree::collect_loop_core_nodes iterates on all
empty_loop_nodes (loop 1 nodes included, not just starting from the
loop 2 backedge). That's inefficient (loop 1 nodes can't help find
nodes that belong to loop 2) and wrong because there could be an edge
from a node in loop 1 to a node in the body of loop 2. That node in
loop 2 is them pushed to the empty_loop_nodes list.

The fix I propose is to only iterate over loop 2 nodes when loop 2 is
processed.


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-8315088: C2: assert(wq.size() - before == EMPTY_LOOP_SIZE) failed: expect the EMPTY_LOOP_SIZE nodes of this body if empty (Bug - P3)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 15520

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

Using diff file

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

Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Aug 31, 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.

@openjdk openjdk bot added the rfr Pull request is ready for review label Aug 31, 2023
@openjdk
Copy link

openjdk bot commented Aug 31, 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 Aug 31, 2023
@mlbridge
Copy link

mlbridge bot commented Aug 31, 2023

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.

Thanks for the detailed description, the fix looks good to me.


/**
* @test
* @bug 8315088
Copy link
Member

Choose a reason for hiding this comment

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

Please 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.

@openjdk
Copy link

openjdk bot commented Sep 4, 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:

8315088: C2: assert(wq.size() - before == EMPTY_LOOP_SIZE) failed: expect the EMPTY_LOOP_SIZE nodes of this body if empty

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

  • 8bbebbb: 8315644: increase timeout of sun/security/tools/jarsigner/Warning.java
  • f292268: 8315454: Add a way to create an immutable snapshot of a BitSet
  • 9def453: 8314580: PhaseIdealLoop::transform_long_range_checks fails with assert "was tested before"
  • 6c821f5: 8315545: C1: x86 cmove can use short branches
  • d7e4087: 8315369: [JVMCI] failure to attach to a libgraal isolate during shutdown should not be fatal
  • d1cabe4: 8315566: [JVMCI] deadlock in JVMCI startup when bad option specified
  • 94a74a0: 8315534: Incorrect warnings about implicit annotation processing
  • 84425a6: 8315452: Erroneous AST missing modifiers for partial input
  • 3094fd1: 8314662: jshell shows duplicated signatures of javap
  • 0d52c82: 8310220: IGV: dump graph after each IGVN step at level 4
  • ... and 155 more: https://git.openjdk.org/jdk/compare/8939d15d92982300f090bc1c51f59550529eaaf3...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 Sep 4, 2023
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.

Looks good to me, too.

rwestrel and others added 2 commits September 4, 2023 17:19
…pLogic.java

Co-authored-by: Andrey Turbanov <turbanoff@gmail.com>
@rwestrel
Copy link
Contributor Author

rwestrel commented Sep 5, 2023

@TobiHartmann @chhagedorn thanks for the reviews

@rwestrel
Copy link
Contributor Author

rwestrel commented Sep 5, 2023

/integrate

@openjdk
Copy link

openjdk bot commented Sep 5, 2023

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

  • 8bbebbb: 8315644: increase timeout of sun/security/tools/jarsigner/Warning.java
  • f292268: 8315454: Add a way to create an immutable snapshot of a BitSet
  • 9def453: 8314580: PhaseIdealLoop::transform_long_range_checks fails with assert "was tested before"
  • 6c821f5: 8315545: C1: x86 cmove can use short branches
  • d7e4087: 8315369: [JVMCI] failure to attach to a libgraal isolate during shutdown should not be fatal
  • d1cabe4: 8315566: [JVMCI] deadlock in JVMCI startup when bad option specified
  • 94a74a0: 8315534: Incorrect warnings about implicit annotation processing
  • 84425a6: 8315452: Erroneous AST missing modifiers for partial input
  • 3094fd1: 8314662: jshell shows duplicated signatures of javap
  • 0d52c82: 8310220: IGV: dump graph after each IGVN step at level 4
  • ... and 155 more: https://git.openjdk.org/jdk/compare/8939d15d92982300f090bc1c51f59550529eaaf3...master

Your commit was automatically rebased without conflicts.

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

openjdk bot commented Sep 5, 2023

@rwestrel Pushed as commit fe4f900.

💡 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.

4 participants