RFR: 8354996: Reduce dynamic code generation for a single downcall [v3]

Luca Kellermann duke at openjdk.org
Sun May 4 19:41:55 UTC 2025


On Mon, 28 Apr 2025 14:36:33 GMT, Chen Liang <liach at openjdk.org> wrote:

>> Perf numbers for simple main:
>> Linking of `Class::forName0` down from ~152 to ~83
>> 
>> For calling little color management system https://bugs.openjdk.org/browse/JDK-8313344:
>> JNI: ~45
>> baseline panama: ~164
>> patch: ~103
>> 
>> Also see #24705.
>
> Chen Liang has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains five additional commits since the last revision:
> 
>  - Merge branch 'master' of https://github.com/openjdk/jdk into exp/ffm-lcms
>  - Use more simple function descriptor
>  - Simplify FFM linker warmup
>  - Merge branch 'master' of https://github.com/openjdk/jdk into exp/ffm-lcms
>  - Wip work trying to speed up FFM

src/java.base/share/classes/java/lang/foreign/Linker.java line 866:

> 864:                     .map(CapturableState::forName)
> 865:                     .mapToInt(state -> 1 << state.ordinal())
> 866:                     .sum();

Using `sum` means the result will be incorrect if `capturedState` contains a valid name multiple times:

var option = (LinkerOptions.CaptureCallState)Linker.Option.captureCallState("WSAGetLastError", "WSAGetLastError");

// will print [ERRNO] on Windows
System.out.println(option.saved());


option = (LinkerOptions.CaptureCallState)Linker.Option.captureCallState("errno", "errno");

// will throw IndexOutOfBoundsException on all platforms
option.saved();

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

PR Review Comment: https://git.openjdk.org/jdk/pull/24742#discussion_r2072694511


More information about the core-libs-dev mailing list