[code-reflection] RFR: Support storing the code that builds the code model [v18]

Maurizio Cimadamore mcimadamore at openjdk.org
Thu Mar 13 13:31:18 UTC 2025


On Wed, 12 Mar 2025 18:00:05 GMT, Mourad Abbay <mabbay at openjdk.org> wrote:

>> In this PR we allow the user to decide how to store the code model. The first option is `TEXT`, if this is selected, we store the textual representation of the code model. The second option is `CODE_BUILDR`, if this is selected, we store the code that builds the code model. All work done here is around the second option, because the first option is already supported.
>
> Mourad Abbay has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains 20 additional commits since the last revision:
> 
>  - Merge branch 'code-reflection' into code-model-storage-option
>  - Load OpFactory and TypeElementFactory before invocation of opMethod only if the opMethod has there params.
>  - Fix the remaining compiler tests failures
>  - Fix some of the test failures (3 remains)
>  - Fix the remaining test failures of SwitchExpressionTest2
>  - Fix almost all test failures of SwitchExpressionTest2 (one remaining)
>  - Pass arrayType instead of eleType in OpBuilder.buildArray
>  - Ensure that block params are inserted in the correct order
>  - Add missing imports
>  - Merge branch 'code-reflection' into code-model-storage-option
>  - ... and 10 more: https://git.openjdk.org/babylon/compare/40db887c...966005ce

src/java.base/share/classes/java/lang/invoke/InnerClassLambdaMetafactory.java line 453:

> 451:         }
> 452:         if (quotableOpGetterInfo.getMethodType().parameterList().equals(List.of(CodeReflectionSupport.OP_FACTORY_CLASS,
> 453:                 CodeReflectionSupport.TYPE_ELEMENT_FACTORY_CLASS))) {

If these fields are public/static, why don't we load them from inside the compiler-generated method, instead of injecting them here?

src/jdk.incubator.code/share/classes/jdk/incubator/code/Op.java line 544:

> 542:                 opMethod = method.getDeclaringClass().getDeclaredMethod(opMethodName, OpFactory.class,
> 543:                         TypeElementFactory.class);
> 544:                 args = new Object[] {ExtendedOp.FACTORY, CoreTypeFactory.CORE_TYPE_FACTORY};

Same questions -- why are these fields injected into the code -- instead of being emitted into the compiler-generated code? (keeping these no-arg methods would simplify this PR)

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

PR Review Comment: https://git.openjdk.org/babylon/pull/305#discussion_r1993522330
PR Review Comment: https://git.openjdk.org/babylon/pull/305#discussion_r1993523632


More information about the babylon-dev mailing list