[lworld] RFR: 8281166: [lworld] javac should generate BSM to invoke the static factory for value class
Rémi Forax
forax at openjdk.java.net
Mon Feb 7 09:32:28 UTC 2022
On Mon, 7 Feb 2022 08:11:57 GMT, Srikanth Adayapalam <sadayapalam at openjdk.org> wrote:
>> I wonder if the transformation from a constructor call to a static method call when it's a value class should not be done before the lambda transformation ?
>
>> I wonder if the transformation from a constructor call to a static method call when it's a value class should not be done before the lambda transformation ?
>
> This is technically feasible, but has some practical complications. As the top level comment in com.sun.tools.javac.jvm.TransValues calls out:
>
>
> /**
> * This pass translates value class constructors into static factory methods and patches up constructor
> * calls to become invocations of those static factory methods.
> *
> * We get commissioned as a subpass of Gen. Constructor trees undergo plenty of change in Lower
> * (enclosing instance injection, captured locals ...) and in Gen (instance field initialization,
> * see normalizeDefs) and so it is most effective to wait until things reach a quiescent state
> * before undertaking the tinkering that we do.
> *
> * See https://bugs.openjdk.java.net/browse/JDK-8198749 for the kind of transformations we do.
> *
> */
>
>
> Lambda lowering happens well before Lower and Gen pipeline phases. TransValues is a subphase of Gen - we need to wait until Gen because constructors undergo lots of changes up until and well into Gen. So if we want to group all transformations - of constructors into static factories and constructor invocations into static value factory invocations - into one centralized localized pipeline stage (i.e TransValues) the present approach is the best
Okay, make sense
-------------
PR: https://git.openjdk.java.net/valhalla/pull/629
More information about the valhalla-dev
mailing list