Improve Switches Lowering

XMLWordPrintable

    • Type: Enhancement
    • Resolution: Unresolved
    • Priority: P4
    • None
    • Affects Version/s: repo-babylon
    • Component/s: core-libs

      The `JavaOp.JavaSwitchOp::lower` method currently lowers switch operations into a tree of blocks with conditional branches, handling cases individually.

      In contrast, `jdk.incubator.code.bytecode.impl.LoweringTransform` offers an alternative lowering strategy that transforms switches into `ConstantLabelSwitchOp` structures. This enables the `BytecodeGenerator` to produce optimized bytecode instructions like `tableswitch` and `lookupswitch`.

      However, `LoweringTransform` is currently restricted to integer-based selectors and constant labels.

      Meanwhile, the `javac` compiler can generate efficient bytecode for a broader range, including switches on `String` or `Enum` selectors, as well as pattern-based switches.

      To align with `javac`'s capabilities, `LoweringTransform` should be extended to support this full domain of switch expressions.

            Assignee:
            Unassigned
            Reporter:
            Adam Sotona
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: