From duke at openjdk.org Thu Apr 3 12:35:15 2025 From: duke at openjdk.org (duke) Date: Thu, 3 Apr 2025 12:35:15 GMT Subject: RFR: 7903983: Remove redundant findOrThrow method In-Reply-To: References: Message-ID: <-ZvbvkUJOWmB2oUT8uK2cUyA26KufauMy5gmRYlqRzc=.bc3e79c8-06e0-4cbd-a77e-1720192dc5fa@github.com> On Fri, 28 Mar 2025 14:11:26 GMT, Nizar Benalla wrote: > `SymbolLookup::FindOrThrow` was introduced in JDK 23, making this method in the generated code redundant: > > static MemorySegment findOrThrow(String symbol) { > return SYMBOL_LOOKUP.findOrThrow(symbol); > } > > The generated method should have been dropped in https://github.com/openjdk/jextract/commit/a53f5c05e3ee2cca057cadb78b2e381c39f943d7 but I didn't cleanup all uses of it. > > A small additional cleanup in PR is that the newly added option for framworks now uses `--` rather than `-` > > Edit: all tests pass in CI on all platforms, GitHub failure is unrelated > > TIA @nizarbenalla Your change (at version ff9b31ba4df650331a9663b6a21c84571eddf060) is now ready to be sponsored by a Committer. ------------- PR Comment: https://git.openjdk.org/jextract/pull/280#issuecomment-2775641105 From nbenalla at openjdk.org Thu Apr 3 15:03:14 2025 From: nbenalla at openjdk.org (Nizar Benalla) Date: Thu, 3 Apr 2025 15:03:14 GMT Subject: Integrated: 7903983: Remove redundant findOrThrow method In-Reply-To: References: Message-ID: On Fri, 28 Mar 2025 14:11:26 GMT, Nizar Benalla wrote: > `SymbolLookup::FindOrThrow` was introduced in JDK 23, making this method in the generated code redundant: > > static MemorySegment findOrThrow(String symbol) { > return SYMBOL_LOOKUP.findOrThrow(symbol); > } > > The generated method should have been dropped in https://github.com/openjdk/jextract/commit/a53f5c05e3ee2cca057cadb78b2e381c39f943d7 but I didn't cleanup all uses of it. > > A small additional cleanup in PR is that the newly added option for framworks now uses `--` rather than `-` > > Edit: all tests pass in CI on all platforms, GitHub failure is unrelated > > TIA This pull request has now been integrated. Changeset: 3fe6e4ea Author: Nizar Benalla Committer: Maurizio Cimadamore URL: https://git.openjdk.org/jextract/commit/3fe6e4ea9480aa0489407ddd215cdf2a4c9f2430 Stats: 27 lines in 5 files changed: 3 ins; 4 del; 20 mod 7903983: Remove redundant findOrThrow method Reviewed-by: mcimadamore ------------- PR: https://git.openjdk.org/jextract/pull/280 From nbenalla at openjdk.org Fri Apr 4 15:26:40 2025 From: nbenalla at openjdk.org (Nizar Benalla) Date: Fri, 4 Apr 2025 15:26:40 GMT Subject: RFR: 7903984: Inline upcallHandle method to reduce shared code across multiple generations [v2] In-Reply-To: References: Message-ID: > 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 Nizar Benalla has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains three commits: - Merge branch 'master' into inline-upcallhandle # Conflicts: # src/main/java/org/openjdk/jextract/impl/HeaderFileBuilder.java - remove whitespace - inline method ------------- Changes: https://git.openjdk.org/jextract/pull/279/files Webrev: https://webrevs.openjdk.org/?repo=jextract&pr=279&range=01 Stats: 18 lines in 2 files changed: 8 ins; 8 del; 2 mod Patch: https://git.openjdk.org/jextract/pull/279.diff Fetch: git fetch https://git.openjdk.org/jextract.git pull/279/head:pull/279 PR: https://git.openjdk.org/jextract/pull/279 From nbenalla at openjdk.org Fri Apr 4 15:26:41 2025 From: nbenalla at openjdk.org (Nizar Benalla) Date: Fri, 4 Apr 2025 15:26:41 GMT Subject: RFR: 7903984: Inline upcallHandle method to reduce shared code across multiple generations In-Reply-To: References: Message-ID: On Fri, 28 Mar 2025 14:05:23 GMT, Nizar Benalla 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 Pushed a new commit to resolve merge conflict. ------------- PR Comment: https://git.openjdk.org/jextract/pull/279#issuecomment-2779068969 From jvernee at openjdk.org Fri Apr 4 16:09:12 2025 From: jvernee at openjdk.org (Jorn Vernee) Date: Fri, 4 Apr 2025 16:09:12 GMT Subject: RFR: 7903984: Inline upcallHandle method to reduce shared code across multiple generations [v2] In-Reply-To: References: Message-ID: On Fri, 4 Apr 2025 15:26:40 GMT, Nizar Benalla 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 > > Nizar Benalla has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains three commits: > > - Merge branch 'master' into inline-upcallhandle > > # Conflicts: > # src/main/java/org/openjdk/jextract/impl/HeaderFileBuilder.java > - remove whitespace > - inline method Looks good. To repeat some of the offline discussion: I don't think `ConstantBootstraps` is the right class to add a helper, since that class contains runtime support methods for implementing dynamic constants. However, if you wanted a MethodHandle constant, you could just use a `CONSTANT_MethodHandle_info` instead. I think if we added a more general API, there would also be a need to support ref kinds (not just invokevirtual). src/main/java/org/openjdk/jextract/impl/FunctionalInterfaceBuilder.java line 94: > 92: } > 93: > 94: private static final MethodHandle UP$MH = upcallHandle(%2$s.%3$s.class, "apply", $DESC); Maybe you can inline the arguments into the implementation, since they seem to be constant? Suggestion: static MethodHandle upcallHandle() { try { return MethodHandles.lookup().findVirtual(%2$s.%3$s.class, "apply", $DESC.toMethodType()); } catch (ReflectiveOperationException ex) { throw new AssertionError(ex); } } private static final MethodHandle UP$MH = upcallHandle(); ------------- Marked as reviewed by jvernee (Committer). PR Review: https://git.openjdk.org/jextract/pull/279#pullrequestreview-2743523594 PR Review Comment: https://git.openjdk.org/jextract/pull/279#discussion_r2029086110 From nbenalla at openjdk.org Fri Apr 4 16:44:40 2025 From: nbenalla at openjdk.org (Nizar Benalla) Date: Fri, 4 Apr 2025 16:44:40 GMT Subject: RFR: 7903984: Inline upcallHandle method to reduce shared code across multiple generations [v3] In-Reply-To: References: Message-ID: > 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 Nizar Benalla has updated the pull request incrementally with one additional commit since the last revision: inline values fi, name, fdesc ------------- Changes: - all: https://git.openjdk.org/jextract/pull/279/files - new: https://git.openjdk.org/jextract/pull/279/files/273f5f22..fc8c1471 Webrevs: - full: https://webrevs.openjdk.org/?repo=jextract&pr=279&range=02 - incr: https://webrevs.openjdk.org/?repo=jextract&pr=279&range=01-02 Stats: 3 lines in 1 file changed: 0 ins; 0 del; 3 mod Patch: https://git.openjdk.org/jextract/pull/279.diff Fetch: git fetch https://git.openjdk.org/jextract.git pull/279/head:pull/279 PR: https://git.openjdk.org/jextract/pull/279 From nbenalla at openjdk.org Fri Apr 11 08:39:28 2025 From: nbenalla at openjdk.org (Nizar Benalla) Date: Fri, 11 Apr 2025 08:39:28 GMT Subject: RFR: 7903984: Inline upcallHandle method to reduce shared code across multiple generations [v4] In-Reply-To: References: Message-ID: > 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 Nizar Benalla has updated the pull request incrementally with one additional commit since the last revision: make utility classes final with a private constructor ------------- Changes: - all: https://git.openjdk.org/jextract/pull/279/files - new: https://git.openjdk.org/jextract/pull/279/files/fc8c1471..3f2d95e7 Webrevs: - full: https://webrevs.openjdk.org/?repo=jextract&pr=279&range=03 - incr: https://webrevs.openjdk.org/?repo=jextract&pr=279&range=02-03 Stats: 24 lines in 3 files changed: 18 ins; 0 del; 6 mod Patch: https://git.openjdk.org/jextract/pull/279.diff Fetch: git fetch https://git.openjdk.org/jextract.git pull/279/head:pull/279 PR: https://git.openjdk.org/jextract/pull/279 From nbenalla at openjdk.org Fri Apr 11 08:42:47 2025 From: nbenalla at openjdk.org (Nizar Benalla) Date: Fri, 11 Apr 2025 08:42:47 GMT Subject: RFR: 7903984: Inline upcallHandle method to reduce shared code across multiple generations [v4] In-Reply-To: References: Message-ID: On Fri, 11 Apr 2025 08:39:28 GMT, Nizar Benalla 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 > > Nizar Benalla has updated the pull request incrementally with one additional commit since the last revision: > > make utility classes final with a private constructor Based on some offline discussions, I made the function classes final with a private constructor. ------------- PR Comment: https://git.openjdk.org/jextract/pull/279#issuecomment-2796241055 From nbenalla at openjdk.org Fri Apr 11 09:52:44 2025 From: nbenalla at openjdk.org (Nizar Benalla) Date: Fri, 11 Apr 2025 09:52:44 GMT Subject: Withdrawn: 7903984: Inline upcallHandle method to reduce shared code across multiple generations In-Reply-To: References: Message-ID: <9RANaWqbNZDFZ75HWe7n5lOUVyZraRCOAtrrIC2mvlw=.446f7167-eae5-426c-bdb5-1981109eefba@github.com> On Fri, 28 Mar 2025 14:05:23 GMT, Nizar Benalla 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 This pull request has been closed without being integrated. ------------- PR: https://git.openjdk.org/jextract/pull/279 From nbenalla at openjdk.org Wed Apr 16 19:34:37 2025 From: nbenalla at openjdk.org (Nizar Benalla) Date: Wed, 16 Apr 2025 19:34:37 GMT Subject: RFR: 7903933: Move sharable items from different generations to a common file [v5] In-Reply-To: References: Message-ID: <4-1CsJZ1tr61SHItRZS97xRituIRsX_ON4AI9XeRvDg=.2f108f8f-1dea-4a5a-a59d-e6e169b7e5cd@github.com> > Please review this patch to move the `C_*` layouts and the static utility methods into separate classes: `LayoutUtils.java` and `FFMUtils.java`, respectively. > > - The names could later be personalized through a JSON configuration. > - We can use static imports if the `-t` option is no used and the files are generated into the default package, in that case we use the classname to call the static methods or use the `C_*` constants. > > Some tests had to be modified slightly, either by adding new static imports or replacing classnames. Nizar Benalla has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains eight commits: - - Move shared symbols to a different class - Add option to override the name of the shared symbol class - Merge branch 'master' into shareable-items - Merge branch 'master' into shareable-items - add new option to create a sharable utility class cleanup: longer cmd option `framework` should use -- rather than - small other cleanups - Merge branch 'master' into shareable-items - Revert all changes - starting over from scratch - replace hardcoded strings I missed - move sharable items to a common class ------------- Changes: https://git.openjdk.org/jextract/pull/278/files Webrev: https://webrevs.openjdk.org/?repo=jextract&pr=278&range=04 Stats: 155 lines in 10 files changed: 107 ins; 19 del; 29 mod Patch: https://git.openjdk.org/jextract/pull/278.diff Fetch: git fetch https://git.openjdk.org/jextract.git pull/278/head:pull/278 PR: https://git.openjdk.org/jextract/pull/278 From nbenalla at openjdk.org Wed Apr 16 19:37:52 2025 From: nbenalla at openjdk.org (Nizar Benalla) Date: Wed, 16 Apr 2025 19:37:52 GMT Subject: RFR: 7903933: Move sharable items from different generations to a common file [v5] In-Reply-To: <4-1CsJZ1tr61SHItRZS97xRituIRsX_ON4AI9XeRvDg=.2f108f8f-1dea-4a5a-a59d-e6e169b7e5cd@github.com> References: <4-1CsJZ1tr61SHItRZS97xRituIRsX_ON4AI9XeRvDg=.2f108f8f-1dea-4a5a-a59d-e6e169b7e5cd@github.com> Message-ID: On Wed, 16 Apr 2025 19:34:37 GMT, Nizar Benalla wrote: >> Please review this patch to move the `C_*` layouts and the static utility methods into separate classes: `LayoutUtils.java` and `FFMUtils.java`, respectively. >> >> - The names could later be personalized through a JSON configuration. >> - We can use static imports if the `-t` option is no used and the files are generated into the default package, in that case we use the classname to call the static methods or use the `C_*` constants. >> >> Some tests had to be modified slightly, either by adding new static imports or replacing classnames. > > Nizar Benalla has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains eight commits: > > - - Move shared symbols to a different class > - Add option to override the name of the shared symbol class > - Merge branch 'master' into shareable-items > - Merge branch 'master' into shareable-items > - add new option to create a sharable utility class > > cleanup: longer cmd option `framework` should use -- rather than - > > small other cleanups > - Merge branch 'master' into shareable-items > - Revert all changes - starting over from scratch > - replace hardcoded strings I missed > - move sharable items to a common class I've moved the shared symbols to a different class `foo_h$shared` that all headers extend from. The new command line option was renamed to `--shared-symbols`to allow users to specify the name of the class if they want to. ------------- PR Comment: https://git.openjdk.org/jextract/pull/278#issuecomment-2810569983 From nbenalla at openjdk.org Fri Apr 18 15:35:08 2025 From: nbenalla at openjdk.org (Nizar Benalla) Date: Fri, 18 Apr 2025 15:35:08 GMT Subject: RFR: 7903933: Move sharable items from different generations to a common file [v6] In-Reply-To: References: Message-ID: > Please review this patch to move the `C_*` layouts and the static utility methods into separate classes: `LayoutUtils.java` and `FFMUtils.java`, respectively. > > - The names could later be personalized through a JSON configuration. > - We can use static imports if the `-t` option is no used and the files are generated into the default package, in that case we use the classname to call the static methods or use the `C_*` constants. > > Some tests had to be modified slightly, either by adding new static imports or replacing classnames. Nizar Benalla has updated the pull request incrementally with one additional commit since the last revision: make utility classes final with a private constructor ------------- Changes: - all: https://git.openjdk.org/jextract/pull/278/files - new: https://git.openjdk.org/jextract/pull/278/files/01c8205f..532ee1a6 Webrevs: - full: https://webrevs.openjdk.org/?repo=jextract&pr=278&range=05 - incr: https://webrevs.openjdk.org/?repo=jextract&pr=278&range=04-05 Stats: 24 lines in 3 files changed: 18 ins; 0 del; 6 mod Patch: https://git.openjdk.org/jextract/pull/278.diff Fetch: git fetch https://git.openjdk.org/jextract.git pull/278/head:pull/278 PR: https://git.openjdk.org/jextract/pull/278