I am having a hard time squaring two different parts of the component spec. In the prose for canon lower, it says:
if len(flatten_types(ft.result_type())) > max_flat_results, realloc is required.
However, the definition of flattening also says:
When lowering into linear memory, this requires the Canonical ABI to call realloc (in lower below) to allocate space to put the tuple. As an optimization, when lowering the return value of an imported function (via canon lower), the caller can have already allocated space for the return value (e.g., efficiently on the stack), passing in an i32 pointer as an parameter instead of returning an i32 as a return value.
And the definition of flatten_functype makes this explicit by appending a pointer parameter and settings results to [].
These two paragraphs seem to contradict each other. The point of the out parameter is explicitly to avoid a realloc for results on lower. Is the prose in canon lower just wrong, or is realloc still conservatively required even if it won't necessarily be called?
(This is separate from the question of string or list results; I realize realloc is always required in that case. I am only asking about whether realloc is required when results are spilled on lower.)
I am having a hard time squaring two different parts of the component spec. In the prose for
canon lower, it says:However, the definition of flattening also says:
And the definition of
flatten_functypemakes this explicit by appending a pointer parameter and settings results to[].These two paragraphs seem to contradict each other. The point of the out parameter is explicitly to avoid a
reallocfor results on lower. Is the prose incanon lowerjust wrong, or isreallocstill conservatively required even if it won't necessarily be called?(This is separate from the question of string or list results; I realize
reallocis always required in that case. I am only asking about whetherreallocis required when results are spilled on lower.)