jdk
jdk copied to clipboard
8342206: Convenience method to check if a ClassEntry matches a ClassDesc
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:
- This is not straightforward. Users may be tempted to write
inst.owner().asSymbol().equals(CD_System)
unaware of the degraded performance from extra conversions.
- 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
: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.
❗ This change is not yet ready to be integrated. See the Progress checklist in the description for automated requirements.
@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.
Webrevs
- 03: Full - Incremental (668335ad)
- 02: Full - Incremental (7f5a7ac4)
- 01: Full - Incremental (54139eae)
- 00: Full (c6e40fd9)
I think it might be a good idea to also have equalsSymbol(…) methods for the other pool entries.
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 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!
@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.