RFR: 8347408: Create an internal method handle adapter for system calls with errno [v2]

Per Minborg pminborg at openjdk.org
Fri Jan 10 10:47:34 UTC 2025


> Going forward, converting older JDK code to use the relatively new FFM API requires system calls that can provide `errno` and the likes to explicitly allocate a MemorySegment to capture potential error states. This can lead to negative performance implications if not designed carefully and also introduces unnecessary code complexity.
> 
> Hence, this PR proposes to add a _JDK internal_ method handle adapter that can be used to handle system calls with `errno`, `GetLastError`, and `WSAGetLastError`.
> 
> It currently relies on a thread-local cache of MemorySegments to allide allocations. If, in the future, a more efficient thread-associated allocation scheme becomes available, we could easily migrate to that one.
> 
> Tested and passed tiers 1-3.

Per Minborg has updated the pull request incrementally with one additional commit since the last revision:

  Add thread stress test

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

Changes:
  - all: https://git.openjdk.org/jdk/pull/22391/files
  - new: https://git.openjdk.org/jdk/pull/22391/files/878a4096..124567cf

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=jdk&pr=22391&range=01
 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=22391&range=00-01

  Stats: 45 lines in 1 file changed: 35 ins; 6 del; 4 mod
  Patch: https://git.openjdk.org/jdk/pull/22391.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/22391/head:pull/22391

PR: https://git.openjdk.org/jdk/pull/22391


More information about the core-libs-dev mailing list