[code-reflection] RFR: OpBuilder optimizations - part 1. [v2]

Adam Sotona asotona at openjdk.org
Wed Nov 12 20:32:16 UTC 2025


On Wed, 12 Nov 2025 19:24:22 GMT, Paul Sandoz <psandoz at openjdk.org> wrote:

>> Unfortunately, generating the .class file here is not great. Basically, javac compilation happens in stages, and the classfile generation is the last stage. Typically if there's errors, or if the user has selected specific compilation policies, we might stop at a certain phase w/o generating bytecode -- but since here we're generating bytecode in the middle of a "lowering" step, we end up violating these constraints.
>> 
>> The right way to do things here would be to generate a class AST in ReflectMethods (e.g. like `Lower` does in some cases -- e.g. for private constructors). I suspect that, to do that, you might need to resurrect the logic that goes from the func ops down to an AST (which this PR deletes).
>
> Good point, too clever perhaps :-) I suspect it is easy to enhance `CodeModelTranslator` to support the generation of multiple AST methods from func ops, and on a case by case basis enhanced to support the translation of additional ops we need to use (e.g., conditional expression op to the ? : operator node).

Unfortunately I found `CodeModelTranslator` only supports very limited set of ops, no nested bodies and no more than a single entry block per method. I expect getting it at least to the shape of `BytecodeGenerator` would require non-trivial amount of work.

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

PR Review Comment: https://git.openjdk.org/babylon/pull/679#discussion_r2519712478


More information about the babylon-dev mailing list