[code-reflection] RFR: Code transformer
Maurizio Cimadamore
mcimadamore at openjdk.org
Fri Nov 21 13:07:24 UTC 2025
On Thu, 20 Nov 2025 23:50:52 GMT, Paul Sandoz <psandoz at openjdk.org> wrote:
> Rename `OpTransformer` to `CodeTransformer`, and `CopyContext` to `CodeContext`.
>
> Add a simplified operation transformer which is composed into a code transformer, for cases where operations are mostly replaced with one or more other operations (replacing with zero other operations is also possible). In such cases it is not necessary to deal with the code context and value mappings, nor return the block builder, as is required with a code transformer.
Marked as reviewed by mcimadamore (Reviewer).
src/jdk.incubator.code/share/classes/jdk/incubator/code/CodeTransformer.java line 54:
> 52: * that map to the input operation
> 53: */
> 54: void acceptOp(Function<Op, Op.Result> builder, Op in, List<Value> outOperands);
I found the use of `in` and `out` confusing. In the tests I see you just use `op` and `operands` and in my mind that's a bit clearer. Also, the name `OpTransformerRename` feels a bit odd -- isn't this an `OpMapper`? (and the resulting `opTranformer` method a `mapOps` ?
test/jdk/java/lang/reflect/code/transform/TestTransform.java line 22:
> 20: * @run junit TestTransform
> 21: */
> 22: public class TestTransform {
This is great functionality -- most of the time I wanted to transform, I really just wanted something like this :-)
-------------
PR Review: https://git.openjdk.org/babylon/pull/690#pullrequestreview-3492681395
PR Review Comment: https://git.openjdk.org/babylon/pull/690#discussion_r2549696516
PR Review Comment: https://git.openjdk.org/babylon/pull/690#discussion_r2549699968
More information about the babylon-dev
mailing list