<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body style="overflow-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;">
<div>
<blockquote type="cite">
<div>On Apr 19, 2023, at 6:47 PM, John Rose <john.r.rose@oracle.com> wrote:</div>
<br class="Apple-interchange-newline">
<div><span style="caret-color: rgb(0, 0, 0); font-family: sans-serif; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;">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 (</span><code style="caret-color: rgb(0, 0, 0); font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; margin: 0px; padding: 0px 0.4em; border-radius: 3px; background-color: rgb(247, 247, 247);">getstatic</code><span style="caret-color: rgb(0, 0, 0); font-family: sans-serif; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;">),
at the same time as we dynamically indirect the hidden indirection, we<span class="Apple-converted-space"> </span></span><em style="caret-color: rgb(0, 0, 0); font-family: sans-serif; font-size: 12px; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;">also
check for null</em><span style="caret-color: rgb(0, 0, 0); font-family: sans-serif; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;"><span class="Apple-converted-space"> </span>and
substitute the default instance. That would work for arrays as well. In any case, the JVM has the<span class="Apple-converted-space"> </span></span><em style="caret-color: rgb(0, 0, 0); font-family: sans-serif; font-size: 12px; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;">option</em><span style="caret-color: rgb(0, 0, 0); font-family: sans-serif; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;"><span class="Apple-converted-space"> </span>of
stamping out zeroes in all cases. For hidden indirections, the<span class="Apple-converted-space"> </span></span><em style="caret-color: rgb(0, 0, 0); font-family: sans-serif; font-size: 12px; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;">option</em><span style="caret-color: rgb(0, 0, 0); font-family: sans-serif; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;"><span class="Apple-converted-space"> </span>is
to either eagerly stamp out a pointer to the hidden default<span class="Apple-converted-space"> </span></span><em style="caret-color: rgb(0, 0, 0); font-family: sans-serif; font-size: 12px; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none;">or</em><span style="caret-color: rgb(0, 0, 0); font-family: sans-serif; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration: none; float: none; display: inline !important;"><span class="Apple-converted-space"> </span>stamp
out zeroes and map on the fly to the default instance.</span></div>
</blockquote>
</div>
<div><br>
</div>
<div>Yes, agree. My understanding of the current implementation of (2) is that we eagerly stamp out arrays and lazily check-and-swap fields.</div>
<div><br>
</div>
<div>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.</div>
</body>
</html>