RFR: 7903984: Inline upcallHandle method to reduce shared code across multiple generations

Maurizio Cimadamore mcimadamore at openjdk.org
Fri Mar 28 18:11:20 UTC 2025


On Fri, 28 Mar 2025 14:05:23 GMT, Nizar Benalla <nbenalla at openjdk.org> wrote:

> Please review this patch to inline the upcallHandle method, reducing the amount of shared items across multiple jextract generations.
> 
> Edit: all tests pass in CI, GitHub failure is unrelated 
> 
> TIA

Looks good. Let's also hear from @JornVernee

(when looking at some generated code I also noted that the functional interface code already has a try/catch block in the `invoke` method).

I guess the unfortunate issue here is that the use is from a static initializer - which means we either need to put the logic in a method (as you have done) or use a static initializer. So we pay a bit more than just for the single try/catch block.

One thing I noticed is that `ConstantBootstraps` has bootstraps to make field var handles (static and non-static) as well as array element var handles. I wonder if we should double down on those and add a way to create direct method handles too... these methods don't throw checked exception, so they are more amenable to generated code like this.

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

Marked as reviewed by mcimadamore (Reviewer).

PR Review: https://git.openjdk.org/jextract/pull/279#pullrequestreview-2726320459


More information about the jextract-dev mailing list