RFR: 7903660: Drop layout-inferring varargs invoker + add method handle factory [v3]

Maurizio Cimadamore mcimadamore at openjdk.org
Mon Feb 12 16:57:04 UTC 2024


On Mon, 12 Feb 2024 16:18:01 GMT, Jorn Vernee <jvernee at openjdk.org> wrote:

> See the latest version. Invoker interface is replaced with an invoker class which caches the spread invoker. Performance is really good with that. A client can grab the specialized method handle from the invoker instance and stash that in a `static final` to get full performance.
> 
> Two nits:
> 
>     1. Maybe we should drop the top-level invoker factory, and just have the factory method in the invoker class itself. This signals that this is really a special case, and a client can't just directly call a variadic function, but needs to specialize first. Auto-complete will still find the invoker class when the name of the symbol is typed.
> 
>     2. Maybe we should rename `apply` to `invoke`, to match what we do for function pointer classes.

Re. (1), not sure. Usage seems a bit better with the existing arrangement - e.g.


printf(C_INT).apply(formatSegment, 42);

vs.

printf.invoker(C_INT).apply(formatSegment, 42);


I think having a toplevel method in the header class with same name helps connecting things together.

As for (2), I was thinking the same, but then noticed that the functional interface we generate for function pointer has a method called `apply` - e.g. `invoke` is more of a static invoke helper. I believe the variadic invoker method is closer to the former than the latter (which justifies the name we have right now) ?

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

PR Comment: https://git.openjdk.org/jextract/pull/205#issuecomment-1939140111


More information about the jextract-dev mailing list