[code-reflection] RFR: Improved NormalizeBlocksTransformer and its application in BytecodeGenerator. [v6]
Paul Sandoz
psandoz at openjdk.org
Thu Jan 15 17:59:08 UTC 2026
On Thu, 15 Jan 2026 08:25:32 GMT, Adam Sotona <asotona at openjdk.org> wrote:
>> Lowering of pattern matching in switch statements and expressions produces an inefficient tree of conditional branches. This PR does not improve the lowering itself; however, it reduces overhead in the generated bytecode.
>>
>> `NormalizeBlocksTransformer` is improved to handle redundant conditional branches. It skips intermediate conditional branches with constant boolean arguments and re-targets them directly to the true or false branch, based on the argument's constant value.
>>
>> The `BytecodeGenerator` prepends `NormalizeBlocksTransformer` to leverage the optimized models for bytecode generation.
>
> Adam Sotona has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains eight commits:
>
> - Merge remote-tracking branch 'babylon/code-reflection' into skip-cbranch-transform
> - fixed javadoc
>
> - added test
>
> - removed debug prints
>
> - Merge of SKIP_CBRANCH_TRANSFORM with NormalizeBlocksTransformer
>
> - Merge remote-tracking branch 'babylon/code-reflection' into skip-cbranch-transform
> - removed debug print
>
> - Skip constant conditional branch transformation.
Marked as reviewed by psandoz (Lead).
src/jdk.incubator.code/share/classes/jdk/incubator/code/analysis/NormalizeBlocksTransformer.java line 140:
> 138: && cbo.trueBranch().arguments().isEmpty()
> 139: && cbo.falseBranch().arguments().isEmpty();
> 140: }
Eventually i hope we can represent this as a pattern.
-------------
PR Review: https://git.openjdk.org/babylon/pull/829#pullrequestreview-3666740164
PR Review Comment: https://git.openjdk.org/babylon/pull/829#discussion_r2695287930
More information about the babylon-dev
mailing list