Skip to content

8342945: Replace predicate walking code in get_assertion_predicates() used for Loop Unswitching and cleaning useless Template Assertion Predicates with a predicate visitor #21918

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

Closed
wants to merge 1 commit into from

Conversation

chhagedorn
Copy link
Member

@chhagedorn chhagedorn commented Nov 6, 2024

Replacing the Remaining Predicate Walking and Cloning Code

The goal is to replace and unify all the remaining custom predicate walking and cloning code currently used for:


(Sections taken over from #21679 / #21790))

Single Template Assertion Predicate Check

This replacement allows us to have a single TemplateAssertionPredicate::is_predicate() check that is called for all predicate matching code. This enables the removal of uncommon traps for Template Assertion Predicates with JDK-8342047 which is a missing piece in order to fix the remaining problems with Assertion Predicates (JDK-8288981).

Common Refactorings for all the Patches in this Series

In each of the patch, I will do similar refactoring ideas:

  • Replace the existing code in the corresponding PhaseIdealLoop method with call to a new (or existing) predicate visitor which extends the PredicateVisitor interface.
  • The visitor implements the Assertion Predicate visit() methods to implement the cloning and initialization of the Template Assertion Predicates.
  • The predicate visitor is then passed to the PredicateIterator which walks through all predicates found at a loop and applies the visitor for each predicate.
  • The visitor creates new nodes (if there are Template Assertion Predicates) either in place or at the loop entry of a target loop. In the latter case, the calling code of the PredicateIterator must make sure to connect the tail of the newly created predicate chain after the old loop entry to the target loop head.
  • Keep the semantics which includes to only apply the Template Assertion Predicate processing if there are Parse Predicates. This limitation should eventually be removed. But I want to do that separately at a later point.

Refactorings of this Patch

  • This patch replaces the predicate walking in PhaseIdealLoop::get_assertion_predicates() which is used for Loop Unswitching and removing useless Template Assertion Predicates (called from PhaseIdealLoop::collect_useful_template_assertion_predicates_for_loop()).
  • Note that the cloning code in Loop Unswitching is not replaced, yet, because we clone the Template Assertion Predicates in the original order as currently found in the graph which also allowed us to use PhaseIdealLoop::create_new_if_for_predicate().
    This means that we first walk from the loop entry to the last Template Assertion Predicate and then start cloning them in the reverse order (which ensures that we keep the original order of the Template Assertion Predicates). I don't think that keeping the original order is a strong requirement.
    Once we replace the UCTs with halt nodes, we do not require to call create_new_if_for_predicate() anymore and could theoretically just clone and initialize the Template Assertion Predicates in the opposite order as originally found in the graph which is easier to implement. This is currently also done for the other loop opts that require Assertion Predicates cloning/initialization. I think it's probably safe to do this for Loop Unswitching as well once we replace UCTs with halt nodes (@rwestrel what do you think?).
    If at some point, we need to keep the Assertion Predicate order, we can just add this functionality to the PredicateIterator classes. Anyhow, I'm leaving this code inclone_assertion_predicates_to_unswitched_loop() as it is for now and revisit it later again.

Thanks,
Christian


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-8342945: Replace predicate walking code in get_assertion_predicates() used for Loop Unswitching and cleaning useless Template Assertion Predicates with a predicate visitor (Sub-task - P4)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 21918

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

Using diff file

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

Using Webrev

Link to Webrev Comment

… used for Loop Unswitching and cleaning useless Template Assertion Predicates with a predicate visitor
@bridgekeeper
Copy link

bridgekeeper bot commented Nov 6, 2024

👋 Welcome back chagedorn! 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
Copy link

openjdk bot commented Nov 6, 2024

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

8342945: Replace predicate walking code in get_assertion_predicates() used for Loop Unswitching and cleaning useless Template Assertion Predicates with a predicate visitor

Reviewed-by: thartmann, roland, kvn

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

  • c0e6c3b: 8343214: Fix encoding errors in APX New Data Destination Instructions Support
  • 0be7118: 8279016: JFR Leak Profiler is broken with Shenandoah
  • 6811a11: 8341408: Implement JEP 488: Primitive Types in Patterns, instanceof, and switch (Second Preview)
  • 72a45dd: 8341834: C2 compilation fails with "bad AD file" due to Replicate
  • 57c3bb6: 8343068: C2: CastX2P Ideal transformation not always applied
  • 83f3d42: 8339303: C2: dead node after failing to match cloned address expression
  • ead0116: 8331341: secondary_super_cache does not scale well: C1 and interpreter
  • 06d8216: 8318442: java/net/httpclient/ManyRequests2.java fails intermittently on Linux
  • bdd6816: 8343502: RISC-V: SIGBUS in updateBytesCRC32 after JDK-8339738

Please see this link for an up-to-date comparison between the source branch of this pull request and the master branch.
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 rfr Pull request is ready for review label Nov 6, 2024
@openjdk
Copy link

openjdk bot commented Nov 6, 2024

@chhagedorn 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 6, 2024
@mlbridge
Copy link

mlbridge bot commented Nov 6, 2024

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.

Looks good to me.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Nov 6, 2024
@chhagedorn
Copy link
Member Author

Thanks Tobias for your review!

Copy link
Contributor

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

@chhagedorn
Copy link
Member Author

Thanks Roland for your review!

Copy link
Contributor

@vnkozlov vnkozlov 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.

@chhagedorn
Copy link
Member Author

Thanks Vladimir for your review!

/integrate

@openjdk
Copy link

openjdk bot commented Nov 7, 2024

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

  • 97b681e: 8340586: JdkJfrEvent::get_all_klasses stores non-strong oops in JNI handles
  • f2316f6: 8343505: Problemlist java/lang/Thread/jni/AttachCurrentThread/AttachTest.java
  • 9e31e78: 8342647: [macosx] Clean up the NSInvocation based call to NSProcessInfo.operatingSystemVersion
  • e33dc13: 8343343: Misc crash dump improvements on more platforms after JDK-8294160
  • d20ccd1: 8335583: Avoid using pointers in CDS tables
  • 342fe42: 8342270: Test sun/security/pkcs11/Provider/RequiredMechCheck.java needs write access to src tree
  • 78b378a: 8342540: InterfaceCalls micro-benchmark gives misleading results
  • c0e6c3b: 8343214: Fix encoding errors in APX New Data Destination Instructions Support
  • 0be7118: 8279016: JFR Leak Profiler is broken with Shenandoah
  • 6811a11: 8341408: Implement JEP 488: Primitive Types in Patterns, instanceof, and switch (Second Preview)
  • ... and 6 more: https://git.openjdk.org/jdk/compare/4431852a880b06241231d346311170331c20ab2d...master

Your commit was automatically rebased without conflicts.

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

openjdk bot commented Nov 7, 2024

@chhagedorn Pushed as commit a6c85da.

💡 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