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.

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

Commit messages:
 - Simplify and optimize return filters
 - Select the appropriate layout
 - Merge branch 'master' into errno-util
 - Bump copyright years and rename method
 - Merge branch 'master' into errno-util
 - Merge branch 'master' into errno-util
 - Add tests and improve docs
 - Clean up
 - Rename test
 - Reuse MHs
 - ... and 8 more: https://git.openjdk.org/jdk/compare/8c87ea2b...878a4096

Changes: https://git.openjdk.org/jdk/pull/22391/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=22391&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8347408
  Stats: 368 lines in 3 files changed: 367 ins; 0 del; 1 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

Reply via email to