RFR: 7903587: Revisit inlining of struct layouts into other layouts/descriptors [v4]
Maurizio Cimadamore
mcimadamore at openjdk.org
Tue Dec 12 18:01:58 UTC 2023
> This PR completes the sequence of changes that I've been working on, by allowing layout and descriptor strings to be generated directly from jextract types. This allows for generated layouts to respect the "structure" found in the corresponding C header. Consider this case:
>
>
> struct Point {
> int x;
> int y;
> };
>
> struct Rectangle {
> struct Point topLeft;
> struct Point bottomRight;
> };
>
>
> With the changes in this PR, the generate layout for `Rectangle` becomes:
>
>
> private static final MemoryLayout $LAYOUT = MemoryLayout.structLayout(
> Point.$LAYOUT().withName("topLeft"),
> Point.$LAYOUT().withName("bottomRight")
> ).withName("Rectangle");
>
>
> Note how the layout for `Point` is no longer inlined, but instead is referred to "by name".
>
> The patch is quite straightforward, and aims at replacing the functions Declaration/Type.layoutFor/descriptorFor with new functions (now in the builder hierarchy) which generate layout and descriptor strings from the corresponding jextract types.
>
> Note: this patch introduces some additional issues when it comes with static initializer circularities. These issues will be dealt with in a separate change (since we have started accumulating some of these since https://git.openjdk.org/jextract/pull/145)
Maurizio Cimadamore has updated the pull request incrementally with one additional commit since the last revision:
Address review comments
-------------
Changes:
- all: https://git.openjdk.org/jextract/pull/157/files
- new: https://git.openjdk.org/jextract/pull/157/files/679d8c2c..b3ae0c9b
Webrevs:
- full: https://webrevs.openjdk.org/?repo=jextract&pr=157&range=03
- incr: https://webrevs.openjdk.org/?repo=jextract&pr=157&range=02-03
Stats: 28 lines in 4 files changed: 7 ins; 19 del; 2 mod
Patch: https://git.openjdk.org/jextract/pull/157.diff
Fetch: git fetch https://git.openjdk.org/jextract.git pull/157/head:pull/157
PR: https://git.openjdk.org/jextract/pull/157
More information about the jextract-dev
mailing list