[foreign-jextract] RFR: 8262198: Overhaul bitfield parsing logic

Jorn Vernee jvernee at openjdk.java.net
Tue Feb 23 18:09:51 UTC 2021


On Tue, 23 Feb 2021 18:02:40 GMT, Jorn Vernee <jvernee at openjdk.org> wrote:

>> My understanding is that bitfields in union are just disjoint. If you want them to be adjacent, then you need to put them inside a struct.
>> 
>> https://godbolt.org/z/nGoe38
>
> I guess that's what I'm saying. The patch seems to be collecting all the bitfields at once and then emitting a struct layout that holds them right? But, since in a union bitfields overlap, it seems that by putting them adjacent in a struct like this has the potential to create a layout that is larger then the actual expected size.

Ah, never mind. I see you are only collecting all the bitfields in the Struct case, but in the union case are just emitting a Struct layout with a single bitfield inside, more like:

union Foo {
    int x;
    struct {
        int bitfield1: 24;
    }
    struct {
        int bitfield2: 24;
    }
};

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

PR: https://git.openjdk.java.net/panama-foreign/pull/459


More information about the panama-dev mailing list