-
Notifications
You must be signed in to change notification settings - Fork 5.8k
8346774: Use Predicate classes instead of Node classes #23234
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 chagedorn! A progress list of the required criteria for merging this PR into |
@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:
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 1 new commit 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 |
@chhagedorn The following label will be automatically applied to this pull request:
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. |
OpaqueLoopInitNode* new_opaque_init = new OpaqueLoopInitNode(phase->C, new_opaque_input); | ||
phase->register_new_node(new_opaque_init, new_control); |
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.
Moved here from the caller of clone_and_replace_init()
. He now provides the input to the opaque node instead of creating the opaque node and passing the created node to this method.
// of the newly created Initialized Assertion Predicate. | ||
IfTrueNode* TemplateAssertionPredicate::initialize(PhaseIdealLoop* phase, Node* new_control) const { | ||
// Create a new Initialized Assertion Predicate from this template at the template success projection. | ||
InitializedAssertionPredicate TemplateAssertionPredicate::initialize(PhaseIdealLoop* phase) 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.
Removed new_control
. All callers created the Initialized Assertion Predicate below the template. Eventually, this will always be the case since we want to keep Template Assertion Predicates around in the future.
InitializedAssertionPredicate InitializedAssertionPredicateCreator::create_from_template( | ||
IfNode* template_assertion_predicate, Node* new_control, Node* new_init, Node* new_stride) 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.
Also made const
and split long line.
InitializedAssertionPredicate InitializedAssertionPredicateCreator::create_from_template_and_insert_below( | ||
const TemplateAssertionPredicate& template_assertion_predicate) 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.
Same as above: Removed new_control
.
Also made const
.
IfNode* template_assertion_predicate_if = template_assertion_predicate.head(); | ||
AssertionPredicateType assertion_predicate_type = template_assertion_predicate_if->assertion_predicate_type(); | ||
int if_opcode = template_assertion_predicate_if->Opcode(); |
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.
Need to fetch the information from the Template Assertion Predicate now instead of directly from the If
.
OpaqueLoopInitNode* opaque_init = new OpaqueLoopInitNode(_phase->C, _init); | ||
_phase->register_new_node(opaque_init, _old_target_loop_entry); |
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.
See earlier comment about moving opaque creation from caller -> callee.
assert(predicate.head()->_idx >= _node_index_before_cloning, "must be a newly cloned predicate"); | ||
assert(predicate.tail()->_idx >= _node_index_before_cloning, "must be a newly cloned predicate"); |
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.
Can now verify both the head and tail.
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.
You use copy constructors to return *Predicate*
objects (I assume because base class is StackObj
). How it affects performance of C2? Unless all these methods are inlined.
I assumed that RVO will make sure that we do not create an extra copy regardless of whether a method is inlined or not. Maybe @kimbarrett can comment on that. Nevertheless, let me run some performance testing. |
Performance testing looked good. |
Thanks Vladimir for your review! |
Not a review, just a response to the question about RVO. The use of NRVO and RVO here looks fine to me. C++17 makes RVO mandatory. We're not using C++17 yet, but part of the While NRVO was not made mandatory, that may have been more a matter of concern https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2015/p0135r0.html Support for guaranteed copy elision |
Thanks a lot Kim for your detailed answer and the links! That's great to hear and gives us more confidence about these changes. |
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.
Looks reasonable, I have a few minor suggestions.
// Clone this Template Assertion Predicate and replace the OpaqueLoopInitNode with the provided 'new_opaque_init' node. | ||
IfTrueNode* TemplateAssertionPredicate::clone_and_replace_init(Node* new_control, OpaqueLoopInitNode* new_opaque_init, | ||
PhaseIdealLoop* phase) const { | ||
// Clone this Template Assertion Predicate and replace the input of the OpaqueLoopInitNode with 'new_opaque_input'. |
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.
Looks like you now also create a new OpaqueLoopInitNode
, so that is slightly inaccurate, right?
IfTrueNode* success_proj = create_control_nodes(new_control, template_assertion_predicate->Opcode(), | ||
assertion_expression, | ||
template_assertion_predicate->assertion_predicate_type()); | ||
return InitializedAssertionPredicate(success_proj); |
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.
IfTrueNode* success_proj = create_control_nodes(new_control, template_assertion_predicate->Opcode(), | |
assertion_expression, | |
template_assertion_predicate->assertion_predicate_type()); | |
return InitializedAssertionPredicate(success_proj); | |
IfTrueNode* success_proj = create_control_nodes(new_control, | |
template_assertion_predicate->Opcode(), | |
assertion_expression, | |
template_assertion_predicate->assertion_predicate_type()); | |
return InitializedAssertionPredicate(success_proj); |
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.
Indentation, and: If you split the args over lines, I would at least split all of them consistently.
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 usually just make sure that long lines split but don't enforce a single arg per line. But I don't mind adapting to that here :-)
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.
Looks good now!
Thanks Emanuel for your review! I'm running some testing again with latest master and will then integrate it. |
/integrate |
Going to push as commit c545a3e.
Your commit was automatically rebased without conflicts. |
@chhagedorn Pushed as commit c545a3e. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
This small cleanup PR replaces a lot of usages of
Node
pointers, to pass around either the head (i.e.IfNode
) or the tail (i.e. a success projection) of predicates, with actualPredicate
classes. This simplifies the usages, readability and the logical flow, and enables more simplifications in the future, especially once we replace Template Assertion Predicates with a dedicated node.I've also included some minor refactorings like adding
const
or fixing typos.There are no semantic changes involved. The return value optimization should take care to avoid a lot of copies when returning new objects from methods.
Thanks,
Christian
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/23234/head:pull/23234
$ git checkout pull/23234
Update a local copy of the PR:
$ git checkout pull/23234
$ git pull https://git.openjdk.org/jdk.git pull/23234/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 23234
View PR using the GUI difftool:
$ git pr show -t 23234
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/23234.diff
Using Webrev
Link to Webrev Comment