Integrated: 8359412: Template-Framework Library: Operations and Expressions

Emanuel Peter epeter at openjdk.org
Mon Oct 13 14:03:49 UTC 2025


On Thu, 21 Aug 2025 15:03:57 GMT, Emanuel Peter <epeter at openjdk.org> wrote:

> Impliementing ideas from original draft PR: https://github.com/openjdk/jdk/pull/23418 ([Exceptions](https://github.com/openjdk/jdk/pull/23418/files#diff-77e7db8cc0c5e02786e1c993362f98fabe219042eb342fdaffc09fd11380259dR41), [ExpressionFuzzer](https://github.com/openjdk/jdk/pull/23418/files#diff-01844ca5cb007f5eab5fa4195f2f1378d4e7c64ba477fba64626c98ff4054038R66)).
> 
> Specifically, I'm extending the Template Library with `Expression`s, and lists of `Operations` (some basic Expressions). These Expressions can easily be nested and then filled with arguments, and applied in a `Template`.
> 
> Details, in **order you should review**:
> - `Operations.java`: maps lots of primitive operators as Expressions.
> - `Expression.java`: the fundamental engine behind Expressions.
> - `examples/TestExpressions.java`: basic example using Expressions, filling them with random constants.
> - `tests/TestExpression.java`: correctness test of Expression machinery.
> - `compiler/igvn/ExpressionFuzzer.java`: expression fuzzer for primitive type expressions, including input range/bits constraints and output range/bits verification.
> - `PrimitiveType.java`: added `LibraryRNG` facility. We already had `type.con()` which gave us random constants. But we also want to have `type.callLibraryRNG()` so that we can insert a call to a random number generator of the corresponding primitive type. I use this facility in the `ExpressionFuzzer.java` to generate random arguments for the expressions.
> - `examples/TestPrimitiveTypes.java`: added a `LibraryRNG` example, that tests that has a weak test for randomness: we should have at least 2 different value in 1000 calls.
> 
> If the reviewers absolutely insist, I could split out `LibraryRNG` into a separate RFE. But it's really not that much code, and has direct use in the `Expression` examples.
> 
> **Future Work**:
> - Use `Expression`s in a loop over arrays / MemorySegment: fuzz auto-vectorization.
> - Use `Expression`s to model more operations:
>   - `Vector API`, more arithmetic operations like from `Math` classes etc.
> - Ensure that the constraints / checksum mechanic in `compiler/igvn/ExpressionFuzzer.java` work, using IR rules. We may even need to add new IGVN optimizations. Add unsigned constraints.
> - Find a way to delay IGVN optimizations to test worklist notification: For example, we could add a new testing operator call `TestUtils.delay(x) -> x`, which is intrinsified as some new `DelayNode` that in normal circumstances just folds away, but under `StressIGVN` and `Stres...

This pull request has now been integrated.

Changeset: 04968061
Author:    Emanuel Peter <epeter at openjdk.org>
URL:       https://git.openjdk.org/jdk/commit/0496806102bb621bdd82613d5796651d9655ea1c
Stats:     1611 lines in 7 files changed: 1611 ins; 0 del; 0 mod

8359412: Template-Framework Library: Operations and Expressions

Reviewed-by: chagedorn, mhaessig, galder

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

PR: https://git.openjdk.org/jdk/pull/26885


More information about the hotspot-compiler-dev mailing list