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

Emanuel Peter epeter at openjdk.org
Thu Sep 18 08:12:50 UTC 2025


> 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...

Emanuel Peter has updated the pull request incrementally with two additional commits since the last revision:

 - more comments
 - add othervm to test

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

Changes:
  - all: https://git.openjdk.org/jdk/pull/26885/files
  - new: https://git.openjdk.org/jdk/pull/26885/files/a6f83b5a..c04c879c

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=jdk&pr=26885&range=05
 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=26885&range=04-05

  Stats: 2 lines in 1 file changed: 1 ins; 0 del; 1 mod
  Patch: https://git.openjdk.org/jdk/pull/26885.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/26885/head:pull/26885

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


More information about the hotspot-compiler-dev mailing list