Civilizer - let's civilize those primitive types !

Brian Goetz brian.goetz at oracle.com
Fri Jan 13 15:34:34 UTC 2023


> 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. 
> 
> 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. 


It is easy to think about Valhalla as being about “blocks and pointers”, and see the main benefit as eliminating some of those pointers by inlining layout into enclosing blocks.  And indeed, that is one of the benefits of Valhalla, and the easiest to visualize from a C-centric viewpoint.  But, that’s only part of the story.  If you have a value type Point, and you return a Point from a method, the calling convention for the method will routinely pass the Point fields in registers.   And in many cases, where a value is used only to communicate an aggregate between a caller and a callee, the value need never hit memory at all.  This is a significant part of what Valhalla is providing.  




More information about the valhalla-dev mailing list