Skip to content
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

8344035: Replace predicate walking code in Loop Unswitching with a predicate visitor #22828

Closed
wants to merge 2 commits into from

Conversation

chhagedorn
Copy link
Member

@chhagedorn chhagedorn commented Dec 19, 2024

This patch is a follow up to the clean-ups done with JDK-8342945 and introduces a new predicate visitor for Loop Unswitching to update the last remaining custom predicate cloning code.

This patch includes the following:

  • New CloneUnswitchedLoopPredicatesVisitor class which delegates the cloning work to a new ClonePredicateToTargetLoop class.

    • We walk the predicate chain in the PredicateIterator and call the CloneUnswitchedLoopPredicatesVisitor for each visited predicate. Then we clone the predicate on the fly to the target loop.
  • New ClonePredicateToTargetLoop class:

    • Clones Parse Predicates
    • Clones Template Assertion Predicates
      • Includes rewiring of control dependent data nodes
    • Rewires the cloned predicates to the target loop with new TargetLoopPredicateChain class:
      • Keeps track of the current chain head, which is the target loop itself when the chain is still empty.
      • Each time a new predicate is inserted at the target loop, the old predicate chain head is set as output of the new predicate.
      • An example is shown as class comment at TargetLoopPredicateChain.
      • I plan to reuse this class later again when also updating CreateAssertionPredicatesVisitor which is done when we tackle the actual still remaining Assertion Predicate bugs.
  • Removal of custom predicate cloning code found in PhaseIdealLoop.

  • Changed steps performed in Loop Unswitching from:

    1. Clone loop
    2. Clone predicates and insert them below the unswitched loop selector If projections
    3. Connect the cloned predicates to the unswitched loops

    to:

    1. Clone loop
    2. Connect unswitched loop selector If projections to unswitched loops such that they are now the new loop entries
    3. Clone predicates and insert them between the unswitched loop selector If projections and the unswitched loops
  • Rename/update get_template_assertion_predicates()/TemplateAssertionPredicateCollector to reflect the only use left.

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-8344035: Replace predicate walking code in Loop Unswitching with a predicate visitor (Sub-task - P4)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 22828

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

Using diff file

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

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Dec 19, 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 Dec 19, 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:

8344035: Replace predicate walking code in Loop Unswitching with a predicate visitor

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

  • 1ef77cd: 8347171: (dc) java/nio/channels/DatagramChannel/InterruptibleOrNot.java fails with virtual thread factory
  • 72f1114: 8346705: SNI not sent with Java 22+ using java.net.http.HttpClient.Builder#sslParameters
  • cb9a98b: 8347141: Several javac tests compile with an unnecessary -Xlint:-path flag
  • f9b1133: 8346880: [aix] java/lang/ProcessHandle/InfoTest.java still fails: "reported cputime less than expected"
  • 9c72ded: 8346036: Unnecessary Hashtable usage in javax.swing.text.html.parser.Entity
  • 3024a73: 8345782: Refining the cases that libjsig deprecation warning is issued
  • 2801bc6: 8346460: NotifyFramePop should return JVMTI_ERROR_DUPLICATE
  • ceae2b9: 8347121: Add missing @serial tags to module java.base
  • 8c87ea2: 8346478: RISC-V: Refactor add/sub assembler routines
  • 765b9e6: 8346706: RISC-V: Add available registers to hs_err
  • ... and 63 more: https://git.openjdk.org/jdk/compare/f1d85ab3e61f923b4e120cf30e16109e04505b53...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
Copy link

openjdk bot commented Dec 19, 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 Dec 19, 2024
const int opcode, const bool rewire_uncommon_proj_phi_inputs,
AssertionPredicateType assertion_predicate_type) {
const int opcode, const bool rewire_uncommon_proj_phi_inputs) {
Copy link
Member Author

Choose a reason for hiding this comment

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

Squeezed this in here: assertion_predicate_type is dead.

Comment on lines +273 to +274
void PhaseIdealLoop::get_opaque_template_assertion_predicate_nodes(ParsePredicateSuccessProj* parse_predicate_proj,
Unique_Node_List& list) {
Copy link
Member Author

Choose a reason for hiding this comment

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

Only applied a renaming here.

Comment on lines +241 to +250
void unswitch(const UnswitchedLoopSelector& unswitched_loop_selector) {
const uint first_false_path_loop_node_index = _phase->C->unique();
clone_loop(unswitched_loop_selector);

move_parse_and_template_assertion_predicates_to_unswitched_loops(unswitched_loop_selector,
first_false_path_loop_node_index);
DEBUG_ONLY(verify_unswitched_loop_versions(_loop->_head->as_Loop(), unswitched_loop_selector);)

_phase->recompute_dom_depth();
remove_unswitch_candidate_from_loops(unswitched_loop_selector);
Copy link
Member Author

Choose a reason for hiding this comment

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

New order of operation (see PR description).

Comment on lines +271 to +279
const UnswitchedLoopSelector& unswitched_loop_selector, const uint first_false_path_loop_node_index) const {
const NodeInOriginalLoopBody node_in_true_path_loop_body(first_false_path_loop_node_index, _old_new);
const NodeInClonedLoopBody node_in_false_path_loop_body(first_false_path_loop_node_index);
CloneUnswitchedLoopPredicatesVisitor
clone_unswitched_loop_predicates_visitor(_loop_head, old_to_new(_loop_head)->as_Loop(), node_in_true_path_loop_body,
node_in_false_path_loop_body, _phase);
Node* source_loop_entry = unswitched_loop_selector.selector()->in(0);
PredicateIterator predicate_iterator(source_loop_entry);
predicate_iterator.for_each(clone_unswitched_loop_predicates_visitor);
Copy link
Member Author

Choose a reason for hiding this comment

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

The main part that is new here: We use visitors to clone the predicates and rewire them correctly.

Comment on lines +298 to +300
Node* old_to_new(const Node* old) const {
return _old_new[old->_idx];
}
Copy link
Member Author

Choose a reason for hiding this comment

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

Only moved.

@chhagedorn chhagedorn marked this pull request as ready for review December 19, 2024 14:00
@openjdk openjdk bot added the rfr Pull request is ready for review label Dec 19, 2024
@mlbridge
Copy link

mlbridge bot commented Dec 19, 2024

Webrevs

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.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Jan 9, 2025
@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!

@chhagedorn
Copy link
Member Author

/integrate

@openjdk
Copy link

openjdk bot commented Jan 13, 2025

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

  • b37f123: 8347407: [BACKOUT] C1/C2 don't handle allocation failure properly during initialization (RuntimeStub::new_runtime_stub fatal crash)
  • 1f7925c: 8347270: Remove unix_getParentPidAndTimings, unix_getChildren and unix_getCmdlineAndUserInfo
  • 9fafd63: 8346828: javax/swing/JScrollBar/4865918/bug4865918.java still fails in CI
  • f04a642: 8346717: serviceability/dcmd/vm/SystemDumpMapTest.java failing on Windows with "Stack base not yet set for thread id"
  • 3145278: 8346727: JvmtiVTMSTransitionDisabler deadlock
  • 761774a: 8346143: add ClearAllFramePops function to speedup debugger single stepping in some cases
  • 6f1f2f2: 8347063: Add comments in ClassFileFormatVersion for class file format evolution history
  • 10f7142: 8347295: Fix WinResourceTest to make it work with WiX v4.0+
  • 01c8ba2: 8347298: Bug in JPackageCommand.ignoreFakeRuntime()
  • d69463e: 8347300: Don't exclude the "PATH" var from the environment when running app launchers in jpackage tests
  • ... and 99 more: https://git.openjdk.org/jdk/compare/f1d85ab3e61f923b4e120cf30e16109e04505b53...master

Your commit was automatically rebased without conflicts.

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

openjdk bot commented Jan 13, 2025

@chhagedorn Pushed as commit ed0b555.

💡 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