carbon-lang
carbon-lang copied to clipboard
value representation for structs and tuples
Summary of issue:
From this review comment:
What should the value representation for a struct or tuple be? Some options:
- A by-copy struct or tuple of the value representations of the elements. (This is presumably the right answer when the struct or tuple is small, such as when it has a single element.)
- A by-pointer struct or tuple of the value representations of the elements. (This is option 1a in the review comment, and what the toolchain currently does for multi-element structs and tuples.)
- A by-pointer struct or tuple of the value representations of the elements, except that by-pointer elements are flattened to by-copy elements. (This is option 1b.)
- A by-pointer object representation of the struct or tuple. (This is option 2.)
Details:
All of the options have downsides -- see the review comment thread. Selecting between them based on criteria such as the size of the elements may be the best choice.
Any other information that you want to share?
No response
It's worth noting that this choice is influenced strongly by Carbon's goal of predictable performance. If we come up with criteria by which we switch between strategies, we will presumably want to provide some way of controlling the decision or at least clear rules by which it can be understood.