[lworld] RFR: 8359370: [lworld] allow instance fields of identity classes to be readable in the prologue phase [v13]
Maurizio Cimadamore
mcimadamore at openjdk.org
Thu Aug 28 16:28:05 UTC 2025
On Thu, 28 Aug 2025 12:55:05 GMT, Vicente Romero <vromero at openjdk.org> wrote:
>> Before this fix only strict fields were readable in the prologue phase. The proposed fix should allow any instance fields of identity classes to be readable in the prologue phase. This implies changes in flow analysis as before we were only tracking final and strict fields. There is also some "cooperation" needed in the code to detect cases when reading a field is not allowed in the prologue phase. For example some methods in Resolve don't have all the needed information at the moment they are dealing with some ASTs and part of the processing needs to be done in Attr
>>
>> TIA
>>
>> This PR is a remake of https://github.com/openjdk/valhalla/pull/1490
>
> Vicente Romero has updated the pull request incrementally with one additional commit since the last revision:
>
> minor diff
src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java line 1261:
> 1259: for (JCTree stat : tree.body.stats) {
> 1260: prologueCode.add(stat);
> 1261: /* gather all the stats in the body until a `super` or `this` constructor invocation is found,
I understand that you wanted to simplify the visitor -- but doing a linear pass on the constructor and creating a new list of statements is also kind of expensive -- maybe when we're done with this change we can see if there's a way to set a flag on the visitor to shortcircuit the analysis after the super call is found.
src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeInfo.java line 971:
> 969: public record SymAndTree(Symbol symbol, JCTree tree) {}
> 970:
> 971: public static java.util.List<SymAndTree> symbolsFor(List<JCTree> nodes) {
Is the use of `j.u.List` deliberate here?
src/jdk.compiler/share/classes/com/sun/tools/javac/tree/TreeInfo.java line 982:
> 980: }
> 981:
> 982: public static java.util.List<SymAndTree> symbolsFor(JCTree node) {
Can you provide some examples on what this method is supposed to do? E.g. example input and output?
-------------
PR Review Comment: https://git.openjdk.org/valhalla/pull/1523#discussion_r2307921664
PR Review Comment: https://git.openjdk.org/valhalla/pull/1523#discussion_r2307925310
PR Review Comment: https://git.openjdk.org/valhalla/pull/1523#discussion_r2307929864
More information about the valhalla-dev
mailing list