On Fri, 21 Apr 2023 18:25:32 GMT, Jorn Vernee <[email protected]> wrote:
> Implement captureCallState support for upcall stubs.
>
> The method handle of an upcall stub linked with this linker option has an
> additional leading memory segment parameter into which the capture state
> (e.g. errno) should be written. After returning from Java, this value is then
> actually written to the corresponding execution state.
test/jdk/java/foreign/capturecallstate/TestCaptureCallState.java line 89:
> 87: FunctionDescriptor downcallDesc = testCase.retValueLayout()
> 88: .map(rl -> FunctionDescriptor.of(rl, JAVA_INT, rl))
> 89: .orElse(FunctionDescriptor.ofVoid(JAVA_INT));
Using [`Optional::orElseGet(…)`] avoids allocating the `FunctionDescriptor`
corresponding to `(int)void` when `testCase.retValueLayout()` is present:
Suggestion:
.orElseGet(() -> FunctionDescriptor.ofVoid(JAVA_INT));
[`Optional::orElseGet(…)`]:
https://docs.oracle.com/en/java/javase/20/docs/api/java.base/java/util/Optional.html#orElseGet(java.util.function.Supplier)
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/13588#discussion_r1174607193