[foreign-jextract] RFR 8237809: Use platform independent layout constants in jextract generated code
sundararajan.athijegannathan at oracle.com
sundararajan.athijegannathan at oracle.com
Mon Jan 27 09:20:51 UTC 2020
I had an offline discussion on this with Maurizio.
The current use of C language layout constants in jextract template code
(which will be part of jextracted code) is nothing specific to platform
as such. Varargs handling is the current use-case where we just need to
distinguish ints, floats and pointers (all 64-bit). We have a
preexisting bug - we've need to use C_LONGLONG instead of C_LONG for
ints [Windows 64 bit "long long"]. So it is okay to use platform
independent layout constants for *this use case*. But for possible use
of C language memory layout constants elsewhere (future-proof), it is
better to generate platform specific constants.
I've filed: https://bugs.openjdk.java.net/browse/JDK-8237870 and I'll
send RFR shortly.
-Sundar
On 24/01/20 4:59 pm, Jorn Vernee wrote:
> Ah yes, sorry. I got tripped up by the fact that this is not code
> used by jextract itself, but is included in the generated bindings.
> And, there was some discussion earlier about changing this out for
> using platform independent constant:
> https://mail.openjdk.java.net/pipermail/panama-dev/2020-January/007210.html
>
> We had some offline discussion about this as well. One argument for
> not using constants that get selected at runtime in the generated
> bindings, is that we don't know what the right selection strategy is.
> e.g. we can select the native ABI's 'char' layout on each platform,
> but maybe the native library is expecting 'char' on one platform, and
> 'int' on another (for instance due to compiler switches). So, probably
> better to generate bindings that use constants of the platform
> jextract runs on by default, and leave it up to users to manually
> implement a strategy for selecting the layouts based on the runtime
> platform.
>
> Jorn
>
> On 24/01/2020 12:17, Maurizio Cimadamore wrote:
>> Uhm - no :-)
>>
>> If I'm reading correctly, this patch will make jextract use platform
>> independent layout - which is not correct, as jextract should always
>> use the layouts which are valid for the platform in which the
>> extraction is being ran.
>>
>> Maurizio
>>
>>
>> On 24/01/2020 10:14, Jorn Vernee wrote:
>>> Looks good.
>>>
>>> Jorn
>>>
>>> On 24/01/2020 08:38, sundararajan.athijegannathan at oracle.com wrote:
>>>> Please review.
>>>>
>>>> Bug: https://bugs.openjdk.java.net/browse/JDK-8237809
>>>>
>>>> Webrev: http://cr.openjdk.java.net/~sundar/8237809/webrev.00/
>>>>
>>>> Thanks
>>>>
>>>> -Sundar
>>>>
More information about the panama-dev
mailing list