[External] : Re: We have to talk about "primitive".
John Rose
john.r.rose at oracle.com
Thu Dec 16 01:49:34 UTC 2021
On 15 Dec 2021, at 15:06, Brian Goetz wrote:
> It took us a while to unravel this one, but I think we did.
> … What this says is that tearing/non-tearing is a property of
> reference-vs-primitive-ness; accessing a (fat) value through a
> reference gives you *more guarantees* than accessing it directly.
> (Correspondingly, this has more costs.)
>
> All of this is to say, as I think you are saying: primitives of a
> certain size were always tearable, and they still are; references
> never were, and they are still not.
Of course references don’t tear, and more to the point, `final` fields
reached by references also don’t tear, because they are (a) safely
published and (b) never mutated after publication. So, as Brian says,
wrapping a reference around some chunks of state has a special benefit
(as well as a special cost). The reference wrapper freezes those chunks
in place, relative to each other.
More information about the valhalla-spec-observers
mailing list