-
Couldn't load subscription status.
- Fork 6.1k
8370220: C2: rename methods and improve documentation around get_ctrl and idom lazy updating/forwarding of ctrl and idom via dead ctrl nodes #27892
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
Conversation
|
👋 Welcome back epeter! A progress list of the required criteria for merging this PR into |
|
@eme64 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: 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 3 new commits pushed to the
Please see this link for an up-to-date comparison between the source branch of this pull request and the ➡️ To integrate this PR with the above commit message to the |
Webrevs
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot for following up with a documentation and renaming! Some small suggestions, otherwise, looks good!
Note: There are some build failures in GHA.
src/hotspot/share/opto/loopnode.hpp
Outdated
| // reach a live ctrl node. Shorten the path to avoid chasing the | ||
| // forwarding in the future. | ||
| // - When querying "idom": from some node get its old idom, which | ||
| // may be dead but has a ctrl forwarding to the new and live |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe add this:
| // may be dead but has a ctrl forwarding to the new and live | |
| // may be dead but has an idom forwarding (piggy-backing on '_loop_or_ctrl') to the new and live |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the suggestion. I applied something that is inspired by your suggestion instead :)
src/hotspot/share/opto/loopnode.hpp
Outdated
| // Using "install_lazy_ctrl_and_idom_forwarding" allows us to only edit | ||
| // the entry for the old dead node now, and we do not have to update all | ||
| // the nodes that had the old_node as their "get_ctrl" or "idom". We | ||
| // clean up the forwarding links when we query "get_ctrl" or "idom". |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| // clean up the forwarding links when we query "get_ctrl" or "idom". | |
| // clean up the forwarding links when we query "get_ctrl" or "idom" for these nodes the next time. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Applied it but with a line break ;)
src/hotspot/share/opto/loopnode.hpp
Outdated
| // If everything went right, this dead CFG node should have had a idom/ctrl | ||
| // forwarding installed, using "install_lazy_ctrl_and_idom_forwarding". | ||
| // We now have to jump from the old (dead) ctrl node to the new (live) | ||
| // ctrl/idom node, in possibly multiple ctrl/idom forwarding steps. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe for clarification since it's somehow surprising at first that we reuse _loop_or_ctrl:
| // ctrl/idom node, in possibly multiple ctrl/idom forwarding steps. | |
| // idom node, in possibly multiple idom forwarding steps. | |
| // Note that we piggy back on `_loop_or_ctrl` do the the forwarding. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Applied with even more information.
src/hotspot/share/opto/loopnode.hpp
Outdated
| Node* n = idom_no_update(didx); | ||
| // We store the found idom in the side-table again. In most cases, | ||
| // this is a no-op, since we just read from _idom. But in cases where | ||
| // there was a ctrl forwarding via dead ctrl nodes, this shortens the path. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| // there was a ctrl forwarding via dead ctrl nodes, this shortens the path. | |
| // there was an idom forwarding via dead idom nodes, this shortens the path. |
src/hotspot/share/opto/loopnode.hpp
Outdated
| Node *idom(uint didx) const { | ||
| Node *n = idom_no_update(didx); | ||
| _idom[didx] = n; // Lazily remove dead CFG nodes from table. | ||
| Node* idom(uint didx) const { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While at it: Maybe also name this node_index?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I chose to replace it with node_idx, since it comes from n->_idx.
|
@eme64 |
Co-authored-by: Christian Hagedorn <christian.hagedorn@oracle.com>
src/hotspot/share/opto/loopnode.hpp
Outdated
| // Replace the old ctrl node with a new ctrl node. | ||
| // - Update the node inputs of all uses. | ||
| // - Lazily update the ctrl and idom info of all uses, via a ctrl/idom forwarding. | ||
| void replace_ctrl_node_and_forward_ctrl_and_idom(Node *old_node, Node *new_node) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Drive-by comment (sorry): I think this is way too heavy. Descriptive names are good but for complex methods, not all the semantics can be put into the name but should rather be in a comment.
Couldn't we just name these replace_and_update_ctrl and update_ctrl? I think this entails updating idom which is dependent on ctrl. And the comments explain the details well enough.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
update_ctrl: Sounds too much like set_ctrl, but it is not at all similar conceptually.
What about:
install_ctrl_and_idom_forwarding->forward_ctrlreplace_ctrl_node_and_forward_ctrl_and_idom->replace_node_and_forward_ctrl- Because it is really a specialization of
_igvn.replace_node, so it should have some name similarity.
- Because it is really a specialization of
What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that's much better, good with me!
Co-authored-by: Tobias Hartmann <tobias.hartmann@oracle.com>
|
@chhagedorn Thanks for all the suggestions / comments, I think I applied them all now :) @TobiHartmann thanks for the drive-by comment / suggestion. @rwestrel You are somewhat familiar with this code, would you mind reviewing? @vnkozlov You may also want to have quick look, just so you are aware of the renamings. But feel free to also review ;) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice improvement, looks good to me!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good naming update! The update looks good to me apart from some last nits.
Co-authored-by: Christian Hagedorn <christian.hagedorn@oracle.com>
|
Seems GHA is giving me some failures I did not see in our internal testing:
This is part of the assert I added. Will have to investigate. |
…om/eme64/jdk into JDK-8370220-get-ctrl-documentation
|
|
| fix_memory_uses(u, n, n, c); | ||
| } else if (_phase->C->get_alias_index(u->adr_type()) == _alias) { | ||
| _phase->lazy_replace(u, n); | ||
| _phase->igvn().replace_node(u, n); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As far as I can see, the lazy_replace only did igvn.replace_node for non-ctrl nodes anyway. Since we are dealing with PhiNodes here, we might as well only use igvn.replace_node.
I discovered this, because it hit my !old_node->is_CFG() check.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rwestrel Do you have an opinion on this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That change looks good to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rwestrel Thank, good to know :)
|
@chhagedorn @TobiHartmann Would either of you be able to re-approve? I've fixed a little issue for shenandoah, and Roland approved that change. I merged with master and am currently running some last testing. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still good!
|
@chhagedorn @TobiHartmann Thanks for the review / approval! /integrate |
|
Going to push as commit d5ce666.
Your commit was automatically rebased without conflicts. |
When working on #27889, I was irritated by the lack of documentation and suboptimal naming.
Here, I'm doing the following:
lazy_replace->replace_ctrl_node_and_forward_ctrl_and_idomlazy_update->install_lazy_ctrl_and_idom_forwardingI'd be more than happy for even better names, and suggestions how to improve the documentation further :)
Related issues:
#27889
#15720
Progress
Issue
Reviewers
Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/27892/head:pull/27892$ git checkout pull/27892Update a local copy of the PR:
$ git checkout pull/27892$ git pull https://git.openjdk.org/jdk.git pull/27892/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 27892View PR using the GUI difftool:
$ git pr show -t 27892Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/27892.diff
Using Webrev
Link to Webrev Comment