[lworld] RFR: 8244313: [lworld] Evolve javac's code generation to match scheme documented in SoV

Maurizio Cimadamore mcimadamore at openjdk.java.net
Mon Apr 19 10:31:54 UTC 2021

On Mon, 19 Apr 2021 10:22:45 GMT, Maurizio Cimadamore <mcimadamore at openjdk.org> wrote:

>> Trying to understand - is switchPool called only once?
>> If so, can't we replace switchPool by simply creating a new PoolWriter? I know that, up to now, we had only one instance of PW, but of the various abstractions, PW seems the one that is more amenable in terms of spawning new instances?
> Ok, I see - switch pool is also called from ClassWriter whenever we need to add a new symbol to the pool and we see that the symbol belongs to a different projection.
> I guess the approach that seems intuitively more natural to me (as it requires less modifiable state) is one where we create _two_ ClassWriter instances for the same symbol/AST - but one on the reference projection polarity, the other on the inline polarity. Symbols that do not belong to the correct polarity are just skipped.
> I agree that splitting JCClassDecl seems like overkill for this.

I now see where my "intuitive" idea falls apart: Gen is doing some of the work which causes entries to be written to the pool (e.g. visitMethod). E.g. by the time we get to ClassWriter, the pool is already partially written. This is probably what motivated the split at that level. So, I agree, it's either current approach, with mutable pool writer, or one where we have two JCClassDecl (and two Gen passes). Ugh.


PR: https://git.openjdk.java.net/valhalla/pull/386

More information about the valhalla-dev mailing list