RFR: 7903586: Revisit jextract constant classes [v3]
Maurizio Cimadamore
mcimadamore at openjdk.org
Wed Nov 29 12:07:55 UTC 2023
> This PR removes the use of jextract constant classes, and falls back to a simpler code generation strategies which move the various constants closer to where they belong:
>
> * for structs and callbacks, the constants are added to the class/interface being generated;
> * for the header class, we use a local holder class per function to hold the method handle and function descriptor constants.
>
> This scheme results in much less generated code (as no constant class is emitted), but with the same performance and laziness as the old scheme.
>
> When working with the code, I've decided to simplify the handling of constant generation, in the spirit of what was recently done with the introduction of string templates. That is, instead of using a magic `Constant` class, which has methods to generate getters/setters for a given constant, I converted much of the code into "static" string templates, so that it's easier to see which code gets generated when staring at the jextract code. As a result, the `Constant` class has been removed.
Maurizio Cimadamore has updated the pull request incrementally with one additional commit since the last revision:
Reuse layoutString in `emitGlobalSegment`
-------------
Changes:
- all: https://git.openjdk.org/jextract/pull/145/files
- new: https://git.openjdk.org/jextract/pull/145/files/71e72f85..d08045c1
Webrevs:
- full: https://webrevs.openjdk.org/?repo=jextract&pr=145&range=02
- incr: https://webrevs.openjdk.org/?repo=jextract&pr=145&range=01-02
Stats: 6 lines in 2 files changed: 0 ins; 2 del; 4 mod
Patch: https://git.openjdk.org/jextract/pull/145.diff
Fetch: git fetch https://git.openjdk.org/jextract.git pull/145/head:pull/145
PR: https://git.openjdk.org/jextract/pull/145
More information about the jextract-dev
mailing list