<div dir="auto">Thanks,<div dir="auto">I didn't think about registers at all while underestimating the depth of optimization the runtime can do. I wasn't expecting the vm to intelligently manage registers at runtime. </div><div dir="auto"><br></div><div dir="auto">But I doubt that value objects will be often only stored in registers since their space is (on most platforms) pretty limited. You would need to strip unused fields from the object which often will reduce the object to maybe 1-2 int or something, reducing it to nothing more than the arguments for the next cpu cycle. But storing a larger object > ~200 bytes completely in registers is impossible in the first place. And storing multiple value objects simultaneously in registers is even more unlikely to happen. </div><div dir="auto"><br></div><div dir="auto">This level of optimization really makes value objects feel like c structs which shows how great the improvement from objects to value objects really is. It's really only a grouping of local variables in 1 name. Which totally makes sense for pure data carriers especially records. </div><div dir="auto"><br></div><div dir="auto">Great regards </div><div dir="auto">RedIODev </div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Jan 12, 2023, 22:18 Brian Goetz <<a href="mailto:brian.goetz@oracle.com">brian.goetz@oracle.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
<br>
> Everything has a memory address period. <br>
<br>
Despite emphasizing it with “period” as if it were obviously true, this statement is not correct.  <br>
<br>
Value objects can be scalarized into their fields, and those fields can be hoisted into registers, and registers have no memory address.   There is no reason why a copy of the object need be placed in memory at all.  In fact, this is much of the raison d’être for Valhalla — to give the runtime permission to confidently make this optimization, by saying that an object need not live in a single — or even any — place in “memory".  <br>
<br>
<br>
</blockquote></div>