Get the latest tech news
Encodings for flattened heap values
2024 (v-0.3) A key goal in Project Valhalla is to flatten value objects into their heap containers, while simultaneously upholding all specified behaviors of those containers. A value’s flat representation must provide storage bits for each field of the value, allocated directly in the container (or at least indirectly accessible).
In a Valhalla prototype, the experimental value class annotation@LooselyConsistentValue disavows full consistency, allowing the VM to use faster access methods that might cause fieldwise tearing. The rest of this note talks about various implementation tactics for flattening fields, especially in the challenging case of adding nullability to types which already occupy a machine word, while (in addition) avoiding new race conditions. The fix to this potential problem is not only to update the container before asserting the non-null state in the null channel, but also to issue a store-store barrier between the two write instructions, to prevent the effects from being reordered.
Or read this on Hacker News