FAQ: why no user-defined default instances?
Dan Smith
daniel.smith at oracle.com
Thu Apr 20 16:03:11 UTC 2023
On Apr 19, 2023, at 6:47 PM, John Rose <john.r.rose at oracle.com> wrote:
That’s a good point about “hidden indirections”, but it is not true that we always eagerly “stamp out” the canned pointer to the default value. In at least one place (getstatic), at the same time as we dynamically indirect the hidden indirection, we also check for null and substitute the default instance. That would work for arrays as well. In any case, the JVM has the option of stamping out zeroes in all cases. For hidden indirections, the option is to either eagerly stamp out a pointer to the hidden default or stamp out zeroes and map on the fly to the default instance.
Yes, agree. My understanding of the current implementation of (2) is that we eagerly stamp out arrays and lazily check-and-swap fields.
Of course both of these techniques would also work for a class with a custom default instance, which undercuts the argument that the performance of such a feature would be unacceptable.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/valhalla-spec-experts/attachments/20230420/89030338/attachment-0001.htm>
More information about the valhalla-spec-experts
mailing list