jdk icon indicating copy to clipboard operation
jdk copied to clipboard

8342206: Convenience method to check if a ClassEntry matches a ClassDesc

Open liach opened this issue 1 year ago • 6 comments

Currently, to efficiently check if a ClassEntry, such as one from an InvokeInstruction, is of a particular class, we use such a pattern (as seen in JEP 486 Appendix):

inst.owner().name().equalsString("java/lang/System")

This pattern has a few issues:

  1. This is not straightforward. Users may be tempted to write
inst.owner().asSymbol().equals(CD_System)

unaware of the degraded performance from extra conversions.

  1. We aim to reduce the use of "internal names" with encapsulation. Direct use of "java/lang/System" goes against this, and we have no constants offered to reduce such error-prone use of internal name.

Thus, I propose a new API in ClassEntry:

boolean equalsSymbol(ClassDesc)

that can be used conveniently to check the identity of a class entry with a clean syntax and better performance.


Progress

  • [ ] Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • [x] Change must not contain extraneous whitespace
  • [x] Commit message must refer to an issue
  • [ ] Change requires CSR request JDK-8342210 to be approved

Issues

  • JDK-8342206: Convenience method to check if a ClassEntry matches a ClassDesc (Enhancement - P4)
  • JDK-8342210: Convenience method to check if a ClassEntry matches a ClassDesc (CSR)

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 21526

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

Using diff file

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

Webrev

Link to Webrev Comment

liach avatar Oct 15 '24 17:10 liach

:wave: Welcome back liach! 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.

bridgekeeper[bot] avatar Oct 15 '24 17:10 bridgekeeper[bot]

❗ This change is not yet ready to be integrated. See the Progress checklist in the description for automated requirements.

openjdk[bot] avatar Oct 15 '24 17:10 openjdk[bot]

@liach The following label will be automatically applied to this pull request:

  • core-libs

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[bot] avatar Oct 15 '24 17:10 openjdk[bot]

Webrevs

mlbridge[bot] avatar Oct 15 '24 17:10 mlbridge[bot]

I think it might be a good idea to also have equalsSymbol(…) methods for the other pool entries.

ExE-Boss avatar Oct 22 '24 22:10 ExE-Boss

I think it might be a good idea to also have equalsSymbol(…) methods for the other pool entries.

Indeed, this can avoid promotion to String state for all applicable symbols. I decide to start with the ClassEntry as this is the most error-prone and worth optimization. (Feel free to submit a ticket through bugs.java.com)

liach avatar Oct 22 '24 23:10 liach

@liach This pull request has been inactive for more than 4 weeks and will be automatically closed if another 4 weeks passes without any activity. To avoid this, simply add a new comment to the pull request. Feel free to ask for assistance if you need help with progressing this pull request towards integration!

bridgekeeper[bot] avatar Nov 20 '24 02:11 bridgekeeper[bot]

@liach This pull request has been inactive for more than 8 weeks and will now be automatically closed. If you would like to continue working on this pull request in the future, feel free to reopen it! This can be done using the /open pull request command.

bridgekeeper[bot] avatar Dec 18 '24 07:12 bridgekeeper[bot]