From asotona at openjdk.org Mon Dec 1 08:17:53 2025 From: asotona at openjdk.org (Adam Sotona) Date: Mon, 1 Dec 2025 08:17:53 GMT Subject: [code-reflection] RFR: BytecodeGenerator cleanup and switch support Message-ID: - `BytecodeGenerator` performs proprietary lowering transformation - `OpBuilder` and tests adjusted to do not lower before calling `BytecodeGenerator` - `BytecodeGenerator.ConstantLabelSwitchOp` is an internal lowered representation of `JavaOp.JavaSwitchOp` with constant labels, and it generates `tableswitch` or `lookupswitch` instruction - post-processing transformations are slightly refactored ------------- Commit messages: - switch operand fix - nit rename - imports reorder - imports reorder - tableswitch and lookupswitch generation - BytecodeGenerator.ConstantLabelSwitchOp work in progress - selective lowering in BytecodeGenerator - BytecodeGenerator cleanup Changes: https://git.openjdk.org/babylon/pull/706/files Webrev: https://webrevs.openjdk.org/?repo=babylon&pr=706&range=00 Stats: 315 lines in 15 files changed: 176 ins; 93 del; 46 mod Patch: https://git.openjdk.org/babylon/pull/706.diff Fetch: git fetch https://git.openjdk.org/babylon.git pull/706/head:pull/706 PR: https://git.openjdk.org/babylon/pull/706 From maurizio.cimadamore at oracle.com Mon Dec 1 10:12:38 2025 From: maurizio.cimadamore at oracle.com (Maurizio Cimadamore) Date: Mon, 1 Dec 2025 10:12:38 +0000 Subject: Where does the code model stored in the class file In-Reply-To: References: Message-ID: Hi Nadeesh, the translation strategy has morphed a little... now all the code models are generated into a separate static nested class -- in this case: build/hat-example-mandel-1.0.classes/mandel/Main$$CM.class We did this to limit the size of the generated code by sharing common code patterns among all the code models in a class (see https://git.openjdk.org/babylon/pull/679) Hope this helps Maurizio On 29/11/2025 00:26, nadeesh t v wrote: > Hello, > IIRC some of the talks, ?code models are stored in class files. But > when I have inspected the class file of one of the example > s?from > HAT using *javap*, I have not seen that in the class file. > > javap -c -v build/hat-example-mandel-1.0.classes/mandel/Main.class > > > Have I overlooked the class file or is it not in the class file? > > -- > Thanks and Regards, > Nadeesh TV > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From juan.fumero at oracle.com Mon Dec 1 10:23:06 2025 From: juan.fumero at oracle.com (Juan Jose Fumero Alfonso) Date: Mon, 1 Dec 2025 10:23:06 +0000 Subject: [External] : Re: Babylon building document correction In-Reply-To: References: Message-ID: Hi Nadeesh, Thank you. Feel free to open a PR. Juan From: nadeesh t v Date: Saturday, 29 November 2025 at 01:16 To: Juan Jose Fumero Alfonso Cc: babylon-dev at openjdk.org Subject: [External] : Re: Babylon building document correction Hello, Some minor corrections and improvements to the HAT building doc. On Fri, Nov 28, 2025 at 11:06?AM nadeesh t v > wrote: Thank you very much. -- Thanks and Regards, Nadeesh TV -------------- next part -------------- An HTML attachment was scrubbed... URL: From mcimadamore at openjdk.org Mon Dec 1 10:31:25 2025 From: mcimadamore at openjdk.org (Maurizio Cimadamore) Date: Mon, 1 Dec 2025 10:31:25 GMT Subject: [code-reflection] Integrated: Fix javadoc issues In-Reply-To: References: Message-ID: On Fri, 28 Nov 2025 12:46:11 GMT, Maurizio Cimadamore wrote: > This simple PR fixes some issues preventing `make docs` to complete normally. This pull request has now been integrated. Changeset: fa097e59 Author: Maurizio Cimadamore URL: https://git.openjdk.org/babylon/commit/fa097e590fc5bcbf74b75a123939cadad59b3ed3 Stats: 10 lines in 4 files changed: 2 ins; 2 del; 6 mod Fix javadoc issues Reviewed-by: psandoz ------------- PR: https://git.openjdk.org/babylon/pull/715 From mcimadamore at openjdk.org Mon Dec 1 10:32:21 2025 From: mcimadamore at openjdk.org (Maurizio Cimadamore) Date: Mon, 1 Dec 2025 10:32:21 GMT Subject: git: openjdk/babylon: code-reflection: 2 new changesets Message-ID: <98f27c59-aa33-4abc-af4f-834864f803d3@openjdk.org> Changeset: fa097e59 Branch: code-reflection Author: Maurizio Cimadamore Date: 2025-12-01 10:28:58 +0000 URL: https://git.openjdk.org/babylon/commit/fa097e590fc5bcbf74b75a123939cadad59b3ed3 Fix javadoc issues Reviewed-by: psandoz ! src/jdk.compiler/share/classes/module-info.java ! src/jdk.incubator.code/share/classes/jdk/incubator/code/dialect/java/FieldRef.java ! src/jdk.incubator.code/share/classes/jdk/incubator/code/dialect/java/MethodRef.java ! src/jdk.incubator.code/share/classes/jdk/incubator/code/interpreter/Interpreter.java Changeset: b07ea22c Branch: code-reflection Author: Maurizio Cimadamore Date: 2025-12-01 10:29:26 +0000 URL: https://git.openjdk.org/babylon/commit/b07ea22c6cac90defb932c39425461f9922eccb7 Remove minor unnecessary changes from main javac codebase Reviewed-by: psandoz ! src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symtab.java ! src/jdk.compiler/share/classes/com/sun/tools/javac/comp/LambdaToMethod.java ! src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeInfo.java ! src/jdk.incubator.code/share/classes/jdk/incubator/code/internal/CodeReflectionSymbols.java ! src/jdk.incubator.code/share/classes/jdk/incubator/code/internal/ReflectMethods.java From mcimadamore at openjdk.org Mon Dec 1 10:32:25 2025 From: mcimadamore at openjdk.org (Maurizio Cimadamore) Date: Mon, 1 Dec 2025 10:32:25 GMT Subject: [code-reflection] Integrated: Remove minor unnecessary changes from main javac codebase In-Reply-To: References: Message-ID: On Wed, 26 Nov 2025 18:36:24 GMT, Maurizio Cimadamore wrote: > This PR undoes some unnecessary changes to the javac code: > * `LambdaToMethod` still mentions the `QUOTABLE` flag, which is no longer in use > * `Symtab` has an helper method to load classes from a string name, but that's not really required > * `TreeInfo` defines a new helper function to detect `super` in an expression. Further analysis revealed this was unnecessary (as we can piggy back on the method reference kind instead) This pull request has now been integrated. Changeset: b07ea22c Author: Maurizio Cimadamore URL: https://git.openjdk.org/babylon/commit/b07ea22c6cac90defb932c39425461f9922eccb7 Stats: 45 lines in 5 files changed: 6 ins; 32 del; 7 mod Remove minor unnecessary changes from main javac codebase Reviewed-by: psandoz ------------- PR: https://git.openjdk.org/babylon/pull/711 From mcimadamore at openjdk.org Mon Dec 1 10:47:16 2025 From: mcimadamore at openjdk.org (Maurizio Cimadamore) Date: Mon, 1 Dec 2025 10:47:16 GMT Subject: [code-reflection] Integrated: Refactor code for computing denotable projection of types In-Reply-To: References: Message-ID: On Tue, 25 Nov 2025 19:07:45 GMT, Maurizio Cimadamore wrote: > The code reflection support needs a way to compute the closest fully denotable supertype of the type of an expression. To do this we build on [type projections](https://docs.oracle.com/javase/specs/jls/se25/html/jls-4.html#jls-4.10.5), but this doesn't work fully, because type projectios still allow intersection types in, and the `JavaType` API (or the `j.l.r.Type` API) doesn't have a way to model these. > > For this reason, we had to tweak the compiler code in `Types` to accept an extra parameter to tell the projection to also discard intersection/union types. While this works, this creates a lot of noise in the compiler codebase, so I've been looking for a lower-maintenance alternative. > > The basic idea behind this PR is to apply a normalization pass _before_ we compute a vanilla type projection. This normalization pass essentially replaces any intersection type with a fresh type variable whose bound is the first bound of the intersection. > > As an example, consider the type: `Foo`: > > 1. we first transform this type into `Foo<#1>` where `#1` is a fresh type-variable with upper bound `A` > 2. we then add `#1` to the list of type variables to be "projected" > 3. we then compute the upward projectin of `Foo<#1>`, and obtain `Foo`. > > This process is sound because (a) replacing `A & B & C` with a fresh type variable with bound `A & B & C` is sound, and because (b) upward projection will always map such type variables into some kind of wildcard (so dropping some bounds from the intersection doesn't make any difference) -- unless the type is a toplevel type, in which case, again dropping a bound doesn't make any difference. This pull request has now been integrated. Changeset: e458d3fe Author: Maurizio Cimadamore URL: https://git.openjdk.org/babylon/commit/e458d3fe74afcb15c65ce70119603b1dbe8c43e7 Stats: 334 lines in 3 files changed: 244 ins; 76 del; 14 mod Refactor code for computing denotable projection of types Reviewed-by: psandoz ------------- PR: https://git.openjdk.org/babylon/pull/707 From mcimadamore at openjdk.org Mon Dec 1 10:50:47 2025 From: mcimadamore at openjdk.org (Maurizio Cimadamore) Date: Mon, 1 Dec 2025 10:50:47 GMT Subject: git: openjdk/babylon: code-reflection: Refactor code for computing denotable projection of types Message-ID: Changeset: e458d3fe Branch: code-reflection Author: Maurizio Cimadamore Date: 2025-12-01 10:44:32 +0000 URL: https://git.openjdk.org/babylon/commit/e458d3fe74afcb15c65ce70119603b1dbe8c43e7 Refactor code for computing denotable projection of types Reviewed-by: psandoz ! src/jdk.compiler/share/classes/com/sun/tools/javac/code/Types.java ! src/jdk.incubator.code/share/classes/jdk/incubator/code/internal/ReflectMethods.java ! test/langtools/tools/javac/reflect/DenotableTypesTest.java From jfumero at openjdk.org Mon Dec 1 12:04:29 2025 From: jfumero at openjdk.org (Juan Fumero) Date: Mon, 1 Dec 2025 12:04:29 GMT Subject: [code-reflection] RFR: [hat] Cleanup F16 name impl Message-ID: <6jtPkUkLmb9aPfSmhmW7OMvlHcA5MD8Rgn92Uj7Ydms=.18276b1f-4fb0-4033-ba9e-005c13463d24@github.com> Cleanup F16 name impl ------------- Commit messages: - [hat] Cleanup F16 name impl Changes: https://git.openjdk.org/babylon/pull/717/files Webrev: https://webrevs.openjdk.org/?repo=babylon&pr=717&range=00 Stats: 4 lines in 2 files changed: 0 ins; 3 del; 1 mod Patch: https://git.openjdk.org/babylon/pull/717.diff Fetch: git fetch https://git.openjdk.org/babylon.git pull/717/head:pull/717 PR: https://git.openjdk.org/babylon/pull/717 From jfumero at openjdk.org Mon Dec 1 12:06:37 2025 From: jfumero at openjdk.org (Juan Fumero) Date: Mon, 1 Dec 2025 12:06:37 GMT Subject: git: openjdk/babylon: code-reflection: [hat] Cleanup F16 name impl Message-ID: <095cf68e-1ec2-4b63-ab47-ecf4e9813446@openjdk.org> Changeset: 8f3399d3 Branch: code-reflection Author: Juan Fumero Date: 2025-12-01 12:05:44 +0000 URL: https://git.openjdk.org/babylon/commit/8f3399d3959e15a6326dd7773138b848d4ac6153 [hat] Cleanup F16 name impl ! hat/core/src/main/java/hat/buffer/F16Array.java ! hat/core/src/main/java/hat/codebuilders/C99HATKernelBuilder.java From jfumero at openjdk.org Mon Dec 1 12:08:30 2025 From: jfumero at openjdk.org (Juan Fumero) Date: Mon, 1 Dec 2025 12:08:30 GMT Subject: [code-reflection] Integrated: [hat] Cleanup F16 name impl In-Reply-To: <6jtPkUkLmb9aPfSmhmW7OMvlHcA5MD8Rgn92Uj7Ydms=.18276b1f-4fb0-4033-ba9e-005c13463d24@github.com> References: <6jtPkUkLmb9aPfSmhmW7OMvlHcA5MD8Rgn92Uj7Ydms=.18276b1f-4fb0-4033-ba9e-005c13463d24@github.com> Message-ID: On Mon, 1 Dec 2025 11:58:43 GMT, Juan Fumero wrote: > Cleanup F16 name impl This pull request has now been integrated. Changeset: 8f3399d3 Author: Juan Fumero URL: https://git.openjdk.org/babylon/commit/8f3399d3959e15a6326dd7773138b848d4ac6153 Stats: 4 lines in 2 files changed: 0 ins; 3 del; 1 mod [hat] Cleanup F16 name impl ------------- PR: https://git.openjdk.org/babylon/pull/717 From gfrost at openjdk.org Mon Dec 1 15:30:03 2025 From: gfrost at openjdk.org (Gary Frost) Date: Mon, 1 Dec 2025 15:30:03 GMT Subject: git: openjdk/babylon: code-reflection: Make it easier to create simple schemas Message-ID: <2ac233c0-237d-4cee-887a-b36a5568a0aa@openjdk.org> Changeset: 15e442c8 Branch: code-reflection Author: Gary Frost Date: 2025-12-01 15:26:31 +0000 URL: https://git.openjdk.org/babylon/commit/15e442c8679ddae7cbb01611a7e860972a97ec0c Make it easier to create simple schemas = hat/core/src/main/java/hat/annotations/After.java = hat/core/src/main/java/hat/annotations/Align.java = hat/core/src/main/java/hat/annotations/Order.java = hat/core/src/main/java/hat/annotations/Pad.java = hat/core/src/main/java/hat/annotations/ProvidesDimFor.java ! hat/core/src/main/java/hat/buffer/ArgArray.java ! hat/core/src/main/java/hat/buffer/Buffer.java ! hat/core/src/main/java/hat/buffer/F32Array.java ! hat/core/src/main/java/hat/buffer/F32ArrayPadded.java - hat/core/src/main/java/hat/buffer/HATVector.java ! hat/core/src/main/java/hat/buffer/KernelBufferContext.java ! hat/core/src/main/java/hat/buffer/S32Array.java ! hat/core/src/main/java/hat/ifacemapper/Schema.java From gfrost at openjdk.org Mon Dec 1 15:30:26 2025 From: gfrost at openjdk.org (Gary Frost) Date: Mon, 1 Dec 2025 15:30:26 GMT Subject: [code-reflection] Integrated: Make it easier to create simple schemas Message-ID: An attempt to simplify the creation of simple schemas. We may be able to extend this approach (skipping the builder) to other more complex schemas later. ------------- Commit messages: - Make it easier to create simple schemas Changes: https://git.openjdk.org/babylon/pull/718/files Webrev: https://webrevs.openjdk.org/?repo=babylon&pr=718&range=00 Stats: 139 lines in 13 files changed: 56 ins; 54 del; 29 mod Patch: https://git.openjdk.org/babylon/pull/718.diff Fetch: git fetch https://git.openjdk.org/babylon.git pull/718/head:pull/718 PR: https://git.openjdk.org/babylon/pull/718 From gfrost at openjdk.org Mon Dec 1 15:30:26 2025 From: gfrost at openjdk.org (Gary Frost) Date: Mon, 1 Dec 2025 15:30:26 GMT Subject: [code-reflection] Integrated: Make it easier to create simple schemas In-Reply-To: References: Message-ID: <-PArnFzaR_9tm4TyEIT6g5EdCKAxp9u30NZr6PLihFs=.a25b2be9-69a4-443a-8117-03b5771fff3e@github.com> On Mon, 1 Dec 2025 15:23:32 GMT, Gary Frost wrote: > An attempt to simplify the creation of simple schemas. We may be able to extend this approach (skipping the builder) to other more complex schemas later. This pull request has now been integrated. Changeset: 15e442c8 Author: Gary Frost URL: https://git.openjdk.org/babylon/commit/15e442c8679ddae7cbb01611a7e860972a97ec0c Stats: 139 lines in 13 files changed: 56 ins; 54 del; 29 mod Make it easier to create simple schemas ------------- PR: https://git.openjdk.org/babylon/pull/718 From gfrost at openjdk.org Mon Dec 1 15:42:26 2025 From: gfrost at openjdk.org (Gary Frost) Date: Mon, 1 Dec 2025 15:42:26 GMT Subject: [code-reflection] Integrated: Replace string literals with class names with references to Class apis Message-ID: We had a few references to class names as String literals, I replaced with Class.getSimpleName() so that we can safely refactor code (rename classes). ------------- Commit messages: - Replace string literals with class names with references to Class apis Changes: https://git.openjdk.org/babylon/pull/719/files Webrev: https://webrevs.openjdk.org/?repo=babylon&pr=719&range=00 Stats: 7 lines in 3 files changed: 1 ins; 2 del; 4 mod Patch: https://git.openjdk.org/babylon/pull/719.diff Fetch: git fetch https://git.openjdk.org/babylon.git pull/719/head:pull/719 PR: https://git.openjdk.org/babylon/pull/719 From gfrost at openjdk.org Mon Dec 1 15:42:27 2025 From: gfrost at openjdk.org (Gary Frost) Date: Mon, 1 Dec 2025 15:42:27 GMT Subject: [code-reflection] Integrated: Replace string literals with class names with references to Class apis In-Reply-To: References: Message-ID: On Mon, 1 Dec 2025 15:35:22 GMT, Gary Frost wrote: > We had a few references to class names as String literals, I replaced with Class.getSimpleName() so that we can safely refactor code (rename classes). This pull request has now been integrated. Changeset: 76e4d3b7 Author: Gary Frost URL: https://git.openjdk.org/babylon/commit/76e4d3b785a1c63b536a93fcc4d70e6db7aba1eb Stats: 7 lines in 3 files changed: 1 ins; 2 del; 4 mod Replace string literals with class names with references to Class apis ------------- PR: https://git.openjdk.org/babylon/pull/719 From gfrost at openjdk.org Mon Dec 1 15:44:24 2025 From: gfrost at openjdk.org (Gary Frost) Date: Mon, 1 Dec 2025 15:44:24 GMT Subject: git: openjdk/babylon: code-reflection: Replace string literals with class names with references to Class apis Message-ID: <43105d2c-0acd-474e-9d0f-5774cff73db7@openjdk.org> Changeset: 76e4d3b7 Branch: code-reflection Author: Gary Frost Date: 2025-12-01 15:39:35 +0000 URL: https://git.openjdk.org/babylon/commit/76e4d3b785a1c63b536a93fcc4d70e6db7aba1eb Replace string literals with class names with references to Class apis ! hat/core/src/main/java/hat/buffer/F16.java ! hat/core/src/main/java/hat/codebuilders/C99HATKernelBuilder.java ! hat/core/src/main/java/hat/codebuilders/CodeBuilder.java From jfumero at openjdk.org Mon Dec 1 15:59:19 2025 From: jfumero at openjdk.org (Juan Fumero) Date: Mon, 1 Dec 2025 15:59:19 GMT Subject: [code-reflection] RFR: [hat] Proposal for bfloat16 Message-ID: This PR introduces the type [`bfloat16`](https://cloud.google.com/blog/products/ai-machine-learning/bfloat16-the-secret-to-high-performance-on-cloud-tpus) for HAT. Testing for OpenCL: HAT=SHOW_CODE java -cp hat/job.jar hat.java test ffi-opencl hat.test.TestBFloat16Type Testing for CUDA: HAT=SHOW_CODE java -cp hat/job.jar hat.java test ffi-cuda hat.test.TestBFloat16Type Some tests are expecting to fail due to precision error. We will need to improve the type conversion with round-to-nearest-even for example. ------------- Commit messages: - Merge branch 'code-reflection' into hat/type/bfloat16 - [hat] remove custom Op for bfloat - single line imports in hat code builders - single line imports in hat code builders - [hat] test matmul with bfloat16 - [hat] dialect for bfloat16 removed - [hat] new test file included in the hat test list - [hat] OpenCL handler for bfloat16 via float convs - Merge branch 'code-reflection' into hat/type/bfloat16 - [hat][wip] bfloat16 conversions for OpenCL - ... and 10 more: https://git.openjdk.org/babylon/compare/76e4d3b7...60f7140c Changes: https://git.openjdk.org/babylon/pull/716/files Webrev: https://webrevs.openjdk.org/?repo=babylon&pr=716&range=00 Stats: 1517 lines in 29 files changed: 1399 ins; 44 del; 74 mod Patch: https://git.openjdk.org/babylon/pull/716.diff Fetch: git fetch https://git.openjdk.org/babylon.git pull/716/head:pull/716 PR: https://git.openjdk.org/babylon/pull/716 From nadeeshtv at gmail.com Mon Dec 1 16:01:59 2025 From: nadeeshtv at gmail.com (nadeesh t v) Date: Mon, 1 Dec 2025 17:01:59 +0100 Subject: Where does the code model stored in the class file In-Reply-To: References: Message-ID: Thank you for the information. On Mon, 1 Dec 2025 at 11:12, Maurizio Cimadamore < maurizio.cimadamore at oracle.com> wrote: > Hi Nadeesh, > the translation strategy has morphed a little... now all the code models > are generated into a separate static nested class -- in this case: > build/hat-example-mandel-1.0.classes/mandel/Main$$CM.class > > We did this to limit the size of the generated code by sharing common code > patterns among all the code models in a class (see > https://git.openjdk.org/babylon/pull/679) > > Hope this helps > > > Maurizio > On 29/11/2025 00:26, nadeesh t v wrote: > > Hello, > IIRC some of the talks, code models are stored in class files. But when I > have inspected the class file of one of the example > s from > HAT using *javap*, I have not seen that in the class file. > > javap -c -v build/hat-example-mandel-1.0.classes/mandel/Main.class > > > Have I overlooked the class file or is it not in the class file? > -- > Thanks and Regards, > Nadeesh TV > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From asotona at openjdk.org Mon Dec 1 16:00:29 2025 From: asotona at openjdk.org (Adam Sotona) Date: Mon, 1 Dec 2025 16:00:29 GMT Subject: [code-reflection] RFR: BytecodeGenerator cleanup and switch support [v2] In-Reply-To: References: Message-ID: > The current `BytecodeGenerator` implementation assumes that code models have already been lowered before generation. Both `SwitchExpressionOp` and `SwitchStatementOp` with all-constant labels are examples of operations that can be lowered an alternative way, allowing `BytecodeGenerator` to produce more efficient bytecode using `tableswitch` and `lookupswitch` instructions. > > The proposed change shifts the responsibility for lowering these operations into the `BytecodeGenerator` itself, enabling selective lowering during bytecode generation. Consequently, `OpBuilder` and `BytecodeGenerator` tests have been updated to avoid invoking the lower transformation step before the `BytecodeGenerator` is called. > > A new internal operation, `BytecodeGenerator.ConstantLabelSwitchOp`, has been introduced. This acts as an intermediate representation for lowered `SwitchExpressionOp` and `SwitchStatementOp` instances with constant labels. Logic for detecting constant labels and transforming them into `BytecodeGenerator.ConstantLabelSwitchOp` will be introduced in a follow-up pull request. > > This PR also makes minor refinements to the BytecodeGenerator post-processing transformations. Adam Sotona has updated the pull request incrementally with two additional commits since the last revision: - added test - ConstantLabelSwitchOp refactored out to jdk.incubator.code.bytecode.impl package ------------- Changes: - all: https://git.openjdk.org/babylon/pull/706/files - new: https://git.openjdk.org/babylon/pull/706/files/d5c550cb..abff6609 Webrevs: - full: https://webrevs.openjdk.org/?repo=babylon&pr=706&range=01 - incr: https://webrevs.openjdk.org/?repo=babylon&pr=706&range=00-01 Stats: 250 lines in 3 files changed: 211 ins; 33 del; 6 mod Patch: https://git.openjdk.org/babylon/pull/706.diff Fetch: git fetch https://git.openjdk.org/babylon.git pull/706/head:pull/706 PR: https://git.openjdk.org/babylon/pull/706 From asotona at openjdk.org Mon Dec 1 16:35:40 2025 From: asotona at openjdk.org (Adam Sotona) Date: Mon, 1 Dec 2025 16:35:40 GMT Subject: [code-reflection] RFR: BytecodeGenerator cleanup and switch support [v3] In-Reply-To: References: Message-ID: > The current `BytecodeGenerator` implementation assumes that code models have already been lowered before generation. Both `SwitchExpressionOp` and `SwitchStatementOp` with all-constant labels are examples of operations that can be lowered an alternative way, allowing `BytecodeGenerator` to produce more efficient bytecode using `tableswitch` and `lookupswitch` instructions. > > The proposed change shifts the responsibility for lowering these operations into the `BytecodeGenerator` itself, enabling selective lowering during bytecode generation. Consequently, `OpBuilder` and `BytecodeGenerator` tests have been updated to avoid invoking the lower transformation step before the `BytecodeGenerator` is called. > > A new internal operation, `BytecodeGenerator.ConstantLabelSwitchOp`, has been introduced. This acts as an intermediate representation for lowered `SwitchExpressionOp` and `SwitchStatementOp` instances with constant labels. Logic for detecting constant labels and transforming them into `BytecodeGenerator.ConstantLabelSwitchOp` will be introduced in a follow-up pull request. > > This PR also makes minor refinements to the BytecodeGenerator post-processing transformations. Adam Sotona has updated the pull request incrementally with one additional commit since the last revision: added javadoc ------------- Changes: - all: https://git.openjdk.org/babylon/pull/706/files - new: https://git.openjdk.org/babylon/pull/706/files/abff6609..a2753cba Webrevs: - full: https://webrevs.openjdk.org/?repo=babylon&pr=706&range=02 - incr: https://webrevs.openjdk.org/?repo=babylon&pr=706&range=01-02 Stats: 10 lines in 1 file changed: 9 ins; 0 del; 1 mod Patch: https://git.openjdk.org/babylon/pull/706.diff Fetch: git fetch https://git.openjdk.org/babylon.git pull/706/head:pull/706 PR: https://git.openjdk.org/babylon/pull/706 From asotona at openjdk.org Mon Dec 1 16:40:00 2025 From: asotona at openjdk.org (Adam Sotona) Date: Mon, 1 Dec 2025 16:40:00 GMT Subject: [code-reflection] RFR: BytecodeGenerator cleanup and switch support [v4] In-Reply-To: References: Message-ID: > The current `BytecodeGenerator` implementation assumes that code models have already been lowered before generation. Both `SwitchExpressionOp` and `SwitchStatementOp` with all-constant labels are examples of operations that can be lowered an alternative way, allowing `BytecodeGenerator` to produce more efficient bytecode using `tableswitch` and `lookupswitch` instructions. > > The proposed change shifts the responsibility for lowering these operations into the `BytecodeGenerator` itself, enabling selective lowering during bytecode generation. Consequently, `OpBuilder` and `BytecodeGenerator` tests have been updated to avoid invoking the lower transformation step before the `BytecodeGenerator` is called. > > A new internal operation, `ConstantLabelSwitchOp`, has been introduced. This acts as an intermediate representation for lowered `SwitchExpressionOp` and `SwitchStatementOp` instances with constant labels. Logic for detecting constant labels and transforming them into `ConstantLabelSwitchOp` will be introduced in a follow-up pull request. > > This PR also makes minor refinements to the BytecodeGenerator post-processing transformations. Adam Sotona has updated the pull request incrementally with two additional commits since the last revision: - Merge remote-tracking branch 'asotona/bytecodegenerator-cleanup' into bytecodegenerator-cleanup - Lower JavaSwitchOp to ConstantLabelSwitchOp ------------- Changes: - all: https://git.openjdk.org/babylon/pull/706/files - new: https://git.openjdk.org/babylon/pull/706/files/a2753cba..98235aff Webrevs: - full: https://webrevs.openjdk.org/?repo=babylon&pr=706&range=03 - incr: https://webrevs.openjdk.org/?repo=babylon&pr=706&range=02-03 Stats: 517 lines in 4 files changed: 487 ins; 13 del; 17 mod Patch: https://git.openjdk.org/babylon/pull/706.diff Fetch: git fetch https://git.openjdk.org/babylon.git pull/706/head:pull/706 PR: https://git.openjdk.org/babylon/pull/706 From mabbay at openjdk.org Mon Dec 1 16:50:53 2025 From: mabbay at openjdk.org (Mourad Abbay) Date: Mon, 1 Dec 2025 16:50:53 GMT Subject: [code-reflection] RFR: Detect if a java switch is case constant [v2] In-Reply-To: References: <7uiQQC2YeiLsvzGX15uYO1Lltdn1mW1wqz17hq5vsko=.ef7c6cb8-7fc9-411e-984e-4a8938f4e726@github.com> Message-ID: On Fri, 28 Nov 2025 16:05:41 GMT, Mourad Abbay wrote: >> Add the logic to check if a switch op is case constant. > > Mourad Abbay has updated the pull request incrementally with one additional commit since the last revision: > > Change the logic to return true only when labels in bytecode matches labels in source code I pushed the changes directly to https://github.com/openjdk/babylon/pull/706. ------------- PR Comment: https://git.openjdk.org/babylon/pull/710#issuecomment-3597667208 From mabbay at openjdk.org Mon Dec 1 16:50:55 2025 From: mabbay at openjdk.org (Mourad Abbay) Date: Mon, 1 Dec 2025 16:50:55 GMT Subject: [code-reflection] Withdrawn: Detect if a java switch is case constant In-Reply-To: <7uiQQC2YeiLsvzGX15uYO1Lltdn1mW1wqz17hq5vsko=.ef7c6cb8-7fc9-411e-984e-4a8938f4e726@github.com> References: <7uiQQC2YeiLsvzGX15uYO1Lltdn1mW1wqz17hq5vsko=.ef7c6cb8-7fc9-411e-984e-4a8938f4e726@github.com> Message-ID: On Wed, 26 Nov 2025 09:20:29 GMT, Mourad Abbay wrote: > Add the logic to check if a switch op is case constant. This pull request has been closed without being integrated. ------------- PR: https://git.openjdk.org/babylon/pull/710 From asotona at openjdk.org Mon Dec 1 17:07:12 2025 From: asotona at openjdk.org (Adam Sotona) Date: Mon, 1 Dec 2025 17:07:12 GMT Subject: [code-reflection] RFR: BytecodeGenerator cleanup and switch support [v5] In-Reply-To: References: Message-ID: > The current `BytecodeGenerator` implementation assumes that code models have already been lowered before generation. Both `SwitchExpressionOp` and `SwitchStatementOp` with all-constant labels are examples of operations that can be lowered an alternative way, allowing `BytecodeGenerator` to produce more efficient bytecode using `tableswitch` and `lookupswitch` instructions. > > The proposed change shifts the responsibility for lowering these operations into the `BytecodeGenerator` itself, enabling selective lowering during bytecode generation. Consequently, `OpBuilder` and `BytecodeGenerator` tests have been updated to avoid invoking the lower transformation step before the `BytecodeGenerator` is called. > > A new internal operation, `ConstantLabelSwitchOp`, has been introduced. This acts as an intermediate representation for lowered `SwitchExpressionOp` and `SwitchStatementOp` instances with constant labels. > > Lowering of `SwitchExpressionOp` and `SwitchStatementOp` into `ConstantLabelSwitchOp` is also a part of this PR. > > This PR also makes minor refinements to the BytecodeGenerator post-processing transformations. Adam Sotona has updated the pull request incrementally with one additional commit since the last revision: test update ------------- Changes: - all: https://git.openjdk.org/babylon/pull/706/files - new: https://git.openjdk.org/babylon/pull/706/files/98235aff..b9a75e2c Webrevs: - full: https://webrevs.openjdk.org/?repo=babylon&pr=706&range=04 - incr: https://webrevs.openjdk.org/?repo=babylon&pr=706&range=03-04 Stats: 66 lines in 1 file changed: 11 ins; 50 del; 5 mod Patch: https://git.openjdk.org/babylon/pull/706.diff Fetch: git fetch https://git.openjdk.org/babylon.git pull/706/head:pull/706 PR: https://git.openjdk.org/babylon/pull/706 From psandoz at openjdk.org Mon Dec 1 17:07:13 2025 From: psandoz at openjdk.org (Paul Sandoz) Date: Mon, 1 Dec 2025 17:07:13 GMT Subject: [code-reflection] RFR: BytecodeGenerator cleanup and switch support [v5] In-Reply-To: References: Message-ID: On Mon, 1 Dec 2025 17:03:34 GMT, Adam Sotona wrote: >> The current `BytecodeGenerator` implementation assumes that code models have already been lowered before generation. Both `SwitchExpressionOp` and `SwitchStatementOp` with all-constant labels are examples of operations that can be lowered an alternative way, allowing `BytecodeGenerator` to produce more efficient bytecode using `tableswitch` and `lookupswitch` instructions. >> >> The proposed change shifts the responsibility for lowering these operations into the `BytecodeGenerator` itself, enabling selective lowering during bytecode generation. Consequently, `OpBuilder` and `BytecodeGenerator` tests have been updated to avoid invoking the lower transformation step before the `BytecodeGenerator` is called. >> >> A new internal operation, `ConstantLabelSwitchOp`, has been introduced. This acts as an intermediate representation for lowered `SwitchExpressionOp` and `SwitchStatementOp` instances with constant labels. >> >> Lowering of `SwitchExpressionOp` and `SwitchStatementOp` into `ConstantLabelSwitchOp` is also a part of this PR. >> >> This PR also makes minor refinements to the BytecodeGenerator post-processing transformations. > > Adam Sotona has updated the pull request incrementally with one additional commit since the last revision: > > test update src/jdk.incubator.code/share/classes/jdk/incubator/code/Block.java line 119: > 117: * @param arguments the target block arguments, a copy will be made as needed. > 118: */ > 119: public Reference(Block target, List arguments) { Why is this made public? ------------- PR Review Comment: https://git.openjdk.org/babylon/pull/706#discussion_r2577896216 From jfumero at openjdk.org Mon Dec 1 17:11:50 2025 From: jfumero at openjdk.org (Juan Fumero) Date: Mon, 1 Dec 2025 17:11:50 GMT Subject: [code-reflection] RFR: [hat] Testing suite - avoid log duplications Message-ID: HAT Testing framework suite - avoid log duplications ------------- Commit messages: - [hat] Testing suite - avoid log duplications Changes: https://git.openjdk.org/babylon/pull/720/files Webrev: https://webrevs.openjdk.org/?repo=babylon&pr=720&range=00 Stats: 4 lines in 4 files changed: 0 ins; 0 del; 4 mod Patch: https://git.openjdk.org/babylon/pull/720.diff Fetch: git fetch https://git.openjdk.org/babylon.git pull/720/head:pull/720 PR: https://git.openjdk.org/babylon/pull/720 From asotona at openjdk.org Mon Dec 1 17:12:23 2025 From: asotona at openjdk.org (Adam Sotona) Date: Mon, 1 Dec 2025 17:12:23 GMT Subject: [code-reflection] RFR: BytecodeGenerator cleanup and switch support [v5] In-Reply-To: References: Message-ID: On Mon, 1 Dec 2025 16:59:07 GMT, Paul Sandoz wrote: >> Adam Sotona has updated the pull request incrementally with one additional commit since the last revision: >> >> test update > > src/jdk.incubator.code/share/classes/jdk/incubator/code/Block.java line 119: > >> 117: * @param arguments the target block arguments, a copy will be made as needed. >> 118: */ >> 119: public Reference(Block target, List arguments) { > > Why is this made public? @mabbay Do you need a help to fix the `Block.Reference` construction in the `BytecodeGenerator::getLabelsAndTargets`? ------------- PR Review Comment: https://git.openjdk.org/babylon/pull/706#discussion_r2577927582 From asotona at openjdk.org Mon Dec 1 17:18:01 2025 From: asotona at openjdk.org (Adam Sotona) Date: Mon, 1 Dec 2025 17:18:01 GMT Subject: [code-reflection] RFR: BytecodeGenerator cleanup and switch support [v5] In-Reply-To: References: Message-ID: On Mon, 1 Dec 2025 17:07:12 GMT, Adam Sotona wrote: >> The current `BytecodeGenerator` implementation assumes that code models have already been lowered before generation. Both `SwitchExpressionOp` and `SwitchStatementOp` with all-constant labels are examples of operations that can be lowered an alternative way, allowing `BytecodeGenerator` to produce more efficient bytecode using `tableswitch` and `lookupswitch` instructions. >> >> The proposed change shifts the responsibility for lowering these operations into the `BytecodeGenerator` itself, enabling selective lowering during bytecode generation. Consequently, `OpBuilder` and `BytecodeGenerator` tests have been updated to avoid invoking the lower transformation step before the `BytecodeGenerator` is called. >> >> A new internal operation, `ConstantLabelSwitchOp`, has been introduced. This acts as an intermediate representation for lowered `SwitchExpressionOp` and `SwitchStatementOp` instances with constant labels. >> >> Lowering of `SwitchExpressionOp` and `SwitchStatementOp` into `ConstantLabelSwitchOp` is also a part of this PR. >> >> This PR also makes minor refinements to the BytecodeGenerator post-processing transformations. > > Adam Sotona has updated the pull request incrementally with one additional commit since the last revision: > > test update @mabbay The custom lowering transformation is probably worth to take out of the `BytecodeGenerator` into a standalone class in the `jdk.incubator.code.bytecode.impl` package. ------------- PR Comment: https://git.openjdk.org/babylon/pull/706#issuecomment-3597825167 From jfumero at openjdk.org Mon Dec 1 17:33:02 2025 From: jfumero at openjdk.org (Juan Fumero) Date: Mon, 1 Dec 2025 17:33:02 GMT Subject: [code-reflection] Integrated: [hat] Testing suite - avoid log duplications In-Reply-To: References: Message-ID: On Mon, 1 Dec 2025 17:05:36 GMT, Juan Fumero wrote: > HAT Testing framework suite - avoid log duplications This pull request has now been integrated. Changeset: 9966c196 Author: Juan Fumero URL: https://git.openjdk.org/babylon/commit/9966c196ec80c1e57eb2198e2c71cc98c78abcca Stats: 4 lines in 4 files changed: 0 ins; 0 del; 4 mod [hat] Testing suite - avoid log duplications ------------- PR: https://git.openjdk.org/babylon/pull/720 From jfumero at openjdk.org Mon Dec 1 17:34:45 2025 From: jfumero at openjdk.org (Juan Fumero) Date: Mon, 1 Dec 2025 17:34:45 GMT Subject: git: openjdk/babylon: code-reflection: [hat] Testing suite - avoid log duplications Message-ID: <2a798289-07bc-41a3-8755-bc286b8a1dc2@openjdk.org> Changeset: 9966c196 Branch: code-reflection Author: Juan Fumero Date: 2025-12-01 17:30:17 +0000 URL: https://git.openjdk.org/babylon/commit/9966c196ec80c1e57eb2198e2c71cc98c78abcca [hat] Testing suite - avoid log duplications ! hat/hat.java ! hat/hat/job.jar ! hat/hat/job/src/main/java/job/ForkExec.java ! hat/hat/job/src/main/java/job/Jar.java From jfumero at openjdk.org Mon Dec 1 17:55:25 2025 From: jfumero at openjdk.org (Juan Fumero) Date: Mon, 1 Dec 2025 17:55:25 GMT Subject: [code-reflection] RFR: [hat] Testing suite - cleanup Message-ID: [hat] Testing suite - cleanup ------------- Commit messages: - [hat] Testing suite - cleanup Changes: https://git.openjdk.org/babylon/pull/722/files Webrev: https://webrevs.openjdk.org/?repo=babylon&pr=722&range=00 Stats: 6 lines in 3 files changed: 0 ins; 6 del; 0 mod Patch: https://git.openjdk.org/babylon/pull/722.diff Fetch: git fetch https://git.openjdk.org/babylon.git pull/722/head:pull/722 PR: https://git.openjdk.org/babylon/pull/722 From jfumero at openjdk.org Mon Dec 1 18:03:24 2025 From: jfumero at openjdk.org (Juan Fumero) Date: Mon, 1 Dec 2025 18:03:24 GMT Subject: [code-reflection] Integrated: [hat] Testing suite - cleanup In-Reply-To: References: Message-ID: <6SV1PE0xUknj8ERzuwqh8MEfUsE1awnLz04tp00R0X8=.e6907f8d-1def-41f4-8e0f-9b5632e36253@github.com> On Mon, 1 Dec 2025 17:49:35 GMT, Juan Fumero wrote: > [hat] Testing suite - cleanup This pull request has now been integrated. Changeset: 0a7929cc Author: Juan Fumero URL: https://git.openjdk.org/babylon/commit/0a7929cc4ae568f9c478b80668ad0a7c7af7a57c Stats: 6 lines in 3 files changed: 0 ins; 6 del; 0 mod [hat] Testing suite - cleanup ------------- PR: https://git.openjdk.org/babylon/pull/722 From jfumero at openjdk.org Mon Dec 1 18:05:00 2025 From: jfumero at openjdk.org (Juan Fumero) Date: Mon, 1 Dec 2025 18:05:00 GMT Subject: git: openjdk/babylon: code-reflection: [hat] Testing suite - cleanup Message-ID: <981501f5-3b32-4d3f-b939-a2cc1052c9e8@openjdk.org> Changeset: 0a7929cc Branch: code-reflection Author: Juan Fumero Date: 2025-12-01 18:00:26 +0000 URL: https://git.openjdk.org/babylon/commit/0a7929cc4ae568f9c478b80668ad0a7c7af7a57c [hat] Testing suite - cleanup ! hat/hat/job.jar ! hat/hat/job/src/main/java/job/Jar.java ! hat/tests/src/main/java/hat/test/TestDeviceType.java From mabbay at openjdk.org Mon Dec 1 19:03:29 2025 From: mabbay at openjdk.org (Mourad Abbay) Date: Mon, 1 Dec 2025 19:03:29 GMT Subject: [code-reflection] RFR: BytecodeGenerator cleanup and switch support [v5] In-Reply-To: References: Message-ID: On Mon, 1 Dec 2025 17:09:40 GMT, Adam Sotona wrote: >> src/jdk.incubator.code/share/classes/jdk/incubator/code/Block.java line 119: >> >>> 117: * @param arguments the target block arguments, a copy will be made as needed. >>> 118: */ >>> 119: public Reference(Block target, List arguments) { >> >> Why is this made public? > > @mabbay Do you need a help to fix the `Block.Reference` construction in the `BytecodeGenerator::getLabelsAndTargets`? Yes ------------- PR Review Comment: https://git.openjdk.org/babylon/pull/706#discussion_r2578275834 From asotona at openjdk.org Mon Dec 1 19:37:06 2025 From: asotona at openjdk.org (Adam Sotona) Date: Mon, 1 Dec 2025 19:37:06 GMT Subject: [code-reflection] RFR: BytecodeGenerator cleanup and switch support [v6] In-Reply-To: References: Message-ID: > The current `BytecodeGenerator` implementation assumes that code models have already been lowered before generation. Both `SwitchExpressionOp` and `SwitchStatementOp` with all-constant labels are examples of operations that can be lowered an alternative way, allowing `BytecodeGenerator` to produce more efficient bytecode using `tableswitch` and `lookupswitch` instructions. > > The proposed change shifts the responsibility for lowering these operations into the `BytecodeGenerator` itself, enabling selective lowering during bytecode generation. Consequently, `OpBuilder` and `BytecodeGenerator` tests have been updated to avoid invoking the lower transformation step before the `BytecodeGenerator` is called. > > A new internal operation, `ConstantLabelSwitchOp`, has been introduced. This acts as an intermediate representation for lowered `SwitchExpressionOp` and `SwitchStatementOp` instances with constant labels. > > Lowering of `SwitchExpressionOp` and `SwitchStatementOp` into `ConstantLabelSwitchOp` is also a part of this PR. > > This PR also makes minor refinements to the BytecodeGenerator post-processing transformations. Adam Sotona has updated the pull request incrementally with two additional commits since the last revision: - Merge remote-tracking branch 'asotona/bytecodegenerator-cleanup' into bytecodegenerator-cleanup - Change getLabelsAndTargets to returns targets as list of blocks ------------- Changes: - all: https://git.openjdk.org/babylon/pull/706/files - new: https://git.openjdk.org/babylon/pull/706/files/b9a75e2c..13eceb2c Webrevs: - full: https://webrevs.openjdk.org/?repo=babylon&pr=706&range=05 - incr: https://webrevs.openjdk.org/?repo=babylon&pr=706&range=04-05 Stats: 7 lines in 2 files changed: 0 ins; 0 del; 7 mod Patch: https://git.openjdk.org/babylon/pull/706.diff Fetch: git fetch https://git.openjdk.org/babylon.git pull/706/head:pull/706 PR: https://git.openjdk.org/babylon/pull/706 From amaembo at gmail.com Tue Dec 2 09:58:24 2025 From: amaembo at gmail.com (Tagir Valeev) Date: Tue, 2 Dec 2025 10:58:24 +0100 Subject: An experiment: retrieve record component from accessor literal via code reflection Message-ID: Hello! A recent discussion in amber-dev [1] lead me to the following example how people may use Code Reflection. The problem: Retrieve a RecordComponent object from the corresponding record accessor method reference. Expect the following API: private record MyRecord(int comp, double comp2) {} ... RecordComponent component = ReflectUtil.component(MyRecord::comp); It looks like it's possible to solve this with Code Reflection. My solution is the following: package org.example; import jdk.incubator.code.Quoted; import jdk.incubator.code.Reflect; import jdk.incubator.code.dialect.core.CoreOp; import jdk.incubator.code.dialect.java.JavaOp; import jdk.incubator.code.dialect.java.MethodRef; import java.lang.invoke.MethodHandles; import java.lang.reflect.Method; import java.lang.reflect.RecordComponent; import java.util.Arrays; public final class ReflectUtil { @Reflect @FunctionalInterface public interface RecordAccessor { /** * @param r record type * @return result of the record component * @param an unused generic parameter to avoid accidental use with lambda * (lambdas cannot bind to generic SAM). * Only method references are supported. */ Object get(T r); } /** * @param accessor a method reference bound to a record accessor * @return record component that corresponds to a given accessor * @param record type * @throws IllegalArgumentException if the supplied argument is not a record accessor method reference * @throws RuntimeException if the record accessor cannot be resolved (e.g., due to insufficient access rights) */ public static RecordComponent component(RecordAccessor accessor) { Quoted quoted = CoreOp.QuotedOp.ofQuotable(accessor) .orElseThrow(() -> new IllegalArgumentException("Accessor must be quotable")); if (!(quoted.op() instanceof JavaOp.LambdaOp lambda)) { throw new IllegalArgumentException("Expected method reference"); } JavaOp.InvokeOp invokeOp = lambda.methodReference() .orElseThrow(() -> new IllegalArgumentException("Expected method reference")); if (invokeOp.invokeKind() != JavaOp.InvokeOp.InvokeKind.INSTANCE) { throw new IllegalArgumentException("Method reference bound to record accessor is expected"); } MethodRef descriptor = invokeOp.invokeDescriptor(); Method method; try { method = descriptor.resolveToMethod(MethodHandles.privateLookupIn(accessor.getClass(), MethodHandles.lookup())); } catch (ReflectiveOperationException e) { throw new RuntimeException("Cannot resolve descriptor "+descriptor, e); } Class recordClass = method.getDeclaringClass(); if (!recordClass.isRecord()) { throw new IllegalArgumentException("Not a record accessor method"); } return Arrays.stream(recordClass.getRecordComponents()).filter(rc -> rc.getAccessor().equals(method)) .findFirst() .orElseThrow(() -> new IllegalArgumentException("Not a record accessor: "+method)); } } I'm not completely sure if privateLookupIn is the right thing to do here. Otherwise, it's quite a pleasant experience: the code is simple and self-explanatory. LambdaOp::methodReference was very helpful. With best regards, Tagir Valeev [1] https://mail.openjdk.org/pipermail/amber-dev/2025-November/009472.html -------------- next part -------------- An HTML attachment was scrubbed... URL: From asotona at openjdk.org Tue Dec 2 10:25:34 2025 From: asotona at openjdk.org (Adam Sotona) Date: Tue, 2 Dec 2025 10:25:34 GMT Subject: [code-reflection] RFR: BytecodeGenerator cleanup and switch support [v7] In-Reply-To: References: Message-ID: <6-WkPm1LvBi66ya6phNm2i5wWeo9vjmzIrKfzEmyDtM=.3d8927e2-7d0f-4614-8fd7-e1f5ff0916d6@github.com> > The current `BytecodeGenerator` implementation assumes that code models have already been lowered before generation. Both `SwitchExpressionOp` and `SwitchStatementOp` with all-constant labels are examples of operations that can be lowered an alternative way, allowing `BytecodeGenerator` to produce more efficient bytecode using `tableswitch` and `lookupswitch` instructions. > > The proposed change shifts the responsibility for lowering these operations into the `BytecodeGenerator` itself, enabling selective lowering during bytecode generation. Consequently, `OpBuilder` and `BytecodeGenerator` tests have been updated to avoid invoking the lower transformation step before the `BytecodeGenerator` is called. > > A new internal operation, `ConstantLabelSwitchOp`, has been introduced. This acts as an intermediate representation for lowered `SwitchExpressionOp` and `SwitchStatementOp` instances with constant labels. > > Lowering of `SwitchExpressionOp` and `SwitchStatementOp` into `ConstantLabelSwitchOp` is also a part of this PR. > > This PR also makes minor refinements to the BytecodeGenerator post-processing transformations. Adam Sotona has updated the pull request incrementally with two additional commits since the last revision: - removed obsolete block - LoweringTransform refactored out to jdk.incubator.code.bytecode.impl package ------------- Changes: - all: https://git.openjdk.org/babylon/pull/706/files - new: https://git.openjdk.org/babylon/pull/706/files/13eceb2c..0fe1d1f5 Webrevs: - full: https://webrevs.openjdk.org/?repo=babylon&pr=706&range=06 - incr: https://webrevs.openjdk.org/?repo=babylon&pr=706&range=05-06 Stats: 532 lines in 3 files changed: 281 ins; 245 del; 6 mod Patch: https://git.openjdk.org/babylon/pull/706.diff Fetch: git fetch https://git.openjdk.org/babylon.git pull/706/head:pull/706 PR: https://git.openjdk.org/babylon/pull/706 From asotona at openjdk.org Tue Dec 2 13:06:33 2025 From: asotona at openjdk.org (Adam Sotona) Date: Tue, 2 Dec 2025 13:06:33 GMT Subject: [code-reflection] RFR: BytecodeGenerator cleanup and switch support [v7] In-Reply-To: <6-WkPm1LvBi66ya6phNm2i5wWeo9vjmzIrKfzEmyDtM=.3d8927e2-7d0f-4614-8fd7-e1f5ff0916d6@github.com> References: <6-WkPm1LvBi66ya6phNm2i5wWeo9vjmzIrKfzEmyDtM=.3d8927e2-7d0f-4614-8fd7-e1f5ff0916d6@github.com> Message-ID: On Tue, 2 Dec 2025 10:25:34 GMT, Adam Sotona wrote: >> The current `BytecodeGenerator` implementation assumes that code models have already been lowered before generation. Both `SwitchExpressionOp` and `SwitchStatementOp` with all-constant labels are examples of operations that can be lowered an alternative way, allowing `BytecodeGenerator` to produce more efficient bytecode using `tableswitch` and `lookupswitch` instructions. >> >> The proposed change shifts the responsibility for lowering these operations into the `BytecodeGenerator` itself, enabling selective lowering during bytecode generation. Consequently, `OpBuilder` and `BytecodeGenerator` tests have been updated to avoid invoking the lower transformation step before the `BytecodeGenerator` is called. >> >> A new internal operation, `ConstantLabelSwitchOp`, has been introduced. This acts as an intermediate representation for lowered `SwitchExpressionOp` and `SwitchStatementOp` instances with constant labels. >> >> Lowering of `SwitchExpressionOp` and `SwitchStatementOp` into `ConstantLabelSwitchOp` is also a part of this PR. >> >> This PR also makes minor refinements to the BytecodeGenerator post-processing transformations. > > Adam Sotona has updated the pull request incrementally with two additional commits since the last revision: > > - removed obsolete block > > - LoweringTransform refactored out to jdk.incubator.code.bytecode.impl package @mabbay nice job! Synthetic type factory now looks like this: public static jdk.incubator.code.extern.ExternalizedTypeElement $exterType(int); descriptor: (I)Ljdk/incubator/code/extern/ExternalizedTypeElement; flags: (0x0009) ACC_PUBLIC, ACC_STATIC Code: stack=5, locals=9, args_size=1 0: iload_0 1: tableswitch { // 0 to 146 ... ------------- PR Review: https://git.openjdk.org/babylon/pull/706#pullrequestreview-3529999325 From asotona at openjdk.org Tue Dec 2 14:46:56 2025 From: asotona at openjdk.org (Adam Sotona) Date: Tue, 2 Dec 2025 14:46:56 GMT Subject: [code-reflection] RFR: BytecodeGenerator cleanup and switch support [v8] In-Reply-To: References: Message-ID: > The current `BytecodeGenerator` implementation assumes that code models have already been lowered before generation. Both `SwitchExpressionOp` and `SwitchStatementOp` with all-constant labels are examples of operations that can be lowered an alternative way, allowing `BytecodeGenerator` to produce more efficient bytecode using `tableswitch` and `lookupswitch` instructions. > > The proposed change shifts the responsibility for lowering these operations into the `BytecodeGenerator` itself, enabling selective lowering during bytecode generation. Consequently, `OpBuilder` and `BytecodeGenerator` tests have been updated to avoid invoking the lower transformation step before the `BytecodeGenerator` is called. > > A new internal operation, `ConstantLabelSwitchOp`, has been introduced. This acts as an intermediate representation for lowered `SwitchExpressionOp` and `SwitchStatementOp` instances with constant labels. > > Lowering of `SwitchExpressionOp` and `SwitchStatementOp` into `ConstantLabelSwitchOp` is also a part of this PR. > > This PR also makes minor refinements to the BytecodeGenerator post-processing transformations. Adam Sotona has updated the pull request incrementally with one additional commit since the last revision: TestSwitch extended ------------- Changes: - all: https://git.openjdk.org/babylon/pull/706/files - new: https://git.openjdk.org/babylon/pull/706/files/0fe1d1f5..ffb5442c Webrevs: - full: https://webrevs.openjdk.org/?repo=babylon&pr=706&range=07 - incr: https://webrevs.openjdk.org/?repo=babylon&pr=706&range=06-07 Stats: 90 lines in 1 file changed: 79 ins; 1 del; 10 mod Patch: https://git.openjdk.org/babylon/pull/706.diff Fetch: git fetch https://git.openjdk.org/babylon.git pull/706/head:pull/706 PR: https://git.openjdk.org/babylon/pull/706 From davidalayachew at gmail.com Tue Dec 2 16:28:52 2025 From: davidalayachew at gmail.com (David Alayachew) Date: Tue, 2 Dec 2025 11:28:52 -0500 Subject: An experiment: retrieve record component from accessor literal via code reflection In-Reply-To: References: Message-ID: Thanks for putting this together Tagir. It's exciting to see what babylon will be able to provide us if stuff like this is fairly easy to do. On Tue, Dec 2, 2025, 4:59?AM Tagir Valeev wrote: > Hello! > > A recent discussion in amber-dev [1] lead me to the following example how > people may use Code Reflection. > The problem: > Retrieve a RecordComponent object from the corresponding record accessor > method reference. Expect the following API: > > private record MyRecord(int comp, double comp2) {} > ... > RecordComponent component = ReflectUtil.component(MyRecord::comp); > > It looks like it's possible to solve this with Code Reflection. My > solution is the following: > > package org.example; > > import jdk.incubator.code.Quoted; > import jdk.incubator.code.Reflect; > import jdk.incubator.code.dialect.core.CoreOp; > import jdk.incubator.code.dialect.java.JavaOp; > import jdk.incubator.code.dialect.java.MethodRef; > > import java.lang.invoke.MethodHandles; > import java.lang.reflect.Method; > import java.lang.reflect.RecordComponent; > import java.util.Arrays; > > public final class ReflectUtil { > @Reflect > @FunctionalInterface > public interface RecordAccessor { > /** > * @param r record type > * @return result of the record component > * @param an unused generic parameter to avoid accidental use > with lambda > * (lambdas cannot bind to generic SAM). > * Only method references are supported. > */ > Object get(T r); > } > > /** > * @param accessor a method reference bound to a record accessor > * @return record component that corresponds to a given accessor > * @param record type > * @throws IllegalArgumentException if the supplied argument is not a > record accessor method reference > * @throws RuntimeException if the record accessor cannot be resolved > (e.g., due to insufficient access rights) > */ > public static RecordComponent > component(RecordAccessor accessor) { > Quoted quoted = CoreOp.QuotedOp.ofQuotable(accessor) > .orElseThrow(() -> new IllegalArgumentException("Accessor > must be quotable")); > if (!(quoted.op() instanceof JavaOp.LambdaOp lambda)) { > throw new IllegalArgumentException("Expected method > reference"); > } > JavaOp.InvokeOp invokeOp = lambda.methodReference() > .orElseThrow(() -> new IllegalArgumentException("Expected > method reference")); > if (invokeOp.invokeKind() != JavaOp.InvokeOp.InvokeKind.INSTANCE) { > throw new IllegalArgumentException("Method reference bound to > record accessor is expected"); > } > MethodRef descriptor = invokeOp.invokeDescriptor(); > Method method; > try { > method = > descriptor.resolveToMethod(MethodHandles.privateLookupIn(accessor.getClass(), > MethodHandles.lookup())); > } catch (ReflectiveOperationException e) { > throw new RuntimeException("Cannot resolve descriptor > "+descriptor, e); > } > Class recordClass = method.getDeclaringClass(); > if (!recordClass.isRecord()) { > throw new IllegalArgumentException("Not a record accessor > method"); > } > return Arrays.stream(recordClass.getRecordComponents()).filter(rc > -> rc.getAccessor().equals(method)) > .findFirst() > .orElseThrow(() -> new IllegalArgumentException("Not a > record accessor: "+method)); > } > } > > I'm not completely sure if privateLookupIn is the right thing to do here. > Otherwise, it's quite a pleasant experience: the code is simple and > self-explanatory. LambdaOp::methodReference was very helpful. > > With best regards, > Tagir Valeev > > > [1] https://mail.openjdk.org/pipermail/amber-dev/2025-November/009472.html > -------------- next part -------------- An HTML attachment was scrubbed... URL: From psandoz at openjdk.org Tue Dec 2 17:51:10 2025 From: psandoz at openjdk.org (Paul Sandoz) Date: Tue, 2 Dec 2025 17:51:10 GMT Subject: [code-reflection] RFR: BytecodeGenerator cleanup and switch support [v8] In-Reply-To: References: Message-ID: On Tue, 2 Dec 2025 14:46:56 GMT, Adam Sotona wrote: >> The current `BytecodeGenerator` implementation assumes that code models have already been lowered before generation. Both `SwitchExpressionOp` and `SwitchStatementOp` with all-constant labels are examples of operations that can be lowered an alternative way, allowing `BytecodeGenerator` to produce more efficient bytecode using `tableswitch` and `lookupswitch` instructions. >> >> The proposed change shifts the responsibility for lowering these operations into the `BytecodeGenerator` itself, enabling selective lowering during bytecode generation. Consequently, `OpBuilder` and `BytecodeGenerator` tests have been updated to avoid invoking the lower transformation step before the `BytecodeGenerator` is called. >> >> A new internal operation, `ConstantLabelSwitchOp`, has been introduced. This acts as an intermediate representation for lowered `SwitchExpressionOp` and `SwitchStatementOp` instances with constant labels. >> >> Lowering of `SwitchExpressionOp` and `SwitchStatementOp` into `ConstantLabelSwitchOp` is also a part of this PR. >> >> Lowering of `BreakOp`, `SwitchFallthroughOp` and nested switches will be implemented in a follow-up PR. >> >> This PR also makes minor refinements to the BytecodeGenerator post-processing transformations. > > Adam Sotona has updated the pull request incrementally with one additional commit since the last revision: > > TestSwitch extended This is looking good. We should follow up to extract out validating constant expression as per the JLS, and evaluation and place on method of `JavaExpression`. We likely have some limitations validating and evaluating constant expressions because we rely on reflection to resolve to Fields. src/jdk.incubator.code/share/classes/jdk/incubator/code/bytecode/impl/LoweringTransform.java line 124: > 122: } > 123: Op op = opr.op(); > 124: if (op instanceof CoreOp.ConstantOp cop) { Change all this to a switch expression. src/jdk.incubator.code/share/classes/jdk/incubator/code/bytecode/impl/LoweringTransform.java line 140: > 138: Field field; > 139: try { > 140: field = fieldLoadOp.fieldDescriptor().resolveToField(lookup); Will this work for code that is being compiled as there will be no respective classes loaded? (Perhaps there are clues as to what javac does.) We might need to provide an abstraction to resolve a reference in the context of the compiler or runtime and query the referenced state. src/jdk.incubator.code/share/classes/jdk/incubator/code/bytecode/impl/LoweringTransform.java line 156: > 154: } > 155: if (op instanceof JavaOp.ConditionalExpressionOp cexpr) { > 156: // bodies must yield constant expressions We need to constrain the last three ops to bodies with just one block. Relying on the cast is too fragile. src/jdk.incubator.code/share/classes/jdk/incubator/code/bytecode/impl/LoweringTransform.java line 250: > 248: } > 249: > 250: static Integer extractConstantLabel(MethodHandles.Lookup lookup, Body body, Op whenToStop) { This works and is OK for now, but is a bit of a blunt hammer. Since we are dealing with expressions we should be able to traverse from the root of the constant expression tree. test/jdk/java/lang/reflect/code/bytecode/TestIsCaseConstantSwitch.java line 30: > 28: > 29: class C { > 30: static final int x = 26; What about a case label accessing a static field of `TestIsCaseConstantSwitch`? ------------- PR Review: https://git.openjdk.org/babylon/pull/706#pullrequestreview-3531342157 PR Review Comment: https://git.openjdk.org/babylon/pull/706#discussion_r2582174697 PR Review Comment: https://git.openjdk.org/babylon/pull/706#discussion_r2582179055 PR Review Comment: https://git.openjdk.org/babylon/pull/706#discussion_r2582181488 PR Review Comment: https://git.openjdk.org/babylon/pull/706#discussion_r2582209198 PR Review Comment: https://git.openjdk.org/babylon/pull/706#discussion_r2582223589 From asotona at openjdk.org Tue Dec 2 20:09:55 2025 From: asotona at openjdk.org (Adam Sotona) Date: Tue, 2 Dec 2025 20:09:55 GMT Subject: [code-reflection] RFR: BytecodeGenerator cleanup and switch support [v9] In-Reply-To: References: Message-ID: > The current `BytecodeGenerator` implementation assumes that code models have already been lowered before generation. Both `SwitchExpressionOp` and `SwitchStatementOp` with all-constant labels are examples of operations that can be lowered an alternative way, allowing `BytecodeGenerator` to produce more efficient bytecode using `tableswitch` and `lookupswitch` instructions. > > The proposed change shifts the responsibility for lowering these operations into the `BytecodeGenerator` itself, enabling selective lowering during bytecode generation. Consequently, `OpBuilder` and `BytecodeGenerator` tests have been updated to avoid invoking the lower transformation step before the `BytecodeGenerator` is called. > > A new internal operation, `ConstantLabelSwitchOp`, has been introduced. This acts as an intermediate representation for lowered `SwitchExpressionOp` and `SwitchStatementOp` instances with constant labels. > > Lowering of `SwitchExpressionOp` and `SwitchStatementOp` into `ConstantLabelSwitchOp` is also a part of this PR. > > Lowering of `BreakOp`, `SwitchFallthroughOp` and nested switches will be implemented in a follow-up PR. > > This PR also makes minor refinements to the BytecodeGenerator post-processing transformations. Adam Sotona has updated the pull request incrementally with one additional commit since the last revision: ConstantLabelSwitchOp adjusted to keep possition of the default target ------------- Changes: - all: https://git.openjdk.org/babylon/pull/706/files - new: https://git.openjdk.org/babylon/pull/706/files/ffb5442c..2994865c Webrevs: - full: https://webrevs.openjdk.org/?repo=babylon&pr=706&range=08 - incr: https://webrevs.openjdk.org/?repo=babylon&pr=706&range=07-08 Stats: 23 lines in 3 files changed: 12 ins; 1 del; 10 mod Patch: https://git.openjdk.org/babylon/pull/706.diff Fetch: git fetch https://git.openjdk.org/babylon.git pull/706/head:pull/706 PR: https://git.openjdk.org/babylon/pull/706 From asotona at openjdk.org Wed Dec 3 00:22:17 2025 From: asotona at openjdk.org (Adam Sotona) Date: Wed, 3 Dec 2025 00:22:17 GMT Subject: [code-reflection] RFR: BytecodeGenerator cleanup and switch support [v10] In-Reply-To: References: Message-ID: > The current `BytecodeGenerator` implementation assumes that code models have already been lowered before generation. Both `SwitchExpressionOp` and `SwitchStatementOp` with all-constant labels are examples of operations that can be lowered an alternative way, allowing `BytecodeGenerator` to produce more efficient bytecode using `tableswitch` and `lookupswitch` instructions. > > The proposed change shifts the responsibility for lowering these operations into the `BytecodeGenerator` itself, enabling selective lowering during bytecode generation. Consequently, `OpBuilder` and `BytecodeGenerator` tests have been updated to avoid invoking the lower transformation step before the `BytecodeGenerator` is called. > > A new internal operation, `ConstantLabelSwitchOp`, has been introduced. This acts as an intermediate representation for lowered `SwitchExpressionOp` and `SwitchStatementOp` instances with constant labels. > > Lowering of `SwitchExpressionOp` and `SwitchStatementOp` into `ConstantLabelSwitchOp` is also a part of this PR. > > Lowering of `BreakOp`, `SwitchFallthroughOp` and nested switches will be implemented in a follow-up PR. > > This PR also makes minor refinements to the BytecodeGenerator post-processing transformations. Adam Sotona has updated the pull request incrementally with two additional commits since the last revision: - Generalize the lower transform - Keep switch cases in the same order as in source code ------------- Changes: - all: https://git.openjdk.org/babylon/pull/706/files - new: https://git.openjdk.org/babylon/pull/706/files/2994865c..12c3eb91 Webrevs: - full: https://webrevs.openjdk.org/?repo=babylon&pr=706&range=09 - incr: https://webrevs.openjdk.org/?repo=babylon&pr=706&range=08-09 Stats: 225 lines in 6 files changed: 164 ins; 45 del; 16 mod Patch: https://git.openjdk.org/babylon/pull/706.diff Fetch: git fetch https://git.openjdk.org/babylon.git pull/706/head:pull/706 PR: https://git.openjdk.org/babylon/pull/706 From asotona at openjdk.org Wed Dec 3 07:03:24 2025 From: asotona at openjdk.org (Adam Sotona) Date: Wed, 3 Dec 2025 07:03:24 GMT Subject: [code-reflection] RFR: BytecodeGenerator cleanup and switch support [v10] In-Reply-To: References: Message-ID: <-9ej21ELFzj2GgG53VHnzoawcNbf5pHPj6pvQvBKhA0=.7c357255-c4f7-41e3-a26f-b6c95365e78d@github.com> On Wed, 3 Dec 2025 00:22:17 GMT, Adam Sotona wrote: >> The current `BytecodeGenerator` implementation assumes that code models have already been lowered before generation. Both `SwitchExpressionOp` and `SwitchStatementOp` with all-constant labels are examples of operations that can be lowered an alternative way, allowing `BytecodeGenerator` to produce more efficient bytecode using `tableswitch` and `lookupswitch` instructions. >> >> The proposed change shifts the responsibility for lowering these operations into the `BytecodeGenerator` itself, enabling selective lowering during bytecode generation. Consequently, `OpBuilder` and `BytecodeGenerator` tests have been updated to avoid invoking the lower transformation step before the `BytecodeGenerator` is called. >> >> A new internal operation, `ConstantLabelSwitchOp`, has been introduced. This acts as an intermediate representation for lowered `SwitchExpressionOp` and `SwitchStatementOp` instances with constant labels. >> >> Lowering of `SwitchExpressionOp` and `SwitchStatementOp` into `ConstantLabelSwitchOp` is also a part of this PR. >> >> Lowering of `BreakOp`, `SwitchFallthroughOp` and nested switches will be implemented in a follow-up PR. >> >> This PR also makes minor refinements to the BytecodeGenerator post-processing transformations. > > Adam Sotona has updated the pull request incrementally with two additional commits since the last revision: > > - Generalize the lower transform > - Keep switch cases in the same order as in source code src/jdk.incubator.code/share/classes/jdk/incubator/code/bytecode/impl/LoweringTransform.java line 101: > 99: yield b; > 100: } > 101: case Lowerable lop -> lop.lower(b, null); Nested bodies should be lowered using this lowering transformation. src/jdk.incubator.code/share/classes/jdk/incubator/code/dialect/java/JavaOp.java line 2148: > 2146: } > 2147: > 2148: public record BranchTarget(Block.Builder breakBlock, Block.Builder continueBlock) { This forms a new public API. Implementation code worth to internally share across the module and tests must be moved to a non-public package. The other option is to copy/paste. ------------- PR Review Comment: https://git.openjdk.org/babylon/pull/706#discussion_r2583883219 PR Review Comment: https://git.openjdk.org/babylon/pull/706#discussion_r2583879326 From mabbay at openjdk.org Wed Dec 3 10:03:59 2025 From: mabbay at openjdk.org (Mourad Abbay) Date: Wed, 3 Dec 2025 10:03:59 GMT Subject: [code-reflection] RFR: BytecodeGenerator cleanup and switch support [v10] In-Reply-To: <-9ej21ELFzj2GgG53VHnzoawcNbf5pHPj6pvQvBKhA0=.7c357255-c4f7-41e3-a26f-b6c95365e78d@github.com> References: <-9ej21ELFzj2GgG53VHnzoawcNbf5pHPj6pvQvBKhA0=.7c357255-c4f7-41e3-a26f-b6c95365e78d@github.com> Message-ID: On Wed, 3 Dec 2025 06:59:06 GMT, Adam Sotona wrote: >> Adam Sotona has updated the pull request incrementally with two additional commits since the last revision: >> >> - Generalize the lower transform >> - Keep switch cases in the same order as in source code > > src/jdk.incubator.code/share/classes/jdk/incubator/code/dialect/java/JavaOp.java line 2148: > >> 2146: } >> 2147: >> 2148: public record BranchTarget(Block.Builder breakBlock, Block.Builder continueBlock) { > > This forms a new public API. > Implementation code worth to internally share across the module and tests must be moved to a non-public package. The other option is to copy/paste. Copy paste is not going to work, because for example BreakOp.lower depends on JavaOp.BranchTarget. ------------- PR Review Comment: https://git.openjdk.org/babylon/pull/706#discussion_r2584429682 From asotona at openjdk.org Wed Dec 3 10:32:39 2025 From: asotona at openjdk.org (Adam Sotona) Date: Wed, 3 Dec 2025 10:32:39 GMT Subject: [code-reflection] RFR: BytecodeGenerator cleanup and switch support [v11] In-Reply-To: References: Message-ID: > The current `BytecodeGenerator` implementation assumes that code models have already been lowered before generation. Both `SwitchExpressionOp` and `SwitchStatementOp` with all-constant labels are examples of operations that can be lowered an alternative way, allowing `BytecodeGenerator` to produce more efficient bytecode using `tableswitch` and `lookupswitch` instructions. > > The proposed change shifts the responsibility for lowering these operations into the `BytecodeGenerator` itself, enabling selective lowering during bytecode generation. Consequently, `OpBuilder` and `BytecodeGenerator` tests have been updated to avoid invoking the lower transformation step before the `BytecodeGenerator` is called. > > A new internal operation, `ConstantLabelSwitchOp`, has been introduced. This acts as an intermediate representation for lowered `SwitchExpressionOp` and `SwitchStatementOp` instances with constant labels. > > Lowering of `SwitchExpressionOp` and `SwitchStatementOp` into `ConstantLabelSwitchOp` is also a part of this PR. > > Lowering of `BreakOp`, `SwitchFallthroughOp` and nested switches will be implemented in a follow-up PR. > > This PR also makes minor refinements to the BytecodeGenerator post-processing transformations. Adam Sotona has updated the pull request incrementally with one additional commit since the last revision: lower the case bodies of a switch recursively ------------- Changes: - all: https://git.openjdk.org/babylon/pull/706/files - new: https://git.openjdk.org/babylon/pull/706/files/12c3eb91..d6821ba3 Webrevs: - full: https://webrevs.openjdk.org/?repo=babylon&pr=706&range=10 - incr: https://webrevs.openjdk.org/?repo=babylon&pr=706&range=09-10 Stats: 10 lines in 1 file changed: 0 ins; 5 del; 5 mod Patch: https://git.openjdk.org/babylon/pull/706.diff Fetch: git fetch https://git.openjdk.org/babylon.git pull/706/head:pull/706 PR: https://git.openjdk.org/babylon/pull/706 From asotona at openjdk.org Wed Dec 3 10:42:33 2025 From: asotona at openjdk.org (Adam Sotona) Date: Wed, 3 Dec 2025 10:42:33 GMT Subject: [code-reflection] RFR: BytecodeGenerator cleanup and switch support [v12] In-Reply-To: References: Message-ID: > The current `BytecodeGenerator` implementation assumes that code models have already been lowered before generation. Both `SwitchExpressionOp` and `SwitchStatementOp` with all-constant labels are examples of operations that can be lowered an alternative way, allowing `BytecodeGenerator` to produce more efficient bytecode using `tableswitch` and `lookupswitch` instructions. > > The proposed change shifts the responsibility for lowering these operations into the `BytecodeGenerator` itself, enabling selective lowering during bytecode generation. Consequently, `OpBuilder` and `BytecodeGenerator` tests have been updated to avoid invoking the lower transformation step before the `BytecodeGenerator` is called. > > A new internal operation, `ConstantLabelSwitchOp`, has been introduced. This acts as an intermediate representation for lowered `SwitchExpressionOp` and `SwitchStatementOp` instances with constant labels. > > Lowering of `SwitchExpressionOp` and `SwitchStatementOp` into `ConstantLabelSwitchOp` is also a part of this PR. > > Lowering of `BreakOp`, `SwitchFallthroughOp` and nested switches will be implemented in a follow-up PR. > > This PR also makes minor refinements to the BytecodeGenerator post-processing transformations. Adam Sotona has updated the pull request incrementally with one additional commit since the last revision: replace if with switch ------------- Changes: - all: https://git.openjdk.org/babylon/pull/706/files - new: https://git.openjdk.org/babylon/pull/706/files/d6821ba3..d8f88d64 Webrevs: - full: https://webrevs.openjdk.org/?repo=babylon&pr=706&range=11 - incr: https://webrevs.openjdk.org/?repo=babylon&pr=706&range=10-11 Stats: 14 lines in 1 file changed: 2 ins; 1 del; 11 mod Patch: https://git.openjdk.org/babylon/pull/706.diff Fetch: git fetch https://git.openjdk.org/babylon.git pull/706/head:pull/706 PR: https://git.openjdk.org/babylon/pull/706 From asotona at openjdk.org Wed Dec 3 11:05:43 2025 From: asotona at openjdk.org (Adam Sotona) Date: Wed, 3 Dec 2025 11:05:43 GMT Subject: [code-reflection] RFR: BytecodeGenerator cleanup and switch support [v13] In-Reply-To: References: Message-ID: <862Srn8X67Cst33_51BkbQZ2q_nDTvFKVZKkbKg-wTI=.1a40b83d-7ee3-4709-b5ac-7d67c75a4c5a@github.com> > The current `BytecodeGenerator` implementation assumes that code models have already been lowered before generation. Both `SwitchExpressionOp` and `SwitchStatementOp` with all-constant labels are examples of operations that can be lowered an alternative way, allowing `BytecodeGenerator` to produce more efficient bytecode using `tableswitch` and `lookupswitch` instructions. > > The proposed change shifts the responsibility for lowering these operations into the `BytecodeGenerator` itself, enabling selective lowering during bytecode generation. Consequently, `OpBuilder` and `BytecodeGenerator` tests have been updated to avoid invoking the lower transformation step before the `BytecodeGenerator` is called. > > A new internal operation, `ConstantLabelSwitchOp`, has been introduced. This acts as an intermediate representation for lowered `SwitchExpressionOp` and `SwitchStatementOp` instances with constant labels. > > Lowering of `SwitchExpressionOp` and `SwitchStatementOp` into `ConstantLabelSwitchOp` is also a part of this PR. > > Lowering of `BreakOp`, `SwitchFallthroughOp` and nested switches will be implemented in a follow-up PR. > > This PR also makes minor refinements to the BytecodeGenerator post-processing transformations. Adam Sotona has updated the pull request incrementally with two additional commits since the last revision: - BranchTarget moved from JavaOp into jdk.incubator.code.internal package - replace if with switch ------------- Changes: - all: https://git.openjdk.org/babylon/pull/706/files - new: https://git.openjdk.org/babylon/pull/706/files/d8f88d64..811f061a Webrevs: - full: https://webrevs.openjdk.org/?repo=babylon&pr=706&range=12 - incr: https://webrevs.openjdk.org/?repo=babylon&pr=706&range=11-12 Stats: 161 lines in 3 files changed: 55 ins; 39 del; 67 mod Patch: https://git.openjdk.org/babylon/pull/706.diff Fetch: git fetch https://git.openjdk.org/babylon.git pull/706/head:pull/706 PR: https://git.openjdk.org/babylon/pull/706 From jfumero at openjdk.org Wed Dec 3 11:53:56 2025 From: jfumero at openjdk.org (Juan Fumero) Date: Wed, 3 Dec 2025 11:53:56 GMT Subject: [code-reflection] RFR: [hat] Proposal for bfloat16 [v2] In-Reply-To: References: Message-ID: > This PR introduces the type [`bfloat16`](https://cloud.google.com/blog/products/ai-machine-learning/bfloat16-the-secret-to-high-performance-on-cloud-tpus) for HAT. > > Testing for OpenCL: > > > HAT=SHOW_CODE java -cp hat/job.jar hat.java test ffi-opencl hat.test.TestBFloat16Type > > > Testing for CUDA: > > > HAT=SHOW_CODE java -cp hat/job.jar hat.java test ffi-cuda hat.test.TestBFloat16Type > > > Some tests are expecting to fail due to precision error. We will need to improve the type conversion with round-to-nearest-even for example. Juan Fumero has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains 22 commits: - [hat] abstracting the OpenCL and CUDA code builders - Merge branch 'code-reflection' into hat/type/bfloat16 - Merge branch 'code-reflection' into hat/type/bfloat16 - [hat] remove custom Op for bfloat - single line imports in hat code builders - single line imports in hat code builders - [hat] test matmul with bfloat16 - [hat] dialect for bfloat16 removed - [hat] new test file included in the hat test list - [hat] OpenCL handler for bfloat16 via float convs - ... and 12 more: https://git.openjdk.org/babylon/compare/0a7929cc...ddc932c3 ------------- Changes: https://git.openjdk.org/babylon/pull/716/files Webrev: https://webrevs.openjdk.org/?repo=babylon&pr=716&range=01 Stats: 1620 lines in 28 files changed: 1463 ins; 76 del; 81 mod Patch: https://git.openjdk.org/babylon/pull/716.diff Fetch: git fetch https://git.openjdk.org/babylon.git pull/716/head:pull/716 PR: https://git.openjdk.org/babylon/pull/716 From gfrost at openjdk.org Wed Dec 3 12:12:41 2025 From: gfrost at openjdk.org (Gary Frost) Date: Wed, 3 Dec 2025 12:12:41 GMT Subject: [code-reflection] RFR: [hat] Proposal for bfloat16 [v2] In-Reply-To: References: Message-ID: On Wed, 3 Dec 2025 11:53:56 GMT, Juan Fumero wrote: >> This PR introduces the type [`bfloat16`](https://cloud.google.com/blog/products/ai-machine-learning/bfloat16-the-secret-to-high-performance-on-cloud-tpus) for HAT. >> >> Testing for OpenCL: >> >> >> HAT=SHOW_CODE java -cp hat/job.jar hat.java test ffi-opencl hat.test.TestBFloat16Type >> >> >> Testing for CUDA: >> >> >> HAT=SHOW_CODE java -cp hat/job.jar hat.java test ffi-cuda hat.test.TestBFloat16Type >> >> >> Some tests are expecting to fail due to precision error. We will need to improve the type conversion with round-to-nearest-even for example. > > Juan Fumero has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains 22 commits: > > - [hat] abstracting the OpenCL and CUDA code builders > - Merge branch 'code-reflection' into hat/type/bfloat16 > - Merge branch 'code-reflection' into hat/type/bfloat16 > - [hat] remove custom Op for bfloat > - single line imports in hat code builders > - single line imports in hat code builders > - [hat] test matmul with bfloat16 > - [hat] dialect for bfloat16 removed > - [hat] new test file included in the hat test list > - [hat] OpenCL handler for bfloat16 via float convs > - ... and 12 more: https://git.openjdk.org/babylon/compare/0a7929cc...ddc932c3 hat/core/src/main/java/hat/codebuilders/C99HATKernelBuilder.java line 97: > 95: } else if (javaType instanceof ClassType classType && classType.toClassName().equals(F16.class.getCanonicalName())) { > 96: // Check for special types (e.g., FP16) > 97: globalPtrPrefix().suffix_t(F16Impl.class.getSimpleName()).asterisk(); We might consider overloading suffix_t with suffix_t(Class clazz) which extracts the simpleName. T suffix_t(Class clazz){ return suffix_t(clazz.getSimpleNameI()); } Then we can just pass .suffix_t(F16Impl.class) ------------- PR Review Comment: https://git.openjdk.org/babylon/pull/716#discussion_r2584866769 From gfrost at openjdk.org Wed Dec 3 12:26:55 2025 From: gfrost at openjdk.org (Gary Frost) Date: Wed, 3 Dec 2025 12:26:55 GMT Subject: [code-reflection] RFR: [hat] Proposal for bfloat16 [v2] In-Reply-To: References: Message-ID: On Wed, 3 Dec 2025 11:53:56 GMT, Juan Fumero wrote: >> This PR introduces the type [`bfloat16`](https://cloud.google.com/blog/products/ai-machine-learning/bfloat16-the-secret-to-high-performance-on-cloud-tpus) for HAT. >> >> Testing for OpenCL: >> >> >> HAT=SHOW_CODE java -cp hat/job.jar hat.java test ffi-opencl hat.test.TestBFloat16Type >> >> >> Testing for CUDA: >> >> >> HAT=SHOW_CODE java -cp hat/job.jar hat.java test ffi-cuda hat.test.TestBFloat16Type >> >> >> Some tests are expecting to fail due to precision error. We will need to improve the type conversion with round-to-nearest-even for example. > > Juan Fumero has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains 22 commits: > > - [hat] abstracting the OpenCL and CUDA code builders > - Merge branch 'code-reflection' into hat/type/bfloat16 > - Merge branch 'code-reflection' into hat/type/bfloat16 > - [hat] remove custom Op for bfloat > - single line imports in hat code builders > - single line imports in hat code builders > - [hat] test matmul with bfloat16 > - [hat] dialect for bfloat16 removed > - [hat] new test file included in the hat test list > - [hat] OpenCL handler for bfloat16 via float convs > - ... and 12 more: https://git.openjdk.org/babylon/compare/0a7929cc...ddc932c3 hat/backends/ffi/cuda/src/main/java/hat/backend/ffi/CudaHATKernelBuilder.java line 316: > 314: byte f32Mixed = hatF16BinaryOp.getF32(); > 315: > 316: oparen(); you might consider leaning into paren($->$.generateReduceFloat....().) rather than balancing parenthesis yourself. hat/backends/ffi/cuda/src/main/java/hat/backend/ffi/CudaHATKernelBuilder.java line 334: > 332: > 333: if (f32Mixed == HATF16BinaryOp.LAST_OP) { > 334: cparen(); Looks like separate executaionpaths here can create imbalanced paren? ------------- PR Review Comment: https://git.openjdk.org/babylon/pull/716#discussion_r2584905562 PR Review Comment: https://git.openjdk.org/babylon/pull/716#discussion_r2584909503 From jfumero at openjdk.org Wed Dec 3 13:40:38 2025 From: jfumero at openjdk.org (Juan Fumero) Date: Wed, 3 Dec 2025 13:40:38 GMT Subject: [code-reflection] RFR: [hat] Proposal for bfloat16 [v3] In-Reply-To: References: Message-ID: > This PR introduces the type [`bfloat16`](https://cloud.google.com/blog/products/ai-machine-learning/bfloat16-the-secret-to-high-performance-on-cloud-tpus) for HAT. > > Testing for OpenCL: > > > HAT=SHOW_CODE java -cp hat/job.jar hat.java test ffi-opencl hat.test.TestBFloat16Type > > > Testing for CUDA: > > > HAT=SHOW_CODE java -cp hat/job.jar hat.java test ffi-cuda hat.test.TestBFloat16Type > > > Some tests are expecting to fail due to precision error. We will need to improve the type conversion with round-to-nearest-even for example. Juan Fumero has updated the pull request incrementally with one additional commit since the last revision: Use built-ins to process bfloat16 in the OpenCL backend ------------- Changes: - all: https://git.openjdk.org/babylon/pull/716/files - new: https://git.openjdk.org/babylon/pull/716/files/ddc932c3..df55159c Webrevs: - full: https://webrevs.openjdk.org/?repo=babylon&pr=716&range=02 - incr: https://webrevs.openjdk.org/?repo=babylon&pr=716&range=01-02 Stats: 118 lines in 3 files changed: 93 ins; 20 del; 5 mod Patch: https://git.openjdk.org/babylon/pull/716.diff Fetch: git fetch https://git.openjdk.org/babylon.git pull/716/head:pull/716 PR: https://git.openjdk.org/babylon/pull/716 From jfumero at openjdk.org Wed Dec 3 13:47:22 2025 From: jfumero at openjdk.org (Juan Fumero) Date: Wed, 3 Dec 2025 13:47:22 GMT Subject: [code-reflection] RFR: [hat] Proposal for bfloat16 [v2] In-Reply-To: References: Message-ID: <9FqDA6u6E-ykzhDTs3cAkijC-vacL7C5EzznxdlDvDs=.d426b224-51b8-4b10-ada5-39a0f2fb6784@github.com> On Wed, 3 Dec 2025 12:22:47 GMT, Gary Frost wrote: >> Juan Fumero has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains 22 commits: >> >> - [hat] abstracting the OpenCL and CUDA code builders >> - Merge branch 'code-reflection' into hat/type/bfloat16 >> - Merge branch 'code-reflection' into hat/type/bfloat16 >> - [hat] remove custom Op for bfloat >> - single line imports in hat code builders >> - single line imports in hat code builders >> - [hat] test matmul with bfloat16 >> - [hat] dialect for bfloat16 removed >> - [hat] new test file included in the hat test list >> - [hat] OpenCL handler for bfloat16 via float convs >> - ... and 12 more: https://git.openjdk.org/babylon/compare/0a7929cc...ddc932c3 > > hat/backends/ffi/cuda/src/main/java/hat/backend/ffi/CudaHATKernelBuilder.java line 316: > >> 314: byte f32Mixed = hatF16BinaryOp.getF32(); >> 315: >> 316: oparen(); > > you might consider leaning into paren($->$.generateReduceFloat....().) rather than balancing parenthesis yourself. Indeed. Thanks. > hat/backends/ffi/cuda/src/main/java/hat/backend/ffi/CudaHATKernelBuilder.java line 334: > >> 332: >> 333: if (f32Mixed == HATF16BinaryOp.LAST_OP) { >> 334: cparen(); > > Looks like separate executaionpaths here can create imbalanced paren? The `generateReducedFloatConversionToFloat` already inserts an open parenthesis. I moved it out to make it explicit and avoid confusion. ------------- PR Review Comment: https://git.openjdk.org/babylon/pull/716#discussion_r2585175487 PR Review Comment: https://git.openjdk.org/babylon/pull/716#discussion_r2585177940 From jfumero at openjdk.org Wed Dec 3 13:57:21 2025 From: jfumero at openjdk.org (Juan Fumero) Date: Wed, 3 Dec 2025 13:57:21 GMT Subject: [code-reflection] RFR: [hat] Proposal for bfloat16 [v4] In-Reply-To: References: Message-ID: > This PR introduces the type [`bfloat16`](https://cloud.google.com/blog/products/ai-machine-learning/bfloat16-the-secret-to-high-performance-on-cloud-tpus) for HAT. > > Testing for OpenCL: > > > HAT=SHOW_CODE java -cp hat/job.jar hat.java test ffi-opencl hat.test.TestBFloat16Type > > > Testing for CUDA: > > > HAT=SHOW_CODE java -cp hat/job.jar hat.java test ffi-cuda hat.test.TestBFloat16Type > > > Some tests are expecting to fail due to precision error. We will need to improve the type conversion with round-to-nearest-even for example. Juan Fumero has updated the pull request incrementally with one additional commit since the last revision: [hat] bfloat16 codegen refactored ------------- Changes: - all: https://git.openjdk.org/babylon/pull/716/files - new: https://git.openjdk.org/babylon/pull/716/files/df55159c..22d0ef65 Webrevs: - full: https://webrevs.openjdk.org/?repo=babylon&pr=716&range=03 - incr: https://webrevs.openjdk.org/?repo=babylon&pr=716&range=02-03 Stats: 37 lines in 4 files changed: 16 ins; 4 del; 17 mod Patch: https://git.openjdk.org/babylon/pull/716.diff Fetch: git fetch https://git.openjdk.org/babylon.git pull/716/head:pull/716 PR: https://git.openjdk.org/babylon/pull/716 From jfumero at openjdk.org Wed Dec 3 14:04:02 2025 From: jfumero at openjdk.org (Juan Fumero) Date: Wed, 3 Dec 2025 14:04:02 GMT Subject: [code-reflection] RFR: [hat] Proposal for bfloat16 [v5] In-Reply-To: References: Message-ID: > This PR introduces the type [`bfloat16`](https://cloud.google.com/blog/products/ai-machine-learning/bfloat16-the-secret-to-high-performance-on-cloud-tpus) for HAT. > > Testing for OpenCL: > > > HAT=SHOW_CODE java -cp hat/job.jar hat.java test ffi-opencl hat.test.TestBFloat16Type > > > Testing for CUDA: > > > HAT=SHOW_CODE java -cp hat/job.jar hat.java test ffi-cuda hat.test.TestBFloat16Type > > > Some tests are expecting to fail due to precision error. We will need to improve the type conversion with round-to-nearest-even for example. Juan Fumero has updated the pull request incrementally with one additional commit since the last revision: [hat] fix builtin copyBytes ------------- Changes: - all: https://git.openjdk.org/babylon/pull/716/files - new: https://git.openjdk.org/babylon/pull/716/files/22d0ef65..b5dfe87f Webrevs: - full: https://webrevs.openjdk.org/?repo=babylon&pr=716&range=04 - incr: https://webrevs.openjdk.org/?repo=babylon&pr=716&range=03-04 Stats: 7 lines in 2 files changed: 3 ins; 3 del; 1 mod Patch: https://git.openjdk.org/babylon/pull/716.diff Fetch: git fetch https://git.openjdk.org/babylon.git pull/716/head:pull/716 PR: https://git.openjdk.org/babylon/pull/716 From gfrost at openjdk.org Wed Dec 3 14:14:58 2025 From: gfrost at openjdk.org (Gary Frost) Date: Wed, 3 Dec 2025 14:14:58 GMT Subject: [code-reflection] RFR: [hat] Proposal for bfloat16 [v4] In-Reply-To: References: Message-ID: <4nw6EV85OOJbhVhHRoMvseK1aWNxFNSYWzIepvi0vCo=.7da73169-b239-4089-9f79-5d8bce008205@github.com> On Wed, 3 Dec 2025 13:57:21 GMT, Juan Fumero wrote: >> This PR introduces the type [`bfloat16`](https://cloud.google.com/blog/products/ai-machine-learning/bfloat16-the-secret-to-high-performance-on-cloud-tpus) for HAT. >> >> Testing for OpenCL: >> >> >> HAT=SHOW_CODE java -cp hat/job.jar hat.java test ffi-opencl hat.test.TestBFloat16Type >> >> >> Testing for CUDA: >> >> >> HAT=SHOW_CODE java -cp hat/job.jar hat.java test ffi-cuda hat.test.TestBFloat16Type >> >> >> Some tests are expecting to fail due to precision error. We will need to improve the type conversion with round-to-nearest-even for example. > > Juan Fumero has updated the pull request incrementally with one additional commit since the last revision: > > [hat] bfloat16 codegen refactored hat/core/src/main/java/hat/codebuilders/C99HATKernelBuilder.java line 126: > 124: if (OpTk.isAssignable(buildContext.lookup, javaType, MappableIface.class) && javaType instanceof ClassType classType) { > 125: globalPtrPrefix().suffix_t(classType).asterisk(); > 126: } else if (javaType instanceof ClassType classType && classType.toClassName().equals(F16.class.getCanonicalName())) { Can we leverage OpTk.isAssignable ? or at least avoid string comparisons on Class.getCanonicalName Something like OpTK.isAssignable(lookup, classType, F16.class) ? I think we have access to the lookup in the context... hat/core/src/main/java/hat/codebuilders/HATCodeBuilder.java line 84: > 82: } > 83: > 84: public T suffix_t(Class klass) { Can we compose using existing methods? return suffix_t(class.getSimpleName()); hat/core/src/main/java/hat/codebuilders/HATCodeBuilder.java line 89: > 87: > 88: public T suffix_u(Class klass) { > 89: return identifier(klass.getSimpleName()).identifier("_u"); Same as above ------------- PR Review Comment: https://git.openjdk.org/babylon/pull/716#discussion_r2585272419 PR Review Comment: https://git.openjdk.org/babylon/pull/716#discussion_r2585257810 PR Review Comment: https://git.openjdk.org/babylon/pull/716#discussion_r2585259258 From gfrost at openjdk.org Wed Dec 3 14:14:59 2025 From: gfrost at openjdk.org (Gary Frost) Date: Wed, 3 Dec 2025 14:14:59 GMT Subject: [code-reflection] RFR: [hat] Proposal for bfloat16 [v4] In-Reply-To: <4nw6EV85OOJbhVhHRoMvseK1aWNxFNSYWzIepvi0vCo=.7da73169-b239-4089-9f79-5d8bce008205@github.com> References: <4nw6EV85OOJbhVhHRoMvseK1aWNxFNSYWzIepvi0vCo=.7da73169-b239-4089-9f79-5d8bce008205@github.com> Message-ID: On Wed, 3 Dec 2025 14:08:37 GMT, Gary Frost wrote: >> Juan Fumero has updated the pull request incrementally with one additional commit since the last revision: >> >> [hat] bfloat16 codegen refactored > > hat/core/src/main/java/hat/codebuilders/C99HATKernelBuilder.java line 126: > >> 124: if (OpTk.isAssignable(buildContext.lookup, javaType, MappableIface.class) && javaType instanceof ClassType classType) { >> 125: globalPtrPrefix().suffix_t(classType).asterisk(); >> 126: } else if (javaType instanceof ClassType classType && classType.toClassName().equals(F16.class.getCanonicalName())) { > > Can we leverage OpTk.isAssignable ? or at least avoid string comparisons on Class.getCanonicalName > > Something like > OpTK.isAssignable(lookup, classType, F16.class) ? > > I think we have access to the lookup in the context... Actually if you check for DeviceType... you might be able to collapse multiple else ifs... here }else if (javaType instanceof ClassType classType && OpTk.isAssignable(javaType,DeviceType.class){ .... generate the typedef ... } ------------- PR Review Comment: https://git.openjdk.org/babylon/pull/716#discussion_r2585283414 From gfrost at openjdk.org Wed Dec 3 14:18:03 2025 From: gfrost at openjdk.org (Gary Frost) Date: Wed, 3 Dec 2025 14:18:03 GMT Subject: [code-reflection] RFR: [hat] Proposal for bfloat16 [v2] In-Reply-To: <9FqDA6u6E-ykzhDTs3cAkijC-vacL7C5EzznxdlDvDs=.d426b224-51b8-4b10-ada5-39a0f2fb6784@github.com> References: <9FqDA6u6E-ykzhDTs3cAkijC-vacL7C5EzznxdlDvDs=.d426b224-51b8-4b10-ada5-39a0f2fb6784@github.com> Message-ID: On Wed, 3 Dec 2025 13:45:07 GMT, Juan Fumero wrote: >> hat/backends/ffi/cuda/src/main/java/hat/backend/ffi/CudaHATKernelBuilder.java line 334: >> >>> 332: >>> 333: if (f32Mixed == HATF16BinaryOp.LAST_OP) { >>> 334: cparen(); >> >> Looks like separate executaionpaths here can create imbalanced paren? > > The `generateReducedFloatConversionToFloat` already inserts an open parenthesis. I moved it out to make it explicit and avoid confusion. Ah yes, we should avoid having paranthesis imbalances generated by helper methods. Pulling the oparen() (as you did here) out to the top level makes this more explict. ------------- PR Review Comment: https://git.openjdk.org/babylon/pull/716#discussion_r2585297758 From jfumero at openjdk.org Wed Dec 3 15:03:48 2025 From: jfumero at openjdk.org (Juan Fumero) Date: Wed, 3 Dec 2025 15:03:48 GMT Subject: [code-reflection] RFR: [hat] Proposal for bfloat16 [v6] In-Reply-To: References: Message-ID: > This PR introduces the type [`bfloat16`](https://cloud.google.com/blog/products/ai-machine-learning/bfloat16-the-secret-to-high-performance-on-cloud-tpus) for HAT. > > Testing for OpenCL: > > > HAT=SHOW_CODE java -cp hat/job.jar hat.java test ffi-opencl hat.test.TestBFloat16Type > > > Testing for CUDA: > > > HAT=SHOW_CODE java -cp hat/job.jar hat.java test ffi-cuda hat.test.TestBFloat16Type > > > Some tests are expecting to fail due to precision error. We will need to improve the type conversion with round-to-nearest-even for example. Juan Fumero has updated the pull request incrementally with one additional commit since the last revision: [hat] DeviceTypes control for the dialect and codegen simplified ------------- Changes: - all: https://git.openjdk.org/babylon/pull/716/files - new: https://git.openjdk.org/babylon/pull/716/files/b5dfe87f..e672cd0f Webrevs: - full: https://webrevs.openjdk.org/?repo=babylon&pr=716&range=05 - incr: https://webrevs.openjdk.org/?repo=babylon&pr=716&range=04-05 Stats: 147 lines in 13 files changed: 69 ins; 55 del; 23 mod Patch: https://git.openjdk.org/babylon/pull/716.diff Fetch: git fetch https://git.openjdk.org/babylon.git pull/716/head:pull/716 PR: https://git.openjdk.org/babylon/pull/716 From jfumero at openjdk.org Wed Dec 3 15:24:55 2025 From: jfumero at openjdk.org (Juan Fumero) Date: Wed, 3 Dec 2025 15:24:55 GMT Subject: [code-reflection] RFR: [hat] Proposal for bfloat16 [v4] In-Reply-To: References: <4nw6EV85OOJbhVhHRoMvseK1aWNxFNSYWzIepvi0vCo=.7da73169-b239-4089-9f79-5d8bce008205@github.com> Message-ID: On Wed, 3 Dec 2025 14:11:51 GMT, Gary Frost wrote: >> hat/core/src/main/java/hat/codebuilders/C99HATKernelBuilder.java line 126: >> >>> 124: if (OpTk.isAssignable(buildContext.lookup, javaType, MappableIface.class) && javaType instanceof ClassType classType) { >>> 125: globalPtrPrefix().suffix_t(classType).asterisk(); >>> 126: } else if (javaType instanceof ClassType classType && classType.toClassName().equals(F16.class.getCanonicalName())) { >> >> Can we leverage OpTk.isAssignable ? or at least avoid string comparisons on Class.getCanonicalName >> >> Something like >> OpTK.isAssignable(lookup, classType, F16.class) ? >> >> I think we have access to the lookup in the context... > > Actually if you check for DeviceType... you might be able to collapse multiple else ifs... here > > }else if (javaType instanceof ClassType classType && OpTk.isAssignable(javaType,DeviceType.class){ > .... generate the typedef ... > } We need to design a better strategy here. The problem is not that much about the String comparison, but the array implementation (e.g., `F16Impl`. What we could do is to add new Ops in the dialect to handle this case and make it generic, and we could avoid completely these comparisons. I prefer to have a separate PR for this. ------------- PR Review Comment: https://git.openjdk.org/babylon/pull/716#discussion_r2585550861 From jfumero at openjdk.org Wed Dec 3 15:31:02 2025 From: jfumero at openjdk.org (Juan Fumero) Date: Wed, 3 Dec 2025 15:31:02 GMT Subject: [code-reflection] RFR: [hat] Proposal for bfloat16 [v7] In-Reply-To: References: Message-ID: > This PR introduces the type [`bfloat16`](https://cloud.google.com/blog/products/ai-machine-learning/bfloat16-the-secret-to-high-performance-on-cloud-tpus) for HAT. > > Testing for OpenCL: > > > HAT=SHOW_CODE java -cp hat/job.jar hat.java test ffi-opencl hat.test.TestBFloat16Type > > > Testing for CUDA: > > > HAT=SHOW_CODE java -cp hat/job.jar hat.java test ffi-cuda hat.test.TestBFloat16Type > > > Some tests are expecting to fail due to precision error. We will need to improve the type conversion with round-to-nearest-even for example. Juan Fumero has updated the pull request incrementally with one additional commit since the last revision: [hat] type-class builders reused ------------- Changes: - all: https://git.openjdk.org/babylon/pull/716/files - new: https://git.openjdk.org/babylon/pull/716/files/e672cd0f..a592e4b6 Webrevs: - full: https://webrevs.openjdk.org/?repo=babylon&pr=716&range=06 - incr: https://webrevs.openjdk.org/?repo=babylon&pr=716&range=05-06 Stats: 4 lines in 1 file changed: 0 ins; 1 del; 3 mod Patch: https://git.openjdk.org/babylon/pull/716.diff Fetch: git fetch https://git.openjdk.org/babylon.git pull/716/head:pull/716 PR: https://git.openjdk.org/babylon/pull/716 From jfumero at openjdk.org Wed Dec 3 16:49:29 2025 From: jfumero at openjdk.org (Juan Fumero) Date: Wed, 3 Dec 2025 16:49:29 GMT Subject: git: openjdk/babylon: code-reflection: [hat] Proposal for bfloat16 Message-ID: <711031a5-df5f-4d25-a3c6-e247aeab1e04@openjdk.org> Changeset: dedbd84e Branch: code-reflection Author: Juan Fumero Date: 2025-12-03 16:46:22 +0000 URL: https://git.openjdk.org/babylon/commit/dedbd84edeed30a5e2b3993bc1c6aee43231340e [hat] Proposal for bfloat16 ! hat/backends/ffi/cuda/src/main/java/hat/backend/ffi/CudaHATKernelBuilder.java ! hat/backends/ffi/opencl/src/main/java/hat/backend/ffi/OpenCLHATKernelBuilder.java ! hat/backends/ffi/shared/src/main/java/hat/backend/ffi/C99FFIBackend.java ! hat/core/src/main/java/hat/BufferTagger.java + hat/core/src/main/java/hat/buffer/BF16.java + hat/core/src/main/java/hat/buffer/BF16Array.java ! hat/core/src/main/java/hat/buffer/F16.java = hat/core/src/main/java/hat/buffer/HAType.java ! hat/core/src/main/java/hat/codebuilders/BabylonOpBuilder.java ! hat/core/src/main/java/hat/codebuilders/C99HATKernelBuilder.java ! hat/core/src/main/java/hat/codebuilders/CodeBuilder.java ! hat/core/src/main/java/hat/codebuilders/HATCodeBuilder.java ! hat/core/src/main/java/hat/codebuilders/HATCodeBuilderWithContext.java ! hat/core/src/main/java/hat/dialect/HATF16AddOp.java ! hat/core/src/main/java/hat/dialect/HATF16BinaryOp.java ! hat/core/src/main/java/hat/dialect/HATF16ConvOp.java ! hat/core/src/main/java/hat/dialect/HATF16DivOp.java ! hat/core/src/main/java/hat/dialect/HATF16MulOp.java ! hat/core/src/main/java/hat/dialect/HATF16Op.java ! hat/core/src/main/java/hat/dialect/HATF16SubOp.java ! hat/core/src/main/java/hat/dialect/HATF16ToFloatConvOp.java ! hat/core/src/main/java/hat/dialect/HATF16VarOp.java ! hat/core/src/main/java/hat/dialect/HATPhaseUtils.java + hat/core/src/main/java/hat/dialect/ReducedFloatType.java ! hat/core/src/main/java/hat/optools/OpTk.java ! hat/core/src/main/java/hat/phases/HATDialect.java ! hat/core/src/main/java/hat/phases/HATDialectifyFP16Phase.java ! hat/core/src/main/java/hat/phases/HATDialectifyMemoryPhase.java ! hat/core/src/main/java/hat/phases/HATDialectifyVectorOpPhase.java ! hat/core/src/main/java/hat/phases/HATDialectifyVectorSelectPhase.java ! hat/core/src/main/java/hat/phases/HATDialectifyVectorStorePhase.java ! hat/core/src/main/java/hat/phases/HATFinalDetectionPhase.java ! hat/hat/test.java + hat/tests/src/main/java/hat/test/TestBFloat16Type.java ! hat/tests/src/main/java/hat/test/TestF16Type.java ! hat/tests/src/main/java/hat/test/TestMatMul.java ! hat/tools/src/main/java/hat/tools/text/JavaHATCodeBuilder.java From jfumero at openjdk.org Wed Dec 3 16:49:37 2025 From: jfumero at openjdk.org (Juan Fumero) Date: Wed, 3 Dec 2025 16:49:37 GMT Subject: [code-reflection] Integrated: [hat] Proposal for bfloat16 In-Reply-To: References: Message-ID: On Fri, 28 Nov 2025 15:18:43 GMT, Juan Fumero wrote: > This PR introduces the type [`bfloat16`](https://cloud.google.com/blog/products/ai-machine-learning/bfloat16-the-secret-to-high-performance-on-cloud-tpus) for HAT. > > Testing for OpenCL: > > > HAT=SHOW_CODE java -cp hat/job.jar hat.java test ffi-opencl hat.test.TestBFloat16Type > > > Testing for CUDA: > > > HAT=SHOW_CODE java -cp hat/job.jar hat.java test ffi-cuda hat.test.TestBFloat16Type > > > Some tests are expecting to fail due to precision error. We will need to improve the type conversion with round-to-nearest-even for example. This pull request has now been integrated. Changeset: dedbd84e Author: Juan Fumero URL: https://git.openjdk.org/babylon/commit/dedbd84edeed30a5e2b3993bc1c6aee43231340e Stats: 1848 lines in 37 files changed: 1611 ins; 126 del; 111 mod [hat] Proposal for bfloat16 ------------- PR: https://git.openjdk.org/babylon/pull/716 From mcimadamore at openjdk.org Wed Dec 3 17:47:37 2025 From: mcimadamore at openjdk.org (Maurizio Cimadamore) Date: Wed, 3 Dec 2025 17:47:37 GMT Subject: [code-reflection] RFR: Fix issues with local class creation from reflectable constructs Message-ID: Instantiation of local class from reflectable methods/lambdas is generally supported (although we do not support code reflection on local class members themselves). However, when testing I found there are many gaps in the current story: * existing support works or not depending on _where_ the local class is defined * when the local class to create contains its own captures, and the local class is inside a lambda expression, we just fail with `UnsupportedOperationException` (!!) * when a lambda tries to allocate a local class that was declared outside the lambda, the lambda code has no idea of which captures should come with the local class * when a lambda tries to allocate a regular member inner class with an implicit enclosing `this`, the lambda itself is not marked as capturing `this`, so model generation fails I addressed (I hope :-) ) all the above issues, and added several tests to check correctness. The main fix is to share the code to compute the local captures associated with a local class. We should compute such captures whenever we see a class declaration, both in `ReflectMethods` and in all its companion visitors -- otherwise the risk is that we will run some code that will require knowledge of the local class capture, but such knowledge is not available yet. ------------- Commit messages: - Only compute local var captures if not already computed - Initial push Changes: https://git.openjdk.org/babylon/pull/723/files Webrev: https://webrevs.openjdk.org/?repo=babylon&pr=723&range=00 Stats: 169 lines in 2 files changed: 147 ins; 17 del; 5 mod Patch: https://git.openjdk.org/babylon/pull/723.diff Fetch: git fetch https://git.openjdk.org/babylon.git pull/723/head:pull/723 PR: https://git.openjdk.org/babylon/pull/723 From gfrost at openjdk.org Wed Dec 3 19:01:49 2025 From: gfrost at openjdk.org (Gary Frost) Date: Wed, 3 Dec 2025 19:01:49 GMT Subject: [code-reflection] Integrated: Simplify C99 codegen Message-ID: <4P9yItOR2o9OMsxape0p3UC8prlQWkKK20xQFm7Rnfg=.e574c598-72c9-4be9-8437-e1c4c93bfe32@github.com> Some simplification of codegen by building common helpers. ------------- Commit messages: - Simplify C99 codegen Changes: https://git.openjdk.org/babylon/pull/724/files Webrev: https://webrevs.openjdk.org/?repo=babylon&pr=724&range=00 Stats: 115 lines in 6 files changed: 64 ins; 5 del; 46 mod Patch: https://git.openjdk.org/babylon/pull/724.diff Fetch: git fetch https://git.openjdk.org/babylon.git pull/724/head:pull/724 PR: https://git.openjdk.org/babylon/pull/724 From gfrost at openjdk.org Wed Dec 3 19:01:50 2025 From: gfrost at openjdk.org (Gary Frost) Date: Wed, 3 Dec 2025 19:01:50 GMT Subject: [code-reflection] Integrated: Simplify C99 codegen In-Reply-To: <4P9yItOR2o9OMsxape0p3UC8prlQWkKK20xQFm7Rnfg=.e574c598-72c9-4be9-8437-e1c4c93bfe32@github.com> References: <4P9yItOR2o9OMsxape0p3UC8prlQWkKK20xQFm7Rnfg=.e574c598-72c9-4be9-8437-e1c4c93bfe32@github.com> Message-ID: On Wed, 3 Dec 2025 18:55:23 GMT, Gary Frost wrote: > Some simplification of codegen by building common helpers. This pull request has now been integrated. Changeset: 398893b3 Author: Gary Frost URL: https://git.openjdk.org/babylon/commit/398893b37edab24e5da46acb2f76f6ebe1fe1f7a Stats: 115 lines in 6 files changed: 64 ins; 5 del; 46 mod Simplify C99 codegen ------------- PR: https://git.openjdk.org/babylon/pull/724 From psandoz at openjdk.org Wed Dec 3 19:01:26 2025 From: psandoz at openjdk.org (Paul Sandoz) Date: Wed, 3 Dec 2025 19:01:26 GMT Subject: [code-reflection] RFR: Fix issues with local class creation from reflectable constructs In-Reply-To: References: Message-ID: On Wed, 3 Dec 2025 17:42:11 GMT, Maurizio Cimadamore wrote: > Instantiation of local class from reflectable methods/lambdas is generally supported (although we do not support code reflection on local class members themselves). > > However, when testing I found there are many gaps in the current story: > > * existing support works or not depending on _where_ the local class is defined > * when the local class to create contains its own captures, and the local class is inside a lambda expression, we just fail with `UnsupportedOperationException` (!!) > * when a lambda tries to allocate a local class that was declared outside the lambda, the lambda code has no idea of which captures should come with the local class > * when a lambda tries to allocate a regular member inner class with an implicit enclosing `this`, the lambda itself is not marked as capturing `this`, so model generation fails > > I addressed (I hope :-) ) all the above issues, and added several tests to check correctness. > > The main fix is to share the code to compute the local captures associated with a local class. We should compute such captures whenever we see a class declaration, both in `ReflectMethods` and in all its companion visitors -- otherwise the risk is that we will run some code that will require knowledge of the local class capture, but such knowledge is not available yet. Looks good, nice tests. Marked as reviewed by psandoz (Lead). ------------- PR Review: https://git.openjdk.org/babylon/pull/723#pullrequestreview-3536476352 PR Review: https://git.openjdk.org/babylon/pull/723#pullrequestreview-3536477101 From gfrost at openjdk.org Wed Dec 3 19:04:48 2025 From: gfrost at openjdk.org (Gary Frost) Date: Wed, 3 Dec 2025 19:04:48 GMT Subject: git: openjdk/babylon: code-reflection: Simplify C99 codegen Message-ID: <24894afb-0474-4666-b154-5e58abd27fd0@openjdk.org> Changeset: 398893b3 Branch: code-reflection Author: Gary Frost Date: 2025-12-03 18:58:02 +0000 URL: https://git.openjdk.org/babylon/commit/398893b37edab24e5da46acb2f76f6ebe1fe1f7a Simplify C99 codegen ! hat/backends/ffi/opencl/src/main/java/hat/backend/ffi/OpenCLHATKernelBuilder.java ! hat/backends/ffi/shared/src/main/java/hat/backend/ffi/C99FFIBackend.java ! hat/core/src/main/java/hat/codebuilders/C99HATKernelBuilder.java ! hat/core/src/main/java/hat/codebuilders/CodeBuilder.java ! hat/core/src/main/java/hat/codebuilders/HATCodeBuilder.java ! hat/core/src/main/java/hat/codebuilders/HATCodeBuilderWithContext.java From duke at openjdk.org Wed Dec 3 20:31:59 2025 From: duke at openjdk.org (Ruby Chen) Date: Wed, 3 Dec 2025 20:31:59 GMT Subject: [code-reflection] RFR: ModuleOp generation from LambdaOp and FuncOp [v5] In-Reply-To: References: Message-ID: <2q5_UdNNOpwOFE7v3LV-8XnafOLnq1AueLk0urh2idk=.568636b9-655b-4202-9404-b1b8bc7fdeba@github.com> > Add support for generating a ModuleOp from either a LambdaOp or a FuncOp. The given LambdaOp will be converted into the root FuncOp, and the given FuncOp will be assigned as the root FuncOp. > > For `CoreOp.ModuleOp.ofLambdaOp()`, a unique name for the new root FuncOp must be passed as a parameter. Ruby Chen has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains eight additional commits since the last revision: - Add tests - Merge branch 'openjdk:code-reflection' into module-op-support - removing commented code - Suggested changes - Merge branch 'openjdk:code-reflection' into module-op-support - Merge branch 'openjdk:code-reflection' into module-op-support - Update src/jdk.incubator.code/share/classes/jdk/incubator/code/dialect/core/CoreOp.java Co-authored-by: Paul Sandoz - ModuleOp generation from LambdaOp and FuncOp ------------- Changes: - all: https://git.openjdk.org/babylon/pull/691/files - new: https://git.openjdk.org/babylon/pull/691/files/74910c50..ad4bc853 Webrevs: - full: https://webrevs.openjdk.org/?repo=babylon&pr=691&range=04 - incr: https://webrevs.openjdk.org/?repo=babylon&pr=691&range=03-04 Stats: 4533 lines in 93 files changed: 3503 ins; 669 del; 361 mod Patch: https://git.openjdk.org/babylon/pull/691.diff Fetch: git fetch https://git.openjdk.org/babylon.git pull/691/head:pull/691 PR: https://git.openjdk.org/babylon/pull/691 From mcimadamore at openjdk.org Wed Dec 3 22:14:50 2025 From: mcimadamore at openjdk.org (Maurizio Cimadamore) Date: Wed, 3 Dec 2025 22:14:50 GMT Subject: git: openjdk/babylon: code-reflection: Fix issues with local class creation from reflectable constructs Message-ID: Changeset: eff881e1 Branch: code-reflection Author: Maurizio Cimadamore Date: 2025-12-03 22:13:57 +0000 URL: https://git.openjdk.org/babylon/commit/eff881e1f9c145823340f01e30d1262db94122e4 Fix issues with local class creation from reflectable constructs Reviewed-by: psandoz ! src/jdk.incubator.code/share/classes/jdk/incubator/code/internal/ReflectMethods.java ! test/langtools/tools/javac/reflect/LocalClassTest.java From mcimadamore at openjdk.org Wed Dec 3 22:16:27 2025 From: mcimadamore at openjdk.org (Maurizio Cimadamore) Date: Wed, 3 Dec 2025 22:16:27 GMT Subject: [code-reflection] Integrated: Fix issues with local class creation from reflectable constructs In-Reply-To: References: Message-ID: On Wed, 3 Dec 2025 17:42:11 GMT, Maurizio Cimadamore wrote: > Instantiation of local class from reflectable methods/lambdas is generally supported (although we do not support code reflection on local class members themselves). > > However, when testing I found there are many gaps in the current story: > > * existing support works or not depending on _where_ the local class is defined > * when the local class to create contains its own captures, and the local class is inside a lambda expression, we just fail with `UnsupportedOperationException` (!!) > * when a lambda tries to allocate a local class that was declared outside the lambda, the lambda code has no idea of which captures should come with the local class > * when a lambda tries to allocate a regular member inner class with an implicit enclosing `this`, the lambda itself is not marked as capturing `this`, so model generation fails > > I addressed (I hope :-) ) all the above issues, and added several tests to check correctness. > > The main fix is to share the code to compute the local captures associated with a local class. We should compute such captures whenever we see a class declaration, both in `ReflectMethods` and in all its companion visitors -- otherwise the risk is that we will run some code that will require knowledge of the local class capture, but such knowledge is not available yet. This pull request has now been integrated. Changeset: eff881e1 Author: Maurizio Cimadamore URL: https://git.openjdk.org/babylon/commit/eff881e1f9c145823340f01e30d1262db94122e4 Stats: 169 lines in 2 files changed: 147 ins; 17 del; 5 mod Fix issues with local class creation from reflectable constructs Reviewed-by: psandoz ------------- PR: https://git.openjdk.org/babylon/pull/723 From jfumero at openjdk.org Thu Dec 4 10:02:46 2025 From: jfumero at openjdk.org (Juan Fumero) Date: Thu, 4 Dec 2025 10:02:46 GMT Subject: [code-reflection] RFR: [hat] bfloat16 codegen for C99 conversion fixed Message-ID: [hat] bfloat16 codegen for C99 conversion fixed ------------- Commit messages: - [hat] bfloat16 codegen for C99 conversion fixed Changes: https://git.openjdk.org/babylon/pull/725/files Webrev: https://webrevs.openjdk.org/?repo=babylon&pr=725&range=00 Stats: 1 line in 1 file changed: 0 ins; 0 del; 1 mod Patch: https://git.openjdk.org/babylon/pull/725.diff Fetch: git fetch https://git.openjdk.org/babylon.git pull/725/head:pull/725 PR: https://git.openjdk.org/babylon/pull/725 From jfumero at openjdk.org Thu Dec 4 10:07:34 2025 From: jfumero at openjdk.org (Juan Fumero) Date: Thu, 4 Dec 2025 10:07:34 GMT Subject: [code-reflection] Integrated: [hat] bfloat16 codegen for C99 conversion fixed In-Reply-To: References: Message-ID: <4Jt1T62wX9C-xKqLqExIdO8YV4sgIkHvgA07Ffb3d4A=.002ca1be-2784-499f-a952-d9e68d346838@github.com> On Thu, 4 Dec 2025 09:57:53 GMT, Juan Fumero wrote: > [hat] bfloat16 codegen for C99 conversion fixed This pull request has now been integrated. Changeset: d5fff759 Author: Juan Fumero URL: https://git.openjdk.org/babylon/commit/d5fff759a1257af70d648e3ae006edb3a39ed63d Stats: 1 line in 1 file changed: 0 ins; 0 del; 1 mod [hat] bfloat16 codegen for C99 conversion fixed ------------- PR: https://git.openjdk.org/babylon/pull/725 From jfumero at openjdk.org Thu Dec 4 10:08:39 2025 From: jfumero at openjdk.org (Juan Fumero) Date: Thu, 4 Dec 2025 10:08:39 GMT Subject: git: openjdk/babylon: code-reflection: [hat] bfloat16 codegen for C99 conversion fixed Message-ID: <50162458-30e4-4f28-a7da-7ff9f3f62b51@openjdk.org> Changeset: d5fff759 Branch: code-reflection Author: Juan Fumero Date: 2025-12-04 10:04:24 +0000 URL: https://git.openjdk.org/babylon/commit/d5fff759a1257af70d648e3ae006edb3a39ed63d [hat] bfloat16 codegen for C99 conversion fixed ! hat/core/src/main/java/hat/codebuilders/HATCodeBuilder.java From asotona at openjdk.org Thu Dec 4 13:27:56 2025 From: asotona at openjdk.org (Adam Sotona) Date: Thu, 4 Dec 2025 13:27:56 GMT Subject: [code-reflection] RFR: BytecodeGenerator cleanup and switch support [v14] In-Reply-To: References: Message-ID: > The current `BytecodeGenerator` implementation assumes that code models have already been lowered before generation. Both `SwitchExpressionOp` and `SwitchStatementOp` with all-constant labels are examples of operations that can be lowered an alternative way, allowing `BytecodeGenerator` to produce more efficient bytecode using `tableswitch` and `lookupswitch` instructions. > > The proposed change shifts the responsibility for lowering these operations into the `BytecodeGenerator` itself, enabling selective lowering during bytecode generation. Consequently, `OpBuilder` and `BytecodeGenerator` tests have been updated to avoid invoking the lower transformation step before the `BytecodeGenerator` is called. > > A new internal operation, `ConstantLabelSwitchOp`, has been introduced. This acts as an intermediate representation for lowered `SwitchExpressionOp` and `SwitchStatementOp` instances with constant labels. > > Lowering of `SwitchExpressionOp` and `SwitchStatementOp` into `ConstantLabelSwitchOp` is also a part of this PR. > > Lowering of `BreakOp`, `SwitchFallthroughOp` and nested switches will be implemented in a follow-up PR. > > This PR also makes minor refinements to the BytecodeGenerator post-processing transformations. Adam Sotona has updated the pull request incrementally with two additional commits since the last revision: - Merge remote-tracking branch 'asotona/bytecodegenerator-cleanup' into bytecodegenerator-cleanup - Fix JavaSwitchOp.lower to correctly lower regardless of where default case appears ------------- Changes: - all: https://git.openjdk.org/babylon/pull/706/files - new: https://git.openjdk.org/babylon/pull/706/files/811f061a..82c75258 Webrevs: - full: https://webrevs.openjdk.org/?repo=babylon&pr=706&range=13 - incr: https://webrevs.openjdk.org/?repo=babylon&pr=706&range=12-13 Stats: 105 lines in 1 file changed: 65 ins; 32 del; 8 mod Patch: https://git.openjdk.org/babylon/pull/706.diff Fetch: git fetch https://git.openjdk.org/babylon.git pull/706/head:pull/706 PR: https://git.openjdk.org/babylon/pull/706 From mcimadamore at openjdk.org Thu Dec 4 13:43:47 2025 From: mcimadamore at openjdk.org (Maurizio Cimadamore) Date: Thu, 4 Dec 2025 13:43:47 GMT Subject: [code-reflection] RFR: Make @Reflect a use-site annotation Message-ID: In the current iteration of compiler support there are two ways to make a lambda reflectable: 1. cast the lambda to a type that is annotated with the `@Reflect` annotation (use-site) 2. pass the lambda to a functional interface whose declaration is annotated with `@Reflect` (decl-site) While (2) is handy in cases where the library wants to control reflectability of the lambdas it receives, this model is too weak and insecure, as it might lead to unknowing clients exposing private impl details with frameworks using code reflection. For this reason, we have revamped the `@Reflect` annotation to control, at the use-site, which program elements should support code reflection: * If a method is annotated with `@Reflect`, the method itself is reflectable, and all the lambdas it contains are reflectable; * If a field/local variable is annotated with `@Reflect`, all the lambdas that occur inside the initializer (if present), are reflectable; * If a cast type is annotated with `@Reflect` and the cast is applied to a lambda expression, that lambda expression is reflectable (this is the same as (1) above). This means it's no longer possible for a library to create a reflectable functional interface, like: @Reflect interface ReflectableRunnable extends Runnable { } And unilaterally decide, for _all_ clients whether their lambdas should be reflectable. To be clear, this is **not** how things will work longer term, but it's an interim step which provides the desired level of safety w/o requiring the additional language features. I've fixed all tests. I've tried to simplify both javac and JDK tests by dropping redundant functional interface declarations. I also fixed all the samples; for ONNX some tweaks were done, and I've decided to drop the OnnxFunction -- and to use a supplier instead. But if that's not desirable I can change back (or it can be changed back later). I also fixed HAT tests -- in that case it was a bit trickier, as there's lots of tests that end up passing reflectable lambdas to the HAT's compute method. Luckily, all these tests are annotated with `@HatTest`, so I've simply added an extra `@Reflect` to any such test method. Since `@Reflect` now propagates to the body, this guarantees that all the lambdas inside these test methods are treated as reflectable. Of course these HAT change end up enabling reflection for a lot more than it's required. I'll leave it to people more expert with HAT to clean that up, if needed. In the meantime, it was useful to run in this mode, as that uncovered 2 separate issues in the compiler support, one in this PR (default methods were no longer being treated as reflectable) and another pre-existing (compiler crashed when encountering package names in qualified names). ------------- Commit messages: - Fix diags - Fix hat tests - Fix tests - Merge branch 'code-reflection' into better_annos - Initial push - Initial push Changes: https://git.openjdk.org/babylon/pull/726/files Webrev: https://webrevs.openjdk.org/?repo=babylon&pr=726&range=00 Stats: 981 lines in 52 files changed: 281 ins; 575 del; 125 mod Patch: https://git.openjdk.org/babylon/pull/726.diff Fetch: git fetch https://git.openjdk.org/babylon.git pull/726/head:pull/726 PR: https://git.openjdk.org/babylon/pull/726 From mcimadamore at openjdk.org Thu Dec 4 13:43:52 2025 From: mcimadamore at openjdk.org (Maurizio Cimadamore) Date: Thu, 4 Dec 2025 13:43:52 GMT Subject: [code-reflection] RFR: Make @Reflect a use-site annotation In-Reply-To: References: Message-ID: On Thu, 4 Dec 2025 13:27:57 GMT, Maurizio Cimadamore wrote: > In the current iteration of compiler support there are two ways to make a lambda reflectable: > 1. cast the lambda to a type that is annotated with the `@Reflect` annotation (use-site) > 2. pass the lambda to a functional interface whose declaration is annotated with `@Reflect` (decl-site) > > While (2) is handy in cases where the library wants to control reflectability of the lambdas it receives, this model is too weak and insecure, as it might lead to unknowing clients exposing private impl details with frameworks using code reflection. > > For this reason, we have revamped the `@Reflect` annotation to control, at the use-site, which program elements should support code reflection: > > * If a method is annotated with `@Reflect`, the method itself is reflectable, and all the lambdas it contains are reflectable; > * If a field/local variable is annotated with `@Reflect`, all the lambdas that occur inside the initializer (if present), are reflectable; > * If a cast type is annotated with `@Reflect` and the cast is applied to a lambda expression, that lambda expression is reflectable (this is the same as (1) above). > > This means it's no longer possible for a library to create a reflectable functional interface, like: > > > @Reflect > interface ReflectableRunnable extends Runnable { } > > > And unilaterally decide, for _all_ clients whether their lambdas should be reflectable. > > To be clear, this is **not** how things will work longer term, but it's an interim step which provides the desired level of safety w/o requiring the additional language features. > > I've fixed all tests. I've tried to simplify both javac and JDK tests by dropping redundant functional interface declarations. > > I also fixed all the samples; for ONNX some tweaks were done, and I've decided to drop the OnnxFunction -- and to use a supplier instead. But if that's not desirable I can change back (or it can be changed back later). > > I also fixed HAT tests -- in that case it was a bit trickier, as there's lots of tests that end up passing reflectable lambdas to the HAT's compute method. Luckily, all these tests are annotated with `@HatTest`, so I've simply added an extra `@Reflect` to any such test method. Since `@Reflect` now propagates to the body, this guarantees that all the lambdas inside these test methods are treated as reflectable. > > Of course these HAT change end up enabling reflection for a lot more than it's required. I'll leave it to people more expert with HAT to clean that up, if needed. > In the meantime, it was ... src/jdk.incubator.code/share/classes/jdk/incubator/code/Reflect.java line 32: > 30: > 31: /** > 32: * A program element annotated with this annotation enables code reflection in the annotated program element, I've tried to describe a bit more formally how the annotation is supposed to behave -- @PaulSandoz please take a look. src/jdk.incubator.code/share/classes/jdk/incubator/code/Reflect.java line 49: > 47: * > 48: */ > 49: @Target({ElementType.LOCAL_VARIABLE, ElementType.FIELD, One thing I realized: when we made this a type annotation, now you can also use `@Reflect` on classes and constructors as well -- because in those cases the annotation is reinterpreted as a type annotation (ugly, I know) -- and so it will be silently ignored. One alternative would be to drop the annotated cast and just rely on local variable decl annotations, but I didn't want to go there w/o first asking. src/jdk.incubator.code/share/classes/jdk/incubator/code/internal/ReflectMethods.java line 330: > 328: if (currentClassSym.type.getEnclosingType().hasTag(CLASS)) { > 329: // Reflectable method references in local classes are not supported > 330: log.warning(tree, ReflectableMrefInnerClass(currentClassSym.enclClass())); Note: this is no longer an error -- otherwise we'd get errors for any reflectable method that contains local classes with some methods. src/jdk.incubator.code/share/classes/jdk/incubator/code/internal/ReflectMethods.java line 1036: > 1034: } > 1035: } > 1036: case PACKAGE, INTERFACE, CLASS, RECORD, ENUM -> { This is a pre-existing issue -- e.g. calling `println` with a fully qualified name, like `java.lang.System.out.println` causes an exception, because we eventually visit `java` and `java.lang` which are packages src/jdk.incubator.code/share/classes/jdk/incubator/code/internal/ReflectMethods.java line 1499: > 1497: JavaType fiType = typeToTypeElement(tree.target); > 1498: // build functional lambda > 1499: Op lambdaOp = JavaOp.lambda(fiType, stack.body, true); Note: now _all_ lambdas we encounter when scanning a reflectable body are (by definition) quotable. This means that in several tests, the `isQuotable` attribute now shows up as `true` everywhere. And, in the JDK bytecode tests there is no longer a way to test that support for non-reflectable lambdas works correctly (so I dropped some tests there). test/jdk/java/lang/reflect/code/bytecode/lift/TestBytecodeLift.java line 372: > 370: } > 371: > 372: static int consumeQuotable(int i, IntUnaryOperator f) { Note: all lambdas nested inside a `@Reflect` method are reflectable now, so it's no longer possible (I think) to test lifting of non-reflectable lambdas. ------------- PR Review Comment: https://git.openjdk.org/babylon/pull/726#discussion_r2589109180 PR Review Comment: https://git.openjdk.org/babylon/pull/726#discussion_r2589116428 PR Review Comment: https://git.openjdk.org/babylon/pull/726#discussion_r2589120431 PR Review Comment: https://git.openjdk.org/babylon/pull/726#discussion_r2589097043 PR Review Comment: https://git.openjdk.org/babylon/pull/726#discussion_r2589126947 PR Review Comment: https://git.openjdk.org/babylon/pull/726#discussion_r2589130474 From asotona at openjdk.org Thu Dec 4 14:22:40 2025 From: asotona at openjdk.org (Adam Sotona) Date: Thu, 4 Dec 2025 14:22:40 GMT Subject: [code-reflection] RFR: BytecodeGenerator cleanup and switch support [v14] In-Reply-To: References: Message-ID: On Thu, 4 Dec 2025 13:27:56 GMT, Adam Sotona wrote: >> The current `BytecodeGenerator` implementation assumes that code models have already been lowered before generation. Both `SwitchExpressionOp` and `SwitchStatementOp` with all-constant labels are examples of operations that can be lowered an alternative way, allowing `BytecodeGenerator` to produce more efficient bytecode using `tableswitch` and `lookupswitch` instructions. >> >> The proposed change shifts the responsibility for lowering these operations into the `BytecodeGenerator` itself, enabling selective lowering during bytecode generation. Consequently, `OpBuilder` and `BytecodeGenerator` tests have been updated to avoid invoking the lower transformation step before the `BytecodeGenerator` is called. >> >> A new internal operation, `ConstantLabelSwitchOp`, has been introduced. This acts as an intermediate representation for lowered `SwitchExpressionOp` and `SwitchStatementOp` instances with constant labels. >> >> Lowering of `SwitchExpressionOp` and `SwitchStatementOp` into `ConstantLabelSwitchOp` is also a part of this PR. >> >> Lowering of `BreakOp`, `SwitchFallthroughOp` and nested switches will be implemented in a follow-up PR. >> >> This PR also makes minor refinements to the BytecodeGenerator post-processing transformations. > > Adam Sotona has updated the pull request incrementally with two additional commits since the last revision: > > - Merge remote-tracking branch 'asotona/bytecodegenerator-cleanup' into bytecodegenerator-cleanup > - Fix JavaSwitchOp.lower to correctly lower regardless of where default case appears @mabbay Nice fix of the default case lowering. @mcimadamore I think the detection of the default case body by the constant `true` is good enough for now and we may refine it later as needed (either by a custom `DefaultLabelOp`, or by storing its index into an attribute, or any other way). ------------- PR Comment: https://git.openjdk.org/babylon/pull/706#issuecomment-3612492347 From asotona at openjdk.org Thu Dec 4 14:26:57 2025 From: asotona at openjdk.org (Adam Sotona) Date: Thu, 4 Dec 2025 14:26:57 GMT Subject: [code-reflection] RFR: BytecodeGenerator cleanup and switch support [v14] In-Reply-To: References: Message-ID: On Thu, 4 Dec 2025 13:27:56 GMT, Adam Sotona wrote: >> The current `BytecodeGenerator` implementation assumes that code models have already been lowered before generation. Both `SwitchExpressionOp` and `SwitchStatementOp` with all-constant labels are examples of operations that can be lowered an alternative way, allowing `BytecodeGenerator` to produce more efficient bytecode using `tableswitch` and `lookupswitch` instructions. >> >> The proposed change shifts the responsibility for lowering these operations into the `BytecodeGenerator` itself, enabling selective lowering during bytecode generation. Consequently, `OpBuilder` and `BytecodeGenerator` tests have been updated to avoid invoking the lower transformation step before the `BytecodeGenerator` is called. >> >> A new internal operation, `ConstantLabelSwitchOp`, has been introduced. This acts as an intermediate representation for lowered `SwitchExpressionOp` and `SwitchStatementOp` instances with constant labels. >> >> Lowering of `SwitchExpressionOp` and `SwitchStatementOp` into `ConstantLabelSwitchOp` is also a part of this PR. >> >> Lowering of `BreakOp`, `SwitchFallthroughOp` and nested switches will be implemented in a follow-up PR. >> >> This PR also makes minor refinements to the BytecodeGenerator post-processing transformations. > > Adam Sotona has updated the pull request incrementally with two additional commits since the last revision: > > - Merge remote-tracking branch 'asotona/bytecodegenerator-cleanup' into bytecodegenerator-cleanup > - Fix JavaSwitchOp.lower to correctly lower regardless of where default case appears src/jdk.incubator.code/share/classes/jdk/incubator/code/dialect/java/JavaOp.java line 2846: > 2844: > 2845: for (int i = 0; i < bodies().size(); i+=2) { > 2846: if (i == defLabelIndex) { I was thinking this would break the physical body blocks order, however they are allocated early and the order is correct. ------------- PR Review Comment: https://git.openjdk.org/babylon/pull/706#discussion_r2589292172 From asotona at openjdk.org Thu Dec 4 15:02:43 2025 From: asotona at openjdk.org (Adam Sotona) Date: Thu, 4 Dec 2025 15:02:43 GMT Subject: [code-reflection] RFR: BytecodeGenerator cleanup and switch support [v14] In-Reply-To: References: Message-ID: On Thu, 4 Dec 2025 13:27:56 GMT, Adam Sotona wrote: >> The current `BytecodeGenerator` implementation assumes that code models have already been lowered before generation. Both `SwitchExpressionOp` and `SwitchStatementOp` with all-constant labels are examples of operations that can be lowered an alternative way, allowing `BytecodeGenerator` to produce more efficient bytecode using `tableswitch` and `lookupswitch` instructions. >> >> The proposed change shifts the responsibility for lowering these operations into the `BytecodeGenerator` itself, enabling selective lowering during bytecode generation. Consequently, `OpBuilder` and `BytecodeGenerator` tests have been updated to avoid invoking the lower transformation step before the `BytecodeGenerator` is called. >> >> A new internal operation, `ConstantLabelSwitchOp`, has been introduced. This acts as an intermediate representation for lowered `SwitchExpressionOp` and `SwitchStatementOp` instances with constant labels. >> >> Lowering of `SwitchExpressionOp` and `SwitchStatementOp` into `ConstantLabelSwitchOp` is also a part of this PR. >> >> Lowering of `BreakOp`, `SwitchFallthroughOp` and nested switches has been implemented in this PR. >> >> The PR also fixes standard lowering of `SwitchStatementOp` with default case fall-through. >> >> This PR also makes minor refinements to the BytecodeGenerator post-processing transformations. > > Adam Sotona has updated the pull request incrementally with two additional commits since the last revision: > > - Merge remote-tracking branch 'asotona/bytecodegenerator-cleanup' into bytecodegenerator-cleanup > - Fix JavaSwitchOp.lower to correctly lower regardless of where default case appears Thank you for all the reviews. Unresolved comments will be solved in a follow-up PR. ------------- PR Comment: https://git.openjdk.org/babylon/pull/706#issuecomment-3612669716 From gfrost at openjdk.org Thu Dec 4 15:10:18 2025 From: gfrost at openjdk.org (Gary Frost) Date: Thu, 4 Dec 2025 15:10:18 GMT Subject: git: openjdk/babylon: code-reflection: 2 new changesets Message-ID: <0bf2b10f-53c2-4c08-b9b6-b57ebdd9f63e@openjdk.org> Changeset: 832efca9 Branch: code-reflection Author: Adam Sotona Date: 2025-12-04 15:07:10 +0000 URL: https://git.openjdk.org/babylon/commit/832efca9d9e2769118226c532af5e2fc17eb8ba5 BytecodeGenerator cleanup and switch support Co-authored-by: Mourad Abbay ! src/jdk.incubator.code/share/classes/jdk/incubator/code/bytecode/BytecodeGenerator.java + src/jdk.incubator.code/share/classes/jdk/incubator/code/bytecode/impl/ConstantLabelSwitchOp.java + src/jdk.incubator.code/share/classes/jdk/incubator/code/bytecode/impl/ExceptionTableCompactor.java ! src/jdk.incubator.code/share/classes/jdk/incubator/code/bytecode/impl/LocalsCompactor.java + src/jdk.incubator.code/share/classes/jdk/incubator/code/bytecode/impl/LoweringTransform.java ! src/jdk.incubator.code/share/classes/jdk/incubator/code/dialect/java/JavaOp.java + src/jdk.incubator.code/share/classes/jdk/incubator/code/internal/BranchTarget.java ! src/jdk.incubator.code/share/classes/jdk/incubator/code/internal/OpBuilder.java ! src/jdk.incubator.code/share/classes/jdk/incubator/code/internal/ReflectMethods.java ! test/jdk/java/lang/reflect/code/bytecode/TestArrayCreation.java ! test/jdk/java/lang/reflect/code/bytecode/TestBytecode.java ! test/jdk/java/lang/reflect/code/bytecode/TestInvokeSuper.java + test/jdk/java/lang/reflect/code/bytecode/TestIsCaseConstantSwitch.java ! test/jdk/java/lang/reflect/code/bytecode/TestNestedCapturingLambda.java ! test/jdk/java/lang/reflect/code/bytecode/TestSlots.java + test/jdk/java/lang/reflect/code/bytecode/TestSwitch.java ! test/jdk/java/lang/reflect/code/bytecode/TestSynchronizedOp.java ! test/jdk/java/lang/reflect/code/bytecode/TestTry.java ! test/jdk/java/lang/reflect/code/bytecode/TestTryFinally.java ! test/jdk/java/lang/reflect/code/bytecode/TestTryFinallyNested.java ! test/jdk/java/lang/reflect/code/bytecode/TestVarArg.java ! test/jdk/java/lang/reflect/code/writer/TestCodeBuilder.java ! test/langtools/tools/javac/reflect/SwitchExpressionTest2.java ! test/langtools/tools/javac/reflect/SwitchStatementTest.java Changeset: 2a5d7e13 Branch: code-reflection Author: Gary Frost Date: 2025-12-04 15:09:10 +0000 URL: https://git.openjdk.org/babylon/commit/2a5d7e1387f21c62f5b0861cbf52c3cd7a5f1040 Job builder was dropping javac jvmopts ! hat/env.bash ! hat/hat/job.jar ! hat/hat/job/src/main/java/job/Jar.java From asotona at openjdk.org Thu Dec 4 15:12:46 2025 From: asotona at openjdk.org (Adam Sotona) Date: Thu, 4 Dec 2025 15:12:46 GMT Subject: [code-reflection] Integrated: BytecodeGenerator cleanup and switch support In-Reply-To: References: Message-ID: On Tue, 25 Nov 2025 14:23:19 GMT, Adam Sotona wrote: > The current `BytecodeGenerator` implementation assumes that code models have already been lowered before generation. Both `SwitchExpressionOp` and `SwitchStatementOp` with all-constant labels are examples of operations that can be lowered an alternative way, allowing `BytecodeGenerator` to produce more efficient bytecode using `tableswitch` and `lookupswitch` instructions. > > The proposed change shifts the responsibility for lowering these operations into the `BytecodeGenerator` itself, enabling selective lowering during bytecode generation. Consequently, `OpBuilder` and `BytecodeGenerator` tests have been updated to avoid invoking the lower transformation step before the `BytecodeGenerator` is called. > > A new internal operation, `ConstantLabelSwitchOp`, has been introduced. This acts as an intermediate representation for lowered `SwitchExpressionOp` and `SwitchStatementOp` instances with constant labels. > > Lowering of `SwitchExpressionOp` and `SwitchStatementOp` into `ConstantLabelSwitchOp` is also a part of this PR. > > Lowering of `BreakOp`, `SwitchFallthroughOp` and nested switches has been implemented in this PR. > > The PR also fixes standard lowering of `SwitchStatementOp` with default case fall-through. > > This PR also makes minor refinements to the BytecodeGenerator post-processing transformations. This pull request has now been integrated. Changeset: 832efca9 Author: Adam Sotona URL: https://git.openjdk.org/babylon/commit/832efca9d9e2769118226c532af5e2fc17eb8ba5 Stats: 1428 lines in 24 files changed: 1170 ins; 176 del; 82 mod BytecodeGenerator cleanup and switch support Co-authored-by: Mourad Abbay ------------- PR: https://git.openjdk.org/babylon/pull/706 From gfrost at openjdk.org Thu Dec 4 15:13:01 2025 From: gfrost at openjdk.org (Gary Frost) Date: Thu, 4 Dec 2025 15:13:01 GMT Subject: [code-reflection] Integrated: Job builder was dropping javac jvmopts Message-ID: env.bash was pointing to exploded image rather than image. We also had a job bldr bug. job bldr was collecting the javac opts but then sadly discarding them . So when pointing to exploded image this was fine., but when we pointed to the images/jdk we failed to compile code using jdk.incubator.code becuase we had dropped --modules=jdk.incudbator.code option ------------- Commit messages: - Job builder was dropping javac jvmopts Changes: https://git.openjdk.org/babylon/pull/727/files Webrev: https://webrevs.openjdk.org/?repo=babylon&pr=727&range=00 Stats: 18 lines in 3 files changed: 5 ins; 8 del; 5 mod Patch: https://git.openjdk.org/babylon/pull/727.diff Fetch: git fetch https://git.openjdk.org/babylon.git pull/727/head:pull/727 PR: https://git.openjdk.org/babylon/pull/727 From gfrost at openjdk.org Thu Dec 4 15:13:03 2025 From: gfrost at openjdk.org (Gary Frost) Date: Thu, 4 Dec 2025 15:13:03 GMT Subject: [code-reflection] Integrated: Job builder was dropping javac jvmopts In-Reply-To: References: Message-ID: On Thu, 4 Dec 2025 14:48:46 GMT, Gary Frost wrote: > env.bash was pointing to exploded image rather than image. > > We also had a job bldr bug. > > job bldr was collecting the javac opts but then sadly discarding them . > > So when pointing to exploded image this was fine., but when we pointed to the images/jdk we failed to compile code using jdk.incubator.code becuase we had dropped --modules=jdk.incudbator.code option This pull request has now been integrated. Changeset: 2a5d7e13 Author: Gary Frost URL: https://git.openjdk.org/babylon/commit/2a5d7e1387f21c62f5b0861cbf52c3cd7a5f1040 Stats: 18 lines in 3 files changed: 5 ins; 8 del; 5 mod Job builder was dropping javac jvmopts ------------- PR: https://git.openjdk.org/babylon/pull/727 From psandoz at openjdk.org Thu Dec 4 18:48:08 2025 From: psandoz at openjdk.org (Paul Sandoz) Date: Thu, 4 Dec 2025 18:48:08 GMT Subject: [code-reflection] RFR: Make @Reflect a use-site annotation In-Reply-To: References: Message-ID: <_XMkvZTvpBA16m9VtdVDAdh-wgDKU5arIQNnG0NaxXc=.df17569f-167d-4c35-ac0a-4e97679c139a@github.com> On Thu, 4 Dec 2025 13:27:57 GMT, Maurizio Cimadamore wrote: > In the current iteration of compiler support there are two ways to make a lambda reflectable: > 1. cast the lambda to a type that is annotated with the `@Reflect` annotation (use-site) > 2. pass the lambda to a functional interface whose declaration is annotated with `@Reflect` (decl-site) > > While (2) is handy in cases where the library wants to control reflectability of the lambdas it receives, this model is too weak and insecure, as it might lead to unknowing clients exposing private impl details with frameworks using code reflection. > > For this reason, we have revamped the `@Reflect` annotation to control, at the use-site, which program elements should support code reflection: > > * If a method is annotated with `@Reflect`, the method itself is reflectable, and all the lambdas it contains are reflectable; > * If a field/local variable is annotated with `@Reflect`, all the lambdas that occur inside the initializer (if present), are reflectable; > * If a cast type is annotated with `@Reflect` and the cast is applied to a lambda expression, that lambda expression is reflectable (this is the same as (1) above). > > This means it's no longer possible for a library to create a reflectable functional interface, like: > > > @Reflect > interface ReflectableRunnable extends Runnable { } > > > And unilaterally decide, for _all_ clients whether their lambdas should be reflectable. > > To be clear, this is **not** how things will work longer term, but it's an interim step which provides the desired level of safety w/o requiring the additional language features. > > I've fixed all tests. I've tried to simplify both javac and JDK tests by dropping redundant functional interface declarations. > > I also fixed all the samples; for ONNX some tweaks were done, and I've decided to drop the OnnxFunction -- and to use a supplier instead. But if that's not desirable I can change back (or it can be changed back later). > > I also fixed HAT tests -- in that case it was a bit trickier, as there's lots of tests that end up passing reflectable lambdas to the HAT's compute method. Luckily, all these tests are annotated with `@HatTest`, so I've simply added an extra `@Reflect` to any such test method. Since `@Reflect` now propagates to the body, this guarantees that all the lambdas inside these test methods are treated as reflectable. > > Of course these HAT change end up enabling reflection for a lot more than it's required. I'll leave it to people more expert with HAT to clean that up, if needed. > In the meantime, it was ... Very good simplification for the initial mechanism to declare reflectable methods and lambdas. The HAT examples need updating to declare the compute lambda as reflectable. I recommend using a cast for al these, and we can deal with the specialized interface later on if need be. src/jdk.incubator.code/share/classes/jdk/incubator/code/Reflect.java line 43: > 41: *
  • When a method is annotated with this annotation, the method becomes reflectable, and all the lambda expressions > 42: * and method references enclosed in it also become reflectable.
  • > 43: *
  • When a variable declaration (a field, or a local variable) is annotated with this annotation, all the methods, lambda expressions What does it mean "all the methods" in the context of an initializer expression? ------------- PR Review: https://git.openjdk.org/babylon/pull/726#pullrequestreview-3541427985 PR Review Comment: https://git.openjdk.org/babylon/pull/726#discussion_r2590172871 From psandoz at openjdk.org Thu Dec 4 18:48:11 2025 From: psandoz at openjdk.org (Paul Sandoz) Date: Thu, 4 Dec 2025 18:48:11 GMT Subject: [code-reflection] RFR: Make @Reflect a use-site annotation In-Reply-To: References: Message-ID: On Thu, 4 Dec 2025 13:39:06 GMT, Maurizio Cimadamore wrote: >> In the current iteration of compiler support there are two ways to make a lambda reflectable: >> 1. cast the lambda to a type that is annotated with the `@Reflect` annotation (use-site) >> 2. pass the lambda to a functional interface whose declaration is annotated with `@Reflect` (decl-site) >> >> While (2) is handy in cases where the library wants to control reflectability of the lambdas it receives, this model is too weak and insecure, as it might lead to unknowing clients exposing private impl details with frameworks using code reflection. >> >> For this reason, we have revamped the `@Reflect` annotation to control, at the use-site, which program elements should support code reflection: >> >> * If a method is annotated with `@Reflect`, the method itself is reflectable, and all the lambdas it contains are reflectable; >> * If a field/local variable is annotated with `@Reflect`, all the lambdas that occur inside the initializer (if present), are reflectable; >> * If a cast type is annotated with `@Reflect` and the cast is applied to a lambda expression, that lambda expression is reflectable (this is the same as (1) above). >> >> This means it's no longer possible for a library to create a reflectable functional interface, like: >> >> >> @Reflect >> interface ReflectableRunnable extends Runnable { } >> >> >> And unilaterally decide, for _all_ clients whether their lambdas should be reflectable. >> >> To be clear, this is **not** how things will work longer term, but it's an interim step which provides the desired level of safety w/o requiring the additional language features. >> >> I've fixed all tests. I've tried to simplify both javac and JDK tests by dropping redundant functional interface declarations. >> >> I also fixed all the samples; for ONNX some tweaks were done, and I've decided to drop the OnnxFunction -- and to use a supplier instead. But if that's not desirable I can change back (or it can be changed back later). >> >> I also fixed HAT tests -- in that case it was a bit trickier, as there's lots of tests that end up passing reflectable lambdas to the HAT's compute method. Luckily, all these tests are annotated with `@HatTest`, so I've simply added an extra `@Reflect` to any such test method. Since `@Reflect` now propagates to the body, this guarantees that all the lambdas inside these test methods are treated as reflectable. >> >> Of course these HAT change end up enabling reflection for a lot more than it's required. I'll leave it to people more expert wi... > > src/jdk.incubator.code/share/classes/jdk/incubator/code/internal/ReflectMethods.java line 1499: > >> 1497: JavaType fiType = typeToTypeElement(tree.target); >> 1498: // build functional lambda >> 1499: Op lambdaOp = JavaOp.lambda(fiType, stack.body, true); > > Note: now _all_ lambdas we encounter when scanning a reflectable body are (by definition) quotable. This means that in several tests, the `isQuotable` attribute now shows up as `true` everywhere. And, in the JDK bytecode tests there is no longer a way to test that support for non-reflectable lambdas works correctly (so I dropped some tests there). Yes, if needed we could add something separately that built an explicit model (or transform an existing model, dropping the quoted property from lambda ops). ------------- PR Review Comment: https://git.openjdk.org/babylon/pull/726#discussion_r2590104614 From duke at openjdk.org Thu Dec 4 18:59:45 2025 From: duke at openjdk.org (Ruby Chen) Date: Thu, 4 Dec 2025 18:59:45 GMT Subject: [code-reflection] RFR: ModuleOp generation from LambdaOp and FuncOp [v6] In-Reply-To: References: Message-ID: > Add support for generating a ModuleOp from either a LambdaOp or a FuncOp. The given LambdaOp will be converted into the root FuncOp, and the given FuncOp will be assigned as the root FuncOp. > > For `CoreOp.ModuleOp.ofLambdaOp()`, a unique name for the new root FuncOp must be passed as a parameter. Ruby Chen has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains nine additional commits since the last revision: - Merge branch 'openjdk:code-reflection' into module-op-support - Add tests - Merge branch 'openjdk:code-reflection' into module-op-support - removing commented code - Suggested changes - Merge branch 'openjdk:code-reflection' into module-op-support - Merge branch 'openjdk:code-reflection' into module-op-support - Update src/jdk.incubator.code/share/classes/jdk/incubator/code/dialect/core/CoreOp.java Co-authored-by: Paul Sandoz - ModuleOp generation from LambdaOp and FuncOp ------------- Changes: - all: https://git.openjdk.org/babylon/pull/691/files - new: https://git.openjdk.org/babylon/pull/691/files/ad4bc853..4654c480 Webrevs: - full: https://webrevs.openjdk.org/?repo=babylon&pr=691&range=05 - incr: https://webrevs.openjdk.org/?repo=babylon&pr=691&range=04-05 Stats: 1616 lines in 29 files changed: 1322 ins; 201 del; 93 mod Patch: https://git.openjdk.org/babylon/pull/691.diff Fetch: git fetch https://git.openjdk.org/babylon.git pull/691/head:pull/691 PR: https://git.openjdk.org/babylon/pull/691 From mcimadamore at openjdk.org Thu Dec 4 19:26:20 2025 From: mcimadamore at openjdk.org (Maurizio Cimadamore) Date: Thu, 4 Dec 2025 19:26:20 GMT Subject: [code-reflection] RFR: Make @Reflect a use-site annotation [v2] In-Reply-To: References: Message-ID: > In the current iteration of compiler support there are two ways to make a lambda reflectable: > 1. cast the lambda to a type that is annotated with the `@Reflect` annotation (use-site) > 2. pass the lambda to a functional interface whose declaration is annotated with `@Reflect` (decl-site) > > While (2) is handy in cases where the library wants to control reflectability of the lambdas it receives, this model is too weak and insecure, as it might lead to unknowing clients exposing private impl details with frameworks using code reflection. > > For this reason, we have revamped the `@Reflect` annotation to control, at the use-site, which program elements should support code reflection: > > * If a method is annotated with `@Reflect`, the method itself is reflectable, and all the lambdas it contains are reflectable; > * If a field/local variable is annotated with `@Reflect`, all the lambdas that occur inside the initializer (if present), are reflectable; > * If a cast type is annotated with `@Reflect` and the cast is applied to a lambda expression, that lambda expression is reflectable (this is the same as (1) above). > > This means it's no longer possible for a library to create a reflectable functional interface, like: > > > @Reflect > interface ReflectableRunnable extends Runnable { } > > > And unilaterally decide, for _all_ clients whether their lambdas should be reflectable. > > To be clear, this is **not** how things will work longer term, but it's an interim step which provides the desired level of safety w/o requiring the additional language features. > > I've fixed all tests. I've tried to simplify both javac and JDK tests by dropping redundant functional interface declarations. > > I also fixed all the samples; for ONNX some tweaks were done, and I've decided to drop the OnnxFunction -- and to use a supplier instead. But if that's not desirable I can change back (or it can be changed back later). > > I also fixed HAT tests -- in that case it was a bit trickier, as there's lots of tests that end up passing reflectable lambdas to the HAT's compute method. Luckily, all these tests are annotated with `@HatTest`, so I've simply added an extra `@Reflect` to any such test method. Since `@Reflect` now propagates to the body, this guarantees that all the lambdas inside these test methods are treated as reflectable. > > Of course these HAT change end up enabling reflection for a lot more than it's required. I'll leave it to people more expert with HAT to clean that up, if needed. > In the meantime, it was ... Maurizio Cimadamore has updated the pull request incrementally with two additional commits since the last revision: - Fix javadoc - Fix HAT examples ------------- Changes: - all: https://git.openjdk.org/babylon/pull/726/files - new: https://git.openjdk.org/babylon/pull/726/files/11112ad9..5d2db31d Webrevs: - full: https://webrevs.openjdk.org/?repo=babylon&pr=726&range=01 - incr: https://webrevs.openjdk.org/?repo=babylon&pr=726&range=00-01 Stats: 75 lines in 21 files changed: 40 ins; 1 del; 34 mod Patch: https://git.openjdk.org/babylon/pull/726.diff Fetch: git fetch https://git.openjdk.org/babylon.git pull/726/head:pull/726 PR: https://git.openjdk.org/babylon/pull/726 From psandoz at openjdk.org Thu Dec 4 19:26:21 2025 From: psandoz at openjdk.org (Paul Sandoz) Date: Thu, 4 Dec 2025 19:26:21 GMT Subject: [code-reflection] RFR: Make @Reflect a use-site annotation [v2] In-Reply-To: References: Message-ID: On Thu, 4 Dec 2025 19:22:31 GMT, Maurizio Cimadamore wrote: >> In the current iteration of compiler support there are two ways to make a lambda reflectable: >> 1. cast the lambda to a type that is annotated with the `@Reflect` annotation (use-site) >> 2. pass the lambda to a functional interface whose declaration is annotated with `@Reflect` (decl-site) >> >> While (2) is handy in cases where the library wants to control reflectability of the lambdas it receives, this model is too weak and insecure, as it might lead to unknowing clients exposing private impl details with frameworks using code reflection. >> >> For this reason, we have revamped the `@Reflect` annotation to control, at the use-site, which program elements should support code reflection: >> >> * If a method is annotated with `@Reflect`, the method itself is reflectable, and all the lambdas it contains are reflectable; >> * If a field/local variable is annotated with `@Reflect`, all the lambdas that occur inside the initializer (if present), are reflectable; >> * If a cast type is annotated with `@Reflect` and the cast is applied to a lambda expression, that lambda expression is reflectable (this is the same as (1) above). >> >> This means it's no longer possible for a library to create a reflectable functional interface, like: >> >> >> @Reflect >> interface ReflectableRunnable extends Runnable { } >> >> >> And unilaterally decide, for _all_ clients whether their lambdas should be reflectable. >> >> To be clear, this is **not** how things will work longer term, but it's an interim step which provides the desired level of safety w/o requiring the additional language features. >> >> I've fixed all tests. I've tried to simplify both javac and JDK tests by dropping redundant functional interface declarations. >> >> I also fixed all the samples; for ONNX some tweaks were done, and I've decided to drop the OnnxFunction -- and to use a supplier instead. But if that's not desirable I can change back (or it can be changed back later). >> >> I also fixed HAT tests -- in that case it was a bit trickier, as there's lots of tests that end up passing reflectable lambdas to the HAT's compute method. Luckily, all these tests are annotated with `@HatTest`, so I've simply added an extra `@Reflect` to any such test method. Since `@Reflect` now propagates to the body, this guarantees that all the lambdas inside these test methods are treated as reflectable. >> >> Of course these HAT change end up enabling reflection for a lot more than it's required. I'll leave it to people more expert wi... > > Maurizio Cimadamore has updated the pull request incrementally with two additional commits since the last revision: > > - Fix javadoc > - Fix HAT examples Marked as reviewed by psandoz (Lead). ------------- PR Review: https://git.openjdk.org/babylon/pull/726#pullrequestreview-3541700718 From mcimadamore at openjdk.org Thu Dec 4 19:26:22 2025 From: mcimadamore at openjdk.org (Maurizio Cimadamore) Date: Thu, 4 Dec 2025 19:26:22 GMT Subject: [code-reflection] RFR: Make @Reflect a use-site annotation [v2] In-Reply-To: <_XMkvZTvpBA16m9VtdVDAdh-wgDKU5arIQNnG0NaxXc=.df17569f-167d-4c35-ac0a-4e97679c139a@github.com> References: <_XMkvZTvpBA16m9VtdVDAdh-wgDKU5arIQNnG0NaxXc=.df17569f-167d-4c35-ac0a-4e97679c139a@github.com> Message-ID: <5ON4qTfZbTcuw6eCnNCnXpEcNPc8wjT5aE6nHeg2nA8=.2b29c1da-d706-4bd9-8125-741a48542fdc@github.com> On Thu, 4 Dec 2025 18:41:00 GMT, Paul Sandoz wrote: >> Maurizio Cimadamore has updated the pull request incrementally with two additional commits since the last revision: >> >> - Fix javadoc >> - Fix HAT examples > > src/jdk.incubator.code/share/classes/jdk/incubator/code/Reflect.java line 43: > >> 41: *
  • When a method is annotated with this annotation, the method becomes reflectable, and all the lambda expressions >> 42: * and method references enclosed in it also become reflectable.
  • >> 43: *
  • When a variable declaration (a field, or a local variable) is annotated with this annotation, all the methods, lambda expressions > > What does it mean "all the methods" in the context of an initializer expression? I was thinking inner classes, but we don't support those... it's a leftover... ------------- PR Review Comment: https://git.openjdk.org/babylon/pull/726#discussion_r2590274330 From duke at openjdk.org Thu Dec 4 21:04:53 2025 From: duke at openjdk.org (Ruby Chen) Date: Thu, 4 Dec 2025 21:04:53 GMT Subject: [code-reflection] RFR: ModuleOp generation from LambdaOp and FuncOp [v7] In-Reply-To: References: Message-ID: <_DPPl-coxc11AGZaQkvC1cMkv5T-kN8GxdSGVqQtI5g=.a3e93a77-9095-47fa-90da-6b8840631120@github.com> > Add support for generating a ModuleOp from either a LambdaOp or a FuncOp. The given LambdaOp will be converted into the root FuncOp, and the given FuncOp will be assigned as the root FuncOp. > > For `CoreOp.ModuleOp.ofLambdaOp()`, a unique name for the new root FuncOp must be passed as a parameter. Ruby Chen has updated the pull request incrementally with one additional commit since the last revision: fixed tests ------------- Changes: - all: https://git.openjdk.org/babylon/pull/691/files - new: https://git.openjdk.org/babylon/pull/691/files/4654c480..1cc33001 Webrevs: - full: https://webrevs.openjdk.org/?repo=babylon&pr=691&range=06 - incr: https://webrevs.openjdk.org/?repo=babylon&pr=691&range=05-06 Stats: 292 lines in 3 files changed: 16 ins; 247 del; 29 mod Patch: https://git.openjdk.org/babylon/pull/691.diff Fetch: git fetch https://git.openjdk.org/babylon.git pull/691/head:pull/691 PR: https://git.openjdk.org/babylon/pull/691 From mcimadamore at openjdk.org Thu Dec 4 22:31:41 2025 From: mcimadamore at openjdk.org (Maurizio Cimadamore) Date: Thu, 4 Dec 2025 22:31:41 GMT Subject: git: openjdk/babylon: code-reflection: Make @Reflect a use-site annotation Message-ID: <1e75cb72-8885-4509-9e21-ef89f3c458fb@openjdk.org> Changeset: 41258469 Branch: code-reflection Author: Maurizio Cimadamore Date: 2025-12-04 22:29:54 +0000 URL: https://git.openjdk.org/babylon/commit/412584690efed4efb030ebde775c47642996d407 Make @Reflect a use-site annotation Reviewed-by: psandoz ! cr-examples/onnx/src/main/java/oracle/code/onnx/OnnxRuntime.java ! cr-examples/onnx/src/test/java/oracle/code/onnx/CNNTest.java ! cr-examples/onnx/src/test/java/oracle/code/onnx/SimpleTest.java ! cr-examples/onnx/src/test/java/oracle/code/onnx/WalkTheMazeTest.java ! hat/examples/blackscholes/src/main/java/blackscholes/Main.java ! hat/examples/experiments/src/main/java/experiments/ForTests.java ! hat/examples/experiments/src/main/java/experiments/LocalArray.java ! hat/examples/experiments/src/main/java/experiments/LocalIds.java ! hat/examples/experiments/src/main/java/experiments/Mesh.java ! hat/examples/experiments/src/main/java/experiments/MinBufferTest.java ! hat/examples/experiments/src/main/java/experiments/PrefixSum.java ! hat/examples/experiments/src/main/java/experiments/QuotedArrayArg.java ! hat/examples/experiments/src/main/java/experiments/QuotedConstantArgs.java ! hat/examples/experiments/src/main/java/experiments/Reduction.java ! hat/examples/experiments/src/main/java/experiments/spirv/Bad.java ! hat/examples/experiments/src/main/java/experiments/spirv/GetBackend.java ! hat/examples/experiments/src/main/java/experiments/spirv/MatrixMultiply.java ! hat/examples/heal/src/main/java/heal/Compute.java ! hat/examples/life/src/main/java/life/Main.java ! hat/examples/mandel/src/main/java/mandel/Main.java ! hat/examples/matmul/src/main/java/matmul/Main.java ! hat/examples/nbody/src/main/java/nbody/opencl/OpenCLNBodyGLWindow.java ! hat/examples/squares/src/main/java/squares/Main.java ! hat/examples/violajones/src/main/java/violajones/Main.java ! hat/tests/src/main/java/hat/test/TestArrayView.java ! hat/tests/src/main/java/hat/test/TestArrays.java ! hat/tests/src/main/java/hat/test/TestBFloat16Type.java ! hat/tests/src/main/java/hat/test/TestBlackscholes.java ! hat/tests/src/main/java/hat/test/TestConstants.java ! hat/tests/src/main/java/hat/test/TestDeviceType.java ! hat/tests/src/main/java/hat/test/TestF16Type.java ! hat/tests/src/main/java/hat/test/TestFloat2.java ! hat/tests/src/main/java/hat/test/TestLocal.java ! hat/tests/src/main/java/hat/test/TestMandel.java ! hat/tests/src/main/java/hat/test/TestMatMul.java ! hat/tests/src/main/java/hat/test/TestNbody.java ! hat/tests/src/main/java/hat/test/TestParenthesis.java ! hat/tests/src/main/java/hat/test/TestPrivate.java ! hat/tests/src/main/java/hat/test/TestReductions.java ! hat/tests/src/main/java/hat/test/TestVectorArrayView.java ! hat/tests/src/main/java/hat/test/TestVectorTypes.java ! src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties ! src/jdk.incubator.code/share/classes/jdk/incubator/code/Reflect.java ! src/jdk.incubator.code/share/classes/jdk/incubator/code/internal/ReflectMethods.java ! test/jdk/java/lang/reflect/code/TestLambdaOps.java ! test/jdk/java/lang/reflect/code/TestMethodRefLambda.java ! test/jdk/java/lang/reflect/code/bytecode/TestBytecode.java ! test/jdk/java/lang/reflect/code/bytecode/lift/TestBytecodeLift.java ! test/jdk/java/lang/reflect/code/linq/Queryable.java - test/jdk/java/lang/reflect/code/linq/QuotableFunction.java - test/jdk/java/lang/reflect/code/linq/QuotablePredicate.java ! test/jdk/java/lang/reflect/code/linq/TestLinq.java ! test/jdk/java/lang/reflect/code/stream/StreamFuser.java ! test/jdk/java/lang/reflect/code/stream/TestStream.java ! test/langtools/tools/javac/diags/examples.not-yet.txt ! test/langtools/tools/javac/reflect/BlockTest.java ! test/langtools/tools/javac/reflect/BoxingConversionTest.java ! test/langtools/tools/javac/reflect/CodeReflectionTester.java ! test/langtools/tools/javac/reflect/ConditionalExpressionTest.java ! test/langtools/tools/javac/reflect/ForLoopTest.java ! test/langtools/tools/javac/reflect/ImplicitConversionTest.java ! test/langtools/tools/javac/reflect/IntersectionTypeTest.java ! test/langtools/tools/javac/reflect/LambdaTest.java ! test/langtools/tools/javac/reflect/MethodReferenceTest.java ! test/langtools/tools/javac/reflect/NullTest.java - test/langtools/tools/javac/reflect/QuotableSubtypeTest.java - test/langtools/tools/javac/reflect/QuotedSameInstanceTest.java + test/langtools/tools/javac/reflect/ReflectableLambdaSameInstanceTest.java = test/langtools/tools/javac/reflect/ReflectableLambdaTest.java ! test/langtools/tools/javac/reflect/TestNoCodeReflectionInInnerClasses.java ! test/langtools/tools/javac/reflect/TestNoCodeReflectionInInnerClasses.out ! test/langtools/tools/javac/reflect/UnreachableTest.java From mcimadamore at openjdk.org Thu Dec 4 22:32:46 2025 From: mcimadamore at openjdk.org (Maurizio Cimadamore) Date: Thu, 4 Dec 2025 22:32:46 GMT Subject: [code-reflection] Integrated: Make @Reflect a use-site annotation In-Reply-To: References: Message-ID: On Thu, 4 Dec 2025 13:27:57 GMT, Maurizio Cimadamore wrote: > In the current iteration of compiler support there are two ways to make a lambda reflectable: > 1. cast the lambda to a type that is annotated with the `@Reflect` annotation (use-site) > 2. pass the lambda to a functional interface whose declaration is annotated with `@Reflect` (decl-site) > > While (2) is handy in cases where the library wants to control reflectability of the lambdas it receives, this model is too weak and insecure, as it might lead to unknowing clients exposing private impl details with frameworks using code reflection. > > For this reason, we have revamped the `@Reflect` annotation to control, at the use-site, which program elements should support code reflection: > > * If a method is annotated with `@Reflect`, the method itself is reflectable, and all the lambdas it contains are reflectable; > * If a field/local variable is annotated with `@Reflect`, all the lambdas that occur inside the initializer (if present), are reflectable; > * If a cast type is annotated with `@Reflect` and the cast is applied to a lambda expression, that lambda expression is reflectable (this is the same as (1) above). > > This means it's no longer possible for a library to create a reflectable functional interface, like: > > > @Reflect > interface ReflectableRunnable extends Runnable { } > > > And unilaterally decide, for _all_ clients whether their lambdas should be reflectable. > > To be clear, this is **not** how things will work longer term, but it's an interim step which provides the desired level of safety w/o requiring the additional language features. > > I've fixed all tests. I've tried to simplify both javac and JDK tests by dropping redundant functional interface declarations. > > I also fixed all the samples; for ONNX some tweaks were done, and I've decided to drop the OnnxFunction -- and to use a supplier instead. But if that's not desirable I can change back (or it can be changed back later). > > I also fixed HAT tests -- in that case it was a bit trickier, as there's lots of tests that end up passing reflectable lambdas to the HAT's compute method. Luckily, all these tests are annotated with `@HatTest`, so I've simply added an extra `@Reflect` to any such test method. Since `@Reflect` now propagates to the body, this guarantees that all the lambdas inside these test methods are treated as reflectable. > > Of course these HAT change end up enabling reflection for a lot more than it's required. I'll leave it to people more expert with HAT to clean that up, if needed. > In the meantime, it was ... This pull request has now been integrated. Changeset: 41258469 Author: Maurizio Cimadamore URL: https://git.openjdk.org/babylon/commit/412584690efed4efb030ebde775c47642996d407 Stats: 1055 lines in 72 files changed: 321 ins; 576 del; 158 mod Make @Reflect a use-site annotation Reviewed-by: psandoz ------------- PR: https://git.openjdk.org/babylon/pull/726 From psandoz at openjdk.org Thu Dec 4 23:35:31 2025 From: psandoz at openjdk.org (Paul Sandoz) Date: Thu, 4 Dec 2025 23:35:31 GMT Subject: [code-reflection] RFR: ModuleOp generation from LambdaOp and FuncOp [v7] In-Reply-To: <_DPPl-coxc11AGZaQkvC1cMkv5T-kN8GxdSGVqQtI5g=.a3e93a77-9095-47fa-90da-6b8840631120@github.com> References: <_DPPl-coxc11AGZaQkvC1cMkv5T-kN8GxdSGVqQtI5g=.a3e93a77-9095-47fa-90da-6b8840631120@github.com> Message-ID: On Thu, 4 Dec 2025 21:04:53 GMT, Ruby Chen wrote: >> Add support for generating a ModuleOp from either a LambdaOp or a FuncOp. The given LambdaOp will be converted into the root FuncOp, and the given FuncOp will be assigned as the root FuncOp. >> >> For `CoreOp.ModuleOp.ofLambdaOp()`, a unique name for the new root FuncOp must be passed as a parameter. > > Ruby Chen has updated the pull request incrementally with one additional commit since the last revision: > > fixed tests src/jdk.incubator.code/share/classes/jdk/incubator/code/dialect/core/CoreOp.java line 370: > 368: stack.add(f); > 369: while (!stack.isEmpty()) { > 370: CoreOp.FuncOp cur = stack.removeLast(); I find it easier to think in terms of pop/push. I see why you are doing this, to preserve the order of the call graph. Add a comment why you are working from the other end of the stack. You can accumulate into an array list (not a linked list) then do `stack.addAll(temp.reversed())` (also choose a better name than `temp`). Alternatively use pop and push, accumulating into a list and then pushing on the stack like so: for (FuncOp f : invokedFuncs.reversed()) { work.push(f); } src/jdk.incubator.code/share/classes/jdk/incubator/code/dialect/core/CoreOp.java line 372: > 370: CoreOp.FuncOp cur = stack.removeLast(); > 371: if (!visited.add(cur)) continue; > 372: funcs.add(convertInvokeToFuncCallOp(cur, l)); You are traversing the model and resolving methods twice, you can combine the two. If you want to keep it a separate method then pass the temporary list of the encountered invokes to reflectable methods. src/jdk.incubator.code/share/classes/jdk/incubator/code/dialect/core/CoreOp.java line 390: > 388: public static CoreOp.ModuleOp ofLambdaOp(JavaOp.LambdaOp lambdaOp, MethodHandles.Lookup l, String lambdaName) { > 389: boolean methodNameExists = Arrays.stream(l.lookupClass().getMethods()) > 390: .anyMatch(method -> method.getName().equals(lambdaName)); I don't think that check is right. To do this properly we would have to check against the names of methods encountered in the call graph. In general we have another naming clash problem with overloaded methods. A simple approach is to always postfix the function name with the topologically sorted index e.g. "_" test/jdk/java/lang/reflect/code/TestLambdaOps.java line 238: > 236: LambdaOp qop = (LambdaOp) Op.ofQuotable(lambda).get().op(); > 237: FuncOp funcOp = qop.toFuncOp(null); > 238: System.out.println(funcOp.toText()); That's not making any assertions. Use the interpreter to invoke the function and lambda with the same arguments, and assert they produce the same result. ------------- PR Review Comment: https://git.openjdk.org/babylon/pull/691#discussion_r2590919683 PR Review Comment: https://git.openjdk.org/babylon/pull/691#discussion_r2590906013 PR Review Comment: https://git.openjdk.org/babylon/pull/691#discussion_r2590930963 PR Review Comment: https://git.openjdk.org/babylon/pull/691#discussion_r2590935907 From psandoz at openjdk.org Fri Dec 5 23:18:49 2025 From: psandoz at openjdk.org (Paul Sandoz) Date: Fri, 5 Dec 2025 23:18:49 GMT Subject: [babylon-docs:master] Integrated: Update code model article. Message-ID: Update the code model API to be in sync. ------------- Commit messages: - Update code snippet - Update code model article. Changes: https://git.openjdk.org/babylon-docs/pull/10/files Webrev: https://webrevs.openjdk.org/?repo=babylon-docs&pr=10&range=00 Stats: 333 lines in 1 file changed: 33 ins; 9 del; 291 mod Patch: https://git.openjdk.org/babylon-docs/pull/10.diff Fetch: git fetch https://git.openjdk.org/babylon-docs.git pull/10/head:pull/10 PR: https://git.openjdk.org/babylon-docs/pull/10 From psandoz at openjdk.org Fri Dec 5 23:18:49 2025 From: psandoz at openjdk.org (Paul Sandoz) Date: Fri, 5 Dec 2025 23:18:49 GMT Subject: [babylon-docs:master] Integrated: Update code model article. In-Reply-To: References: Message-ID: On Fri, 5 Dec 2025 23:11:32 GMT, Paul Sandoz wrote: > Update the code model API to be in sync. This pull request has now been integrated. Changeset: 60bbceb5 Author: Paul Sandoz URL: https://git.openjdk.org/babylon-docs/commit/60bbceb5e2636130e35022952b84d7b4efba2b17 Stats: 333 lines in 1 file changed: 33 ins; 9 del; 291 mod Update code model article. ------------- PR: https://git.openjdk.org/babylon-docs/pull/10 From psandoz at openjdk.org Fri Dec 5 23:29:58 2025 From: psandoz at openjdk.org (Paul Sandoz) Date: Fri, 5 Dec 2025 23:29:58 GMT Subject: git: openjdk/babylon: code-reflection: Simplify CodeElement.elements Message-ID: <8445b669-6cf6-460c-bc44-a4620fd9acb4@openjdk.org> Changeset: dd77b6b7 Branch: code-reflection Author: Paul Sandoz Date: 2025-12-05 23:26:23 +0000 URL: https://git.openjdk.org/babylon/commit/dd77b6b7e4102d9e908e5cc04420ce597d6c56ec Simplify CodeElement.elements ! src/jdk.incubator.code/share/classes/jdk/incubator/code/CodeElement.java ! test/jdk/java/lang/reflect/code/TestExpressionGraphs.java From psandoz at openjdk.org Fri Dec 5 23:30:02 2025 From: psandoz at openjdk.org (Paul Sandoz) Date: Fri, 5 Dec 2025 23:30:02 GMT Subject: [code-reflection] Integrated: Simplify CodeElement.elements Message-ID: Simplify CodeElement.elements. Update TestExpressionGraphs to use streams only and be in sync with https://openjdk.org/projects/babylon/articles/code-models ------------- Commit messages: - Add back comment. - Simplify CodeElement.elements Changes: https://git.openjdk.org/babylon/pull/728/files Webrev: https://webrevs.openjdk.org/?repo=babylon&pr=728&range=00 Stats: 37 lines in 2 files changed: 4 ins; 26 del; 7 mod Patch: https://git.openjdk.org/babylon/pull/728.diff Fetch: git fetch https://git.openjdk.org/babylon.git pull/728/head:pull/728 PR: https://git.openjdk.org/babylon/pull/728 From psandoz at openjdk.org Fri Dec 5 23:30:02 2025 From: psandoz at openjdk.org (Paul Sandoz) Date: Fri, 5 Dec 2025 23:30:02 GMT Subject: [code-reflection] Integrated: Simplify CodeElement.elements In-Reply-To: References: Message-ID: On Fri, 5 Dec 2025 23:22:07 GMT, Paul Sandoz wrote: > Simplify CodeElement.elements. > > Update TestExpressionGraphs to use streams only and be in sync with https://openjdk.org/projects/babylon/articles/code-models This pull request has now been integrated. Changeset: dd77b6b7 Author: Paul Sandoz URL: https://git.openjdk.org/babylon/commit/dd77b6b7e4102d9e908e5cc04420ce597d6c56ec Stats: 37 lines in 2 files changed: 4 ins; 26 del; 7 mod Simplify CodeElement.elements ------------- PR: https://git.openjdk.org/babylon/pull/728 From duke at openjdk.org Fri Dec 5 23:30:37 2025 From: duke at openjdk.org (duke) Date: Fri, 5 Dec 2025 23:30:37 GMT Subject: git: openjdk/babylon-docs: master: 2 new changesets Message-ID: <4b82cf57-b190-4739-a55e-f090ea146285@openjdk.org> Changeset: f0ec1dbc Branch: master Author: Paul Sandoz Committer: GitHub Date: 2025-12-05 15:29:21 +0000 URL: https://git.openjdk.org/babylon-docs/commit/f0ec1dbc1f1ec0f53948a6540003bb1fb5543380 Update date ! site/_index.md Changeset: 7a8ca77c Branch: master Author: Paul Sandoz Committer: GitHub Date: 2025-12-05 15:29:52 +0000 URL: https://git.openjdk.org/babylon-docs/commit/7a8ca77c19c4acb6dc116f80d42c1fb4e8cf8521 Fix typo ! site/_index.md From gfrost at openjdk.org Sat Dec 6 13:17:09 2025 From: gfrost at openjdk.org (Gary Frost) Date: Sat, 6 Dec 2025 13:17:09 GMT Subject: git: openjdk/babylon: code-reflection: Cleaned up NDRange and initialization of KernelBufferContext Message-ID: <4c8dfd95-5b72-4ad7-9c0d-4906d70d7597@openjdk.org> Changeset: cbb45292 Branch: code-reflection Author: Gary Frost Date: 2025-12-06 13:14:33 +0000 URL: https://git.openjdk.org/babylon/commit/cbb45292a35921cac5c83b1af8407b4f10d7d53b Cleaned up NDRange and initialization of KernelBufferContext ! hat/backends/ffi/shared/src/main/java/hat/backend/ffi/C99FFIBackend.java ! hat/core/src/main/java/hat/ComputeContext.java ! hat/core/src/main/java/hat/KernelContext.java ! hat/core/src/main/java/hat/NDRange.java ! hat/core/src/main/java/hat/backend/java/WorkStealer.java From gfrost at openjdk.org Sat Dec 6 13:18:15 2025 From: gfrost at openjdk.org (Gary Frost) Date: Sat, 6 Dec 2025 13:18:15 GMT Subject: [code-reflection] Integrated: Cleaned up NDRange and initialization of KernelBufferContext Message-ID: In preparing for specializomng kernel code based on Local dispatch dims I wanted to cleanup NDRange Also simplify the initialization of KernelBufferContext (removed mesh initialisation code) ------------- Commit messages: - Cleaned up NDRange and initialization of KernelBufferContext Changes: https://git.openjdk.org/babylon/pull/729/files Webrev: https://webrevs.openjdk.org/?repo=babylon&pr=729&range=00 Stats: 216 lines in 5 files changed: 40 ins; 93 del; 83 mod Patch: https://git.openjdk.org/babylon/pull/729.diff Fetch: git fetch https://git.openjdk.org/babylon.git pull/729/head:pull/729 PR: https://git.openjdk.org/babylon/pull/729 From gfrost at openjdk.org Sat Dec 6 13:18:15 2025 From: gfrost at openjdk.org (Gary Frost) Date: Sat, 6 Dec 2025 13:18:15 GMT Subject: [code-reflection] Integrated: Cleaned up NDRange and initialization of KernelBufferContext In-Reply-To: References: Message-ID: On Sat, 6 Dec 2025 13:11:13 GMT, Gary Frost wrote: > In preparing for specializomng kernel code based on Local dispatch dims I wanted to cleanup NDRange > > Also simplify the initialization of KernelBufferContext (removed mesh initialisation code) This pull request has now been integrated. Changeset: cbb45292 Author: Gary Frost URL: https://git.openjdk.org/babylon/commit/cbb45292a35921cac5c83b1af8407b4f10d7d53b Stats: 216 lines in 5 files changed: 40 ins; 93 del; 83 mod Cleaned up NDRange and initialization of KernelBufferContext ------------- PR: https://git.openjdk.org/babylon/pull/729 From gfrost at openjdk.org Sat Dec 6 15:17:58 2025 From: gfrost at openjdk.org (Gary Frost) Date: Sat, 6 Dec 2025 15:17:58 GMT Subject: git: openjdk/babylon: code-reflection: More C99 code gen cleanup Message-ID: <753bcac1-7d4d-4fce-b268-28a41f221542@openjdk.org> Changeset: a1f80ed3 Branch: code-reflection Author: Gary Frost Date: 2025-12-06 15:16:11 +0000 URL: https://git.openjdk.org/babylon/commit/a1f80ed3da2cbf335d5e804daaff259023163556 More C99 code gen cleanup ! hat/backends/ffi/opencl/src/main/java/hat/backend/ffi/OpenCLHATKernelBuilder.java ! hat/backends/jextracted/opencl/src/main/java/hat/backend/jextracted/OpenCLHatKernelBuilder.java ! hat/core/src/main/java/hat/codebuilders/C99HATKernelBuilder.java ! hat/core/src/main/java/hat/optools/OpTk.java From gfrost at openjdk.org Sat Dec 6 15:19:05 2025 From: gfrost at openjdk.org (Gary Frost) Date: Sat, 6 Dec 2025 15:19:05 GMT Subject: [code-reflection] Integrated: More C99 code gen cleanup Message-ID: Just tidying up some C99 code gen. I added OpTk helpers and resused existing helper. ------------- Commit messages: - More C99 code gecn cleanup Changes: https://git.openjdk.org/babylon/pull/730/files Webrev: https://webrevs.openjdk.org/?repo=babylon&pr=730&range=00 Stats: 147 lines in 4 files changed: 10 ins; 52 del; 85 mod Patch: https://git.openjdk.org/babylon/pull/730.diff Fetch: git fetch https://git.openjdk.org/babylon.git pull/730/head:pull/730 PR: https://git.openjdk.org/babylon/pull/730 From gfrost at openjdk.org Sat Dec 6 15:19:05 2025 From: gfrost at openjdk.org (Gary Frost) Date: Sat, 6 Dec 2025 15:19:05 GMT Subject: [code-reflection] Integrated: More C99 code gen cleanup In-Reply-To: References: Message-ID: On Sat, 6 Dec 2025 15:12:19 GMT, Gary Frost wrote: > Just tidying up some C99 code gen. > > I added OpTk helpers and resused existing helper. This pull request has now been integrated. Changeset: a1f80ed3 Author: Gary Frost URL: https://git.openjdk.org/babylon/commit/a1f80ed3da2cbf335d5e804daaff259023163556 Stats: 147 lines in 4 files changed: 10 ins; 52 del; 85 mod More C99 code gen cleanup ------------- PR: https://git.openjdk.org/babylon/pull/730 From gfrost at openjdk.org Sun Dec 7 15:40:42 2025 From: gfrost at openjdk.org (Gary Frost) Date: Sun, 7 Dec 2025 15:40:42 GMT Subject: git: openjdk/babylon: code-reflection: Fixed the class heiarchy of codegen builders Message-ID: <9c271b8c-ac2f-4249-929c-b0e6feb5dd67@openjdk.org> Changeset: db8002c4 Branch: code-reflection Author: Gary Frost Date: 2025-12-07 15:37:18 +0000 URL: https://git.openjdk.org/babylon/commit/db8002c414f7486da7f15863166b102767a7119a Fixed the class heiarchy of codegen builders ! hat/backends/ffi/cuda/src/main/java/hat/backend/ffi/CudaHATKernelBuilder.java ! hat/backends/ffi/cuda/src/main/java/hat/backend/ffi/PTXHATKernelBuilder.java ! hat/backends/ffi/opencl/src/main/java/hat/backend/ffi/OpenCLHATKernelBuilder.java ! hat/backends/ffi/shared/src/main/java/hat/backend/ffi/C99FFIBackend.java ! hat/backends/jextracted/opencl/src/main/java/hat/backend/jextracted/OpenCLBackend.java = hat/backends/jextracted/opencl/src/main/java/hat/backend/jextracted/OpenCLHATKernelBuilder.java ! hat/backends/jextracted/opencl/src/main/java/hat/backend/jextracted/OpenCLHatKernelBuilder.java ! hat/backends/jextracted/shared/src/main/java/hat/backend/jextracted/C99JExtractedBackend.java ! hat/core/src/main/java/hat/FFIConfigCreator.java ! hat/core/src/main/java/hat/buffer/SchemaBuilder.java + hat/core/src/main/java/hat/codebuilders/BabylonCoreOpBuilder.java + hat/core/src/main/java/hat/codebuilders/BabylonKernelOpBuilder.java - hat/core/src/main/java/hat/codebuilders/BabylonOpBuilder.java - hat/core/src/main/java/hat/codebuilders/C99CodeBuilder.java + hat/core/src/main/java/hat/codebuilders/C99HATCodeBuilder.java + hat/core/src/main/java/hat/codebuilders/C99HATCodeBuilderContext.java ! hat/core/src/main/java/hat/codebuilders/C99HATComputeBuilder.java ! hat/core/src/main/java/hat/codebuilders/C99HATConfigBuilder.java ! hat/core/src/main/java/hat/codebuilders/C99HATKernelBuilder.java ! hat/core/src/main/java/hat/codebuilders/CodeBuilder.java ! hat/core/src/main/java/hat/codebuilders/HATCodeBuilder.java - hat/core/src/main/java/hat/codebuilders/HATCodeBuilderWithContext.java ! hat/core/src/main/java/hat/codebuilders/TextBuilder.java ! hat/core/src/main/java/hat/device/DeviceSchema.java ! hat/tools/src/main/java/hat/tools/text/JavaHATCodeBuilder.java From gfrost at openjdk.org Sun Dec 7 15:41:20 2025 From: gfrost at openjdk.org (Gary Frost) Date: Sun, 7 Dec 2025 15:41:20 GMT Subject: [code-reflection] Integrated: Fixed the class heiarchy of codegen builders Message-ID: Fixed the class hierachy for C99 code builders. Moved non C99 genaration out from common CodeBuilders. ------------- Commit messages: - Fixed the class heiarchy of codegen builders Changes: https://git.openjdk.org/babylon/pull/731/files Webrev: https://webrevs.openjdk.org/?repo=babylon&pr=731&range=00 Stats: 3105 lines in 25 files changed: 1476 ins; 1484 del; 145 mod Patch: https://git.openjdk.org/babylon/pull/731.diff Fetch: git fetch https://git.openjdk.org/babylon.git pull/731/head:pull/731 PR: https://git.openjdk.org/babylon/pull/731 From gfrost at openjdk.org Sun Dec 7 15:41:22 2025 From: gfrost at openjdk.org (Gary Frost) Date: Sun, 7 Dec 2025 15:41:22 GMT Subject: [code-reflection] Integrated: Fixed the class heiarchy of codegen builders In-Reply-To: References: Message-ID: On Sun, 7 Dec 2025 15:34:41 GMT, Gary Frost wrote: > Fixed the class hierachy for C99 code builders. > > Moved non C99 genaration out from common CodeBuilders. This pull request has now been integrated. Changeset: db8002c4 Author: Gary Frost URL: https://git.openjdk.org/babylon/commit/db8002c414f7486da7f15863166b102767a7119a Stats: 3105 lines in 25 files changed: 1476 ins; 1484 del; 145 mod Fixed the class heiarchy of codegen builders ------------- PR: https://git.openjdk.org/babylon/pull/731 From duke at openjdk.org Mon Dec 8 02:17:20 2025 From: duke at openjdk.org (Ruby Chen) Date: Mon, 8 Dec 2025 02:17:20 GMT Subject: [code-reflection] RFR: Add DeviceType support for array views Message-ID: Adding support for both MappableIface and DeviceType to array views. Also shifting the array view phase earlier in the compilation stages. Minor refactoring for array view phase. ------------- Commit messages: - Add DeviceType support for array views Changes: https://git.openjdk.org/babylon/pull/732/files Webrev: https://webrevs.openjdk.org/?repo=babylon&pr=732&range=00 Stats: 201 lines in 2 files changed: 112 ins; 5 del; 84 mod Patch: https://git.openjdk.org/babylon/pull/732.diff Fetch: git fetch https://git.openjdk.org/babylon.git pull/732/head:pull/732 PR: https://git.openjdk.org/babylon/pull/732 From gfrost at openjdk.org Mon Dec 8 11:04:54 2025 From: gfrost at openjdk.org (Gary Frost) Date: Mon, 8 Dec 2025 11:04:54 GMT Subject: git: openjdk/babylon: code-reflection: Hat fix java codebuilder Message-ID: <7a63ef30-bb7f-4198-a1eb-44208b104a1e@openjdk.org> Changeset: ae26fcd5 Branch: code-reflection Author: Gary Frost Date: 2025-12-08 11:03:19 +0000 URL: https://git.openjdk.org/babylon/commit/ae26fcd538ad75921b07a2eb8887268a07f791bc Hat fix java codebuilder - hat/backends/jextracted/opencl/src/main/java/hat/backend/jextracted/OpenCLHatKernelBuilder.java + hat/hat/tool ! hat/tools/src/main/java/hat/tools/text/JavaHATCodeBuilder.java From gfrost at openjdk.org Mon Dec 8 11:05:45 2025 From: gfrost at openjdk.org (Gary Frost) Date: Mon, 8 Dec 2025 11:05:45 GMT Subject: [code-reflection] Integrated: Hat fix java codebuilder Message-ID: Previous PR regressed java code builder. ------------- Commit messages: - OpenCLHatKernelBuilder.java to OpenCLHATKernelBuilder.java - Fix NPE in java code builder Changes: https://git.openjdk.org/babylon/pull/733/files Webrev: https://webrevs.openjdk.org/?repo=babylon&pr=733&range=00 Stats: 218 lines in 3 files changed: 1 ins; 215 del; 2 mod Patch: https://git.openjdk.org/babylon/pull/733.diff Fetch: git fetch https://git.openjdk.org/babylon.git pull/733/head:pull/733 PR: https://git.openjdk.org/babylon/pull/733 From gfrost at openjdk.org Mon Dec 8 11:05:47 2025 From: gfrost at openjdk.org (Gary Frost) Date: Mon, 8 Dec 2025 11:05:47 GMT Subject: [code-reflection] Integrated: Hat fix java codebuilder In-Reply-To: References: Message-ID: <27Y4wZXWl2vXvc5BDSMvs1Ja0R6VMKLykkPCYQSRWPs=.aa9fd262-e332-4bd0-ab29-270fed47b934@github.com> On Mon, 8 Dec 2025 11:00:16 GMT, Gary Frost wrote: > Previous PR regressed java code builder. This pull request has now been integrated. Changeset: ae26fcd5 Author: Gary Frost URL: https://git.openjdk.org/babylon/commit/ae26fcd538ad75921b07a2eb8887268a07f791bc Stats: 218 lines in 3 files changed: 1 ins; 215 del; 2 mod Hat fix java codebuilder ------------- PR: https://git.openjdk.org/babylon/pull/733 From gfrost at openjdk.org Mon Dec 8 13:30:23 2025 From: gfrost at openjdk.org (Gary Frost) Date: Mon, 8 Dec 2025 13:30:23 GMT Subject: [code-reflection] RFR: last pr caused grief. Mac os filename change case Message-ID: Last PR was broken sadly Macos and git can't quite handle changing the case of a filename ------------- Commit messages: - last pr caused grief. Mac os filename change case Changes: https://git.openjdk.org/babylon/pull/734/files Webrev: https://webrevs.openjdk.org/?repo=babylon&pr=734&range=00 Stats: 641 lines in 6 files changed: 212 ins; 426 del; 3 mod Patch: https://git.openjdk.org/babylon/pull/734.diff Fetch: git fetch https://git.openjdk.org/babylon.git pull/734/head:pull/734 PR: https://git.openjdk.org/babylon/pull/734 From gfrost at openjdk.org Mon Dec 8 13:38:02 2025 From: gfrost at openjdk.org (Gary Frost) Date: Mon, 8 Dec 2025 13:38:02 GMT Subject: git: openjdk/babylon: code-reflection: last pr caused grief. Mac os filename change case Message-ID: Changeset: a696ca20 Branch: code-reflection Author: Gary Frost Date: 2025-12-08 13:36:07 +0000 URL: https://git.openjdk.org/babylon/commit/a696ca203f29ea3ed52db58f8948777c1a4e3cf4 last pr caused grief. Mac os filename change case ! hat/backends/jextracted/opencl/src/main/java/hat/backend/jextracted/OpenCLBackend.java - hat/backends/jextracted/opencl/src/main/java/hat/backend/jextracted/OpenCLHATKernelBuilder.java + hat/backends/jextracted/opencl/src/main/java/hat/backend/jextracted/OpenCLJExtractedHATKernelBuilder.java ! hat/core/src/main/java/hat/codebuilders/C99HATKernelBuilder.java From gfrost at openjdk.org Mon Dec 8 13:39:18 2025 From: gfrost at openjdk.org (Gary Frost) Date: Mon, 8 Dec 2025 13:39:18 GMT Subject: [code-reflection] RFR: last pr caused grief. Mac os filename change case [v2] In-Reply-To: References: Message-ID: > Last PR was broken sadly Macos and git can't quite handle changing the case of a filename Gary Frost has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains two commits: - Merge code-reflection - last pr caused grief. Mac os filename change case ------------- Changes: https://git.openjdk.org/babylon/pull/734/files Webrev: https://webrevs.openjdk.org/?repo=babylon&pr=734&range=01 Stats: 427 lines in 4 files changed: 211 ins; 213 del; 3 mod Patch: https://git.openjdk.org/babylon/pull/734.diff Fetch: git fetch https://git.openjdk.org/babylon.git pull/734/head:pull/734 PR: https://git.openjdk.org/babylon/pull/734 From gfrost at openjdk.org Mon Dec 8 13:39:19 2025 From: gfrost at openjdk.org (Gary Frost) Date: Mon, 8 Dec 2025 13:39:19 GMT Subject: [code-reflection] Integrated: last pr caused grief. Mac os filename change case In-Reply-To: References: Message-ID: On Mon, 8 Dec 2025 13:24:11 GMT, Gary Frost wrote: > Last PR was broken sadly Macos and git can't quite handle changing the case of a filename This pull request has now been integrated. Changeset: a696ca20 Author: Gary Frost URL: https://git.openjdk.org/babylon/commit/a696ca203f29ea3ed52db58f8948777c1a4e3cf4 Stats: 427 lines in 4 files changed: 211 ins; 213 del; 3 mod last pr caused grief. Mac os filename change case ------------- PR: https://git.openjdk.org/babylon/pull/734 From gfrost at openjdk.org Mon Dec 8 14:35:56 2025 From: gfrost at openjdk.org (Gary Frost) Date: Mon, 8 Dec 2025 14:35:56 GMT Subject: git: openjdk/babylon: code-reflection: switch text tools to use Regex Message-ID: <11479b81-0d22-49c5-90c9-c38ddd9101f7@openjdk.org> Changeset: 93b2cf3e Branch: code-reflection Author: Gary Frost Date: 2025-12-08 14:32:29 +0000 URL: https://git.openjdk.org/babylon/commit/93b2cf3eb21236c6c94b56e22012cb55e48636e1 switch text tools to use Regex ! hat/core/src/main/java/hat/util/Regex.java ! hat/examples/view/src/main/java/view/EliteMeshParser.java ! hat/tools/src/main/java/hat/tools/jdot/ui/JDot.java ! hat/tools/src/main/java/hat/tools/textmodel/BabylonTextModel.java ! hat/tools/src/main/java/hat/tools/textmodel/JavaTextModel.java ! hat/tools/src/main/java/hat/tools/textmodel/tokens/DottedName.java ! hat/tools/src/main/java/hat/tools/textmodel/tokens/IntConst.java ! hat/tools/src/main/java/hat/tools/textmodel/tokens/Leaf.java From gfrost at openjdk.org Mon Dec 8 14:36:22 2025 From: gfrost at openjdk.org (Gary Frost) Date: Mon, 8 Dec 2025 14:36:22 GMT Subject: [code-reflection] Integrated: switch text tools to use Regex Message-ID: We have simpler Regex tool in HAT (more amenable to pattren switching) so switching uses to it ------------- Commit messages: - switch text tools to use Regex Changes: https://git.openjdk.org/babylon/pull/735/files Webrev: https://webrevs.openjdk.org/?repo=babylon&pr=735&range=00 Stats: 109 lines in 8 files changed: 13 ins; 22 del; 74 mod Patch: https://git.openjdk.org/babylon/pull/735.diff Fetch: git fetch https://git.openjdk.org/babylon.git pull/735/head:pull/735 PR: https://git.openjdk.org/babylon/pull/735 From gfrost at openjdk.org Mon Dec 8 14:36:23 2025 From: gfrost at openjdk.org (Gary Frost) Date: Mon, 8 Dec 2025 14:36:23 GMT Subject: [code-reflection] Integrated: switch text tools to use Regex In-Reply-To: References: Message-ID: On Mon, 8 Dec 2025 14:27:55 GMT, Gary Frost wrote: > We have simpler Regex tool in HAT (more amenable to pattren switching) so switching uses to it This pull request has now been integrated. Changeset: 93b2cf3e Author: Gary Frost URL: https://git.openjdk.org/babylon/commit/93b2cf3eb21236c6c94b56e22012cb55e48636e1 Stats: 109 lines in 8 files changed: 13 ins; 22 del; 74 mod switch text tools to use Regex ------------- PR: https://git.openjdk.org/babylon/pull/735 From gfrost at openjdk.org Mon Dec 8 17:41:46 2025 From: gfrost at openjdk.org (Gary Frost) Date: Mon, 8 Dec 2025 17:41:46 GMT Subject: git: openjdk/babylon: code-reflection: moved c99 codegen out of base class Message-ID: <5dd1ccb8-6a59-43a2-89e2-bf0a6e3c5084@openjdk.org> Changeset: 979ae333 Branch: code-reflection Author: Gary Frost Date: 2025-12-08 17:39:49 +0000 URL: https://git.openjdk.org/babylon/commit/979ae3336c068c4196840c2bbf161a63500f370e moved c99 codegen out of base class ! hat/backends/ffi/cuda/src/main/java/hat/backend/ffi/CudaHATKernelBuilder.java ! hat/backends/ffi/opencl/src/main/java/hat/backend/ffi/OpenCLHATKernelBuilder.java ! hat/backends/jextracted/opencl/src/main/java/hat/backend/jextracted/OpenCLJExtractedHATKernelBuilder.java ! hat/core/src/main/java/hat/FFIConfigCreator.java ! hat/core/src/main/java/hat/codebuilders/C99HATCodeBuilder.java ! hat/core/src/main/java/hat/codebuilders/C99HATConfigBuilder.java ! hat/core/src/main/java/hat/codebuilders/C99HATKernelBuilder.java ! hat/core/src/main/java/hat/codebuilders/CodeBuilder.java ! hat/core/src/main/java/hat/codebuilders/HATCodeBuilder.java ! hat/core/src/main/java/hat/util/Regex.java From gfrost at openjdk.org Mon Dec 8 17:42:59 2025 From: gfrost at openjdk.org (Gary Frost) Date: Mon, 8 Dec 2025 17:42:59 GMT Subject: [code-reflection] Integrated: moved c99 codegen out of base class In-Reply-To: References: Message-ID: <3cYExjH1jdityDkC_eEB5HDd0nefEHTVEanKAtUo-KE=.d462a6a5-ddcd-42a9-8a72-110a45466b7b@github.com> On Mon, 8 Dec 2025 17:36:07 GMT, Gary Frost wrote: > Found some C99 codegen classes in the base CodeGen class > > Generally tidying up all these classes in preparation for generated C99 code from Compute layer This pull request has now been integrated. Changeset: 979ae333 Author: Gary Frost URL: https://git.openjdk.org/babylon/commit/979ae3336c068c4196840c2bbf161a63500f370e Stats: 417 lines in 10 files changed: 113 ins; 194 del; 110 mod moved c99 codegen out of base class ------------- PR: https://git.openjdk.org/babylon/pull/736 From gfrost at openjdk.org Mon Dec 8 17:42:58 2025 From: gfrost at openjdk.org (Gary Frost) Date: Mon, 8 Dec 2025 17:42:58 GMT Subject: [code-reflection] Integrated: moved c99 codegen out of base class Message-ID: Found some C99 codegen classes in the base CodeGen class Generally tidying up all these classes in preparation for generated C99 code from Compute layer ------------- Commit messages: - moved c99 codegen out of base class Changes: https://git.openjdk.org/babylon/pull/736/files Webrev: https://webrevs.openjdk.org/?repo=babylon&pr=736&range=00 Stats: 417 lines in 10 files changed: 113 ins; 194 del; 110 mod Patch: https://git.openjdk.org/babylon/pull/736.diff Fetch: git fetch https://git.openjdk.org/babylon.git pull/736/head:pull/736 PR: https://git.openjdk.org/babylon/pull/736 From psandoz at openjdk.org Mon Dec 8 18:05:54 2025 From: psandoz at openjdk.org (Paul Sandoz) Date: Mon, 8 Dec 2025 18:05:54 GMT Subject: [code-reflection] RFR: Remove CodeElement.transform Message-ID: Remove the `CodeElement.transform` method and the helper methods. Traversal of elements is performed using the `CodeElement.elements` method that returns a stream of code elements. ------------- Commit messages: - Remove comments. - Merge remote-tracking branch 'upstream/code-reflection' into rm-ce-transform - Remove CodeElement.transform method. Changes: https://git.openjdk.org/babylon/pull/737/files Webrev: https://webrevs.openjdk.org/?repo=babylon&pr=737&range=00 Stats: 235 lines in 20 files changed: 47 ins; 91 del; 97 mod Patch: https://git.openjdk.org/babylon/pull/737.diff Fetch: git fetch https://git.openjdk.org/babylon.git pull/737/head:pull/737 PR: https://git.openjdk.org/babylon/pull/737 From psandoz at openjdk.org Mon Dec 8 18:10:17 2025 From: psandoz at openjdk.org (Paul Sandoz) Date: Mon, 8 Dec 2025 18:10:17 GMT Subject: [babylon-docs:master] Integrated: Updates to docs Message-ID: <7tfP-O1ex09D3Ps5qvzbvSpp_cgIbcswAFMYaLM2v_0=.62ff9106-4103-4d01-b780-c524f5ee269d@github.com> Update auto diff and linq documents. ------------- Commit messages: - Updates to docs. Changes: https://git.openjdk.org/babylon-docs/pull/11/files Webrev: https://webrevs.openjdk.org/?repo=babylon-docs&pr=11&range=00 Stats: 425 lines in 2 files changed: 41 ins; 49 del; 335 mod Patch: https://git.openjdk.org/babylon-docs/pull/11.diff Fetch: git fetch https://git.openjdk.org/babylon-docs.git pull/11/head:pull/11 PR: https://git.openjdk.org/babylon-docs/pull/11 From psandoz at openjdk.org Mon Dec 8 18:10:20 2025 From: psandoz at openjdk.org (Paul Sandoz) Date: Mon, 8 Dec 2025 18:10:20 GMT Subject: [babylon-docs:master] Integrated: Updates to docs In-Reply-To: <7tfP-O1ex09D3Ps5qvzbvSpp_cgIbcswAFMYaLM2v_0=.62ff9106-4103-4d01-b780-c524f5ee269d@github.com> References: <7tfP-O1ex09D3Ps5qvzbvSpp_cgIbcswAFMYaLM2v_0=.62ff9106-4103-4d01-b780-c524f5ee269d@github.com> Message-ID: <4RQookNv4UwtgC47cLJf2PS8aEvgwaK6DjBsusE8jpg=.5c249396-67bd-4262-bdf5-4a3b3a9efc9b@github.com> On Mon, 8 Dec 2025 18:03:24 GMT, Paul Sandoz wrote: > Update auto diff and linq documents. This pull request has now been integrated. Changeset: 9211cef3 Author: Paul Sandoz URL: https://git.openjdk.org/babylon-docs/commit/9211cef38654aee0ce2de85291c35d1386a6cbb6 Stats: 425 lines in 2 files changed: 41 ins; 49 del; 335 mod Updates to docs ------------- PR: https://git.openjdk.org/babylon-docs/pull/11 From mabbay at openjdk.org Mon Dec 8 19:39:09 2025 From: mabbay at openjdk.org (Mourad Abbay) Date: Mon, 8 Dec 2025 19:39:09 GMT Subject: [code-reflection] RFR: Fails if code model was compiled by a feature version different from the current Message-ID: <9nk78j8Q4RDPFSyfQ4K9CYcG_o9Z96n3xZv-7K0iF-I=.895417bd-ff5e-4d7e-9128-57480cb65319@github.com> Before we build a code model, we check if the Java feature version used to compile the code model matches the current one. In case there's no match, we throw an exception. ------------- Commit messages: - Fails if code model was compiled by a feature version different from the current Changes: https://git.openjdk.org/babylon/pull/738/files Webrev: https://webrevs.openjdk.org/?repo=babylon&pr=738&range=00 Stats: 40 lines in 2 files changed: 40 ins; 0 del; 0 mod Patch: https://git.openjdk.org/babylon/pull/738.diff Fetch: git fetch https://git.openjdk.org/babylon.git pull/738/head:pull/738 PR: https://git.openjdk.org/babylon/pull/738 From psandoz at openjdk.org Mon Dec 8 20:48:31 2025 From: psandoz at openjdk.org (Paul Sandoz) Date: Mon, 8 Dec 2025 20:48:31 GMT Subject: [code-reflection] RFR: Fails if code model was compiled by a feature version different from the current In-Reply-To: <9nk78j8Q4RDPFSyfQ4K9CYcG_o9Z96n3xZv-7K0iF-I=.895417bd-ff5e-4d7e-9128-57480cb65319@github.com> References: <9nk78j8Q4RDPFSyfQ4K9CYcG_o9Z96n3xZv-7K0iF-I=.895417bd-ff5e-4d7e-9128-57480cb65319@github.com> Message-ID: <4K4gtioHROslxxqpvycV2JL77rU3aWh9-g-js2Q9Mfs=.c659a6bf-c275-464f-b39e-6c433ea51185@github.com> On Mon, 8 Dec 2025 19:32:49 GMT, Mourad Abbay wrote: > Before we build a code model, we check if the Java feature version used to compile the code model matches the current one. In case there's no match, we throw an exception. src/jdk.incubator.code/share/classes/jdk/incubator/code/dialect/java/JavaOp.java line 5268: > 5266: } > 5267: > 5268: /** Retain the declaration order pattern as for the other methods, the var args method occurs before the list method. src/jdk.incubator.code/share/classes/jdk/incubator/code/internal/OpBuilder.java line 440: > 438: InvokeOp.InvokeKind.STATIC, true, > 439: J_L_STRING, STRING_FORMAT, > 440: t.op(constant(J_L_STRING, "Code model was compiled with java version %d, but the actual version is %d")), You can embed the expected runtime version directly in the string, there is no need to pass it a runtime. Then you can simplify further by using the string concat operation to directly concatenate the string and actual version. Suggest a string of: "The Java version used at compile time to generate and store the code model, Java " + expectedVersion + ", is not the same as the Java version used at runtime to load the code model, Java " src/jdk.incubator.code/share/classes/jdk/incubator/code/internal/OpBuilder.java line 444: > 442: )); > 443: t.op(throw_( > 444: t.op(new_(MethodRef.constructor(IllegalStateException.class, String.class), errMessage)) Throw `UnsupportedOperationException`, and then document the throwing of that by `Op.ofMethod` and `Op.ofQuotable`. ------------- PR Review Comment: https://git.openjdk.org/babylon/pull/738#discussion_r2600001606 PR Review Comment: https://git.openjdk.org/babylon/pull/738#discussion_r2600068243 PR Review Comment: https://git.openjdk.org/babylon/pull/738#discussion_r2600061141 From psandoz at openjdk.org Mon Dec 8 23:51:41 2025 From: psandoz at openjdk.org (Paul Sandoz) Date: Mon, 8 Dec 2025 23:51:41 GMT Subject: [code-reflection] RFR: Rename compute/kernel interfaces. Message-ID: <7xwmEMMYlN6qpzths4ZaMP1xIsVnp0qrEZ0K7AlDcd0=.e4334194-1fd9-4b28-bbe9-67dcd7956db6@github.com> Rename `QuotableComputeContextConsumer` to `ComputeConsumer` and `QuotableKernelContextConsumer` to `KernelConsumer`. Since we don't have `Quotable` anymore that prefix is redundant. I also tried to reduce the name further because they, or mainly the `ComputeConsumer`, may need to be referred to in an annotated cast expression. Using the names `Compute` and `Kernel` would be more terse but at least the former conflicted with other code. ------------- Commit messages: - Merge remote-tracking branch 'upstream/code-reflection' into hat-compute-iface - Rename compute/kernel interfaces. Changes: https://git.openjdk.org/babylon/pull/739/files Webrev: https://webrevs.openjdk.org/?repo=babylon&pr=739&range=00 Stats: 113 lines in 25 files changed: 3 ins; 7 del; 103 mod Patch: https://git.openjdk.org/babylon/pull/739.diff Fetch: git fetch https://git.openjdk.org/babylon.git pull/739/head:pull/739 PR: https://git.openjdk.org/babylon/pull/739 From duke at openjdk.org Tue Dec 9 01:08:10 2025 From: duke at openjdk.org (Ruby Chen) Date: Tue, 9 Dec 2025 01:08:10 GMT Subject: [code-reflection] RFR: ModuleOp generation from LambdaOp and FuncOp [v8] In-Reply-To: References: Message-ID: <3WwdNYNnbdiOSjw1UqHcQy18dkn1orWyvdu_aX8Rb1Q=.94be8993-2667-4f2e-8da7-32c0c907ef22@github.com> > Add support for generating a ModuleOp from either a LambdaOp or a FuncOp. The given LambdaOp will be converted into the root FuncOp, and the given FuncOp will be assigned as the root FuncOp. > > For `CoreOp.ModuleOp.ofLambdaOp()`, a unique name for the new root FuncOp must be passed as a parameter. Ruby Chen has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains 12 additional commits since the last revision: - fixes - Merge branch 'openjdk:code-reflection' into module-op-support - fixed tests - Merge branch 'openjdk:code-reflection' into module-op-support - Add tests - Merge branch 'openjdk:code-reflection' into module-op-support - removing commented code - Suggested changes - Merge branch 'openjdk:code-reflection' into module-op-support - Merge branch 'openjdk:code-reflection' into module-op-support - ... and 2 more: https://git.openjdk.org/babylon/compare/be6432ca...e70019bf ------------- Changes: - all: https://git.openjdk.org/babylon/pull/691/files - new: https://git.openjdk.org/babylon/pull/691/files/1cc33001..e70019bf Webrevs: - full: https://webrevs.openjdk.org/?repo=babylon&pr=691&range=07 - incr: https://webrevs.openjdk.org/?repo=babylon&pr=691&range=06-07 Stats: 5297 lines in 115 files changed: 2121 ins; 2586 del; 590 mod Patch: https://git.openjdk.org/babylon/pull/691.diff Fetch: git fetch https://git.openjdk.org/babylon.git pull/691/head:pull/691 PR: https://git.openjdk.org/babylon/pull/691 From jfumero at openjdk.org Tue Dec 9 12:46:01 2025 From: jfumero at openjdk.org (Juan Fumero) Date: Tue, 9 Dec 2025 12:46:01 GMT Subject: [code-reflection] RFR: Fix balanced parenthesis and structs for the CUDA backend Message-ID: Fix balanced parenthesis and structs for the CUDA backend How to test? java -cp hat/job.jar hat.java test-suite ffi-opencl java -cp hat/job.jar hat.java test-suite ffi-cuda ------------- Commit messages: - [hat] CUDA backend vector types fixed - [hat] Fix semicolon in C99 structs declaration Changes: https://git.openjdk.org/babylon/pull/741/files Webrev: https://webrevs.openjdk.org/?repo=babylon&pr=741&range=00 Stats: 6 lines in 3 files changed: 3 ins; 0 del; 3 mod Patch: https://git.openjdk.org/babylon/pull/741.diff Fetch: git fetch https://git.openjdk.org/babylon.git pull/741/head:pull/741 PR: https://git.openjdk.org/babylon/pull/741 From jfumero at openjdk.org Tue Dec 9 13:11:10 2025 From: jfumero at openjdk.org (Juan Fumero) Date: Tue, 9 Dec 2025 13:11:10 GMT Subject: git: openjdk/babylon: code-reflection: Fix balanced parenthesis and structs for the CUDA backend Message-ID: Changeset: 634b8bf4 Branch: code-reflection Author: Juan Fumero Date: 2025-12-09 13:08:45 +0000 URL: https://git.openjdk.org/babylon/commit/634b8bf4b1bf6fceab40ea0a96f082c52902ca8d Fix balanced parenthesis and structs for the CUDA backend ! hat/backends/ffi/cuda/src/main/java/hat/backend/ffi/CudaHATKernelBuilder.java ! hat/core/src/main/java/hat/codebuilders/C99HATKernelBuilder.java ! hat/core/src/main/java/hat/codebuilders/CodeBuilder.java From jfumero at openjdk.org Tue Dec 9 13:11:29 2025 From: jfumero at openjdk.org (Juan Fumero) Date: Tue, 9 Dec 2025 13:11:29 GMT Subject: [code-reflection] Integrated: Fix balanced parenthesis and structs for the CUDA backend In-Reply-To: References: Message-ID: On Tue, 9 Dec 2025 12:41:33 GMT, Juan Fumero wrote: > Fix balanced parenthesis and structs for the CUDA backend > > How to test? > > > java -cp hat/job.jar hat.java test-suite ffi-opencl > > java -cp hat/job.jar hat.java test-suite ffi-cuda This pull request has now been integrated. Changeset: 634b8bf4 Author: Juan Fumero URL: https://git.openjdk.org/babylon/commit/634b8bf4b1bf6fceab40ea0a96f082c52902ca8d Stats: 6 lines in 3 files changed: 3 ins; 0 del; 3 mod Fix balanced parenthesis and structs for the CUDA backend ------------- PR: https://git.openjdk.org/babylon/pull/741 From gfrost at openjdk.org Tue Dec 9 13:19:30 2025 From: gfrost at openjdk.org (Gary Frost) Date: Tue, 9 Dec 2025 13:19:30 GMT Subject: [code-reflection] RFR: Fix balanced parenthesis and structs for the CUDA backend In-Reply-To: References: Message-ID: On Tue, 9 Dec 2025 12:41:33 GMT, Juan Fumero wrote: > Fix balanced parenthesis and structs for the CUDA backend > > How to test? > > > java -cp hat/job.jar hat.java test-suite ffi-opencl > > java -cp hat/job.jar hat.java test-suite ffi-cuda hat/core/src/main/java/hat/codebuilders/CodeBuilder.java line 500: > 498: } > 499: public T semicolonNlSeparated(Iterable iterable, Consumer consumer) { > 500: return separated(iterable,_->semicolonNl(),consumer).semicolon(); No fix this at the call site. Or it effects every use of semicolonNlSeparated... ------------- PR Review Comment: https://git.openjdk.org/babylon/pull/741#discussion_r2602619170 From jfumero at openjdk.org Tue Dec 9 13:26:53 2025 From: jfumero at openjdk.org (Juan Fumero) Date: Tue, 9 Dec 2025 13:26:53 GMT Subject: [code-reflection] RFR: [hat] Type transform between bfloat16 <-> float improved Message-ID: <74Z9vz2EREiL1txgAzl4-UmYaWizCnaj1pXjbQDu7ec=.dceea7e9-16d3-4ff8-bc64-0ed41b7c88f5@github.com> [hat] Type transform between bfloat16 <-> float improved. Unittests with the OpenCL backend passing. CUDA backend not passing due to another error (not related to this PR). We will merge this when we patch the CUDA backed. ------------- Commit messages: - Merge branch 'code-reflection' into hat/dev/bfloat16conv - Address comments from PR#740 - [hat] minor change - [hat] Improvements in the bfloat16 conversion from the OpenCL size Changes: https://git.openjdk.org/babylon/pull/740/files Webrev: https://webrevs.openjdk.org/?repo=babylon&pr=740&range=00 Stats: 181 lines in 4 files changed: 74 ins; 45 del; 62 mod Patch: https://git.openjdk.org/babylon/pull/740.diff Fetch: git fetch https://git.openjdk.org/babylon.git pull/740/head:pull/740 PR: https://git.openjdk.org/babylon/pull/740 From gfrost at openjdk.org Tue Dec 9 13:26:58 2025 From: gfrost at openjdk.org (Gary Frost) Date: Tue, 9 Dec 2025 13:26:58 GMT Subject: [code-reflection] RFR: [hat] Type transform between bfloat16 <-> float improved In-Reply-To: <74Z9vz2EREiL1txgAzl4-UmYaWizCnaj1pXjbQDu7ec=.dceea7e9-16d3-4ff8-bc64-0ed41b7c88f5@github.com> References: <74Z9vz2EREiL1txgAzl4-UmYaWizCnaj1pXjbQDu7ec=.dceea7e9-16d3-4ff8-bc64-0ed41b7c88f5@github.com> Message-ID: On Tue, 9 Dec 2025 10:33:53 GMT, Juan Fumero wrote: > [hat] Type transform between bfloat16 <-> float improved. > > Unittests with the OpenCL backend passing. > CUDA backend not passing due to another error (not related to this PR). We will merge this when we patch the CUDA backed. hat/core/src/main/java/hat/codebuilders/C99HATCodeBuilder.java line 203: > 201: } > 202: > 203: public final T declareTypeBFloat16Type(String identifier) { maybe bf16Type() hat/core/src/main/java/hat/codebuilders/C99HATKernelBuilder.java line 571: > 569: String identifier = "b"; > 570: return funcDef(_ -> f32Type(), > 571: _ -> builtin_bfloat16ToFloat(), bf16Type... hat/core/src/main/java/hat/codebuilders/C99HATKernelBuilder.java line 574: > 572: _ -> ushortType(parameterName), > 573: _ -> declareTypeBFloat16Type(identifier).semicolonNl() > 574: .identifier(identifier).dot().identifier("s").osbrace().intConstZero().csbrace().equals().constant("0x0000").semicolonNl() why constant("0x00000") why not intConstZer(0) or intvalue(0) Replace osbrace() . xxx() .csbrace() === sbrace(_->xxx()) hat/core/src/main/java/hat/codebuilders/C99HATKernelBuilder.java line 594: > 592: _->builtin_float2bfloat16(), > 593: _->f32Type(parameterName), > 594: _-> declareTypeBFloat16Type("b").space().equals().space().obrace().identifier(parameterName).cbrace().semicolonNl() We can reduce the chances of misaligned braces by leaning into various helpers. I think this becomes something lik .assign(_->fb16Type("b"),_->brace(_->identifier(parameterName)).semicolonNl() .returnKeyword(_->identifier("b").dot().identifier("s").sbrace(_->intConstOne())) hat/core/src/main/java/hat/codebuilders/CodeBuilder.java line 588: > 586: > 587: public final T ushort() { > 588: return typeName("ushort"); u16Type ?????? ------------- PR Review Comment: https://git.openjdk.org/babylon/pull/740#discussion_r2602242543 PR Review Comment: https://git.openjdk.org/babylon/pull/740#discussion_r2602247697 PR Review Comment: https://git.openjdk.org/babylon/pull/740#discussion_r2602255216 PR Review Comment: https://git.openjdk.org/babylon/pull/740#discussion_r2602225819 PR Review Comment: https://git.openjdk.org/babylon/pull/740#discussion_r2602234595 From jfumero at openjdk.org Tue Dec 9 13:31:06 2025 From: jfumero at openjdk.org (Juan Fumero) Date: Tue, 9 Dec 2025 13:31:06 GMT Subject: git: openjdk/babylon: code-reflection: [hat] Type transform between bfloat16 <-> float improved Message-ID: <888903b5-e2a9-41ed-bab9-3bb6f90bafcd@openjdk.org> Changeset: 764e9020 Branch: code-reflection Author: Juan Fumero Date: 2025-12-09 13:28:31 +0000 URL: https://git.openjdk.org/babylon/commit/764e9020b79c39e59e83c24e310d415d485c1fa0 [hat] Type transform between bfloat16 <-> float improved ! hat/backends/ffi/opencl/src/main/java/hat/backend/ffi/OpenCLHATKernelBuilder.java ! hat/core/src/main/java/hat/codebuilders/C99HATCodeBuilder.java ! hat/core/src/main/java/hat/codebuilders/C99HATKernelBuilder.java ! hat/core/src/main/java/hat/codebuilders/CodeBuilder.java From jfumero at openjdk.org Tue Dec 9 13:31:36 2025 From: jfumero at openjdk.org (Juan Fumero) Date: Tue, 9 Dec 2025 13:31:36 GMT Subject: [code-reflection] Integrated: [hat] Type transform between bfloat16 <-> float improved In-Reply-To: <74Z9vz2EREiL1txgAzl4-UmYaWizCnaj1pXjbQDu7ec=.dceea7e9-16d3-4ff8-bc64-0ed41b7c88f5@github.com> References: <74Z9vz2EREiL1txgAzl4-UmYaWizCnaj1pXjbQDu7ec=.dceea7e9-16d3-4ff8-bc64-0ed41b7c88f5@github.com> Message-ID: On Tue, 9 Dec 2025 10:33:53 GMT, Juan Fumero wrote: > [hat] Type transform between bfloat16 <-> float improved. > > Unittests with the OpenCL backend passing. > CUDA backend not passing due to another error (not related to this PR). We will merge this when we patch the CUDA backed. This pull request has now been integrated. Changeset: 764e9020 Author: Juan Fumero URL: https://git.openjdk.org/babylon/commit/764e9020b79c39e59e83c24e310d415d485c1fa0 Stats: 181 lines in 4 files changed: 74 ins; 45 del; 62 mod [hat] Type transform between bfloat16 <-> float improved ------------- PR: https://git.openjdk.org/babylon/pull/740 From jfumero at openjdk.org Tue Dec 9 15:02:54 2025 From: jfumero at openjdk.org (Juan Fumero) Date: Tue, 9 Dec 2025 15:02:54 GMT Subject: [code-reflection] RFR: HAT Test Report improved Message-ID: This PR adds a new exception for those tests in which a precision error is expected (E.g., when converting from float to fp16). It also adds an error code once the unit-tests are finished to facilitate integrated with GitHub actions. How to test: java -cp hat/job.jar hat.java test-suite ffi-opencl java -cp hat/job.jar hat.java test-suite ffi-cuda ------------- Commit messages: - [hat] code-formatter applied - Add error code to test report - Add test_bfloat16_04 into the list - [hat] tests with prec. errors identified - [hat] test report with precision errors as expected fails - [hat] test report with precision errors as expected fails Changes: https://git.openjdk.org/babylon/pull/742/files Webrev: https://webrevs.openjdk.org/?repo=babylon&pr=742&range=00 Stats: 235 lines in 25 files changed: 113 ins; 11 del; 111 mod Patch: https://git.openjdk.org/babylon/pull/742.diff Fetch: git fetch https://git.openjdk.org/babylon.git pull/742/head:pull/742 PR: https://git.openjdk.org/babylon/pull/742 From jfumero at openjdk.org Tue Dec 9 15:16:33 2025 From: jfumero at openjdk.org (Juan Fumero) Date: Tue, 9 Dec 2025 15:16:33 GMT Subject: [code-reflection] Integrated: HAT Test Report improved In-Reply-To: References: Message-ID: On Tue, 9 Dec 2025 14:56:56 GMT, Juan Fumero wrote: > This PR adds a new exception for those tests in which a precision error is expected (E.g., when converting from float to fp16). It also adds an error code once the unit-tests are finished to facilitate integrated with GitHub actions. > > How to test: > > java -cp hat/job.jar hat.java test-suite ffi-opencl > java -cp hat/job.jar hat.java test-suite ffi-cuda This pull request has now been integrated. Changeset: 910d14c8 Author: Juan Fumero URL: https://git.openjdk.org/babylon/commit/910d14c8d1e90e4024f6f06e70c2553f74306f3b Stats: 235 lines in 25 files changed: 113 ins; 11 del; 111 mod HAT Test Report improved ------------- PR: https://git.openjdk.org/babylon/pull/742 From jfumero at openjdk.org Tue Dec 9 15:19:16 2025 From: jfumero at openjdk.org (Juan Fumero) Date: Tue, 9 Dec 2025 15:19:16 GMT Subject: git: openjdk/babylon: code-reflection: HAT Test Report improved Message-ID: Changeset: 910d14c8 Branch: code-reflection Author: Juan Fumero Date: 2025-12-09 15:13:18 +0000 URL: https://git.openjdk.org/babylon/commit/910d14c8d1e90e4024f6f06e70c2553f74306f3b HAT Test Report improved ! hat/hat.java ! hat/tests/src/main/java/hat/test/TestArrayView.java ! hat/tests/src/main/java/hat/test/TestArrays.java ! hat/tests/src/main/java/hat/test/TestBFloat16Type.java ! hat/tests/src/main/java/hat/test/TestBlackscholes.java ! hat/tests/src/main/java/hat/test/TestConstants.java ! hat/tests/src/main/java/hat/test/TestDeviceType.java ! hat/tests/src/main/java/hat/test/TestF16Type.java ! hat/tests/src/main/java/hat/test/TestFloat2.java ! hat/tests/src/main/java/hat/test/TestLocal.java ! hat/tests/src/main/java/hat/test/TestMandel.java ! hat/tests/src/main/java/hat/test/TestMatMul.java ! hat/tests/src/main/java/hat/test/TestNbody.java ! hat/tests/src/main/java/hat/test/TestParenthesis.java ! hat/tests/src/main/java/hat/test/TestPrivate.java ! hat/tests/src/main/java/hat/test/TestReductions.java ! hat/tests/src/main/java/hat/test/TestVectorArrayView.java ! hat/tests/src/main/java/hat/test/TestVectorTypes.java ! hat/tests/src/main/java/hat/test/engine/HATAsserts.java ! hat/tests/src/main/java/hat/test/engine/HATTestEngine.java ! hat/tests/src/main/java/hat/test/engine/HATTestFormatter.java = hat/tests/src/main/java/hat/test/exceptions/HATAssertionError.java = hat/tests/src/main/java/hat/test/exceptions/HATExpectedFailureException.java + hat/tests/src/main/java/hat/test/exceptions/HATExpectedPrecisionError.java = hat/tests/src/main/java/hat/test/exceptions/HATTestException.java From gfrost at openjdk.org Tue Dec 9 15:53:40 2025 From: gfrost at openjdk.org (Gary Frost) Date: Tue, 9 Dec 2025 15:53:40 GMT Subject: [code-reflection] Integrated: More C99 code gen fixes Message-ID: Fixes missing semicolon at end of struct which broke CUDA backend. Removed extra '\n' at the end of generated forLoop() Previous fix aggressively impacted all users of semicolonNlSeparated(). Moved primitive typecheck to OpTk ------------- Commit messages: - More C99 code gen fixes Changes: https://git.openjdk.org/babylon/pull/743/files Webrev: https://webrevs.openjdk.org/?repo=babylon&pr=743&range=00 Stats: 27 lines in 6 files changed: 15 ins; 3 del; 9 mod Patch: https://git.openjdk.org/babylon/pull/743.diff Fetch: git fetch https://git.openjdk.org/babylon.git pull/743/head:pull/743 PR: https://git.openjdk.org/babylon/pull/743 From gfrost at openjdk.org Tue Dec 9 15:53:41 2025 From: gfrost at openjdk.org (Gary Frost) Date: Tue, 9 Dec 2025 15:53:41 GMT Subject: [code-reflection] Integrated: More C99 code gen fixes In-Reply-To: References: Message-ID: On Tue, 9 Dec 2025 15:45:49 GMT, Gary Frost wrote: > Fixes missing semicolon at end of struct which broke CUDA backend. > > Removed extra '\n' at the end of generated forLoop() > > Previous fix aggressively impacted all users of semicolonNlSeparated(). > > Moved primitive typecheck to OpTk This pull request has now been integrated. Changeset: 2dbfd51b Author: Gary Frost URL: https://git.openjdk.org/babylon/commit/2dbfd51bc417e00bdee92596e1ea6873f084846c Stats: 27 lines in 6 files changed: 15 ins; 3 del; 9 mod More C99 code gen fixes ------------- PR: https://git.openjdk.org/babylon/pull/743 From gfrost at openjdk.org Tue Dec 9 15:54:30 2025 From: gfrost at openjdk.org (Gary Frost) Date: Tue, 9 Dec 2025 15:54:30 GMT Subject: git: openjdk/babylon: code-reflection: More C99 code gen fixes Message-ID: <8352ef7a-dd7b-4c53-b090-c5d2475a4c5d@openjdk.org> Changeset: 2dbfd51b Branch: code-reflection Author: Gary Frost Date: 2025-12-09 15:49:06 +0000 URL: https://git.openjdk.org/babylon/commit/2dbfd51bc417e00bdee92596e1ea6873f084846c More C99 code gen fixes ! hat/core/src/main/java/hat/codebuilders/C99HATCodeBuilder.java ! hat/core/src/main/java/hat/codebuilders/C99HATKernelBuilder.java ! hat/core/src/main/java/hat/codebuilders/CodeBuilder.java ! hat/core/src/main/java/hat/optools/OpTk.java ! hat/intellij/.idea/misc.xml ! hat/intellij/tests.iml From mabbay at openjdk.org Tue Dec 9 16:43:41 2025 From: mabbay at openjdk.org (Mourad Abbay) Date: Tue, 9 Dec 2025 16:43:41 GMT Subject: [code-reflection] RFR: Fails if code model was compiled by a feature version different from the current [v2] In-Reply-To: <9nk78j8Q4RDPFSyfQ4K9CYcG_o9Z96n3xZv-7K0iF-I=.895417bd-ff5e-4d7e-9128-57480cb65319@github.com> References: <9nk78j8Q4RDPFSyfQ4K9CYcG_o9Z96n3xZv-7K0iF-I=.895417bd-ff5e-4d7e-9128-57480cb65319@github.com> Message-ID: > Before we build a code model, we check if the Java feature version used to compile the code model matches the current one. In case there's no match, we throw an exception. Mourad Abbay has updated the pull request incrementally with one additional commit since the last revision: Apply Paul's comments ------------- Changes: - all: https://git.openjdk.org/babylon/pull/738/files - new: https://git.openjdk.org/babylon/pull/738/files/bfd230e5..325dabd1 Webrevs: - full: https://webrevs.openjdk.org/?repo=babylon&pr=738&range=01 - incr: https://webrevs.openjdk.org/?repo=babylon&pr=738&range=00-01 Stats: 19 lines in 3 files changed: 5 ins; 0 del; 14 mod Patch: https://git.openjdk.org/babylon/pull/738.diff Fetch: git fetch https://git.openjdk.org/babylon.git pull/738/head:pull/738 PR: https://git.openjdk.org/babylon/pull/738 From duke at openjdk.org Tue Dec 9 19:25:54 2025 From: duke at openjdk.org (Ruby Chen) Date: Tue, 9 Dec 2025 19:25:54 GMT Subject: [code-reflection] RFR: Add DeviceType support for array views [v2] In-Reply-To: References: Message-ID: > Adding support for both MappableIface and DeviceType to array views. Also shifting the array view phase earlier in the compilation stages. > > Minor refactoring for array view phase. Ruby Chen has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains two additional commits since the last revision: - Merge branch 'openjdk:code-reflection' into array-view - Add DeviceType support for array views ------------- Changes: - all: https://git.openjdk.org/babylon/pull/732/files - new: https://git.openjdk.org/babylon/pull/732/files/47df325e..8a0727e2 Webrevs: - full: https://webrevs.openjdk.org/?repo=babylon&pr=732&range=01 - incr: https://webrevs.openjdk.org/?repo=babylon&pr=732&range=00-01 Stats: 1530 lines in 50 files changed: 489 ins; 649 del; 392 mod Patch: https://git.openjdk.org/babylon/pull/732.diff Fetch: git fetch https://git.openjdk.org/babylon.git pull/732/head:pull/732 PR: https://git.openjdk.org/babylon/pull/732 From psandoz at openjdk.org Tue Dec 9 20:19:40 2025 From: psandoz at openjdk.org (Paul Sandoz) Date: Tue, 9 Dec 2025 20:19:40 GMT Subject: [code-reflection] RFR: Fails if code model was compiled by a feature version different from the current [v2] In-Reply-To: References: <9nk78j8Q4RDPFSyfQ4K9CYcG_o9Z96n3xZv-7K0iF-I=.895417bd-ff5e-4d7e-9128-57480cb65319@github.com> Message-ID: On Tue, 9 Dec 2025 16:43:41 GMT, Mourad Abbay wrote: >> Before we build a code model, we check if the Java feature version used to compile the code model matches the current one. In case there's no match, we throw an exception. > > Mourad Abbay has updated the pull request incrementally with one additional commit since the last revision: > > Apply Paul's comments Much better. Any thoughts on how to test this? We could modify the bytecode of the class afterwards to replace the constant pool entry with a different version? src/jdk.incubator.code/share/classes/jdk/incubator/code/internal/OpBuilder.java line 179: > 177: J_L_OBJECT); // body definition(s): Body.Builder, List or null > 178: > 179: static final MethodRef STRING_FORMAT = MethodRef.method(String.class, "format", String.class, String.class, Unused. src/jdk.incubator.code/share/classes/jdk/incubator/code/internal/OpBuilder.java line 429: > 427: FuncOp build(String name, Op op) { > 428: Value ancestorBody = builder.op(constant(type(Body.Builder.class), null)); > 429: // check if java version at compile time matches the java version at runtime Now we have the right code shape we could move this to a static helper method rather that repeating the logic. ------------- PR Review: https://git.openjdk.org/babylon/pull/738#pullrequestreview-3559265353 PR Review Comment: https://git.openjdk.org/babylon/pull/738#discussion_r2604011114 PR Review Comment: https://git.openjdk.org/babylon/pull/738#discussion_r2604192181 From psandoz at openjdk.org Tue Dec 9 21:45:29 2025 From: psandoz at openjdk.org (Paul Sandoz) Date: Tue, 9 Dec 2025 21:45:29 GMT Subject: [code-reflection] RFR: Rename compute/kernel interfaces. [v2] In-Reply-To: <7xwmEMMYlN6qpzths4ZaMP1xIsVnp0qrEZ0K7AlDcd0=.e4334194-1fd9-4b28-bbe9-67dcd7956db6@github.com> References: <7xwmEMMYlN6qpzths4ZaMP1xIsVnp0qrEZ0K7AlDcd0=.e4334194-1fd9-4b28-bbe9-67dcd7956db6@github.com> Message-ID: > Rename `QuotableComputeContextConsumer` to `Compute` and `QuotableKernelContextConsumer` to `Kernel`. Since we don't have `Quotable` anymore that prefix is redundant. > > Note that the following wil fail to compile since it is a compile time error to annotate the statically qualified type: > > > import hat.Accelerator; > ... > accelerator.compute((@Reflect Accelerator.Compute) > cc -> blackScholes(cc, call, put, S, X, T, r, v)); > > > We need to do this: > > > import hat.Accelerator; > import hat.Accelerator.Compute > ... > accelerator.compute((@Reflect Compute) > cc -> blackScholes(cc, call, put, S, X, T, r, v)); > > > This could motivate making `Compute` a top-level FI. Paul Sandoz has updated the pull request incrementally with one additional commit since the last revision: Rename to Compute and Kernel. ------------- Changes: - all: https://git.openjdk.org/babylon/pull/739/files - new: https://git.openjdk.org/babylon/pull/739/files/01ddd40f..37ff8168 Webrevs: - full: https://webrevs.openjdk.org/?repo=babylon&pr=739&range=01 - incr: https://webrevs.openjdk.org/?repo=babylon&pr=739&range=00-01 Stats: 85 lines in 24 files changed: 0 ins; 5 del; 80 mod Patch: https://git.openjdk.org/babylon/pull/739.diff Fetch: git fetch https://git.openjdk.org/babylon.git pull/739/head:pull/739 PR: https://git.openjdk.org/babylon/pull/739 From psandoz at openjdk.org Tue Dec 9 23:21:07 2025 From: psandoz at openjdk.org (Paul Sandoz) Date: Tue, 9 Dec 2025 23:21:07 GMT Subject: [code-reflection] RFR: ModuleOp generation from LambdaOp and FuncOp [v8] In-Reply-To: <3WwdNYNnbdiOSjw1UqHcQy18dkn1orWyvdu_aX8Rb1Q=.94be8993-2667-4f2e-8da7-32c0c907ef22@github.com> References: <3WwdNYNnbdiOSjw1UqHcQy18dkn1orWyvdu_aX8Rb1Q=.94be8993-2667-4f2e-8da7-32c0c907ef22@github.com> Message-ID: On Tue, 9 Dec 2025 01:08:10 GMT, Ruby Chen wrote: >> Add support for generating a ModuleOp from either a LambdaOp or a FuncOp. The given LambdaOp will be converted into the root FuncOp, and the given FuncOp will be assigned as the root FuncOp. >> >> For `CoreOp.ModuleOp.ofLambdaOp()`, a unique name for the new root FuncOp must be passed as a parameter. > > Ruby Chen has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains 12 additional commits since the last revision: > > - fixes > - Merge branch 'openjdk:code-reflection' into module-op-support > - fixed tests > - Merge branch 'openjdk:code-reflection' into module-op-support > - Add tests > - Merge branch 'openjdk:code-reflection' into module-op-support > - removing commented code > - Suggested changes > - Merge branch 'openjdk:code-reflection' into module-op-support > - Merge branch 'openjdk:code-reflection' into module-op-support > - ... and 2 more: https://git.openjdk.org/babylon/compare/c18d7cec...e70019bf src/jdk.incubator.code/share/classes/jdk/incubator/code/dialect/core/CoreOp.java line 370: > 368: temp.add(funcOp); > 369: Op.Result result = blockBuilder.op(CoreOp.funcCall( > 370: iop.invokeDescriptor().name(), The name of the func to call differs from the transformed func's name, so the model you create is incorrect. You need to test more robustly e.g., run through the interpreter or compare text output. src/jdk.incubator.code/share/classes/jdk/incubator/code/dialect/java/JavaOp.java line 337: > 335: * Such a lambda operation is one with the following constraints: > 336: *
      > 337: *
    1. Zero or one captured value (assuming correspondence to the {@code this} variable). That is too restrictive. For method references they may or may not capture `this`, but for a direct invocation there will be captures e.g., the optimization pattern in HAT is a lambda expression that makes a direct call to another method, capturing variables and passing then on as arguments to the method. So you need to test out those cases with mixture of lambda parameters and captured variables. ------------- PR Review Comment: https://git.openjdk.org/babylon/pull/691#discussion_r2604662572 PR Review Comment: https://git.openjdk.org/babylon/pull/691#discussion_r2604579846 From jfumero at openjdk.org Wed Dec 10 08:53:13 2025 From: jfumero at openjdk.org (Juan Fumero) Date: Wed, 10 Dec 2025 08:53:13 GMT Subject: [code-reflection] RFR: [hat] Assert moved to hat.test.exceptions package Message-ID: HATAsserts is moved to exceptions package within the testing framework. ------------- Commit messages: - [hat] Assert moved to hat.test.exceptions package Changes: https://git.openjdk.org/babylon/pull/744/files Webrev: https://webrevs.openjdk.org/?repo=babylon&pr=744&range=00 Stats: 10 lines in 2 files changed: 1 ins; 9 del; 0 mod Patch: https://git.openjdk.org/babylon/pull/744.diff Fetch: git fetch https://git.openjdk.org/babylon.git pull/744/head:pull/744 PR: https://git.openjdk.org/babylon/pull/744 From jfumero at openjdk.org Wed Dec 10 09:06:36 2025 From: jfumero at openjdk.org (Juan Fumero) Date: Wed, 10 Dec 2025 09:06:36 GMT Subject: [code-reflection] RFR: [hat] Assert moved to hat.test.exceptions package [v2] In-Reply-To: References: Message-ID: > HATAsserts is moved to exceptions package within the testing framework. Juan Fumero has updated the pull request incrementally with one additional commit since the last revision: Internal HAT-test script updated ------------- Changes: - all: https://git.openjdk.org/babylon/pull/744/files - new: https://git.openjdk.org/babylon/pull/744/files/b5b6a2ab..8b317048 Webrevs: - full: https://webrevs.openjdk.org/?repo=babylon&pr=744&range=01 - incr: https://webrevs.openjdk.org/?repo=babylon&pr=744&range=00-01 Stats: 19 lines in 1 file changed: 12 ins; 2 del; 5 mod Patch: https://git.openjdk.org/babylon/pull/744.diff Fetch: git fetch https://git.openjdk.org/babylon.git pull/744/head:pull/744 PR: https://git.openjdk.org/babylon/pull/744 From jfumero at openjdk.org Wed Dec 10 09:13:17 2025 From: jfumero at openjdk.org (Juan Fumero) Date: Wed, 10 Dec 2025 09:13:17 GMT Subject: git: openjdk/babylon: code-reflection: [hat] Assert moved to hat.test.exceptions package Message-ID: <6ce17bb3-cd74-46c9-b069-014cc250e657@openjdk.org> Changeset: d8b67f83 Branch: code-reflection Author: Juan Fumero Date: 2025-12-10 09:11:34 +0000 URL: https://git.openjdk.org/babylon/commit/d8b67f83738201d87ce0eecc02d44dd4e5087368 [hat] Assert moved to hat.test.exceptions package ! hat/hat/test.java ! hat/tests/src/main/java/hat/test/engine/HATTestEngine.java = hat/tests/src/main/java/hat/test/exceptions/HATAsserts.java From jfumero at openjdk.org Wed Dec 10 09:14:08 2025 From: jfumero at openjdk.org (Juan Fumero) Date: Wed, 10 Dec 2025 09:14:08 GMT Subject: [code-reflection] Integrated: [hat] Assert moved to hat.test.exceptions package In-Reply-To: References: Message-ID: <9-aOTZQrF8qsqcrEyaAKW9Iw78YHMyEaUePGOuoBzhM=.00840c92-d2c6-4265-9ffd-7d118cb7a1b3@github.com> On Wed, 10 Dec 2025 08:48:08 GMT, Juan Fumero wrote: > HATAsserts is moved to exceptions package within the testing framework. This pull request has now been integrated. Changeset: d8b67f83 Author: Juan Fumero URL: https://git.openjdk.org/babylon/commit/d8b67f83738201d87ce0eecc02d44dd4e5087368 Stats: 29 lines in 3 files changed: 13 ins; 11 del; 5 mod [hat] Assert moved to hat.test.exceptions package ------------- PR: https://git.openjdk.org/babylon/pull/744 From mabbay at openjdk.org Wed Dec 10 15:09:45 2025 From: mabbay at openjdk.org (Mourad Abbay) Date: Wed, 10 Dec 2025 15:09:45 GMT Subject: [code-reflection] RFR: Fails if code model was compiled by a feature version different from the current [v3] In-Reply-To: <9nk78j8Q4RDPFSyfQ4K9CYcG_o9Z96n3xZv-7K0iF-I=.895417bd-ff5e-4d7e-9128-57480cb65319@github.com> References: <9nk78j8Q4RDPFSyfQ4K9CYcG_o9Z96n3xZv-7K0iF-I=.895417bd-ff5e-4d7e-9128-57480cb65319@github.com> Message-ID: <_wBRjeQthPbQsOcbPQ9AZ5_aJvlutro5S5D6RbyPkrk=.b0e958c8-af80-40d5-859d-0d1396583531@github.com> > Before we build a code model, we check if the Java feature version used to compile the code model matches the current one. In case there's no match, we throw an exception. Mourad Abbay has updated the pull request incrementally with two additional commits since the last revision: - Encapsulate the logic of checking java version in a helper func - Delete unused field ------------- Changes: - all: https://git.openjdk.org/babylon/pull/738/files - new: https://git.openjdk.org/babylon/pull/738/files/325dabd1..d3ee0f78 Webrevs: - full: https://webrevs.openjdk.org/?repo=babylon&pr=738&range=02 - incr: https://webrevs.openjdk.org/?repo=babylon&pr=738&range=01-02 Stats: 46 lines in 1 file changed: 23 ins; 22 del; 1 mod Patch: https://git.openjdk.org/babylon/pull/738.diff Fetch: git fetch https://git.openjdk.org/babylon.git pull/738/head:pull/738 PR: https://git.openjdk.org/babylon/pull/738 From psandoz at openjdk.org Wed Dec 10 22:50:28 2025 From: psandoz at openjdk.org (Paul Sandoz) Date: Wed, 10 Dec 2025 22:50:28 GMT Subject: [code-reflection] Integrated: Rename compute/kernel interfaces. In-Reply-To: <7xwmEMMYlN6qpzths4ZaMP1xIsVnp0qrEZ0K7AlDcd0=.e4334194-1fd9-4b28-bbe9-67dcd7956db6@github.com> References: <7xwmEMMYlN6qpzths4ZaMP1xIsVnp0qrEZ0K7AlDcd0=.e4334194-1fd9-4b28-bbe9-67dcd7956db6@github.com> Message-ID: On Mon, 8 Dec 2025 23:40:37 GMT, Paul Sandoz wrote: > Rename `QuotableComputeContextConsumer` to `Compute` and `QuotableKernelContextConsumer` to `Kernel`. Since we don't have `Quotable` anymore that prefix is redundant. > > Note that the following wil fail to compile since it is a compile time error to annotate the statically qualified type: > > > import hat.Accelerator; > ... > accelerator.compute((@Reflect Accelerator.Compute) > cc -> blackScholes(cc, call, put, S, X, T, r, v)); > > > We need to do this: > > > import hat.Accelerator; > import hat.Accelerator.Compute > ... > accelerator.compute((@Reflect Compute) > cc -> blackScholes(cc, call, put, S, X, T, r, v)); > > > This could motivate making `Compute` a top-level FI. This pull request has now been integrated. Changeset: 4bf33c66 Author: Paul Sandoz URL: https://git.openjdk.org/babylon/commit/4bf33c6637b86dcd04512370701e032a82d3c7db Stats: 131 lines in 27 files changed: 3 ins; 12 del; 116 mod Rename compute/kernel interfaces. ------------- PR: https://git.openjdk.org/babylon/pull/739 From psandoz at openjdk.org Wed Dec 10 22:52:49 2025 From: psandoz at openjdk.org (Paul Sandoz) Date: Wed, 10 Dec 2025 22:52:49 GMT Subject: git: openjdk/babylon: code-reflection: Rename compute/kernel interfaces. Message-ID: <1a19b857-a947-4522-a8f0-fd4c024d06c9@openjdk.org> Changeset: 4bf33c66 Branch: code-reflection Author: Paul Sandoz Date: 2025-12-10 22:48:02 +0000 URL: https://git.openjdk.org/babylon/commit/4bf33c6637b86dcd04512370701e032a82d3c7db Rename compute/kernel interfaces. ! hat/core/src/main/java/hat/Accelerator.java ! hat/core/src/main/java/hat/ComputeContext.java ! hat/core/src/main/java/hat/optools/OpTk.java ! hat/core/src/main/test/hat/SquaresTest.java ! hat/docs/hat-05-accelerator-compute.md ! hat/examples/blackscholes/src/main/java/blackscholes/Main.java ! hat/examples/experiments/src/main/java/experiments/ForTests.java ! hat/examples/experiments/src/main/java/experiments/LocalArray.java ! hat/examples/experiments/src/main/java/experiments/LocalIds.java ! hat/examples/experiments/src/main/java/experiments/Mesh.java ! hat/examples/experiments/src/main/java/experiments/MinBufferTest.java ! hat/examples/experiments/src/main/java/experiments/PrefixSum.java ! hat/examples/experiments/src/main/java/experiments/QuotedArrayArg.java ! hat/examples/experiments/src/main/java/experiments/QuotedConstantArgs.java ! hat/examples/experiments/src/main/java/experiments/Reduction.java ! hat/examples/experiments/src/main/java/experiments/spirv/Bad.java ! hat/examples/experiments/src/main/java/experiments/spirv/GetBackend.java ! hat/examples/experiments/src/main/java/experiments/spirv/MatrixMultiply.java = hat/examples/heal/src/main/java/heal/ComputeHeal.java ! hat/examples/heal/src/main/java/heal/Viewer.java ! hat/examples/life/src/main/java/life/Main.java ! hat/examples/mandel/src/main/java/mandel/Main.java ! hat/examples/matmul/src/main/java/matmul/Main.java ! hat/examples/nbody/src/main/java/nbody/opencl/OpenCLNBodyGLWindow.java ! hat/examples/squares/src/main/java/squares/Main.java ! hat/examples/violajones/src/main/java/violajones/Main.java ! hat/tests/src/main/java/hat/test/TestArrayView.java From psandoz at openjdk.org Wed Dec 10 23:14:41 2025 From: psandoz at openjdk.org (Paul Sandoz) Date: Wed, 10 Dec 2025 23:14:41 GMT Subject: git: openjdk/babylon: code-reflection: Remove CodeElement.transform Message-ID: Changeset: f971f47b Branch: code-reflection Author: Paul Sandoz Date: 2025-12-10 23:13:18 +0000 URL: https://git.openjdk.org/babylon/commit/f971f47b358f7d50b765529b02bfef3a0ca67104 Remove CodeElement.transform ! cr-examples/onnx/src/main/java/oracle/code/onnx/compiler/OnnxTransformer.java ! cr-examples/onnx/src/main/java/oracle/code/onnx/compiler/TypeConvertor.java ! cr-examples/samples/src/main/java/oracle/code/samples/HelloCodeReflection.java ! cr-examples/samples/src/main/java/oracle/code/samples/MathOptimizer.java ! cr-examples/triton/src/main/java/oracle/code/triton/TritonTransformer.java ! hat/core/src/main/java/hat/callgraph/KernelCallGraph.java ! hat/core/src/main/java/hat/optools/OpTk.java ! src/jdk.incubator.code/share/classes/jdk/incubator/code/CodeElement.java ! src/jdk.incubator.code/share/classes/jdk/incubator/code/analysis/Liveness.java ! src/jdk.incubator.code/share/classes/jdk/incubator/code/analysis/Patterns.java ! src/jdk.incubator.code/share/classes/jdk/incubator/code/analysis/SSABraun.java ! src/jdk.incubator.code/share/classes/jdk/incubator/code/analysis/SSACytron.java ! test/jdk/java/lang/reflect/code/TestBlockParameters.java ! test/jdk/java/lang/reflect/code/TestLiveness.java ! test/jdk/java/lang/reflect/code/TestTraverse.java ! test/jdk/java/lang/reflect/code/TestUsesDependsOn.java ! test/jdk/java/lang/reflect/code/bytecode/lift/SlotToVarTransformer.java ! test/jdk/java/lang/reflect/code/bytecode/lift/UnresolvedTypesTransformer.java ! test/jdk/java/lang/reflect/code/bytecode/lift/Verifier.java ! test/jdk/java/lang/reflect/code/location/TestLocation.java From psandoz at openjdk.org Wed Dec 10 23:18:35 2025 From: psandoz at openjdk.org (Paul Sandoz) Date: Wed, 10 Dec 2025 23:18:35 GMT Subject: [code-reflection] RFR: Remove CodeElement.transform [v2] In-Reply-To: References: Message-ID: > Remove the `CodeElement.transform` method and the helper methods. Traversal of elements is performed using the `CodeElement.elements` method that returns a stream of code elements. Paul Sandoz has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains four additional commits since the last revision: - Merge remote-tracking branch 'upstream/code-reflection' into rm-ce-transform - Remove comments. - Merge remote-tracking branch 'upstream/code-reflection' into rm-ce-transform - Remove CodeElement.transform method. ------------- Changes: - all: https://git.openjdk.org/babylon/pull/737/files - new: https://git.openjdk.org/babylon/pull/737/files/d4c3bb54..6d5444ec Webrevs: - full: https://webrevs.openjdk.org/?repo=babylon&pr=737&range=01 - incr: https://webrevs.openjdk.org/?repo=babylon&pr=737&range=00-01 Stats: 600 lines in 59 files changed: 217 ins; 78 del; 305 mod Patch: https://git.openjdk.org/babylon/pull/737.diff Fetch: git fetch https://git.openjdk.org/babylon.git pull/737/head:pull/737 PR: https://git.openjdk.org/babylon/pull/737 From psandoz at openjdk.org Wed Dec 10 23:18:35 2025 From: psandoz at openjdk.org (Paul Sandoz) Date: Wed, 10 Dec 2025 23:18:35 GMT Subject: [code-reflection] Integrated: Remove CodeElement.transform In-Reply-To: References: Message-ID: On Mon, 8 Dec 2025 17:54:26 GMT, Paul Sandoz wrote: > Remove the `CodeElement.transform` method and the helper methods. Traversal of elements is performed using the `CodeElement.elements` method that returns a stream of code elements. This pull request has now been integrated. Changeset: f971f47b Author: Paul Sandoz URL: https://git.openjdk.org/babylon/commit/f971f47b358f7d50b765529b02bfef3a0ca67104 Stats: 235 lines in 20 files changed: 47 ins; 91 del; 97 mod Remove CodeElement.transform ------------- PR: https://git.openjdk.org/babylon/pull/737 From psandoz at openjdk.org Wed Dec 10 23:29:38 2025 From: psandoz at openjdk.org (Paul Sandoz) Date: Wed, 10 Dec 2025 23:29:38 GMT Subject: [code-reflection] RFR: Fails if code model was compiled by a feature version different from the current [v3] In-Reply-To: <_wBRjeQthPbQsOcbPQ9AZ5_aJvlutro5S5D6RbyPkrk=.b0e958c8-af80-40d5-859d-0d1396583531@github.com> References: <9nk78j8Q4RDPFSyfQ4K9CYcG_o9Z96n3xZv-7K0iF-I=.895417bd-ff5e-4d7e-9128-57480cb65319@github.com> <_wBRjeQthPbQsOcbPQ9AZ5_aJvlutro5S5D6RbyPkrk=.b0e958c8-af80-40d5-859d-0d1396583531@github.com> Message-ID: On Wed, 10 Dec 2025 15:09:45 GMT, Mourad Abbay wrote: >> Before we build a code model, we check if the Java feature version used to compile the code model matches the current one. In case there's no match, we throw an exception. > > Mourad Abbay has updated the pull request incrementally with two additional commits since the last revision: > > - Encapsulate the logic of checking java version in a helper func > - Delete unused field We can work out how to test this in a subsequent PR. ------------- Marked as reviewed by psandoz (Lead). PR Review: https://git.openjdk.org/babylon/pull/738#pullrequestreview-3564908271 From mabbay at openjdk.org Thu Dec 11 00:15:25 2025 From: mabbay at openjdk.org (Mourad Abbay) Date: Thu, 11 Dec 2025 00:15:25 GMT Subject: git: openjdk/babylon: code-reflection: Fails if code model was compiled by a feature version different from the current Message-ID: Changeset: e529f177 Branch: code-reflection Author: Mourad Abbay Date: 2025-12-11 00:13:01 +0000 URL: https://git.openjdk.org/babylon/commit/e529f17778a40d27835ab7fcd0b6e89f4d53a44f Fails if code model was compiled by a feature version different from the current Reviewed-by: psandoz ! src/jdk.incubator.code/share/classes/jdk/incubator/code/Op.java ! src/jdk.incubator.code/share/classes/jdk/incubator/code/dialect/java/JavaOp.java ! src/jdk.incubator.code/share/classes/jdk/incubator/code/internal/OpBuilder.java From mabbay at openjdk.org Thu Dec 11 00:15:37 2025 From: mabbay at openjdk.org (Mourad Abbay) Date: Thu, 11 Dec 2025 00:15:37 GMT Subject: [code-reflection] Integrated: Fails if code model was compiled by a feature version different from the current In-Reply-To: <9nk78j8Q4RDPFSyfQ4K9CYcG_o9Z96n3xZv-7K0iF-I=.895417bd-ff5e-4d7e-9128-57480cb65319@github.com> References: <9nk78j8Q4RDPFSyfQ4K9CYcG_o9Z96n3xZv-7K0iF-I=.895417bd-ff5e-4d7e-9128-57480cb65319@github.com> Message-ID: On Mon, 8 Dec 2025 19:32:49 GMT, Mourad Abbay wrote: > Before we build a code model, we check if the Java feature version used to compile the code model matches the current one. In case there's no match, we throw an exception. This pull request has now been integrated. Changeset: e529f177 Author: Mourad Abbay URL: https://git.openjdk.org/babylon/commit/e529f17778a40d27835ab7fcd0b6e89f4d53a44f Stats: 46 lines in 3 files changed: 46 ins; 0 del; 0 mod Fails if code model was compiled by a feature version different from the current Reviewed-by: psandoz ------------- PR: https://git.openjdk.org/babylon/pull/738 From psandoz at openjdk.org Thu Dec 11 19:58:12 2025 From: psandoz at openjdk.org (Paul Sandoz) Date: Thu, 11 Dec 2025 19:58:12 GMT Subject: [babylon-docs:master] Integrated: Triton doc updates. Message-ID: Triton doc updates. ------------- Commit messages: - Triton doc updates. Changes: https://git.openjdk.org/babylon-docs/pull/12/files Webrev: https://webrevs.openjdk.org/?repo=babylon-docs&pr=12&range=00 Stats: 272 lines in 1 file changed: 5 ins; 16 del; 251 mod Patch: https://git.openjdk.org/babylon-docs/pull/12.diff Fetch: git fetch https://git.openjdk.org/babylon-docs.git pull/12/head:pull/12 PR: https://git.openjdk.org/babylon-docs/pull/12 From psandoz at openjdk.org Thu Dec 11 19:58:13 2025 From: psandoz at openjdk.org (Paul Sandoz) Date: Thu, 11 Dec 2025 19:58:13 GMT Subject: [babylon-docs:master] Integrated: Triton doc updates. In-Reply-To: References: Message-ID: On Thu, 11 Dec 2025 19:52:11 GMT, Paul Sandoz wrote: > Triton doc updates. This pull request has now been integrated. Changeset: fed2a84f Author: Paul Sandoz URL: https://git.openjdk.org/babylon-docs/commit/fed2a84fb662e4db9179d72b663435e76a38f044 Stats: 272 lines in 1 file changed: 5 ins; 16 del; 251 mod Triton doc updates. ------------- PR: https://git.openjdk.org/babylon-docs/pull/12 From duke at openjdk.org Thu Dec 11 20:00:50 2025 From: duke at openjdk.org (Ruby Chen) Date: Thu, 11 Dec 2025 20:00:50 GMT Subject: [code-reflection] RFR: Add DeviceType support for array views [v3] In-Reply-To: References: Message-ID: > Adding support for both MappableIface and DeviceType to array views. Also shifting the array view phase earlier in the compilation stages. > > Minor refactoring for array view phase. Ruby Chen has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains three additional commits since the last revision: - Merge branch 'openjdk:code-reflection' into array-view - Merge branch 'openjdk:code-reflection' into array-view - Add DeviceType support for array views ------------- Changes: - all: https://git.openjdk.org/babylon/pull/732/files - new: https://git.openjdk.org/babylon/pull/732/files/8a0727e2..b9facd6c Webrevs: - full: https://webrevs.openjdk.org/?repo=babylon&pr=732&range=02 - incr: https://webrevs.openjdk.org/?repo=babylon&pr=732&range=01-02 Stats: 441 lines in 52 files changed: 109 ins; 114 del; 218 mod Patch: https://git.openjdk.org/babylon/pull/732.diff Fetch: git fetch https://git.openjdk.org/babylon.git pull/732/head:pull/732 PR: https://git.openjdk.org/babylon/pull/732 From duke at openjdk.org Thu Dec 11 20:06:48 2025 From: duke at openjdk.org (Ruby Chen) Date: Thu, 11 Dec 2025 20:06:48 GMT Subject: [code-reflection] RFR: Add DeviceType support for array views [v4] In-Reply-To: References: Message-ID: > Adding support for both MappableIface and DeviceType to array views. Also shifting the array view phase earlier in the compilation stages. > > Minor refactoring for array view phase. Ruby Chen has updated the pull request incrementally with one additional commit since the last revision: Added tests ------------- Changes: - all: https://git.openjdk.org/babylon/pull/732/files - new: https://git.openjdk.org/babylon/pull/732/files/b9facd6c..73cf6b4e Webrevs: - full: https://webrevs.openjdk.org/?repo=babylon&pr=732&range=03 - incr: https://webrevs.openjdk.org/?repo=babylon&pr=732&range=02-03 Stats: 236 lines in 2 files changed: 166 ins; 68 del; 2 mod Patch: https://git.openjdk.org/babylon/pull/732.diff Fetch: git fetch https://git.openjdk.org/babylon.git pull/732/head:pull/732 PR: https://git.openjdk.org/babylon/pull/732 From duke at openjdk.org Thu Dec 11 20:06:51 2025 From: duke at openjdk.org (duke) Date: Thu, 11 Dec 2025 20:06:51 GMT Subject: [code-reflection] RFR: Add DeviceType support for array views [v3] In-Reply-To: References: Message-ID: On Thu, 11 Dec 2025 20:00:50 GMT, Ruby Chen wrote: >> Adding support for both MappableIface and DeviceType to array views. Also shifting the array view phase earlier in the compilation stages. >> >> Minor refactoring for array view phase. > > Ruby Chen has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains three additional commits since the last revision: > > - Merge branch 'openjdk:code-reflection' into array-view > - Merge branch 'openjdk:code-reflection' into array-view > - Add DeviceType support for array views @rbrchen Your change (at version 73cf6b4e03cc786a09e4d641949ed100912212dd) is now ready to be sponsored by a Committer. ------------- PR Comment: https://git.openjdk.org/babylon/pull/732#issuecomment-3643586081 From jfumero at openjdk.org Fri Dec 12 11:40:44 2025 From: jfumero at openjdk.org (Juan Fumero) Date: Fri, 12 Dec 2025 11:40:44 GMT Subject: [code-reflection] RFR: HAT memory mallocs and copies improved Message-ID: Use of `MappableIface` annotations to tag the buffer accessor for OpenCL. In addition, this PR reuses buffers attach to each dispatch and copies the data that is needed. For OpenCL and macOS, this PR in HAT increases performance of up to 30% end-to-end time (including data movement). Buffer accessors are not available for CUDA, but the CUDA runtime in HAT minimizes the transfers as well as cuda allocations. How to test? All unit-tests should be passing: java @hat/test-suite ffi-opencl Run violajones: HAT=MINIMIZE_COPIES java -cp hat/job.jar hat.java run ffi-opencl -Dheadless=true violajones ``` Run GoL: java @hat/run ffi-opencl life ------------- Commit messages: - Merge branch 'code-reflection' into hat/memory/accessors - [hat] using the same type for accessors - [hat] improving data handler and transfers - [hat] cuda buffer allocs and copies minimized - [hat][wip] Improvements MemAlloc and data copies Changes: https://git.openjdk.org/babylon/pull/746/files Webrev: https://webrevs.openjdk.org/?repo=babylon&pr=746&range=00 Stats: 120 lines in 15 files changed: 24 ins; 22 del; 74 mod Patch: https://git.openjdk.org/babylon/pull/746.diff Fetch: git fetch https://git.openjdk.org/babylon.git pull/746/head:pull/746 PR: https://git.openjdk.org/babylon/pull/746 From jfumero at openjdk.org Fri Dec 12 11:54:25 2025 From: jfumero at openjdk.org (Juan Fumero) Date: Fri, 12 Dec 2025 11:54:25 GMT Subject: [code-reflection] RFR: Add DeviceType support for array views [v4] In-Reply-To: References: Message-ID: On Thu, 11 Dec 2025 20:06:48 GMT, Ruby Chen wrote: >> Adding support for both MappableIface and DeviceType to array views. Also shifting the array view phase earlier in the compilation stages. >> >> Minor refactoring for array view phase. > > Ruby Chen has updated the pull request incrementally with one additional commit since the last revision: > > Added tests Thanks Ruby. All tests passing now. I think this version does not need the records `ArrayAccessInfo` and `Node` and the methods associated with it. Any reason to keep them? ------------- PR Review: https://git.openjdk.org/babylon/pull/732#pullrequestreview-3571522537 From jfumero at openjdk.org Fri Dec 12 12:14:51 2025 From: jfumero at openjdk.org (Juan Fumero) Date: Fri, 12 Dec 2025 12:14:51 GMT Subject: [code-reflection] RFR: HAT memory mallocs and copies improved [v2] In-Reply-To: References: Message-ID: > Use of `MappableIface` annotations to tag the buffer accessor for OpenCL. > In addition, this PR reuses buffers attach to each dispatch and copies the data that is needed. > > For OpenCL and macOS, this PR in HAT increases performance of up to 30% end-to-end time (including data movement). > > Buffer accessors are not available for CUDA, but the CUDA runtime in HAT minimizes the transfers as well as cuda allocations. > > How to test? All unit-tests should be passing: > > > java @hat/test-suite ffi-opencl > > > Run violajones: > > > HAT=MINIMIZE_COPIES java -cp hat/job.jar hat.java run ffi-opencl -Dheadless=true violajones > ``` > > Run GoL: > > > java @hat/run ffi-opencl life Juan Fumero has updated the pull request incrementally with one additional commit since the last revision: [hat] life-example revert control to RO ------------- Changes: - all: https://git.openjdk.org/babylon/pull/746/files - new: https://git.openjdk.org/babylon/pull/746/files/654d1b53..fe11189a Webrevs: - full: https://webrevs.openjdk.org/?repo=babylon&pr=746&range=01 - incr: https://webrevs.openjdk.org/?repo=babylon&pr=746&range=00-01 Stats: 3 lines in 1 file changed: 0 ins; 1 del; 2 mod Patch: https://git.openjdk.org/babylon/pull/746.diff Fetch: git fetch https://git.openjdk.org/babylon.git pull/746/head:pull/746 PR: https://git.openjdk.org/babylon/pull/746 From jfumero at openjdk.org Fri Dec 12 13:11:54 2025 From: jfumero at openjdk.org (Juan Fumero) Date: Fri, 12 Dec 2025 13:11:54 GMT Subject: git: openjdk/babylon: code-reflection: HAT memory mallocs and copies improved Message-ID: <3181a678-8396-45f5-bea1-a54445391f1d@openjdk.org> Changeset: df6fb50e Branch: code-reflection Author: Juan Fumero Date: 2025-12-12 13:09:43 +0000 URL: https://git.openjdk.org/babylon/commit/df6fb50ec25517c19838fecc2ae6a6ebcb009849 HAT memory mallocs and copies improved ! hat/backends/ffi/cuda/src/main/native/cpp/cuda_backend.cpp ! hat/backends/ffi/cuda/src/main/native/cpp/cuda_backend_buffer.cpp ! hat/backends/ffi/cuda/src/main/native/include/cuda_backend.h ! hat/backends/ffi/mock/src/main/native/cpp/mock_backend.cpp ! hat/backends/ffi/opencl/src/main/java/hat/backend/ffi/OpenCLBackend.java ! hat/backends/ffi/opencl/src/main/native/cpp/opencl_backend.cpp ! hat/backends/ffi/opencl/src/main/native/cpp/opencl_backend_buffer.cpp ! hat/backends/ffi/opencl/src/main/native/include/opencl_backend.h ! hat/backends/ffi/shared/src/main/native/cpp/shared.cpp ! hat/backends/ffi/shared/src/main/native/include/shared.h ! hat/examples/life/src/main/java/life/Main.java ! hat/examples/matmul/src/main/java/matmul/Main.java ! hat/examples/violajones/src/main/java/violajones/ViolaJonesCoreCompute.java ! hat/tests/src/main/java/hat/test/TestBFloat16Type.java ! hat/tests/src/main/java/hat/test/TestF16Type.java From jfumero at openjdk.org Fri Dec 12 13:12:29 2025 From: jfumero at openjdk.org (Juan Fumero) Date: Fri, 12 Dec 2025 13:12:29 GMT Subject: [code-reflection] Integrated: HAT memory mallocs and copies improved In-Reply-To: References: Message-ID: On Fri, 12 Dec 2025 11:33:56 GMT, Juan Fumero wrote: > Use of `MappableIface` annotations to tag the buffer accessor for OpenCL. > In addition, this PR reuses buffers attach to each dispatch and copies the data that is needed. > > For OpenCL and macOS, this PR in HAT increases performance of up to 30% end-to-end time (including data movement). > > Buffer accessors are not available for CUDA, but the CUDA runtime in HAT minimizes the transfers as well as cuda allocations. > > How to test? All unit-tests should be passing: > > > java @hat/test-suite ffi-opencl > > > Run violajones: > > > HAT=MINIMIZE_COPIES java -cp hat/job.jar hat.java run ffi-opencl -Dheadless=true violajones > ``` > > Run GoL: > > > java @hat/run ffi-opencl life This pull request has now been integrated. Changeset: df6fb50e Author: Juan Fumero URL: https://git.openjdk.org/babylon/commit/df6fb50ec25517c19838fecc2ae6a6ebcb009849 Stats: 117 lines in 15 files changed: 23 ins; 22 del; 72 mod HAT memory mallocs and copies improved ------------- PR: https://git.openjdk.org/babylon/pull/746 From asotona at openjdk.org Fri Dec 12 14:07:10 2025 From: asotona at openjdk.org (Adam Sotona) Date: Fri, 12 Dec 2025 14:07:10 GMT Subject: [code-reflection] RFR: 8373576: BytecodeGenerator fails with AssertionError on InvokeOp with varargs Message-ID: The first operand of a static vararg method invocation is wrongly identified as the first operand on stack for the following bytecode instruction. However several bytecode instructions prepend the operand use, so the operand presence on the stack must be deferred. ------------- Commit messages: - 8373576: BytecodeGenerator fails with AssertionError on InvokeOp with varargs Changes: https://git.openjdk.org/babylon/pull/747/files Webrev: https://webrevs.openjdk.org/?repo=babylon&pr=747&range=00 Issue: https://bugs.openjdk.org/browse/JDK-8373576 Stats: 8 lines in 2 files changed: 8 ins; 0 del; 0 mod Patch: https://git.openjdk.org/babylon/pull/747.diff Fetch: git fetch https://git.openjdk.org/babylon.git pull/747/head:pull/747 PR: https://git.openjdk.org/babylon/pull/747 From gfrost at openjdk.org Fri Dec 12 17:34:25 2025 From: gfrost at openjdk.org (Gary Frost) Date: Fri, 12 Dec 2025 17:34:25 GMT Subject: [code-reflection] RFR: HAT memory mallocs and copies improved [v2] In-Reply-To: References: Message-ID: On Fri, 12 Dec 2025 12:14:51 GMT, Juan Fumero wrote: >> Use of `MappableIface` annotations to tag the buffer accessor for OpenCL. >> In addition, this PR reuses buffers attach to each dispatch and copies the data that is needed. >> >> For OpenCL and macOS, this PR in HAT increases performance of up to 30% end-to-end time (including data movement). >> >> Buffer accessors are not available for CUDA, but the CUDA runtime in HAT minimizes the transfers as well as cuda allocations. >> >> How to test? All unit-tests should be passing: >> >> >> java @hat/test-suite ffi-opencl >> >> >> Run violajones: >> >> >> HAT=MINIMIZE_COPIES java -cp hat/job.jar hat.java run ffi-opencl -Dheadless=true violajones >> ``` >> >> Run GoL: >> >> >> java @hat/run ffi-opencl life > > Juan Fumero has updated the pull request incrementally with one additional commit since the last revision: > > [hat] life-example revert control to RO hat/backends/ffi/cuda/src/main/native/cpp/cuda_backend.cpp line 366: > 364: CudaBackend::CudaBuffer *CudaBackend::getOrCreateBuffer(BufferState *bufferState, u8_t accessor) { > 365: CudaBuffer *cudaBuffer = nullptr; > 366: if (bufferState->vendorPtr == nullptr || bufferState->state == BufferState::NEW_STATE) { So I understand we are embedding the access (RO|WO etc) in the buffer... we get this access from the arg slot info (RO|WO etc) and then putting this in the memory segment.. What if we pass this to another kernel whose access is different? ------------- PR Review Comment: https://git.openjdk.org/babylon/pull/746#discussion_r2615045605 From duke at openjdk.org Fri Dec 12 18:07:05 2025 From: duke at openjdk.org (Ruby Chen) Date: Fri, 12 Dec 2025 18:07:05 GMT Subject: [code-reflection] RFR: Add DeviceType support for array views [v5] In-Reply-To: References: Message-ID: > Adding support for both MappableIface and DeviceType to array views. Also shifting the array view phase earlier in the compilation stages. > > Minor refactoring for array view phase. Ruby Chen has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains six additional commits since the last revision: - Removed more code - Merge branch 'openjdk:code-reflection' into array-view - Added tests - Merge branch 'openjdk:code-reflection' into array-view - Merge branch 'openjdk:code-reflection' into array-view - Add DeviceType support for array views ------------- Changes: - all: https://git.openjdk.org/babylon/pull/732/files - new: https://git.openjdk.org/babylon/pull/732/files/73cf6b4e..56af3150 Webrevs: - full: https://webrevs.openjdk.org/?repo=babylon&pr=732&range=04 - incr: https://webrevs.openjdk.org/?repo=babylon&pr=732&range=03-04 Stats: 184 lines in 16 files changed: 23 ins; 89 del; 72 mod Patch: https://git.openjdk.org/babylon/pull/732.diff Fetch: git fetch https://git.openjdk.org/babylon.git pull/732/head:pull/732 PR: https://git.openjdk.org/babylon/pull/732 From duke at openjdk.org Fri Dec 12 18:07:07 2025 From: duke at openjdk.org (Ruby Chen) Date: Fri, 12 Dec 2025 18:07:07 GMT Subject: [code-reflection] RFR: Add DeviceType support for array views [v4] In-Reply-To: References: Message-ID: On Thu, 11 Dec 2025 20:06:48 GMT, Ruby Chen wrote: >> Adding support for both MappableIface and DeviceType to array views. Also shifting the array view phase earlier in the compilation stages. >> >> Minor refactoring for array view phase. > > Ruby Chen has updated the pull request incrementally with one additional commit since the last revision: > > Added tests Hi Juan! No reason to keep them :) Just removed those plus a few other methods that won't be used anymore - thanks for catching that! ------------- PR Comment: https://git.openjdk.org/babylon/pull/732#issuecomment-3647573220 From duke at openjdk.org Fri Dec 12 18:07:08 2025 From: duke at openjdk.org (duke) Date: Fri, 12 Dec 2025 18:07:08 GMT Subject: [code-reflection] RFR: Add DeviceType support for array views [v4] In-Reply-To: References: Message-ID: <0WnL-Venvx1LjodjmrB21T4Ch8BqXF9PaQ394TcnWvw=.8ec109f2-4174-41be-8d58-191bb83036ed@github.com> On Thu, 11 Dec 2025 20:06:48 GMT, Ruby Chen wrote: >> Adding support for both MappableIface and DeviceType to array views. Also shifting the array view phase earlier in the compilation stages. >> >> Minor refactoring for array view phase. > > Ruby Chen has updated the pull request incrementally with one additional commit since the last revision: > > Added tests @rbrchen Your change (at version 56af3150e6b52e547132f63e296b92896dbd7d2d) is now ready to be sponsored by a Committer. ------------- PR Comment: https://git.openjdk.org/babylon/pull/732#issuecomment-3647578847 From gfrost at openjdk.org Fri Dec 12 18:20:19 2025 From: gfrost at openjdk.org (Gary Frost) Date: Fri, 12 Dec 2025 18:20:19 GMT Subject: git: openjdk/babylon: code-reflection: Add DeviceType support for array views Message-ID: <64d16cd9-06af-4d1d-a0a3-75b87406085e@openjdk.org> Changeset: 486841fc Branch: code-reflection Author: Ruby Chen Committer: Gary Frost Date: 2025-12-12 18:17:03 +0000 URL: https://git.openjdk.org/babylon/commit/486841fc7ed1651e5372651c4d69ad022a8540de Add DeviceType support for array views ! hat/core/src/main/java/hat/phases/HATDialectifyArrayViewPhase.java ! hat/core/src/main/java/hat/phases/HATDialectifyTier.java ! hat/tests/src/main/java/hat/test/TestArrayView.java From duke at openjdk.org Fri Dec 12 18:20:25 2025 From: duke at openjdk.org (Ruby Chen) Date: Fri, 12 Dec 2025 18:20:25 GMT Subject: [code-reflection] Integrated: Add DeviceType support for array views In-Reply-To: References: Message-ID: On Mon, 8 Dec 2025 02:10:48 GMT, Ruby Chen wrote: > Adding support for both MappableIface and DeviceType to array views. Also shifting the array view phase earlier in the compilation stages. > > Minor refactoring for array view phase. This pull request has now been integrated. Changeset: 486841fc Author: Ruby Chen Committer: Gary Frost URL: https://git.openjdk.org/babylon/commit/486841fc7ed1651e5372651c4d69ad022a8540de Stats: 367 lines in 3 files changed: 209 ins; 71 del; 87 mod Add DeviceType support for array views ------------- PR: https://git.openjdk.org/babylon/pull/732 From mabbay at openjdk.org Fri Dec 12 18:59:58 2025 From: mabbay at openjdk.org (Mourad Abbay) Date: Fri, 12 Dec 2025 18:59:58 GMT Subject: [code-reflection] RFR: Test java version check we do in op building methods Message-ID: Write test to make sure java version check we do before building models is working. There are other options to do the test, one in particular is passing the java compile time version as option and update the OpBuilder to accept the feature version we test against. ------------- Commit messages: - Write test for $checkJavaVersion Changes: https://git.openjdk.org/babylon/pull/748/files Webrev: https://webrevs.openjdk.org/?repo=babylon&pr=748&range=00 Stats: 115 lines in 1 file changed: 115 ins; 0 del; 0 mod Patch: https://git.openjdk.org/babylon/pull/748.diff Fetch: git fetch https://git.openjdk.org/babylon.git pull/748/head:pull/748 PR: https://git.openjdk.org/babylon/pull/748 From nadeeshtv at gmail.com Sat Dec 13 17:22:04 2025 From: nadeeshtv at gmail.com (nadeesh t v) Date: Sat, 13 Dec 2025 18:22:04 +0100 Subject: Some minor errors observed in while experimenting with a sample Message-ID: Hello, I was experimenting with a HAT Squares sample () and noticed a couple of minor issues ( at least I think). Since this is still in the development stage, I am not sure whether it?s right to bring it up or not. Let me know if these kinds of minor issues should not be brought up or not. I was using the *OpenCL* backend. 1 I can mark the argument of kernel function with any one of the RO/RW annotations and still seem to work. For eg: in the original example it was* void squareKernel(@RO KernelContext kc, @RW S32Array array)* But if I change that to `*void squareKernel(@WO KernelContext kc, @RO S32Array array)* `, it still works. I would expect it to throw some errors because the access byte has changed. 2 If I add a *System.out.println("Hello")* in the kernel, it is running to the below issue. ``` *@Reflect* *public static void squareKernel(@WO KernelContext kc, @RO S32Array array) {* * System.out.println("Hello");* * if (kc.gix < kc.gsx){* * ?.* * }* * }* ``` Is there some rule about what should go into the kernel function? ``` *what?org.example.MainWithHAT::squareKernel(hat.KernelContext, hat.buffer.S32Array):void java.lang.IllegalStateException: What is this field load ?jdk.incubator.code.dialect.java.JavaOp$FieldAccessOp$FieldLoadOp at 1fc32e4fjava.lang.IllegalStateException: What is this field load ?jdk.incubator.code.dialect.java.JavaOp$FieldAccessOp$FieldLoadOp at 1fc32e4f* * at hat.codebuilders.C99HATKernelBuilder.fieldLoadOp(C99HATKernelBuilder.java:72)* * at hat.codebuilders.C99HATKernelBuilder.fieldLoadOp(C99HATKernelBuilder.java:58)* ?. ``` 3. If I comment out the *Reflect *on the function that is called from kernel function ``` *// @Reflect* public static int squareit(int v) { return v * v; } ``` Then *,* I am running into the familiar `c` error. ``` *UNSUPPORTED (log once): buildComputeProgram: cl2Metal failed* *buildStatus =failed* *logLen = 186 log = program_source:50:37: error: implicit declaration of function 'squareit' is invalid in OpenCL* * array->array[(long)HAT_GIX]=squareit(value);* ``` 4. If I comment out the *Reflect *on the *compute method* function that is throwing an error from *Optional* but for that I can create a pull request to throw the one similar to the `did you miss @Reflect annotation?`. -- Thanks and Regards, Nadeesh TV -------------- next part -------------- An HTML attachment was scrubbed... URL: From duke at openjdk.org Sun Dec 14 04:58:13 2025 From: duke at openjdk.org (Ruby Chen) Date: Sun, 14 Dec 2025 04:58:13 GMT Subject: [code-reflection] RFR: ModuleOp generation from LambdaOp and FuncOp [v9] In-Reply-To: References: Message-ID: > Add support for generating a ModuleOp from either a LambdaOp or a FuncOp. The given LambdaOp will be converted into the root FuncOp, and the given FuncOp will be assigned as the root FuncOp. > > For `CoreOp.ModuleOp.ofLambdaOp()`, a unique name for the new root FuncOp must be passed as a parameter. Ruby Chen has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains 14 additional commits since the last revision: - Suggested changes - Merge branch 'openjdk:code-reflection' into module-op-support - fixes - Merge branch 'openjdk:code-reflection' into module-op-support - fixed tests - Merge branch 'openjdk:code-reflection' into module-op-support - Add tests - Merge branch 'openjdk:code-reflection' into module-op-support - removing commented code - Suggested changes - ... and 4 more: https://git.openjdk.org/babylon/compare/7164bb9e...630cb9d0 ------------- Changes: - all: https://git.openjdk.org/babylon/pull/691/files - new: https://git.openjdk.org/babylon/pull/691/files/e70019bf..630cb9d0 Webrevs: - full: https://webrevs.openjdk.org/?repo=babylon&pr=691&range=08 - incr: https://webrevs.openjdk.org/?repo=babylon&pr=691&range=07-08 Stats: 1422 lines in 96 files changed: 555 ins; 280 del; 587 mod Patch: https://git.openjdk.org/babylon/pull/691.diff Fetch: git fetch https://git.openjdk.org/babylon.git pull/691/head:pull/691 PR: https://git.openjdk.org/babylon/pull/691 From gary.frost at oracle.com Mon Dec 15 08:59:32 2025 From: gary.frost at oracle.com (Gary Frost) Date: Mon, 15 Dec 2025 08:59:32 +0000 Subject: Some minor errors observed in while experimenting with a sample In-Reply-To: References: Message-ID: Hello Nadesh. Thanks for checking out HAT and for the feedback. Basicallyference the question numbers in your email in my response. 1) The access annotations for kernel args (and compute args) are currently needed, but will soon be unnecessary. These annotations indicate a contract with the kernel, indicating how the kernel expects to access its 'buffer' args (MemorySegments) . We have code which can determine the access patterns by static analysis of the kernel call tree (a closure over the kernel and all methods reachable from it) and at present we are validating that our analysis matches the annotations. So you should endeavour to annotate corrrectly. Failure to do so, will mean that we will treat it as RW. So we may copy unnecessarily to the GPU. 2) Kernels are intended to be run on the GPU (or FPGA or some other accelerator device). So code should be restricted to code that can be executed on those devices. Basically kernels should only receive primitives and memory segments. It should only operate on its received args using the 'identity' communicated via the KernelContext. Generally you should not Allocate any Object (or array) , either directly (via new)or by calling methods that will allocate an object or array. So sadly no Strings (* 1 see below) Call any method (static or instance) that is not itself code reflectable via @Reflect annotation. (* 2 see below) Reference any fields (static or instance) not under HAT's control. (* 3 below again) We can map certain Math.xxx() methods. but generally even this may need to be controlled Throw any exceptions or call any method that throws an exception. You can only call static methods which follow the rules above, 3) System.out.println(...) in a kernel fails for multiple reasons (#1, #2 and #3) above :) because it references a static field of System and then tries to call println() on the object that is retrieved from that field and it tries to pass a String which is allocated (the "literal") The first check fails because of the field load on System.out ... hence the (sadly cryptic) "What is this field load"? Regarding ... UNSUPPORTED (log once): buildComputeProgram: cl2Metal failed buildStatus =failed logLen = 186 log = program_source:50:37: error: implicit declaration of function 'squareit' is invalid in OpenCL array->array[(long)HAT_GIX]=squareit(value); Can you send a (small as possible) example that creates this error? If we follow all the rules above (and the ones I have forgotten to include ;) ) you shoduring see this. And The change from @CodeReflection -> @Reflect and requiring lambdas to cast to Compute or Kernel Quotable's is very new. You may have pulled babylon and HAT during a sequence of checkins. Can you try to pull the latest (and rebuild your Babylon enabled JDK) .. and just check that you have the latest version. Regards Gary Confidential- Oracle Internal ________________________________ From: babylon-dev on behalf of nadeesh t v Sent: Saturday, December 13, 2025 5:22 PM To: babylon-dev at openjdk.org Subject: Some minor errors observed in while experimenting with a sample Hello, I was experimenting with a HAT Squares sample () and noticed a couple of minor issues ( at least I think). Since this is still in the development stage, I am not sure whether it?s right to bring it up or not. Let me know if these kinds of minor issues should not be brought up or not. I was using the OpenCL backend. 1 I can mark the argument of kernel function with any one of the RO/RW annotations and still seem to work. For eg: in the original example it was void squareKernel(@RO KernelContext kc, @RW S32Array array) But if I change that to `void squareKernel(@WO KernelContext kc, @RO S32Array array) `, it still works. I would expect it to throw some errors because the access byte has changed. 2 If I add a System.out.println("Hello") in the kernel, it is running to the below issue. ``` @Reflect public static void squareKernel(@WO KernelContext kc, @RO S32Array array) { System.out.println("Hello"); if (kc.gix < kc.gsx){ ?. } } ``` Is there some rule about what should go into the kernel function? ``` what?org.example.MainWithHAT::squareKernel(hat.KernelContext, hat.buffer.S32Array):void java.lang.IllegalStateException: What is this field load ?jdk.incubator.code.dialect.java.JavaOp$FieldAccessOp$FieldLoadOp at 1fc32e4fjava.lang.IllegalStateException: What is this field load ?jdk.incubator.code.dialect.java.JavaOp$FieldAccessOp$FieldLoadOp at 1fc32e4f at hat.codebuilders.C99HATKernelBuilder.fieldLoadOp(C99HATKernelBuilder.java:72) at hat.codebuilders.C99HATKernelBuilder.fieldLoadOp(C99HATKernelBuilder.java:58) ?. ``` 3. If I comment out the Reflect on the function that is called from kernel function ``` // @Reflect public static int squareit(int v) { return v * v; } ``` Then , I am running into the familiar `c` error. ``` UNSUPPORTED (log once): buildComputeProgram: cl2Metal failed buildStatus =failed logLen = 186 log = program_source:50:37: error: implicit declaration of function 'squareit' is invalid in OpenCL array->array[(long)HAT_GIX]=squareit(value); ``` 4. If I comment out the Reflect on the compute method function that is throwing an error from Optional but for that I can create a pull request to throw the one similar to the `did you miss @Reflect annotation?`. -- Thanks and Regards, Nadeesh TV -------------- next part -------------- An HTML attachment was scrubbed... URL: From jfumero at openjdk.org Mon Dec 15 09:47:25 2025 From: jfumero at openjdk.org (Juan Fumero) Date: Mon, 15 Dec 2025 09:47:25 GMT Subject: [code-reflection] RFR: HAT memory mallocs and copies improved [v2] In-Reply-To: References: Message-ID: <4r5sFN63SmvMiLQnJ7Xp4dAedDqfDttN32Yqj_ofBf4=.81d9fdc8-80fe-4c4b-88bd-b3ffd97e619b@github.com> On Fri, 12 Dec 2025 17:31:32 GMT, Gary Frost wrote: >> Juan Fumero has updated the pull request incrementally with one additional commit since the last revision: >> >> [hat] life-example revert control to RO > > hat/backends/ffi/cuda/src/main/native/cpp/cuda_backend.cpp line 366: > >> 364: CudaBackend::CudaBuffer *CudaBackend::getOrCreateBuffer(BufferState *bufferState, u8_t accessor) { >> 365: CudaBuffer *cudaBuffer = nullptr; >> 366: if (bufferState->vendorPtr == nullptr || bufferState->state == BufferState::NEW_STATE) { > > So I understand we are embedding the access (RO|WO etc) in the buffer... > > we get this access from the arg slot info (RO|WO etc) and then putting this in the memory segment.. > > What if we pass this to another kernel whose access is different? Accesses declared from the API side are immutable. In the case it changes it should be declared as R/W. The copy on-demand will work because it takes the access for the arg slot. We can revisit this model. Note that, if a buffer is Read-only, later we can't change it, unless we do a new malloc and move the data to the new buffer. But this is very inefficient. So, if this is what we want, we need to find other options. ------------- PR Review Comment: https://git.openjdk.org/babylon/pull/746#discussion_r2618694305 From gfrost at openjdk.org Mon Dec 15 10:24:50 2025 From: gfrost at openjdk.org (Gary Frost) Date: Mon, 15 Dec 2025 10:24:50 GMT Subject: git: openjdk/babylon: code-reflection: Config parsing was not capturing PLATFORM:n or DEVICE:n Message-ID: <4db0ee8b-448c-41ab-bfd2-c0a4a27fb5a8@openjdk.org> Changeset: 8465bab5 Branch: code-reflection Author: Gary Frost Date: 2025-12-15 10:22:49 +0000 URL: https://git.openjdk.org/babylon/commit/8465bab5ed2bc2cbe7a8fd6d8d07b9107babb5c8 Config parsing was not capturing PLATFORM:n or DEVICE:n ! hat/core/src/main/java/hat/Config.java ! hat/intellij/.idea/misc.xml From gfrost at openjdk.org Mon Dec 15 10:25:51 2025 From: gfrost at openjdk.org (Gary Frost) Date: Mon, 15 Dec 2025 10:25:51 GMT Subject: [code-reflection] Integrated: Config parsing was not capturing PLATFORM:n or DEVICE:n Message-ID: Fixed Config parser which was failing to parse PLATFORN:n and DEVICE:n Tidied up parser and deleted dead code. ------------- Commit messages: - Config parsing was not capturing PLATFORM:n or DEVICE:n Changes: https://git.openjdk.org/babylon/pull/749/files Webrev: https://webrevs.openjdk.org/?repo=babylon&pr=749&range=00 Stats: 73 lines in 2 files changed: 16 ins; 39 del; 18 mod Patch: https://git.openjdk.org/babylon/pull/749.diff Fetch: git fetch https://git.openjdk.org/babylon.git pull/749/head:pull/749 PR: https://git.openjdk.org/babylon/pull/749 From gfrost at openjdk.org Mon Dec 15 10:25:52 2025 From: gfrost at openjdk.org (Gary Frost) Date: Mon, 15 Dec 2025 10:25:52 GMT Subject: [code-reflection] Integrated: Config parsing was not capturing PLATFORM:n or DEVICE:n In-Reply-To: References: Message-ID: On Mon, 15 Dec 2025 10:18:57 GMT, Gary Frost wrote: > Fixed Config parser which was failing to parse PLATFORN:n and DEVICE:n > > Tidied up parser and deleted dead code. This pull request has now been integrated. Changeset: 8465bab5 Author: Gary Frost URL: https://git.openjdk.org/babylon/commit/8465bab5ed2bc2cbe7a8fd6d8d07b9107babb5c8 Stats: 73 lines in 2 files changed: 16 ins; 39 del; 18 mod Config parsing was not capturing PLATFORM:n or DEVICE:n ------------- PR: https://git.openjdk.org/babylon/pull/749 From asotona at openjdk.org Mon Dec 15 10:28:12 2025 From: asotona at openjdk.org (Adam Sotona) Date: Mon, 15 Dec 2025 10:28:12 GMT Subject: [code-reflection] Integrated: 8373576: BytecodeGenerator fails with AssertionError on InvokeOp with varargs In-Reply-To: References: Message-ID: On Fri, 12 Dec 2025 14:01:27 GMT, Adam Sotona wrote: > The first operand of a static vararg method invocation is wrongly identified as the first operand on stack for the following bytecode instruction. > However several bytecode instructions prepend the operand use, so the operand presence on the stack must be deferred. This pull request has now been integrated. Changeset: 476bbf7b Author: Adam Sotona URL: https://git.openjdk.org/babylon/commit/476bbf7b3649002487ecf9ce63734a2fb70bf312 Stats: 8 lines in 2 files changed: 8 ins; 0 del; 0 mod 8373576: BytecodeGenerator fails with AssertionError on InvokeOp with varargs ------------- PR: https://git.openjdk.org/babylon/pull/747 From asotona at openjdk.org Mon Dec 15 10:30:18 2025 From: asotona at openjdk.org (Adam Sotona) Date: Mon, 15 Dec 2025 10:30:18 GMT Subject: git: openjdk/babylon: code-reflection: 8373576: BytecodeGenerator fails with AssertionError on InvokeOp with varargs Message-ID: <5c52d400-e14d-4544-b40f-4da1cec2564b@openjdk.org> Changeset: 476bbf7b Branch: code-reflection Author: Adam Sotona Date: 2025-12-15 10:25:31 +0000 URL: https://git.openjdk.org/babylon/commit/476bbf7b3649002487ecf9ce63734a2fb70bf312 8373576: BytecodeGenerator fails with AssertionError on InvokeOp with varargs ! src/jdk.incubator.code/share/classes/jdk/incubator/code/bytecode/BytecodeGenerator.java ! test/jdk/java/lang/reflect/code/bytecode/TestBytecode.java From mcimadamore at openjdk.org Mon Dec 15 11:38:42 2025 From: mcimadamore at openjdk.org (Maurizio Cimadamore) Date: Mon, 15 Dec 2025 11:38:42 GMT Subject: [code-reflection] RFR: 8373571: Code model of JavaOp.ForOp does not handle (un)boxing correctly Message-ID: This PR addresses an issue in for-each loop model generation. The for each op factory takes three bodies: 1. the for each expression (e.g. either a collection, or an array) 2. the for each initializer (the logic that receives an element from the expression, and turns it into the expected variable type in the source code) 3. the for each body The translation for (2) seems to contain a bug: javac erroneously assumes that the initializer body has type `(V)->V`, where `V` is the type of the induction variable declared in the source code. This PR fixes that so that (2) has type `(ELEM)->V`, where `ELEM` is the static type of an element of the for-each expression, and `V` is the static type of the induction variable. This translation allows uboxing operations to appear manifest in the generated model. ------------- Commit messages: - Add tests - Initial push Changes: https://git.openjdk.org/babylon/pull/750/files Webrev: https://webrevs.openjdk.org/?repo=babylon&pr=750&range=00 Issue: https://bugs.openjdk.org/browse/JDK-8373571 Stats: 79 lines in 2 files changed: 76 ins; 1 del; 2 mod Patch: https://git.openjdk.org/babylon/pull/750.diff Fetch: git fetch https://git.openjdk.org/babylon.git pull/750/head:pull/750 PR: https://git.openjdk.org/babylon/pull/750 From mcimadamore at openjdk.org Mon Dec 15 11:53:42 2025 From: mcimadamore at openjdk.org (Maurizio Cimadamore) Date: Mon, 15 Dec 2025 11:53:42 GMT Subject: [code-reflection] RFR: 8373571: Code model of JavaOp.ForOp does not handle (un)boxing correctly [v2] In-Reply-To: References: Message-ID: > This PR addresses an issue in for-each loop model generation. > The for each op factory takes three bodies: > 1. the for each expression (e.g. either a collection, or an array) > 2. the for each initializer (the logic that receives an element from the expression, and turns it into the expected variable type in the source code) > 3. the for each body > > The translation for (2) seems to contain a bug: javac erroneously assumes that the initializer body has type `(V)->V`, where `V` is the type of the induction variable declared in the source code. > > This PR fixes that so that (2) has type `(ELEM)->V`, where `ELEM` is the static type of an element of the for-each expression, and `V` is the static type of the induction variable. > > This translation allows uboxing operations to appear manifest in the generated model. Maurizio Cimadamore has updated the pull request incrementally with one additional commit since the last revision: Make sure logic for determining expression element type is same as in `Attr` Add more tests ------------- Changes: - all: https://git.openjdk.org/babylon/pull/750/files - new: https://git.openjdk.org/babylon/pull/750/files/c08ee937..7e220e1b Webrevs: - full: https://webrevs.openjdk.org/?repo=babylon&pr=750&range=01 - incr: https://webrevs.openjdk.org/?repo=babylon&pr=750&range=00-01 Stats: 82 lines in 2 files changed: 79 ins; 0 del; 3 mod Patch: https://git.openjdk.org/babylon/pull/750.diff Fetch: git fetch https://git.openjdk.org/babylon.git pull/750/head:pull/750 PR: https://git.openjdk.org/babylon/pull/750 From mcimadamore at openjdk.org Mon Dec 15 11:53:44 2025 From: mcimadamore at openjdk.org (Maurizio Cimadamore) Date: Mon, 15 Dec 2025 11:53:44 GMT Subject: [code-reflection] RFR: 8373571: Code model of JavaOp.ForOp does not handle (un)boxing correctly [v2] In-Reply-To: References: Message-ID: On Mon, 15 Dec 2025 11:50:20 GMT, Maurizio Cimadamore wrote: >> This PR addresses an issue in for-each loop model generation. >> The for each op factory takes three bodies: >> 1. the for each expression (e.g. either a collection, or an array) >> 2. the for each initializer (the logic that receives an element from the expression, and turns it into the expected variable type in the source code) >> 3. the for each body >> >> The translation for (2) seems to contain a bug: javac erroneously assumes that the initializer body has type `(V)->V`, where `V` is the type of the induction variable declared in the source code. >> >> This PR fixes that so that (2) has type `(ELEM)->V`, where `ELEM` is the static type of an element of the for-each expression, and `V` is the static type of the induction variable. >> >> This translation allows uboxing operations to appear manifest in the generated model. > > Maurizio Cimadamore has updated the pull request incrementally with one additional commit since the last revision: > > Make sure logic for determining expression element type is same as in `Attr` > Add more tests src/jdk.incubator.code/share/classes/jdk/incubator/code/internal/ReflectMethods.java line 1874: > 1872: // return the bound variables > 1873: Type exprType = types.cvarUpperBound(tree.expr.type); > 1874: Type elemtype = types.elemtype(exprType); // perhaps expr is an array? The logic here is very similar with what `Attr` does -- as we really want to use the same expression element type ------------- PR Review Comment: https://git.openjdk.org/babylon/pull/750#discussion_r2619091016 From jfumero at openjdk.org Mon Dec 15 17:00:09 2025 From: jfumero at openjdk.org (Juan Fumero) Date: Mon, 15 Dec 2025 17:00:09 GMT Subject: [code-reflection] RFR: [hat] Remove device custom data types that inherit from Buffer Message-ID: This PR removes the codegen that implemented the logic for processing custom data types for device types that inherit from the iFace buffer. >From now on, iFace buffers represent data represent to be allocated and pass to device's global memory. These buffers backup memory segment on the CPU. For device types, we can build custom data types as well but they inherit from `DeviceType`. For example, local memory, and private memory. How to test: java @hat/test-suite ffi-opencl java @hat/test-suite ffi-cuda ------------- Commit messages: - minor chanage - formatter - [hat] obtain varOp name for the CUDA Vector BinOps - [hat] DeviceType via iFace buffers removed Changes: https://git.openjdk.org/babylon/pull/751/files Webrev: https://webrevs.openjdk.org/?repo=babylon&pr=751&range=00 Stats: 118 lines in 4 files changed: 30 ins; 57 del; 31 mod Patch: https://git.openjdk.org/babylon/pull/751.diff Fetch: git fetch https://git.openjdk.org/babylon.git pull/751/head:pull/751 PR: https://git.openjdk.org/babylon/pull/751 From jfumero at openjdk.org Mon Dec 15 17:32:17 2025 From: jfumero at openjdk.org (Juan Fumero) Date: Mon, 15 Dec 2025 17:32:17 GMT Subject: [code-reflection] Integrated: [hat] Remove device custom data types that inherit from Buffer In-Reply-To: References: Message-ID: On Mon, 15 Dec 2025 14:56:48 GMT, Juan Fumero wrote: > This PR removes the codegen that implemented the logic for processing custom data types for device types that inherit from the iFace buffer. > > From now on, iFace buffers represent data represent to be allocated and pass to device's global memory. > These buffers backup memory segment on the CPU. > > For device types, we can build custom data types as well but they inherit from `DeviceType`. For example, local memory, and private memory. > > How to test: > > > java @hat/test-suite ffi-opencl > > java @hat/test-suite ffi-cuda This pull request has now been integrated. Changeset: 4d5e9a0c Author: Juan Fumero URL: https://git.openjdk.org/babylon/commit/4d5e9a0c8d3c69a779674e9f36f7f4d9aba6627d Stats: 118 lines in 4 files changed: 30 ins; 57 del; 31 mod [hat] Remove device custom data types that inherit from Buffer ------------- PR: https://git.openjdk.org/babylon/pull/751 From jfumero at openjdk.org Mon Dec 15 17:33:09 2025 From: jfumero at openjdk.org (Juan Fumero) Date: Mon, 15 Dec 2025 17:33:09 GMT Subject: git: openjdk/babylon: code-reflection: [hat] Remove device custom data types that inherit from Buffer Message-ID: <092790c2-431f-417a-89b2-c80659aa39d4@openjdk.org> Changeset: 4d5e9a0c Branch: code-reflection Author: Juan Fumero Date: 2025-12-15 17:29:19 +0000 URL: https://git.openjdk.org/babylon/commit/4d5e9a0c8d3c69a779674e9f36f7f4d9aba6627d [hat] Remove device custom data types that inherit from Buffer ! hat/backends/ffi/shared/src/main/java/hat/backend/ffi/C99FFIBackend.java ! hat/core/src/main/java/hat/phases/HATDialectifyArrayViewPhase.java ! hat/tests/src/main/java/hat/test/TestArrayView.java ! hat/tests/src/main/java/hat/test/TestVectorArrayView.java From asotona at openjdk.org Mon Dec 15 17:47:46 2025 From: asotona at openjdk.org (Adam Sotona) Date: Mon, 15 Dec 2025 17:47:46 GMT Subject: [code-reflection] RFR: 8373572: BytecodeGenerator throws UnsupportedOperationException for JavaOp.InvokeOp when invoke kind is SUPER. Message-ID: We cannot generate an invokespecial as it will result in a verify error, since the owner is not assignable to generated hidden class. This patch constructs method handle via lookup.findSpecial using the lookup's class as the specialCaller. Original lookup is stored in class data of the constructed hidden class. ------------- Commit messages: - 8373572: BytecodeGenerator throws UnsupportedOperationException for JavaOp.InvokeOp when invoke kind is SUPER. Changes: https://git.openjdk.org/babylon/pull/752/files Webrev: https://webrevs.openjdk.org/?repo=babylon&pr=752&range=00 Issue: https://bugs.openjdk.org/browse/JDK-8373572 Stats: 57 lines in 2 files changed: 29 ins; 19 del; 9 mod Patch: https://git.openjdk.org/babylon/pull/752.diff Fetch: git fetch https://git.openjdk.org/babylon.git pull/752/head:pull/752 PR: https://git.openjdk.org/babylon/pull/752 From asotona at openjdk.org Mon Dec 15 17:47:47 2025 From: asotona at openjdk.org (Adam Sotona) Date: Mon, 15 Dec 2025 17:47:47 GMT Subject: [code-reflection] RFR: 8373572: BytecodeGenerator throws UnsupportedOperationException for JavaOp.InvokeOp when invoke kind is SUPER. In-Reply-To: References: Message-ID: On Mon, 15 Dec 2025 17:39:47 GMT, Adam Sotona wrote: > We cannot generate an invokespecial as it will result in a verify error, since the owner is not assignable to generated hidden class. > > This patch constructs method handle via lookup.findSpecial using the lookup's class as the specialCaller. > Original lookup is stored in class data of the constructed hidden class. src/jdk.incubator.code/share/classes/jdk/incubator/code/bytecode/BytecodeGenerator.java line 814: > 812: .invokevirtual(CD_MethodHandles_Lookup, > 813: "findSpecial", > 814: MethodTypeDesc.of(CD_MethodHandle, CD_Class, CD_String, CD_MethodType, CD_Class)); Performance can be improved (if necessary) by indexing of all resolved method handles and storing them in class data as a list. Invoke code would not perform search for the method handle, but it will receive it directly from class data. ------------- PR Review Comment: https://git.openjdk.org/babylon/pull/752#discussion_r2620295479 From asotona at openjdk.org Mon Dec 15 17:58:57 2025 From: asotona at openjdk.org (Adam Sotona) Date: Mon, 15 Dec 2025 17:58:57 GMT Subject: [code-reflection] RFR: 8373571: Code model of JavaOp.ForOp does not handle (un)boxing correctly [v2] In-Reply-To: References: Message-ID: On Mon, 15 Dec 2025 11:53:42 GMT, Maurizio Cimadamore wrote: >> This PR addresses an issue in for-each loop model generation. >> The for each op factory takes three bodies: >> 1. the for each expression (e.g. either a collection, or an array) >> 2. the for each initializer (the logic that receives an element from the expression, and turns it into the expected variable type in the source code) >> 3. the for each body >> >> The translation for (2) seems to contain a bug: javac erroneously assumes that the initializer body has type `(V)->V`, where `V` is the type of the induction variable declared in the source code. >> >> This PR fixes that so that (2) has type `(ELEM)->V`, where `ELEM` is the static type of an element of the for-each expression, and `V` is the static type of the induction variable. >> >> This translation allows uboxing operations to appear manifest in the generated model. > > Maurizio Cimadamore has updated the pull request incrementally with one additional commit since the last revision: > > Make sure logic for determining expression element type is same as in `Attr` > Add more tests It looks good to me. ------------- Marked as reviewed by asotona (Reviewer). PR Review: https://git.openjdk.org/babylon/pull/750#pullrequestreview-3579481918 From nadeeshtv at gmail.com Mon Dec 15 22:23:30 2025 From: nadeeshtv at gmail.com (nadeesh t v) Date: Mon, 15 Dec 2025 23:23:30 +0100 Subject: Some minor errors observed in while experimenting with a sample In-Reply-To: References: Message-ID: Hi Gary, >Can you send a (small as possible) example that creates this error? I have attached the sample ( not sure , mail server will be stripped away) but it is similar to the Squares sample . For error 3 (Implicit declaration of function 'squareit' is invalid in OpenCL ), I am wondering whether we can check that all functions that are reachable from the kernel function is annotated with @Reflect using the KernelGraph, and if not fail early with a Java exception rather than the current error. > You may have pulled Babylon and HAT during a sequence of checkins. Yes, mine is 2-3 weeks old. >.>If we follow all the rules above (and the ones I have forgotten to include ;) ) you shoduring see this. Sorry, this part, I have not understood completely. Even if I use the latest Babylon JDK, all errors should stay the same right? Best regards, Nadeesh -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: MainWithHAT.java Type: application/octet-stream Size: 1995 bytes Desc: not available URL: From psandoz at openjdk.org Mon Dec 15 22:29:46 2025 From: psandoz at openjdk.org (Paul Sandoz) Date: Mon, 15 Dec 2025 22:29:46 GMT Subject: [code-reflection] RFR: 8373572: BytecodeGenerator throws UnsupportedOperationException for JavaOp.InvokeOp when invoke kind is SUPER. In-Reply-To: References: Message-ID: On Mon, 15 Dec 2025 17:39:47 GMT, Adam Sotona wrote: > We cannot generate an invokespecial as it will result in a verify error, since the owner is not assignable to generated hidden class. > > This patch constructs method handle via lookup.findSpecial using the lookup's class as the specialCaller. > Original lookup is stored in class data of the constructed hidden class. src/jdk.incubator.code/share/classes/jdk/incubator/code/bytecode/BytecodeGenerator.java line 860: > 858: case SUPER -> > 859: cob.invokevirtual(CD_MethodHandle, > 860: "invoke", Can you use `invokeExact`? ------------- PR Review Comment: https://git.openjdk.org/babylon/pull/752#discussion_r2621068488 From psandoz at openjdk.org Tue Dec 16 00:27:19 2025 From: psandoz at openjdk.org (Paul Sandoz) Date: Tue, 16 Dec 2025 00:27:19 GMT Subject: [code-reflection] RFR: 8373571: Code model of JavaOp.ForOp does not handle (un)boxing correctly [v2] In-Reply-To: References: Message-ID: <9U7mZPyNpDA8fccTVitk2fJVJ9LJN9RxfEKb-GhjoUI=.8f72e086-77a5-433d-98cc-7d44bf83718d@github.com> On Mon, 15 Dec 2025 11:53:42 GMT, Maurizio Cimadamore wrote: >> This PR addresses an issue in for-each loop model generation. >> The for each op factory takes three bodies: >> 1. the for each expression (e.g. either a collection, or an array) >> 2. the for each initializer (the logic that receives an element from the expression, and turns it into the expected variable type in the source code) >> 3. the for each body >> >> The translation for (2) seems to contain a bug: javac erroneously assumes that the initializer body has type `(V)->V`, where `V` is the type of the induction variable declared in the source code. >> >> This PR fixes that so that (2) has type `(ELEM)->V`, where `ELEM` is the static type of an element of the for-each expression, and `V` is the static type of the induction variable. >> >> This translation allows uboxing operations to appear manifest in the generated model. > > Maurizio Cimadamore has updated the pull request incrementally with one additional commit since the last revision: > > Make sure logic for determining expression element type is same as in `Attr` > Add more tests Looks good. This should also allow for conversions. When building the enhanced for op it us up to code building to ensure the types line up. At first i was questioning whether we should keep the enhanced for op or remove and model as a de-sugared for op, and provide a way to detect as if it were modeled from an enhanced for. But when patterns in the initializer come back the enhanced for op modelling (which anticipated use of patterns) will be clearer than that of the desugared for loop. ------------- Marked as reviewed by psandoz (Lead). PR Review: https://git.openjdk.org/babylon/pull/750#pullrequestreview-3580670512 From asotona at openjdk.org Tue Dec 16 08:40:29 2025 From: asotona at openjdk.org (Adam Sotona) Date: Tue, 16 Dec 2025 08:40:29 GMT Subject: [code-reflection] RFR: 8373572: BytecodeGenerator throws UnsupportedOperationException for JavaOp.InvokeOp when invoke kind is SUPER. [v2] In-Reply-To: References: Message-ID: > We cannot generate an invokespecial as it will result in a verify error, since the owner is not assignable to generated hidden class. > > This patch constructs method handle via lookup.findSpecial using the lookup's class as the specialCaller. > Original lookup is stored in class data of the constructed hidden class. Adam Sotona has updated the pull request incrementally with one additional commit since the last revision: MH::invokeExact ------------- Changes: - all: https://git.openjdk.org/babylon/pull/752/files - new: https://git.openjdk.org/babylon/pull/752/files/ba0d11f8..8b044a6a Webrevs: - full: https://webrevs.openjdk.org/?repo=babylon&pr=752&range=01 - incr: https://webrevs.openjdk.org/?repo=babylon&pr=752&range=00-01 Stats: 1 line in 1 file changed: 0 ins; 0 del; 1 mod Patch: https://git.openjdk.org/babylon/pull/752.diff Fetch: git fetch https://git.openjdk.org/babylon.git pull/752/head:pull/752 PR: https://git.openjdk.org/babylon/pull/752 From mcimadamore at openjdk.org Tue Dec 16 10:00:07 2025 From: mcimadamore at openjdk.org (Maurizio Cimadamore) Date: Tue, 16 Dec 2025 10:00:07 GMT Subject: git: openjdk/babylon: code-reflection: 8373571: Code model of JavaOp.ForOp does not handle (un)boxing correctly Message-ID: <58d7b872-6a84-48f4-82ba-e1811e2fa51c@openjdk.org> Changeset: c3455b1d Branch: code-reflection Author: Maurizio Cimadamore Date: 2025-12-16 09:58:16 +0000 URL: https://git.openjdk.org/babylon/commit/c3455b1d11f9d2b50739f702b42cf4c620569dc7 8373571: Code model of JavaOp.ForOp does not handle (un)boxing correctly Reviewed-by: asotona, psandoz ! src/jdk.incubator.code/share/classes/jdk/incubator/code/internal/ReflectMethods.java ! test/langtools/tools/javac/reflect/BoxingConversionTest.java ! test/langtools/tools/javac/reflect/ImplicitConversionTest.java From mcimadamore at openjdk.org Tue Dec 16 10:02:41 2025 From: mcimadamore at openjdk.org (Maurizio Cimadamore) Date: Tue, 16 Dec 2025 10:02:41 GMT Subject: [code-reflection] RFR: 8373571: Code model of JavaOp.ForOp does not handle (un)boxing correctly [v3] In-Reply-To: References: Message-ID: > This PR addresses an issue in for-each loop model generation. > The for each op factory takes three bodies: > 1. the for each expression (e.g. either a collection, or an array) > 2. the for each initializer (the logic that receives an element from the expression, and turns it into the expected variable type in the source code) > 3. the for each body > > The translation for (2) seems to contain a bug: javac erroneously assumes that the initializer body has type `(V)->V`, where `V` is the type of the induction variable declared in the source code. > > This PR fixes that so that (2) has type `(ELEM)->V`, where `ELEM` is the static type of an element of the for-each expression, and `V` is the static type of the induction variable. > > This translation allows uboxing operations to appear manifest in the generated model. Maurizio Cimadamore has updated the pull request incrementally with one additional commit since the last revision: Add test on implicit primitive widening in for each ------------- Changes: - all: https://git.openjdk.org/babylon/pull/750/files - new: https://git.openjdk.org/babylon/pull/750/files/7e220e1b..e19a0930 Webrevs: - full: https://webrevs.openjdk.org/?repo=babylon&pr=750&range=02 - incr: https://webrevs.openjdk.org/?repo=babylon&pr=750&range=01-02 Stats: 35 lines in 1 file changed: 35 ins; 0 del; 0 mod Patch: https://git.openjdk.org/babylon/pull/750.diff Fetch: git fetch https://git.openjdk.org/babylon.git pull/750/head:pull/750 PR: https://git.openjdk.org/babylon/pull/750 From mcimadamore at openjdk.org Tue Dec 16 10:02:42 2025 From: mcimadamore at openjdk.org (Maurizio Cimadamore) Date: Tue, 16 Dec 2025 10:02:42 GMT Subject: [code-reflection] Integrated: 8373571: Code model of JavaOp.ForOp does not handle (un)boxing correctly In-Reply-To: References: Message-ID: On Mon, 15 Dec 2025 11:31:45 GMT, Maurizio Cimadamore wrote: > This PR addresses an issue in for-each loop model generation. > The for each op factory takes three bodies: > 1. the for each expression (e.g. either a collection, or an array) > 2. the for each initializer (the logic that receives an element from the expression, and turns it into the expected variable type in the source code) > 3. the for each body > > The translation for (2) seems to contain a bug: javac erroneously assumes that the initializer body has type `(V)->V`, where `V` is the type of the induction variable declared in the source code. > > This PR fixes that so that (2) has type `(ELEM)->V`, where `ELEM` is the static type of an element of the for-each expression, and `V` is the static type of the induction variable. > > This translation allows uboxing operations to appear manifest in the generated model. This pull request has now been integrated. Changeset: c3455b1d Author: Maurizio Cimadamore URL: https://git.openjdk.org/babylon/commit/c3455b1d11f9d2b50739f702b42cf4c620569dc7 Stats: 193 lines in 3 files changed: 190 ins; 1 del; 2 mod 8373571: Code model of JavaOp.ForOp does not handle (un)boxing correctly Reviewed-by: asotona, psandoz ------------- PR: https://git.openjdk.org/babylon/pull/750 From asotona at openjdk.org Tue Dec 16 15:47:33 2025 From: asotona at openjdk.org (Adam Sotona) Date: Tue, 16 Dec 2025 15:47:33 GMT Subject: [code-reflection] Integrated: 8373572: BytecodeGenerator throws UnsupportedOperationException for JavaOp.InvokeOp when invoke kind is SUPER. In-Reply-To: References: Message-ID: On Mon, 15 Dec 2025 17:39:47 GMT, Adam Sotona wrote: > We cannot generate an invokespecial as it will result in a verify error, since the owner is not assignable to generated hidden class. > > This patch constructs method handle via lookup.findSpecial using the lookup's class as the specialCaller. > Original lookup is stored in class data of the constructed hidden class. This pull request has now been integrated. Changeset: f70f53ac Author: Adam Sotona URL: https://git.openjdk.org/babylon/commit/f70f53ac2b56c7f1e0968e4a3115b92e9447f1c9 Stats: 57 lines in 2 files changed: 29 ins; 19 del; 9 mod 8373572: BytecodeGenerator throws UnsupportedOperationException for JavaOp.InvokeOp when invoke kind is SUPER. ------------- PR: https://git.openjdk.org/babylon/pull/752 From asotona at openjdk.org Tue Dec 16 15:51:45 2025 From: asotona at openjdk.org (Adam Sotona) Date: Tue, 16 Dec 2025 15:51:45 GMT Subject: git: openjdk/babylon: code-reflection: 8373572: BytecodeGenerator throws UnsupportedOperationException for JavaOp.InvokeOp when invoke kind is SUPER. Message-ID: <960beec5-4d36-4b51-925b-3dfb30c142dd@openjdk.org> Changeset: f70f53ac Branch: code-reflection Author: Adam Sotona Date: 2025-12-16 15:45:12 +0000 URL: https://git.openjdk.org/babylon/commit/f70f53ac2b56c7f1e0968e4a3115b92e9447f1c9 8373572: BytecodeGenerator throws UnsupportedOperationException for JavaOp.InvokeOp when invoke kind is SUPER. ! src/jdk.incubator.code/share/classes/jdk/incubator/code/bytecode/BytecodeGenerator.java ! test/jdk/java/lang/reflect/code/bytecode/TestInvokeSuper.java From gfrost at openjdk.org Tue Dec 16 16:13:35 2025 From: gfrost at openjdk.org (Gary Frost) Date: Tue, 16 Dec 2025 16:13:35 GMT Subject: git: openjdk/babylon: code-reflection: Streamlining OpTk and preparing to move out of HAT core Message-ID: Changeset: be81a41a Branch: code-reflection Author: Gary Frost Date: 2025-12-16 16:11:20 +0000 URL: https://git.openjdk.org/babylon/commit/be81a41a71d6453aadea76a70f8052aaf560c231 Streamlining OpTk and preparing to move out of HAT core ! hat/backends/ffi/cuda/src/main/java/hat/backend/ffi/CudaBackend.java ! hat/backends/ffi/opencl/src/main/java/hat/backend/ffi/OpenCLBackend.java ! hat/backends/ffi/shared/src/main/java/hat/backend/ffi/FFIBackend.java ! hat/backends/jextracted/shared/src/main/java/hat/backend/jextracted/JExtractedBackend.java ! hat/core/src/main/java/hat/codebuilders/C99HATCodeBuilderContext.java ! hat/core/src/main/java/hat/optools/OpTk.java + hat/core/src/main/java/hat/optools/Trxfmr.java ! hat/core/src/main/java/hat/phases/HATDialect.java ! hat/core/src/main/java/hat/phases/HATDialectifyArrayViewPhase.java ! hat/core/src/main/java/hat/phases/HATDialectifyBarrierPhase.java ! hat/core/src/main/java/hat/phases/HATDialectifyFP16Phase.java ! hat/core/src/main/java/hat/phases/HATDialectifyMemoryPhase.java ! hat/core/src/main/java/hat/phases/HATDialectifyThreadsPhase.java ! hat/core/src/main/java/hat/phases/HATDialectifyVectorOpPhase.java ! hat/core/src/main/java/hat/phases/HATDialectifyVectorSelectPhase.java ! hat/core/src/main/java/hat/phases/HATDialectifyVectorStorePhase.java ! hat/tools/src/main/java/hat/tools/text/JavaHATCodeBuilder.java From gfrost at openjdk.org Tue Dec 16 16:14:38 2025 From: gfrost at openjdk.org (Gary Frost) Date: Tue, 16 Dec 2025 16:14:38 GMT Subject: [code-reflection] Integrated: Streamlining OpTk and preparing to move out of HAT core Message-ID: <9Pu0qs-a9xhoiPxhqiL0qaXCA_WIvJBaMITQjc_V5KI=.79fa257c-7bcd-4cef-8d26-91bf36c32400@github.com> I have been moving common code into OpTk Also added a strawman Txfmr class for simplifying common transformations I plan to move OpTk (well the parts not requireing HAT) up to its own lib This code leaves code artifacts (HAT_GIX) in generated C99. I need to track thoose down. They seem to compile ok and run.. ------------- Commit messages: - Streamlining OpTk and preparing to move out of HAT core Changes: https://git.openjdk.org/babylon/pull/753/files Webrev: https://webrevs.openjdk.org/?repo=babylon&pr=753&range=00 Stats: 998 lines in 17 files changed: 586 ins; 197 del; 215 mod Patch: https://git.openjdk.org/babylon/pull/753.diff Fetch: git fetch https://git.openjdk.org/babylon.git pull/753/head:pull/753 PR: https://git.openjdk.org/babylon/pull/753 From gfrost at openjdk.org Tue Dec 16 16:14:39 2025 From: gfrost at openjdk.org (Gary Frost) Date: Tue, 16 Dec 2025 16:14:39 GMT Subject: [code-reflection] Integrated: Streamlining OpTk and preparing to move out of HAT core In-Reply-To: <9Pu0qs-a9xhoiPxhqiL0qaXCA_WIvJBaMITQjc_V5KI=.79fa257c-7bcd-4cef-8d26-91bf36c32400@github.com> References: <9Pu0qs-a9xhoiPxhqiL0qaXCA_WIvJBaMITQjc_V5KI=.79fa257c-7bcd-4cef-8d26-91bf36c32400@github.com> Message-ID: On Tue, 16 Dec 2025 16:08:26 GMT, Gary Frost wrote: > I have been moving common code into OpTk > > Also added a strawman Txfmr class for simplifying common transformations > > I plan to move OpTk (well the parts not requireing HAT) up to its own lib > > This code leaves code artifacts (HAT_GIX) in generated C99. I need to track thoose down. They seem to compile ok and run.. This pull request has now been integrated. Changeset: be81a41a Author: Gary Frost URL: https://git.openjdk.org/babylon/commit/be81a41a71d6453aadea76a70f8052aaf560c231 Stats: 998 lines in 17 files changed: 586 ins; 197 del; 215 mod Streamlining OpTk and preparing to move out of HAT core ------------- PR: https://git.openjdk.org/babylon/pull/753 From nadeeshtv at gmail.com Tue Dec 16 23:12:21 2025 From: nadeeshtv at gmail.com (nadeesh t v) Date: Wed, 17 Dec 2025 00:12:21 +0100 Subject: Some minor errors observed in while experimenting with a sample In-Reply-To: References: Message-ID: Hi Gary, I tried with the latest build and I can reproduce reported issue *3* with the TestArrays ``` *diff --git a/hat/tests/src/main/java/hat/test/TestArrays.java b/hat/tests/src/main/java/hat/test/TestArrays.java* *index b5aed9f85da..3dccbaabf8c 100644* *--- a/hat/tests/src/main/java/hat/test/TestArrays.java* *+++ b/hat/tests/src/main/java/hat/test/TestArrays.java* @@ -42,7 +42,7 @@ public class TestArrays { - @Reflect + //@Reflect public static int squareit(int v) { return v * v; ``` With the following command `java -cp hat/job.jar hat.java test ffi-opencl hat.test.TestArrays` ``` HAT Engine Testing Framework Testing Backend: hat.backend.ffi.OpenCLBackend UNSUPPORTED (log once): buildComputeProgram: cl2Metal failed buildStatus =failed logLen = 186 log = program_source:70:37: error: implicit declaration of function 'squareit' is invalid in OpenCL array->array[(long)HAT_GIX]=squareit(value); ^ what?hat.test.TestArrays::squareKernel(hat.KernelContext, hat.buffer.S32Array):void java.lang.IllegalStateException: OpenCL program failed to compilejava.lang.IllegalStateException: OpenCL program failed to compile at hat.backend.ffi.OpenCLBackend.lambda$dispatchKernel$0(OpenCLBackend.java:58) at java.base/java.util.HashMap.computeIfAbsent(HashMap.java:1229) at hat.backend.ffi.OpenCLBackend.dispatchKernel(OpenCLBackend.java:47) at hat.ComputeContext.dispatchKernelWithComputeRange(ComputeContext.java:133) at hat.ComputeContext.dispatchKernel(ComputeContext.java:111) ``` Regards, Nadeesh -------------- next part -------------- An HTML attachment was scrubbed... URL: From jfumero at openjdk.org Wed Dec 17 09:08:19 2025 From: jfumero at openjdk.org (Juan Fumero) Date: Wed, 17 Dec 2025 09:08:19 GMT Subject: [code-reflection] RFR: [hat] CUDA Backend Codegen fixed Message-ID: CUDA Backend Codegen fixed ------------- Commit messages: - [hat] CUDA Backend Codegen fixed Changes: https://git.openjdk.org/babylon/pull/754/files Webrev: https://webrevs.openjdk.org/?repo=babylon&pr=754&range=00 Stats: 3 lines in 1 file changed: 2 ins; 0 del; 1 mod Patch: https://git.openjdk.org/babylon/pull/754.diff Fetch: git fetch https://git.openjdk.org/babylon.git pull/754/head:pull/754 PR: https://git.openjdk.org/babylon/pull/754 From mabbay at openjdk.org Wed Dec 17 10:27:13 2025 From: mabbay at openjdk.org (Mourad Abbay) Date: Wed, 17 Dec 2025 10:27:13 GMT Subject: [code-reflection] Withdrawn: Local class model In-Reply-To: References: Message-ID: <26P0-GqpldDVjctES3ecu4UsA4XPynT1jvOThSXbnaw=.d586696b-44c6-4f64-af1f-e5b68ff1deca@github.com> On Fri, 21 Nov 2025 04:44:16 GMT, Mourad Abbay wrote: > An attempt to model local classes. This pull request has been closed without being integrated. ------------- PR: https://git.openjdk.org/babylon/pull/692 From mabbay at openjdk.org Wed Dec 17 10:28:10 2025 From: mabbay at openjdk.org (Mourad Abbay) Date: Wed, 17 Dec 2025 10:28:10 GMT Subject: [code-reflection] RFR: Test java version check we do in op building methods [v2] In-Reply-To: References: Message-ID: > Write test to make sure java version check we do before building models is working. > There are other options to do the test, one in particular is passing the java compile time version as option and update the OpBuilder to accept the feature version we test against. Mourad Abbay has updated the pull request incrementally with one additional commit since the last revision: Run the tests in two steps ------------- Changes: - all: https://git.openjdk.org/babylon/pull/748/files - new: https://git.openjdk.org/babylon/pull/748/files/6ce91b04..c4249a63 Webrevs: - full: https://webrevs.openjdk.org/?repo=babylon&pr=748&range=01 - incr: https://webrevs.openjdk.org/?repo=babylon&pr=748&range=00-01 Stats: 62 lines in 2 files changed: 15 ins; 41 del; 6 mod Patch: https://git.openjdk.org/babylon/pull/748.diff Fetch: git fetch https://git.openjdk.org/babylon.git pull/748/head:pull/748 PR: https://git.openjdk.org/babylon/pull/748 From jfumero at openjdk.org Wed Dec 17 12:15:00 2025 From: jfumero at openjdk.org (Juan Fumero) Date: Wed, 17 Dec 2025 12:15:00 GMT Subject: git: openjdk/babylon: code-reflection: [hat] CUDA Backend Codegen fixed Message-ID: Changeset: d4f16ac9 Branch: code-reflection Author: Juan Fumero Date: 2025-12-17 12:12:44 +0000 URL: https://git.openjdk.org/babylon/commit/d4f16ac9b1898df9b1b12044b6c52a14de2ce265 [hat] CUDA Backend Codegen fixed ! hat/core/src/main/java/hat/optools/OpTk.java From jfumero at openjdk.org Wed Dec 17 12:15:21 2025 From: jfumero at openjdk.org (Juan Fumero) Date: Wed, 17 Dec 2025 12:15:21 GMT Subject: [code-reflection] Integrated: [hat] CUDA Backend Codegen fixed In-Reply-To: References: Message-ID: On Wed, 17 Dec 2025 09:03:28 GMT, Juan Fumero wrote: > CUDA Backend Codegen fixed This pull request has now been integrated. Changeset: d4f16ac9 Author: Juan Fumero URL: https://git.openjdk.org/babylon/commit/d4f16ac9b1898df9b1b12044b6c52a14de2ce265 Stats: 3 lines in 1 file changed: 2 ins; 0 del; 1 mod [hat] CUDA Backend Codegen fixed ------------- PR: https://git.openjdk.org/babylon/pull/754 From mcimadamore at openjdk.org Wed Dec 17 12:41:23 2025 From: mcimadamore at openjdk.org (Maurizio Cimadamore) Date: Wed, 17 Dec 2025 12:41:23 GMT Subject: [code-reflection] RFR: Test java version check we do in op building methods [v2] In-Reply-To: References: Message-ID: <-HQxKk_dFOoOjgP80mbJOxOqIrIYaM9Xo-N4nt-zEDE=.25857776-3c7b-4df0-8e94-36a92b5a2a39@github.com> On Wed, 17 Dec 2025 10:28:10 GMT, Mourad Abbay wrote: >> Write test to make sure java version check we do before building models is working. >> There are other options to do the test, one in particular is passing the java compile time version as option and update the OpBuilder to accept the feature version we test against. > > Mourad Abbay has updated the pull request incrementally with one additional commit since the last revision: > > Run the tests in two steps test/jdk/java/lang/reflect/code/writer/TestJavaVersionChecker.java line 27: > 25: String testClassName = TestJavaVersionChecker.class.getName(); > 26: Path testClassesDir = Path.of(System.getProperty("test.classes")); > 27: Path innerClassPath = FileSystems.getDefault().getPath(testClassesDir.toString(), testClassName + "$$CM.class"); I think this can be: Path innerClassPath = testClassesDir.resolve(testClassName + "$$CM.class"); ------------- PR Review Comment: https://git.openjdk.org/babylon/pull/748#discussion_r2626902807 From mcimadamore at openjdk.org Wed Dec 17 12:45:54 2025 From: mcimadamore at openjdk.org (Maurizio Cimadamore) Date: Wed, 17 Dec 2025 12:45:54 GMT Subject: [code-reflection] RFR: Test java version check we do in op building methods [v2] In-Reply-To: References: Message-ID: On Wed, 17 Dec 2025 10:28:10 GMT, Mourad Abbay wrote: >> Write test to make sure java version check we do before building models is working. >> There are other options to do the test, one in particular is passing the java compile time version as option and update the OpBuilder to accept the feature version we test against. > > Mourad Abbay has updated the pull request incrementally with one additional commit since the last revision: > > Run the tests in two steps Marked as reviewed by mcimadamore (Reviewer). ------------- PR Review: https://git.openjdk.org/babylon/pull/748#pullrequestreview-3587554928 From gfrost at openjdk.org Wed Dec 17 13:14:39 2025 From: gfrost at openjdk.org (Gary Frost) Date: Wed, 17 Dec 2025 13:14:39 GMT Subject: git: openjdk/babylon: code-reflection: Added HatVarOp marker interface and OpTk helpers Message-ID: <7000a04f-26f1-4469-aa23-46d8b945e98a@openjdk.org> Changeset: 74dc49d7 Branch: code-reflection Author: Gary Frost Date: 2025-12-17 13:13:18 +0000 URL: https://git.openjdk.org/babylon/commit/74dc49d70afb3374a7754443e09dbe7ab7bf083f Added HatVarOp marker interface and OpTk helpers ! hat/core/src/main/java/hat/dialect/HATF16Op.java ! hat/core/src/main/java/hat/dialect/HATMemoryOp.java = hat/core/src/main/java/hat/dialect/HATVarOp.java ! hat/core/src/main/java/hat/dialect/HATVectorOp.java ! hat/core/src/main/java/hat/optools/OpTk.java ! hat/core/src/main/java/hat/phases/HATDialectifyThreadsPhase.java From gfrost at openjdk.org Wed Dec 17 13:17:18 2025 From: gfrost at openjdk.org (Gary Frost) Date: Wed, 17 Dec 2025 13:17:18 GMT Subject: [code-reflection] Integrated: Added HatVarOp marker interface and OpTk helpers Message-ID: <0LUGizoGPEswtxrtDENJW4D6MA89XJbNdWAvjCnUzfU=.2f7b06db-d305-4ee8-9ec3-1d32db4589ef@github.com> Added HATVarOp marker interface to group HATOp's yielding a varName; Also added some OpTk helpers to simplyfy selecting op's for transformations. ------------- Commit messages: - Added HatVarOp marker interface and OpTk helpers Changes: https://git.openjdk.org/babylon/pull/755/files Webrev: https://webrevs.openjdk.org/?repo=babylon&pr=755&range=00 Stats: 95 lines in 6 files changed: 37 ins; 13 del; 45 mod Patch: https://git.openjdk.org/babylon/pull/755.diff Fetch: git fetch https://git.openjdk.org/babylon.git pull/755/head:pull/755 PR: https://git.openjdk.org/babylon/pull/755 From gfrost at openjdk.org Wed Dec 17 13:17:19 2025 From: gfrost at openjdk.org (Gary Frost) Date: Wed, 17 Dec 2025 13:17:19 GMT Subject: [code-reflection] Integrated: Added HatVarOp marker interface and OpTk helpers In-Reply-To: <0LUGizoGPEswtxrtDENJW4D6MA89XJbNdWAvjCnUzfU=.2f7b06db-d305-4ee8-9ec3-1d32db4589ef@github.com> References: <0LUGizoGPEswtxrtDENJW4D6MA89XJbNdWAvjCnUzfU=.2f7b06db-d305-4ee8-9ec3-1d32db4589ef@github.com> Message-ID: On Wed, 17 Dec 2025 13:09:22 GMT, Gary Frost wrote: > Added HATVarOp marker interface to group HATOp's yielding a varName; > > Also added some OpTk helpers to simplyfy selecting op's for transformations. This pull request has now been integrated. Changeset: 74dc49d7 Author: Gary Frost URL: https://git.openjdk.org/babylon/commit/74dc49d70afb3374a7754443e09dbe7ab7bf083f Stats: 95 lines in 6 files changed: 37 ins; 13 del; 45 mod Added HatVarOp marker interface and OpTk helpers ------------- PR: https://git.openjdk.org/babylon/pull/755 From gfrost at openjdk.org Wed Dec 17 13:56:34 2025 From: gfrost at openjdk.org (Gary Frost) Date: Wed, 17 Dec 2025 13:56:34 GMT Subject: [code-reflection] Integrated: Fix regression in last PR Message-ID: Turns out a VarOp instanceof check does not work here. For NVidia ------------- Commit messages: - Fix regression in last PR Changes: https://git.openjdk.org/babylon/pull/756/files Webrev: https://webrevs.openjdk.org/?repo=babylon&pr=756&range=00 Stats: 3 lines in 1 file changed: 2 ins; 0 del; 1 mod Patch: https://git.openjdk.org/babylon/pull/756.diff Fetch: git fetch https://git.openjdk.org/babylon.git pull/756/head:pull/756 PR: https://git.openjdk.org/babylon/pull/756 From gfrost at openjdk.org Wed Dec 17 13:56:34 2025 From: gfrost at openjdk.org (Gary Frost) Date: Wed, 17 Dec 2025 13:56:34 GMT Subject: [code-reflection] Integrated: Fix regression in last PR In-Reply-To: References: Message-ID: <06NEiasU0I8o22tTitGsWiO7AGBi48Yhn7nJEgjHQaM=.0399d976-a01c-48f8-84a5-0e29f7840426@github.com> On Wed, 17 Dec 2025 13:48:33 GMT, Gary Frost wrote: > Turns out a VarOp instanceof check does not work here. For NVidia This pull request has now been integrated. Changeset: 7e1b9c9c Author: Gary Frost URL: https://git.openjdk.org/babylon/commit/7e1b9c9cfa2ae342ba9e684c1c27169d8e7e2ef0 Stats: 3 lines in 1 file changed: 2 ins; 0 del; 1 mod Fix regression in last PR ------------- PR: https://git.openjdk.org/babylon/pull/756 From gfrost at openjdk.org Wed Dec 17 13:59:22 2025 From: gfrost at openjdk.org (Gary Frost) Date: Wed, 17 Dec 2025 13:59:22 GMT Subject: git: openjdk/babylon: code-reflection: Fix regression in last PR Message-ID: Changeset: 7e1b9c9c Branch: code-reflection Author: Gary Frost Date: 2025-12-17 13:53:59 +0000 URL: https://git.openjdk.org/babylon/commit/7e1b9c9cfa2ae342ba9e684c1c27169d8e7e2ef0 Fix regression in last PR ! hat/core/src/main/java/hat/optools/OpTk.java From gfrost at openjdk.org Wed Dec 17 16:03:45 2025 From: gfrost at openjdk.org (Gary Frost) Date: Wed, 17 Dec 2025 16:03:45 GMT Subject: git: openjdk/babylon: code-reflection: Removing opencl and cuda warnings nvidia Message-ID: <29bf5975-47ea-4f0b-b85c-66d4559b6a75@openjdk.org> Changeset: c7e76267 Branch: code-reflection Author: Gary Frost Date: 2025-12-17 15:58:47 +0000 URL: https://git.openjdk.org/babylon/commit/c7e762679192cd257c64f869b08205343bbce25d Removing opencl and cuda warnings nvidia ! hat/backends/ffi/cuda/src/main/java/hat/backend/ffi/CudaHATKernelBuilder.java ! hat/backends/ffi/cuda/src/main/native/cpp/squares.cpp ! hat/backends/ffi/opencl/src/main/java/hat/backend/ffi/OpenCLHATKernelBuilder.java ! hat/backends/ffi/opencl/src/main/native/cpp/squares.cpp ! hat/backends/jextracted/opencl/src/main/java/hat/backend/jextracted/OpenCLJExtractedHATKernelBuilder.java ! hat/examples/life/src/main/java/life/Main.java ! hat/examples/violajones/src/main/java/violajones/attic/ViolaJones.java ! hat/intellij/.idea/vcs.xml ! hat/tests/src/main/java/hat/test/TestArrayView.java ! hat/tests/src/main/java/hat/test/TestFloat2.java ! hat/tests/src/main/java/hat/test/TestMatMul.java ! hat/tests/src/main/java/hat/test/TestVectorArrayView.java ! hat/tests/src/main/java/hat/test/TestVectorTypes.java From jfumero at openjdk.org Wed Dec 17 16:04:26 2025 From: jfumero at openjdk.org (Juan Fumero) Date: Wed, 17 Dec 2025 16:04:26 GMT Subject: [babylon-docs:master] RFR: Minor typos fixed for the Triton article Message-ID: Minor typos fixed for the Triton article ------------- Commit messages: - Minor typos fixed for the Triton article Changes: https://git.openjdk.org/babylon-docs/pull/14/files Webrev: https://webrevs.openjdk.org/?repo=babylon-docs&pr=14&range=00 Stats: 4 lines in 1 file changed: 0 ins; 0 del; 4 mod Patch: https://git.openjdk.org/babylon-docs/pull/14.diff Fetch: git fetch https://git.openjdk.org/babylon-docs.git pull/14/head:pull/14 PR: https://git.openjdk.org/babylon-docs/pull/14 From gfrost at openjdk.org Wed Dec 17 16:05:22 2025 From: gfrost at openjdk.org (Gary Frost) Date: Wed, 17 Dec 2025 16:05:22 GMT Subject: [code-reflection] Integrated: Removing opencl and cuda warnings nvidia Message-ID: On Nvidia machines opencl and cuda reported warnings about unused vars in generated C99 code. ------------- Commit messages: - Removing opencl and cuda warnings nvidia Changes: https://git.openjdk.org/babylon/pull/757/files Webrev: https://webrevs.openjdk.org/?repo=babylon&pr=757&range=00 Stats: 22 lines in 13 files changed: 1 ins; 3 del; 18 mod Patch: https://git.openjdk.org/babylon/pull/757.diff Fetch: git fetch https://git.openjdk.org/babylon.git pull/757/head:pull/757 PR: https://git.openjdk.org/babylon/pull/757 From gfrost at openjdk.org Wed Dec 17 16:05:23 2025 From: gfrost at openjdk.org (Gary Frost) Date: Wed, 17 Dec 2025 16:05:23 GMT Subject: [code-reflection] Integrated: Removing opencl and cuda warnings nvidia In-Reply-To: References: Message-ID: On Wed, 17 Dec 2025 15:55:41 GMT, Gary Frost wrote: > On Nvidia machines opencl and cuda reported warnings about unused vars in generated C99 code. This pull request has now been integrated. Changeset: c7e76267 Author: Gary Frost URL: https://git.openjdk.org/babylon/commit/c7e762679192cd257c64f869b08205343bbce25d Stats: 22 lines in 13 files changed: 1 ins; 3 del; 18 mod Removing opencl and cuda warnings nvidia ------------- PR: https://git.openjdk.org/babylon/pull/757 From psandoz at openjdk.org Wed Dec 17 16:42:22 2025 From: psandoz at openjdk.org (Paul Sandoz) Date: Wed, 17 Dec 2025 16:42:22 GMT Subject: [babylon-docs:master] RFR: Minor typos fixed for the Triton article In-Reply-To: References: Message-ID: <3FyQMvZ34VINEQqJZRd6_jYxDS_0LoM-LrYnUgU_gI8=.4b1208b7-c6a3-4e69-94a7-79c176bf7f6a@github.com> On Wed, 17 Dec 2025 15:55:00 GMT, Juan Fumero wrote: > Minor typos fixed for the Triton article Marked as reviewed by psandoz (Lead). ------------- PR Review: https://git.openjdk.org/babylon-docs/pull/14#pullrequestreview-3588608375 From psandoz at openjdk.org Wed Dec 17 16:53:24 2025 From: psandoz at openjdk.org (Paul Sandoz) Date: Wed, 17 Dec 2025 16:53:24 GMT Subject: [code-reflection] RFR: Test java version check we do in op building methods [v2] In-Reply-To: References: Message-ID: On Wed, 17 Dec 2025 10:28:10 GMT, Mourad Abbay wrote: >> Write test to make sure java version check we do before building models is working. >> There are other options to do the test, one in particular is passing the java compile time version as option and update the OpBuilder to accept the feature version we test against. > > Mourad Abbay has updated the pull request incrementally with one additional commit since the last revision: > > Run the tests in two steps Also test a reflectable lambda expression. ------------- PR Review: https://git.openjdk.org/babylon/pull/748#pullrequestreview-3588659540 From jfumero at openjdk.org Wed Dec 17 17:03:18 2025 From: jfumero at openjdk.org (Juan Fumero) Date: Wed, 17 Dec 2025 17:03:18 GMT Subject: [babylon-docs:master] Integrated: Minor typos fixed for the Triton article In-Reply-To: References: Message-ID: On Wed, 17 Dec 2025 15:55:00 GMT, Juan Fumero wrote: > Minor typos fixed for the Triton article This pull request has now been integrated. Changeset: 6f771512 Author: Juan Fumero URL: https://git.openjdk.org/babylon-docs/commit/6f77151253d60b84325d5b84cb22a1af75c5be83 Stats: 4 lines in 1 file changed: 0 ins; 0 del; 4 mod Minor typos fixed for the Triton article Reviewed-by: psandoz ------------- PR: https://git.openjdk.org/babylon-docs/pull/14 From gfrost at openjdk.org Wed Dec 17 17:05:20 2025 From: gfrost at openjdk.org (Gary Frost) Date: Wed, 17 Dec 2025 17:05:20 GMT Subject: git: openjdk/babylon: code-reflection: Created optkl subproject containing tooling that does not depend on HAT Message-ID: <8919feef-0d48-4c6d-8266-7afb813ff4b0@openjdk.org> Changeset: ed10cfe2 Branch: code-reflection Author: Gary Frost Date: 2025-12-17 17:02:11 +0000 URL: https://git.openjdk.org/babylon/commit/ed10cfe20347324e8af53f244a49b89674a2c809 Created optkl subproject containing tooling that does not depend on HAT ! hat/core/pom.xml ! hat/core/src/main/java/hat/ifacemapper/accessor/AccessorInfo.java - hat/core/src/main/java/hat/util/StreamOptionalMutable.java ! hat/examples/view/src/main/java/view/EliteMeshParser.java ! hat/hat.java ! hat/intellij/.idea/modules.xml ! hat/intellij/.idea/vcs.xml ! hat/intellij/core.iml ! hat/intellij/example_view.iml + hat/intellij/optkl.iml ! hat/intellij/tests.iml ! hat/intellij/tools.iml = hat/optkl/pom.xml = hat/optkl/src/main/java/optkl/OpCodeBuilder.java + hat/optkl/src/main/java/optkl/OpTkl.java = hat/optkl/src/main/java/optkl/Regex.java = hat/optkl/src/main/java/optkl/jdot/DotBuilder.java = hat/optkl/src/main/java/optkl/jdot/ui/JDot.java = hat/optkl/src/main/java/optkl/json/Json.java = hat/optkl/src/main/java/optkl/json/JsonArray.java = hat/optkl/src/main/java/optkl/json/JsonBoolean.java = hat/optkl/src/main/java/optkl/json/JsonNull.java = hat/optkl/src/main/java/optkl/json/JsonNumber.java = hat/optkl/src/main/java/optkl/json/JsonObject.java = hat/optkl/src/main/java/optkl/json/JsonParseException.java = hat/optkl/src/main/java/optkl/json/JsonString.java = hat/optkl/src/main/java/optkl/json/JsonValue.java = hat/optkl/src/main/java/optkl/json/impl/JsonArrayImpl.java = hat/optkl/src/main/java/optkl/json/impl/JsonBooleanImpl.java = hat/optkl/src/main/java/optkl/json/impl/JsonNullImpl.java = hat/optkl/src/main/java/optkl/json/impl/JsonNumberImpl.java = hat/optkl/src/main/java/optkl/json/impl/JsonObjectImpl.java = hat/optkl/src/main/java/optkl/json/impl/JsonParser.java = hat/optkl/src/main/java/optkl/json/impl/JsonStringImpl.java = hat/optkl/src/main/java/optkl/json/impl/Utils.java = hat/optkl/src/main/java/optkl/textmodel/BabylonTextModel.java = hat/optkl/src/main/java/optkl/textmodel/Cursor.java + hat/optkl/src/main/java/optkl/textmodel/JavaTextModel.java = hat/optkl/src/main/java/optkl/textmodel/TextModel.java = hat/optkl/src/main/java/optkl/textmodel/html/Spanner.java = hat/optkl/src/main/java/optkl/textmodel/html/tokens/GT_ENTITY.java = hat/optkl/src/main/java/optkl/textmodel/html/tokens/LT_ENTITY.java = hat/optkl/src/main/java/optkl/textmodel/terminal/ANSI.java = hat/optkl/src/main/java/optkl/textmodel/terminal/CodeModelFormatter.java = hat/optkl/src/main/java/optkl/textmodel/terminal/TestANSI.java = hat/optkl/src/main/java/optkl/textmodel/tokens/AbstractParentToken.java = hat/optkl/src/main/java/optkl/textmodel/tokens/AbstractToken.java = hat/optkl/src/main/java/optkl/textmodel/tokens/AbstractTokenWithCh.java = hat/optkl/src/main/java/optkl/textmodel/tokens/AbstractTokenWithLength.java = hat/optkl/src/main/java/optkl/textmodel/tokens/Arrow.java = hat/optkl/src/main/java/optkl/textmodel/tokens/At.java = hat/optkl/src/main/java/optkl/textmodel/tokens/Ch.java = hat/optkl/src/main/java/optkl/textmodel/tokens/CharLiteral.java = hat/optkl/src/main/java/optkl/textmodel/tokens/Close.java = hat/optkl/src/main/java/optkl/textmodel/tokens/Comment.java = hat/optkl/src/main/java/optkl/textmodel/tokens/DottedName.java + hat/optkl/src/main/java/optkl/textmodel/tokens/Factory.java = hat/optkl/src/main/java/optkl/textmodel/tokens/FloatConst.java = hat/optkl/src/main/java/optkl/textmodel/tokens/IntConst.java = hat/optkl/src/main/java/optkl/textmodel/tokens/Leaf.java = hat/optkl/src/main/java/optkl/textmodel/tokens/LeafReplacementToken.java = hat/optkl/src/main/java/optkl/textmodel/tokens/LineCol.java = hat/optkl/src/main/java/optkl/textmodel/tokens/LineComment.java = hat/optkl/src/main/java/optkl/textmodel/tokens/Literal.java = hat/optkl/src/main/java/optkl/textmodel/tokens/MultiLineComment.java = hat/optkl/src/main/java/optkl/textmodel/tokens/Nl.java = hat/optkl/src/main/java/optkl/textmodel/tokens/Open.java = hat/optkl/src/main/java/optkl/textmodel/tokens/OpenClose.java = hat/optkl/src/main/java/optkl/textmodel/tokens/Parent.java = hat/optkl/src/main/java/optkl/textmodel/tokens/Parenthesis.java = hat/optkl/src/main/java/optkl/textmodel/tokens/Pos.java = hat/optkl/src/main/java/optkl/textmodel/tokens/ReservedWord.java = hat/optkl/src/main/java/optkl/textmodel/tokens/Root.java = hat/optkl/src/main/java/optkl/textmodel/tokens/Seq.java = hat/optkl/src/main/java/optkl/textmodel/tokens/SingleCharLeaf.java = hat/optkl/src/main/java/optkl/textmodel/tokens/Span.java = hat/optkl/src/main/java/optkl/textmodel/tokens/StringLiteral.java = hat/optkl/src/main/java/optkl/textmodel/tokens/Token.java = hat/optkl/src/main/java/optkl/textmodel/tokens/Ws.java + hat/optkl/src/main/java/optkl/textmodel/tokens/defaults/Ch.java + hat/optkl/src/main/java/optkl/textmodel/tokens/defaults/CharLiteral.java + hat/optkl/src/main/java/optkl/textmodel/tokens/defaults/Close.java + hat/optkl/src/main/java/optkl/textmodel/tokens/defaults/LineComment.java + hat/optkl/src/main/java/optkl/textmodel/tokens/defaults/MultiLineComment.java + hat/optkl/src/main/java/optkl/textmodel/tokens/defaults/Nl.java + hat/optkl/src/main/java/optkl/textmodel/tokens/defaults/Open.java + hat/optkl/src/main/java/optkl/textmodel/tokens/defaults/Parenthesis.java + hat/optkl/src/main/java/optkl/textmodel/tokens/defaults/Seq.java + hat/optkl/src/main/java/optkl/textmodel/tokens/defaults/StringLiteral.java + hat/optkl/src/main/java/optkl/textmodel/tokens/defaults/Ws.java = hat/optkl/src/main/java/optkl/textmodel/ui/BabylonStyleMapper.java = hat/optkl/src/main/java/optkl/textmodel/ui/ElementSpan.java = hat/optkl/src/main/java/optkl/textmodel/ui/FuncOpTextModelViewer.java = hat/optkl/src/main/java/optkl/textmodel/ui/FuncOpViewer.java = hat/optkl/src/main/java/optkl/textmodel/ui/JavaTextModelViewer.java = hat/optkl/src/main/java/optkl/textmodel/ui/SSAIDViewer.java + hat/optkl/src/main/java/optkl/textmodel/ui/StyleMapper.java = hat/optkl/src/main/java/optkl/textmodel/ui/TextGutter.java = hat/optkl/src/main/java/optkl/textmodel/ui/TextModelViewer.java + hat/optkl/target/antrun/build-main.xml + hat/optkl/target/classes/optkl/OpTkl.class + hat/optkl/target/hat-optkl-1.0.jar + hat/optkl/target/maven-archiver/pom.properties + hat/optkl/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst + hat/optkl/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst ! hat/pom.xml ! hat/tools/src/main/java/hat/tools/text/TestJavaHATCodeBuilder.java - hat/tools/src/main/java/hat/tools/textmodel/JavaTextModel.java - hat/tools/src/main/java/hat/tools/textmodel/tokens/Factory.java - hat/tools/src/main/java/hat/tools/textmodel/tokens/defaults/Ch.java - hat/tools/src/main/java/hat/tools/textmodel/tokens/defaults/CharLiteral.java - hat/tools/src/main/java/hat/tools/textmodel/tokens/defaults/Close.java - hat/tools/src/main/java/hat/tools/textmodel/tokens/defaults/LineComment.java - hat/tools/src/main/java/hat/tools/textmodel/tokens/defaults/MultiLineComment.java - hat/tools/src/main/java/hat/tools/textmodel/tokens/defaults/Nl.java - hat/tools/src/main/java/hat/tools/textmodel/tokens/defaults/Open.java - hat/tools/src/main/java/hat/tools/textmodel/tokens/defaults/Parenthesis.java - hat/tools/src/main/java/hat/tools/textmodel/tokens/defaults/Seq.java - hat/tools/src/main/java/hat/tools/textmodel/tokens/defaults/StringLiteral.java - hat/tools/src/main/java/hat/tools/textmodel/tokens/defaults/Ws.java - hat/tools/src/main/java/hat/tools/textmodel/ui/StyleMapper.java - hat/tools/src/main/java/hat/tools/textmodel/ui/TestFuncOpViewer.java From gfrost at openjdk.org Wed Dec 17 17:08:45 2025 From: gfrost at openjdk.org (Gary Frost) Date: Wed, 17 Dec 2025 17:08:45 GMT Subject: [code-reflection] Integrated: Created optkl subproject containing tooling that does not depend on HAT Message-ID: I created optkl subproject. It contains a bunch of useful tooling that leverage babylon, but does not have depenencies on HAT itself. I plan to move the non HAT code builders down here as well as the iface mapper eventually. ------------- Commit messages: - Created optkl subproject containing tooling that does not depend on HAT Changes: https://git.openjdk.org/babylon/pull/758/files Webrev: https://webrevs.openjdk.org/?repo=babylon&pr=758&range=00 Stats: 1675 lines in 122 files changed: 717 ins; 778 del; 180 mod Patch: https://git.openjdk.org/babylon/pull/758.diff Fetch: git fetch https://git.openjdk.org/babylon.git pull/758/head:pull/758 PR: https://git.openjdk.org/babylon/pull/758 From gfrost at openjdk.org Wed Dec 17 17:08:46 2025 From: gfrost at openjdk.org (Gary Frost) Date: Wed, 17 Dec 2025 17:08:46 GMT Subject: [code-reflection] Integrated: Created optkl subproject containing tooling that does not depend on HAT In-Reply-To: References: Message-ID: <3CnuSP2ZJeSe99rv0Lw-4zjiovSFHQVBAitmdbVPYPg=.f0165756-442d-463c-8118-4d32f5546c5a@github.com> On Wed, 17 Dec 2025 16:59:05 GMT, Gary Frost wrote: > I created optkl subproject. > > It contains a bunch of useful tooling that leverage babylon, but does not have depenencies on HAT itself. > > I plan to move the non HAT code builders down here as well as the iface mapper eventually. This pull request has now been integrated. Changeset: ed10cfe2 Author: Gary Frost URL: https://git.openjdk.org/babylon/commit/ed10cfe20347324e8af53f244a49b89674a2c809 Stats: 1675 lines in 122 files changed: 717 ins; 778 del; 180 mod Created optkl subproject containing tooling that does not depend on HAT ------------- PR: https://git.openjdk.org/babylon/pull/758 From mabbay at openjdk.org Wed Dec 17 20:19:16 2025 From: mabbay at openjdk.org (Mourad Abbay) Date: Wed, 17 Dec 2025 20:19:16 GMT Subject: [code-reflection] RFR: Test java version check we do in op building methods [v3] In-Reply-To: References: Message-ID: > Write test to make sure java version check we do before building models is working. > There are other options to do the test, one in particular is passing the java compile time version as option and update the OpBuilder to accept the feature version we test against. Mourad Abbay has updated the pull request incrementally with two additional commits since the last revision: - Test reflectable lambda - Apply suggestion ------------- Changes: - all: https://git.openjdk.org/babylon/pull/748/files - new: https://git.openjdk.org/babylon/pull/748/files/c4249a63..6aabfef1 Webrevs: - full: https://webrevs.openjdk.org/?repo=babylon&pr=748&range=02 - incr: https://webrevs.openjdk.org/?repo=babylon&pr=748&range=01-02 Stats: 19 lines in 2 files changed: 14 ins; 3 del; 2 mod Patch: https://git.openjdk.org/babylon/pull/748.diff Fetch: git fetch https://git.openjdk.org/babylon.git pull/748/head:pull/748 PR: https://git.openjdk.org/babylon/pull/748