RFR: 7903878: jextract should derive struct field offsets from struct layouts
Maurizio Cimadamore
mcimadamore at openjdk.org
Mon Dec 9 11:55:53 UTC 2024
On Fri, 6 Dec 2024 23:03:47 GMT, Nizar Benalla <nbenalla at openjdk.org> wrote:
> Please read the JBS issue for more details.
>
> Currently jextract emits hardwired offsets, it would be better if the offsets could be computed dynamically from the struct layouts.
>
> Passes all tests, unsure if this patch requires new tests.
> Note: I used `fieldElementPaths(field.name())))` instead of the `javaName` to deal with nested structs.
>
>
> It seems like GitHub actions are broken for Ubuntu? will look into this next week if necessary.
Looks good. In principle we could save the construction of `fieldElementPaths`, as we use that both in the offset and in the layout accessor (e.g. `emitOffsetFieldDecl` and `emitLayoutFieldDecl`) but I'm not sure how much that matters in practice, as I'd expect most layout paths to be a simple call to `groupElement(String)`.
-------------
Marked as reviewed by mcimadamore (Reviewer).
PR Review: https://git.openjdk.org/jextract/pull/262#pullrequestreview-2488573097
More information about the jextract-dev
mailing list