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

8343148: C2: Refactor uses of "PhaseValue::*con*() + PhaseIdealLoop::set_ctrl()" into separate method #21836

Closed

Conversation

theoweidmannoracle
Copy link
Contributor

@theoweidmannoracle theoweidmannoracle commented Nov 1, 2024

This patch introduces the methods PhaseIdealLoop::intcon and PhaseIdealLoop::longcon which are wrappers for:

ConINode* node = _igvn.intcon(i);
set_ctrl(node, C->root());

and

ConLNode* node = _igvn.longcon(i);
set_ctrl(node, C->root());

Occurrences of this pattern in loopnode.cpp were replaced with the appropriate call to the new methods.


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-8343148: C2: Refactor uses of "PhaseValue::con() + PhaseIdealLoop::set_ctrl()" into separate method (Enhancement - P4)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 21836

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

Using diff file

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

Using Webrev

Link to Webrev Comment

@bridgekeeper bridgekeeper bot added the oca Needs verification of OCA signatory status label Nov 1, 2024
@bridgekeeper
Copy link

bridgekeeper bot commented Nov 1, 2024

Hi @theoweidmannoracle, welcome to this OpenJDK project and thanks for contributing!

We do not recognize you as Contributor and need to ensure you have signed the Oracle Contributor Agreement (OCA). If you have not signed the OCA, please follow the instructions. Please fill in your GitHub username in the "Username" field of the application. Once you have signed the OCA, please let us know by writing /signed in a comment in this pull request.

If you already are an OpenJDK Author, Committer or Reviewer, please click here to open a new issue so that we can record that fact. Please use "Add GitHub user theoweidmannoracle" as summary for the issue.

If you are contributing this work on behalf of your employer and your employer has signed the OCA, please let us know by writing /covered in a comment in this pull request.

@openjdk
Copy link

openjdk bot commented Nov 1, 2024

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

8343148: C2: Refactor uses of "PhaseValue::*con*() + PhaseIdealLoop::set_ctrl()" into separate method

Reviewed-by: kvn, chagedorn, thartmann

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

  • 1e9204f: 8345273: Fix -Wzero-as-null-pointer-constant warnings in s390 code
  • c40140e: 8334581: Remove no-arg constructor BasicSliderUI()
  • 8de0622: 8345767: javax/swing/JSplitPane/4164779/JSplitPaneKeyboardNavigationTest.java fails in ubuntu22.04
  • abcd23f: 8334756: javac crashed on call to non-existent generic method with explicit annotated type arg
  • 2ddaa46: 8305010: Test vmTestbase/nsk/jvmti/scenarios/sampling/SP05/sp05t003/TestDescription.java timed out: thread not suspended
  • c631719: 8343170: java/awt/Cursor/JPanelCursorTest/JPanelCursorTest.java does not show the default cursor
  • 29d648c: 8341781: Improve Min/Max node identities
  • 4c39e9f: 8344924: Default CA certificates loaded despite request to use custom keystore
  • 0f03554: 8342469: Improve API documentation for java.lang.classfile.instruction
  • 9bd70ec: 8345888: Broken links in the JDK 24 JavaDoc API documentation, build 27
  • ... and 617 more: https://git.openjdk.org/jdk/compare/5b2f7f3b30adf9942fa8a3382e7661d6816fbb38...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.

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 (@vnkozlov, @chhagedorn, @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
Copy link

openjdk bot commented Nov 1, 2024

@theoweidmannoracle 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 1, 2024
@chhagedorn
Copy link
Member

While at it, we could extend this to the other constant creation methods zerocon, makecon, and integercon as well (uncached_makecon is only called by the other *con* methods - could be made private at some point). I suggest to update the RFE title accordingly since it only mentions intcon now. Maybe something like PhaseValue::*con*() + ....

@theoweidmannoracle theoweidmannoracle changed the title 8343148: C2: Refactor uses of "PhaseValues::intcon() + PhaseIdealLoop::set_ctrl()" into separate method 8343148: C2: Refactor uses of "PhaseValue::*con*() + PhaseIdealLoop::set_ctrl()" into separate method Nov 4, 2024
@bridgekeeper bridgekeeper bot removed the oca Needs verification of OCA signatory status label Nov 5, 2024
@openjdk openjdk bot added the rfr Pull request is ready for review label Nov 5, 2024
@mlbridge
Copy link

mlbridge bot commented Nov 5, 2024

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.

Do we have other places (not new constant node) where we set Root as control?
May be we can add set_root_as_ctrl(n) method in loop node.hpp in such case.

@vnkozlov
Copy link
Contributor

vnkozlov commented Nov 5, 2024

Do we have other places (not new constant node) where we set Root as control?

In loop opts.

@theoweidmannoracle
Copy link
Contributor Author

Do we have other places (not new constant node) where we set Root as control? May be we can add set_root_as_ctrl(n) method in loop node.hpp in such case.

There's only three locations where control is set to the root in the loop files now (not counting the ones in the new methods I added). The main reason for this patch is bugs caused by people forgetting to set control for constants (e.g. https://bugs.openjdk.org/browse/JDK-8343137), which is now prevented if the new helper methods are used.

Do you think there would be any benefit from introducing set_root_as_ctrl(n) given there's only about three places where this pattern occurs now?

theoweidmannoracle and others added 4 commits November 7, 2024 17:05
Co-authored-by: Emanuel Peter <emanuel.peter@oracle.com>
Co-authored-by: Emanuel Peter <emanuel.peter@oracle.com>
Co-authored-by: Emanuel Peter <emanuel.peter@oracle.com>
Co-authored-by: Emanuel Peter <emanuel.peter@oracle.com>
@vnkozlov
Copy link
Contributor

vnkozlov commented Nov 7, 2024

Do we have other places (not new constant node) where we set Root as control? May be we can add set_root_as_ctrl(n) method in loop node.hpp in such case.

There's only three locations where control is set to the root in the loop files now (not counting the ones in the new methods I added). The main reason for this patch is bugs caused by people forgetting to set control for constants (e.g. https://bugs.openjdk.org/browse/JDK-8343137), which is now prevented if the new helper methods are used.

Do you think there would be any benefit from introducing set_root_as_ctrl(n) given there's only about three places where this pattern occurs now?

My suggesting is about additional cleaning code. I think 3 + 5 places are enough to justify to have a new function in header file. Also set_root_as_ctrl(n) could be copy of set_ctrl(n, ctrl) without 2 asserts which checks ctrl. It will be faster.

@theoweidmannoracle
Copy link
Contributor Author

theoweidmannoracle commented Nov 8, 2024

@vnkozlov I implemented your suggestion. Would you like to take another look? (It also helped me discover some more cases which can be replaced with the new *con*() functions.)

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. I have few additional comments.

Comment on lines 3145 to +3147
ConINode* zero = igvn->intcon(0);
if (iloop != nullptr) {
iloop->set_ctrl(zero, igvn->C->root());
iloop->set_root_as_ctrl(zero);
Copy link
Contributor

Choose a reason for hiding this comment

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

Please look on history of this code. This is suspicious - constant nodes should be always attached to Root.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@TobiHartmann Pointed out that this method is also called from code outside of loop opts, for example, PhaseMacroExpand::expand_macro_nodes. Since there's no PhaseIdealLoop in this case, nullptr is passed instead and we cannot set control as we are not inside a loop opt.

Maybe @rwestrel can also take a look as he originally introduced this code in this PR.

Copy link
Contributor

Choose a reason for hiding this comment

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

Got it. That is what (iloop != nullptr) check for.

@openjdk
Copy link

openjdk bot commented Nov 11, 2024

@theoweidmannoracle this pull request can not be integrated into master due to one or more merge conflicts. To resolve these merge conflicts and update this pull request you can run the following commands in the local repository for your personal fork:

git checkout JDK-8343148
git fetch https://git.openjdk.org/jdk.git master
git merge FETCH_HEAD
# resolve conflicts and follow the instructions given by git merge
git commit -m "Merge master"
git push

@openjdk openjdk bot added the merge-conflict Pull request has merge conflict with target branch label Nov 11, 2024
@openjdk openjdk bot removed the merge-conflict Pull request has merge conflict with target branch label Nov 11, 2024
theoweidmannoracle and others added 4 commits November 13, 2024 11:17
Co-authored-by: Christian Hagedorn <christian.hagedorn@oracle.com>
Co-authored-by: Christian Hagedorn <christian.hagedorn@oracle.com>
Co-authored-by: Christian Hagedorn <christian.hagedorn@oracle.com>
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.

Some last minor comments, otherwise the updates look good to me. Thanks for doing this extended refactoring!

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Nov 15, 2024
theoweidmannoracle and others added 3 commits November 18, 2024 08:51
Co-authored-by: Christian Hagedorn <christian.hagedorn@oracle.com>
Co-authored-by: Christian Hagedorn <christian.hagedorn@oracle.com>
Co-authored-by: Christian Hagedorn <christian.hagedorn@oracle.com>
@openjdk openjdk bot removed the ready Pull request is ready to be integrated label Nov 18, 2024
@openjdk openjdk bot added the ready Pull request is ready to be integrated label Nov 18, 2024
@theoweidmannoracle
Copy link
Contributor Author

@vnkozlov Could you take another look at the latest changes?

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. Nice cleanup.

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.

This version looks good.

@theoweidmannoracle
Copy link
Contributor Author

/integrate

@openjdk openjdk bot added the sponsor Pull request is ready to be sponsored label Dec 11, 2024
@openjdk
Copy link

openjdk bot commented Dec 11, 2024

@theoweidmannoracle
Your change (at version 4ed14b2) is now ready to be sponsored by a Committer.

@chhagedorn
Copy link
Member

/sponsor

@openjdk
Copy link

openjdk bot commented Dec 11, 2024

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

  • 1e9204f: 8345273: Fix -Wzero-as-null-pointer-constant warnings in s390 code
  • c40140e: 8334581: Remove no-arg constructor BasicSliderUI()
  • 8de0622: 8345767: javax/swing/JSplitPane/4164779/JSplitPaneKeyboardNavigationTest.java fails in ubuntu22.04
  • abcd23f: 8334756: javac crashed on call to non-existent generic method with explicit annotated type arg
  • 2ddaa46: 8305010: Test vmTestbase/nsk/jvmti/scenarios/sampling/SP05/sp05t003/TestDescription.java timed out: thread not suspended
  • c631719: 8343170: java/awt/Cursor/JPanelCursorTest/JPanelCursorTest.java does not show the default cursor
  • 29d648c: 8341781: Improve Min/Max node identities
  • 4c39e9f: 8344924: Default CA certificates loaded despite request to use custom keystore
  • 0f03554: 8342469: Improve API documentation for java.lang.classfile.instruction
  • 9bd70ec: 8345888: Broken links in the JDK 24 JavaDoc API documentation, build 27
  • ... and 617 more: https://git.openjdk.org/jdk/compare/5b2f7f3b30adf9942fa8a3382e7661d6816fbb38...master

Your commit was automatically rebased without conflicts.

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

openjdk bot commented Dec 11, 2024

@chhagedorn @theoweidmannoracle Pushed as commit e88e793.

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

5 participants