RFR: 8336491: Unnecessary boxing conversions in void-returning lambdas [v3]

Maurizio Cimadamore mcimadamore at openjdk.org
Mon Jul 22 09:28:34 UTC 2024


On Fri, 19 Jul 2024 22:18:05 GMT, Liam Miller-Cushon <cushon at openjdk.org> wrote:

>> Please consider this possible fix for [JDK-8336491](https://bugs.openjdk.org/browse/JDK-8336491), which avoids generating an unnecessary boxing conversion for the result of void-returning expression lambdas.
>
> Liam Miller-Cushon has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Represent void lambda results as Type.noType

The extra check is unfortunate, but I think the code looks good. Conceptually, I still think that returning the tree unmodified when the target is `noType` makes more sense in the general case.

Another (optional) possibility would be to handle this in `visitReturn` - e.g. if the target is `void`, then call `translate(expr)` instead of `translate(expr, type)`. I'll leave that decision to what you think it's cleanest.

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

Marked as reviewed by mcimadamore (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/20222#pullrequestreview-2191085502


More information about the compiler-dev mailing list