RFR: 8359412: Template-Framework Library: Operations and Expressions [v6]

Manuel Hässig mhaessig at openjdk.org
Thu Sep 18 08:28:29 UTC 2025


On Thu, 18 Sep 2025 08:12:50 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 fol...
>
> Emanuel Peter has updated the pull request incrementally with two additional commits since the last revision:
> 
>  - more comments
>  - add othervm to test

Thank you for addressing my comments.

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

Marked as reviewed by mhaessig (Committer).

PR Review: https://git.openjdk.org/jdk/pull/26885#pullrequestreview-3238136469


More information about the hotspot-compiler-dev mailing list