RFR: Simplify jextract backend pipeline [v4]
Maurizio Cimadamore
mcimadamore at openjdk.org
Fri Dec 1 13:12:04 UTC 2023
> Now that we have mutable attributes, we can make the jextract pipeline a little simpler, by making sure that each step in the jextract pipeline doesn't destroy the information contained in the jextract model and, additionally, by making sure that each step can only add attributes to the IR (which are acted upon later on).
>
> To do this, I had to do some foundational changes to TreeMaker, to make sure that all declaration nodes were being correctly de-duplicated: since declarations are referenced back by types, if a declaration is re-created multiple times, the types pointing to that declaration end up being out of sync, and that's not desirable (because that could lead to a loss of some of the attributes).
>
> I also removed the `Transformer` interface: altering the model is not something the jextract pipeline should attempt to do. This meant that existing transformers have been reimplemented as side-effecting visitors, as follows:
>
> * `EnumConstantLifter` adds an attribute to constants which belong to an enum (but no longer drops the enum on the ground);
> * `IncludeFilter` marks several declaration with a `Skip` attribute, to signal `outputFactory` not to generate any code for them;
> * `DuplicateFilter` also uses the `Skip` attribute to drop redundant declarations.
>
> Additionally, the `NameMangler` has been simplified quite a bit, to the point that now it is just a simple visitor which ends up attaching attributes to declarations (`JavaName`, `JavaParameterNames`, `JavaFunctionalInterfaceName`). These attributes are later inspected (from `OutputFactory`). Since now the attribute is added directly to the relevant declaration, there is no need to have complex keying logic inside `NameMangler`.
Maurizio Cimadamore has updated the pull request incrementally with one additional commit since the last revision:
Simplify OutputFactory.Builder interface
-------------
Changes:
- all: https://git.openjdk.org/jextract/pull/148/files
- new: https://git.openjdk.org/jextract/pull/148/files/e81674ee..71297e92
Webrevs:
- full: https://webrevs.openjdk.org/?repo=jextract&pr=148&range=03
- incr: https://webrevs.openjdk.org/?repo=jextract&pr=148&range=02-03
Stats: 95 lines in 4 files changed: 16 ins; 28 del; 51 mod
Patch: https://git.openjdk.org/jextract/pull/148.diff
Fetch: git fetch https://git.openjdk.org/jextract.git pull/148/head:pull/148
PR: https://git.openjdk.org/jextract/pull/148
More information about the jextract-dev
mailing list