On Mon, 5 May 2025 17:13:02 GMT, Per Minborg <pminb...@openjdk.org> wrote:

>> As we advance, 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 adding a JDK internal method handle adapter that can 
>> be used to handle system calls with `errno`, `GetLastError`, and 
>> `WSAGetLastError`.
>> 
>> It relies on an efficient carrier-thread-local cache of memory regions to 
>> allide allocations.
>
> Per Minborg has updated the pull request incrementally with three additional 
> commits since the last revision:
> 
>  - Fix empty line at the end of a third file
>  - Fix empty line at the end of another file
>  - Fix empty line at the end of a file

src/java.base/share/classes/jdk/internal/foreign/BufferStack.java line 176:

> 174:             @ForceInline
> 175:             @Override
> 176:             public NativeMemorySegmentImpl allocateNoInit(long byteSize, 
> long byteAlignment) {

This probably also needs `@SuppressWarnings("restricted")`:
Suggestion:

            @ForceInline
            @Override
            @SuppressWarnings("restricted")
            public NativeMemorySegmentImpl allocateNoInit(long byteSize, long 
byteAlignment) {

src/java.base/share/classes/jdk/internal/foreign/CaptureStateUtil.java line 85:

> 83:     // specific "basic handle" in the `BASIC_HANDLE_CACHE`.
> 84:     //   returnType in {int.class | long.class}
> 85:     //   stateName can be anything non-null but should be in 
> {"GetLastError" | "WSAGetLastError"} | "errno")}

Suggestion:

    //   stateName can be anything non-null but should be in {"GetLastError" | 
"WSAGetLastError" | "errno"}

src/java.base/share/classes/jdk/internal/invoke/MhUtil.java line 88:

> 86:     public static MethodHandle findStatic(MethodHandles.Lookup lookup,
> 87:                                            String name,
> 88:                                            MethodType type) {

Suggestion:

                                          String name,
                                          MethodType type) {

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

PR Review Comment: https://git.openjdk.org/jdk/pull/25043#discussion_r2073948786
PR Review Comment: https://git.openjdk.org/jdk/pull/25043#discussion_r2073955345
PR Review Comment: https://git.openjdk.org/jdk/pull/25043#discussion_r2073949485

Reply via email to