[lworld] RFR: JDK-8252061 [lword] Support Object::toString for inline type

John R Rose jrose at openjdk.java.net
Thu Aug 20 02:48:29 UTC 2020

On Thu, 20 Aug 2020 01:40:40 GMT, Mandy Chung <mchung at openjdk.org> wrote:

> This adds the `Object::toString` support for inline classes.  This will replace the need
> for javac to generate the `toString` method to call the bootstrap method.
> JDK-8206077 will revisit the overlap of `ValueBootstrapMethods` and `ObjectMethods`.
> This patch also removes the private `isSubstituable0` method and makes sure
> that `isSubstitutable` does not have `acmp` instruction and can be invoked by VM.

A couple of comments:

1. In order for this to perform well, the code for each generated toString method needs to be JIT-ted, and to be
reached quickly (or even inlined) via ClassValue::get.  Optimization work (to be done later) should probably consider

2. We should try to handle Record subtypes the same way.  Putting funky bytecodes into classfiles, even using indy, is
worse than allowing Object::toString (and equals and hashCode) to vector through a specified, customized method, using

3. I think it is reasonable to have special intrinsic logic in the JIT to hurry along the previous two steps, although
in the long run the JVM should have a good story (perhaps using ClassValue, perhaps not) for auto-expanded method


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

More information about the valhalla-dev mailing list