RFR: 8305093: Linker cache should not take layout names into account [v2]

ExE Boss duke at openjdk.org
Thu Apr 27 19:07:23 UTC 2023


On Fri, 21 Apr 2023 01:03:57 GMT, Jorn Vernee <jvernee at openjdk.org> wrote:

>> Strip names from the function descriptors used in linkage requests. The names are not important for classification, and this will allow the cached MethodHandle/UpcallStubFactory to be shared across linkage request with the same structure, but with layouts that have different names.
>> 
>> I also have another implementation that avoids copying all the layouts, and instead re-implemented equals and hashCode in the LinkRequest wrapper: https://github.com/openjdk/jdk/compare/pr/13079...JornVernee:jdk:NoNameCache But, this seems too complex. Linking code is not very performance sensitive, so I instead went with a simpler approach in this patch.
>
> Jorn Vernee has updated the pull request incrementally with one additional commit since the last revision:
> 
>   use al instead of ValueLayout.ADDRESS

src/java.base/share/classes/jdk/internal/foreign/abi/AbstractLinker.java line 147:

> 145:             case AddressLayout al -> al.targetLayout()
> 146:                     .map(tl -> al.withoutName().withTargetLayout(stripNames(tl)))
> 147:                     .orElse(al.withoutName());

This can use [`Optional::orElseGet`]:
Suggestion:

                    .orElseGet(al::withoutName);


[`Optional::orElseGet`]: https://docs.oracle.com/en/java/javase/20/docs/api/java.base/java/util/Optional.html#orElseGet%28java.util.function.Supplier%29

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/13562#discussion_r1179526882


More information about the core-libs-dev mailing list