[code-reflection] RFR: Dialect factory
Maurizio Cimadamore
mcimadamore at openjdk.org
Tue Jun 17 11:27:38 UTC 2025
On Fri, 13 Jun 2025 23:51:15 GMT, Paul Sandoz <psandoz at openjdk.org> wrote:
> Group op factory and type element factory into dialect factory record.
>
> The synthetic method added by javac to build a code model now has no parameters. The dialect factory, namely that for Java ops and type elements, is accessed from within the generated method body. This simplifies the connections between compiler/runtime and code reflection (see the reduction in `CodeReflectionSymbols.java` and `InnerClassLambdaMetafactory.java`).
>
> The synthetic method's accessibility is now private, as is the synthetic method to access the quoted instance from a quotable lambda's functional interface implementation.
>
> Further alignment of the factories and their use will occur in one or more subsequent PRs.
src/jdk.incubator.code/share/classes/jdk/incubator/code/internal/CodeModelToAST.java line 108:
> 106:
> 107: public JCTree.JCStatement transformFuncOpToAST(CoreOp.FuncOp funcOp, MethodSymbol ms) {
> 108: Assert.check(funcOp.parameters().isEmpty());
Good strengthening of the code -- also allows to simplify the code, as there's no func parameter to worry about
src/jdk.incubator.code/share/classes/jdk/incubator/code/writer/OpBuilder.java line 154:
> 152: * @return the building code model.
> 153: */
> 154: public static FuncOp createBuilderFunction(Op op, Function<Block.Builder, Value> dialectFactoryF) {
Nice -- the functional parameter effectively allows us to make the compiler-generated op method parameter-less, which then simplifies a lot of other stuff (compiler support and lambda metafactory) -- in reality we could have done this even w/o the dialect factory (e.g. take two lambdas) but good to see this now.
-------------
PR Review Comment: https://git.openjdk.org/babylon/pull/441#discussion_r2152017699
PR Review Comment: https://git.openjdk.org/babylon/pull/441#discussion_r2152016571
More information about the babylon-dev
mailing list