RFR: 8342206: Convenience method to check if a ClassEntry matches a ClassDesc [v4]
Chen Liang
liach at openjdk.org
Wed Oct 30 20:15:58 UTC 2024
> 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](https://openjdk.org/jeps/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.
>
> 2. 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.
Chen Liang has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains eight additional commits since the last revision:
- Compatibility improvements with internal name cache
- Merge branch 'master' of https://github.com/openjdk/jdk into feature/classentry-equalssym
- Merge branch 'master' of https://github.com/openjdk/jdk into feature/classentry-equalssym
- Merge
- Merge branch 'master' of https://github.com/openjdk/jdk into feature/classentry-equalssym
- Reuse cache for arrays, replace some use cases
- Merge branch 'master' of https://github.com/openjdk/jdk into feature/classentry-equalssym
- 8342206: Convenience method to check if a ClassEntry matches a ClassDesc
-------------
Changes:
- all: https://git.openjdk.org/jdk/pull/21526/files
- new: https://git.openjdk.org/jdk/pull/21526/files/7f5a7ac4..668335ad
Webrevs:
- full: https://webrevs.openjdk.org/?repo=jdk&pr=21526&range=03
- incr: https://webrevs.openjdk.org/?repo=jdk&pr=21526&range=02-03
Stats: 165680 lines in 1317 files changed: 18932 ins; 142923 del; 3825 mod
Patch: https://git.openjdk.org/jdk/pull/21526.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/21526/head:pull/21526
PR: https://git.openjdk.org/jdk/pull/21526
More information about the core-libs-dev
mailing list