On Thu, 26 Nov 2026 16:33:07 GMT, Jorn Vernee <[email protected]> wrote:
>> Martin Doerr has updated the pull request incrementally with one additional >> commit since the last revision: >> >> Use invokeExact for MH_getpwuid_r. > > src/jdk.security.auth/share/classes/com/sun/security/auth/module/UnixSystem.java > line 183: > >> 181: // always long in the underlying system. >> 182: int out = (int) MH_getpwuid_r.invoke( >> 183: tmpUid, pwd, buffer, GETPW_R_SIZE_MAX, result); > > It's generally better to use `invokeExact`, since that can be inlined by the > JIT, while `invoke` can not (unless the call site type already matches the MH > type exactly, but in that case we might just as well use `invokeExact`). > > It's possible to use `invokeExact` here by erasing the type of the method > handle beforehand, e.g. with a call to > `asType(MethodType.methodType(int.class, int.class, MemorySegment.class, > MemorySegment.class, int.class, MemorySegment.class))`. On platforms where > the 4th parameter is `int` this would be a no-op, on other platforms it would > be widened to `long` internally inside the methodhandle. Nice trick! I've added the change. This is now an additional enhancement. Please take a look. Note that some native calls could use `Linker.Option.critical(false)`, but I was already told that the performance was not critical, here. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/34071#discussion_r4711580259
