Integrated: 7903587: Revisit inlining of struct layouts into other layouts/descriptors

Maurizio Cimadamore mcimadamore at openjdk.org
Tue Dec 12 23:39:18 UTC 2023


On Tue, 12 Dec 2023 11:39:44 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:

> 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)

This pull request has now been integrated.

Changeset: 120b9bb7
Author:    Maurizio Cimadamore <mcimadamore at openjdk.org>
URL:       https://git.openjdk.org/jextract/commit/120b9bb701189c03f2b172f8bdf60703dc33bbb1
Stats:     721 lines in 19 files changed: 210 ins; 456 del; 55 mod

7903587: Revisit inlining of struct layouts into other layouts/descriptors

Reviewed-by: jvernee

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

PR: https://git.openjdk.org/jextract/pull/157


More information about the jextract-dev mailing list