[foreign-preview] RFR: 8281595: ASM-ify scope acquire/release for down call parameters [v2]
Jorn Vernee
jvernee at openjdk.java.net
Tue Feb 15 15:01:18 UTC 2022
On Tue, 15 Feb 2022 14:39:22 GMT, Jorn Vernee <jvernee at openjdk.org> wrote:
>> src/java.base/share/classes/jdk/internal/foreign/abi/BindingSpecializer.java line 486:
>>
>>> 484:
>>> 485: private void emitReleaseScopes() {
>>> 486: for (int scopeLocal : scopeSlots) {
>>
>> Isn't this emitting more code than required? E.g. if we pass 10 primitives, we will emit 10 scope checks at the end of the adapter? Granted, since all these locals contain "null", there's no correctness issue here - but it is odd to (i) have a local for a scope corresponding to a primitive type (even though we know we never need it) and have extra logic in the preamble/postamble because of it.
>
> There is only a scope slot local for Addressable and NativeSymbol parameters. Not for primitives. See the logic that initializes `scopeSlots`:
>
>
> scopeSlots = Arrays.copyOf(scopeSlots, numScopes); // fit to size
>
>
> (the array is the size of the parameter list initially, but is adjusted downwards. Maybe that should be made clearer...)
I've tried to clarify the code that creates `scopeSlots` a bit by using a local variable for the intermediate array, instead of storing it in the field.
-------------
PR: https://git.openjdk.java.net/panama-foreign/pull/640
More information about the panama-dev
mailing list