Skip to content

Conversation

@merykitty
Copy link
Member

@merykitty merykitty commented Jan 23, 2025

Hi,

This patch removes the control input of LoadKlassNode and LoadNKlassNode. They can only have a control input if created inside Parse::array_store_check(), the reason given is:

// We are allowed to use the constant type only if cast succeeded

But this seems incorrect, the load from the constant type can be done regardless, and it will be constant-folded. This patch only makes that more formal and cleanup LoadKlassNode::can_remove_control.

Please take a look and leave your reviews, thanks a lot.


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-8348411: C2: Remove the control input of LoadKlassNode and LoadNKlassNode (Enhancement - P4)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 23274

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

Using diff file

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

Using Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Jan 23, 2025

👋 Welcome back qamai! 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 Jan 23, 2025

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

8348411: C2: Remove the control input of LoadKlassNode and LoadNKlassNode

Reviewed-by: vlivanov, epeter

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 no new commits pushed to the master branch. If another commit should be pushed before you perform the /integrate command, your PR will be automatically rebased. If you prefer to avoid any potential 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 Jan 23, 2025
@openjdk
Copy link

openjdk bot commented Jan 23, 2025

@merykitty The following labels will be automatically applied to this pull request:

  • graal
  • hotspot-compiler

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing lists. If you would like to change these labels, use the /label pull request command.

@openjdk openjdk bot added graal graal-dev@openjdk.org hotspot-compiler hotspot-compiler-dev@openjdk.org labels Jan 23, 2025
@mlbridge
Copy link

mlbridge bot commented Jan 23, 2025

Webrevs

&& !too_many_traps(Deoptimization::Reason_array_check)
&& !tak->klass_is_exact()
if (MonomorphicArrayCheck && !too_many_traps(Deoptimization::Reason_array_check) && !tak->klass_is_exact()
&& tak != TypeInstKlassPtr::OBJECT) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd also turn tak != TypeInstKlassPtr::OBJECT into tak->isa_aryklassptr() to stress the intention.
(Please, keep the original formatting here.)

Copy link
Member Author

Choose a reason for hiding this comment

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

Done, I assume you meant the formatting of the comment below, right?

Copy link
Contributor

Choose a reason for hiding this comment

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

No, I referred to the original shape of the condition (1 check per line). IMO it is easier to follow.

Copy link
Contributor

@iwanowww iwanowww 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 (w/ minor cleanup suggestions).

Testing (hs-tier1 - hs-tier4) results are clean.

&& !too_many_traps(Deoptimization::Reason_array_check)
&& !tak->klass_is_exact()
if (MonomorphicArrayCheck && !too_many_traps(Deoptimization::Reason_array_check) && !tak->klass_is_exact()
&& tak != TypeInstKlassPtr::OBJECT) {
Copy link
Contributor

Choose a reason for hiding this comment

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

No, I referred to the original shape of the condition (1 check per line). IMO it is easier to follow.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Jan 30, 2025
@merykitty
Copy link
Member Author

@iwanowww Thanks a lot for your reviews and testing, I hope I have addressed all of your concerns.

@openjdk openjdk bot removed the ready Pull request is ready to be integrated label Jan 30, 2025
@openjdk openjdk bot added the ready Pull request is ready to be integrated label Jan 30, 2025
Copy link
Contributor

@eme64 eme64 left a comment

Choose a reason for hiding this comment

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

Nice cleanup.
Though it looks like you are doing more than remove the ctrl input. I don't know the code very well, so I have some questions ;)

if (MonomorphicArrayCheck &&
!too_many_traps(Deoptimization::Reason_array_check) &&
!tak->klass_is_exact() &&
tak->isa_aryklassptr()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like an implicit nullptr check. Not allowed by code style ;)

Copy link
Contributor

Choose a reason for hiding this comment

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

Can you quickly explain this change from tak != TypeInstKlassPtr::OBJECT so I don't need to investigate myself, please?

Copy link
Member Author

Choose a reason for hiding this comment

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

Looks like an implicit nullptr check. Not allowed by code style ;)

But the verb here is isa and we use these as a bool a lot, though :/

Can you quickly explain this change from tak != TypeInstKlassPtr::OBJECT so I don't need to investigate myself, please?

The bottom type of an array can be either Object or an array of some kind, so tak != TypeInstKlassPtr::OBJECT is the same as tak->isa_aryklassptr().

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah great, thanks for the explanation!

//
// See issue JDK-8057622 for details.

always_see_exact_class = true;
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is it ok to remove this?
If this branch is not taken, it used to be false, and would lead to something different below...

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 only use of this is to decide if we need to attach a control input to the LoadKlass. As the control input is not needed, this can be removed.

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, thanks!

Copy link
Contributor

@eme64 eme64 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, thanks for the explanations!

I see we did not yet run internal tests for the last commit, though it is only formatting, so most most likely ok.

But the state of the code is also 2 weeks old, so it would be good if you merged and launched testing again before integration, just in case ;)

@merykitty
Copy link
Member Author

@eme64 I have merged the change with master, could you help me initiate the testing process, please? Thanks very much.

@eme64
Copy link
Contributor

eme64 commented Feb 7, 2025

@merykitty Testing launched!

@eme64
Copy link
Contributor

eme64 commented Feb 7, 2025

@merykitty Testing is all passing!

@merykitty
Copy link
Member Author

Thanks a lot for your reviews and testing!
/integrate

@openjdk
Copy link

openjdk bot commented Feb 8, 2025

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

  • 5395ffa: 8327378: XMLStreamReader throws EOFException instead of XMLStreamException
  • 1ed9ef1: 8349559: Compiler interface doesn't need to store protection domain
  • f0ea38b: 8349509: [macos] Clean up macOS dead code in jpackage
  • 7f6c687: 8349374: [JVMCI] concurrent use of HotSpotSpeculationLog can crash
  • bd9b24c: 8349512: Duplicate PermittedSubclasses entries with doclint enabled
  • b40f8ee: 8337251: C1: Improve Class.isInstance intrinsic
  • 88a8483: 8349121: SSLParameters.setApplicationProtocols() ALPN example could be clarified
  • fb847bb: 8349493: Replace sun.util.locale.ParseStatus usage with java.text.ParsePosition
  • 7cd5cb2: 8349532: Refactor ./util/Pem/encoding.sh to run in java
  • 86cec4e: 8343782: G1: Use one G1CardSet instance for multiple old gen regions
  • ... and 7 more: https://git.openjdk.org/jdk/compare/ed8945a68a67dd51a7cfa332905941afccc12b36...master

Your commit was automatically rebased without conflicts.

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

openjdk bot commented Feb 8, 2025

@merykitty Pushed as commit e9278de.

💡 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

graal graal-dev@openjdk.org 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