how passing value types will work?
Tobias Hartmann
tobias.hartmann at oracle.com
Wed Oct 22 05:10:58 UTC 2025
Hi David,
On 10/20/25 00:56, david Grajales wrote:
> When a value object (let's say a value record) is being passed to a method, does it pass a copy of the values or a reference to where the values are in memory?
The JVM's highly optimizing JIT compiler (C2) will optimize calls such that value objects are passed by value, i.e. it will pass the individual field values in registers / stack slots. The same applies to returns, but there we are limited by the number of available registers.
Best regards,
Tobias
More information about the valhalla-dev
mailing list