RFR: 7903585: Revisit variadic support

Maurizio Cimadamore mcimadamore at openjdk.org
Fri Dec 1 14:17:41 UTC 2023


On Fri, 1 Dec 2023 14:07:59 GMT, Jorn Vernee <jvernee at openjdk.org> wrote:

>> src/main/java/org/openjdk/jextract/impl/HeaderFileBuilder.java line 176:
>> 
>>> 174:             String paramExprs = paramExprs(declType, finalParamNames, isVarArg);
>>> 175:             appendLines(STR."""
>>> 176:                 public interface \{invokerName} {
>> 
>> question: if we used a record here, could we perhaps get rid of the holder class (since record fields are trusted) ? We don't expect this interface to be created by the user, so there's maybe not much value in it being a functional interface?
>
> Not sure what you mean. The holder class is for the base descriptor. We could stick that into the invoker interface instead, but I'm not sure why a record would be better than an interface? Do we want users to be able to access the underlying MethodHandle?

Sorry, I guess what I'm trying to say is that:
* the benefit for caching the base descriptor is low;
* the real benefit would be in treating the final (specialized) method handle as a constant

To do the latter, given we can't use stable fields, the only way to get there is to use a record. So, if we care about maximum performance, we should use a record. If we don't care, an interface is fine. In both cases, I don't think there's much to gain in having an extra holder class here.

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

PR Review Comment: https://git.openjdk.org/jextract/pull/149#discussion_r1412153856


More information about the jextract-dev mailing list