[code-reflection] RFR: BytecodeGenerator cleanup and switch support [v5]
Paul Sandoz
psandoz at openjdk.org
Mon Dec 1 17:07:13 UTC 2025
On Mon, 1 Dec 2025 17:03:34 GMT, Adam Sotona <asotona at openjdk.org> wrote:
>> The current `BytecodeGenerator` implementation assumes that code models have already been lowered before generation. Both `SwitchExpressionOp` and `SwitchStatementOp` with all-constant labels are examples of operations that can be lowered an alternative way, allowing `BytecodeGenerator` to produce more efficient bytecode using `tableswitch` and `lookupswitch` instructions.
>>
>> The proposed change shifts the responsibility for lowering these operations into the `BytecodeGenerator` itself, enabling selective lowering during bytecode generation. Consequently, `OpBuilder` and `BytecodeGenerator` tests have been updated to avoid invoking the lower transformation step before the `BytecodeGenerator` is called.
>>
>> A new internal operation, `ConstantLabelSwitchOp`, has been introduced. This acts as an intermediate representation for lowered `SwitchExpressionOp` and `SwitchStatementOp` instances with constant labels.
>>
>> Lowering of `SwitchExpressionOp` and `SwitchStatementOp` into `ConstantLabelSwitchOp` is also a part of this PR.
>>
>> This PR also makes minor refinements to the BytecodeGenerator post-processing transformations.
>
> Adam Sotona has updated the pull request incrementally with one additional commit since the last revision:
>
> test update
src/jdk.incubator.code/share/classes/jdk/incubator/code/Block.java line 119:
> 117: * @param arguments the target block arguments, a copy will be made as needed.
> 118: */
> 119: public Reference(Block target, List<? extends Value> arguments) {
Why is this made public?
-------------
PR Review Comment: https://git.openjdk.org/babylon/pull/706#discussion_r2577896216
More information about the babylon-dev
mailing list