[code-reflection] RFR: Reduce number of local variables when transforming code model builder to AST [v3]
Maurizio Cimadamore
mcimadamore at openjdk.org
Mon Apr 28 13:34:16 UTC 2025
On Fri, 25 Apr 2025 00:19:48 GMT, Mourad Abbay <mabbay at openjdk.org> wrote:
>> For CODE_BUILDER option, we transform code model builder to equivalent AST. We were introducing local variables for very expressions, as a result we were closer to the limit on local variables. In this PR, we add local variables where it's needed.
>
> Mourad Abbay has updated the pull request incrementally with one additional commit since the last revision:
>
> Add SYNTHETIC flag to the var symbol we add to the AST
Very nice change. This nicely compensates for the fact that javac doesn't perform any optimization on the generated code. Another possible optimization I noticed: if the expression being transformed is constant (e.g. it has a constant type -- `tree.type.constValue() != null`) -- then we don't need a local variable -- because javac will inline the constant value anyway (e.g. emit an `ldc` or something like that). Since there are quite a few string constants in the generated code this might further improve things.
(That said, there doesn't seem to be any value that's used more than once that is also a constant)
-------------
PR Review: https://git.openjdk.org/babylon/pull/410#pullrequestreview-2799315825
More information about the babylon-dev
mailing list