Missing folding in foreign.abi?
Jorn Vernee
jorn.vernee at oracle.com
Wed Nov 19 21:38:13 UTC 2025
Maurizio is right. We only use this information once to generate a
machine code stub and wrapper class, so there's no need for these things
to be constant foldable, as they are not used on the hot path of a
down/upcall
You seem to be looking at the code for the binding interpreter.
UpcallLinker.InvocationData is only used in there. This is basically the
'debug mode' for running the bindings, which doesn't have to be fast.
I did some experiments in the past where I tried to make the interpreter
as fast as the class generation strategy. I don't remember the details,
but the conclusion at the time was that the interpreted strategy
couldn't be made as fast at the class generation strategy that we use now.
Jorn
On 19-11-2025 21:18, Maurizio Cimadamore wrote:
> Hi Ryan,
> I believe constant folding of the data structures we need to compute
> calling sequences is probably not going to matter -- because those
> data structures are only going to be used to _build_ the downcall
> method handles.
>
> Once they are built, I believe no complex access should occur. I'm
> sure Jorn can expand on this more.
>
> That said, thanks for bringing this up -- it is always possible we
> missed something!
>
> Cheers
> Maurizio
>
> On 19/11/2025 18:37, Ryan Hallock wrote:
>> I was reviewing the recent changes in ciField.cpp and noticed that
>> `jdk.internal.foreign.abi` is not included among the special cases
>> for final fields. Is this intentional? My assumption was that you
>> would want all folding possible.
>>
>> I also observed that some structures such as the HashMap stored in
>> UpcallLinker.InvocationData and others like CallingSequence are using
>> mutable collections rather than immutable ones. Similarly, classes
>> such as ABIDescriptor don’t appear to apply the `@Stable` annotation
>> to their arrays, though it might require more constructs because I
>> don't believe Stable is recursive.
>>
>> I’m hoping this is simply an oversight and can be resolved.
>>
>> Cheers,
>> Ryan
More information about the panama-dev
mailing list