Canonical abi: inline passing
There doesn't seem to be an option right now to force parameters to be passed inline
For record, list<T, N>, tuple, flags, etc., they are all transfer forms of ptr + len.
This requires at least
- Know the layout defined by the type
- The layout has been filled and aligned correctly
- A little offset calculation instructions are needed to extract the field
or need
reallocis required to ensure compliance with the language-defined layout- A little offset calculation instructions are needed to extract the field
Is it possible to add an inline-passing option to omit these requirements?
I find this useful in languages where tuples exist.
Can you clarify what you mean by "passed inline"? For example a record is already "splatted" to its parts and passed inline when it's a parameter:
$ cat foo.wit
package a:b;
world foo {
record x {
a: u32,
b: f32,
c: f64,
}
import foo: func(x: x);
}
$ wasm-tools component embed --dummy foo.wit -t
(module
(type (;0;) (func (param i32 f32 f64)))
(type (;1;) (func (param i32 i32 i32 i32) (result i32)))
(import "$root" "foo" (func (;0;) (type 0)))
(func (;1;) (type 1) (param i32 i32 i32 i32) (result i32)
unreachable
)
(memory (;0;) 0)
(export "memory" (memory 0))
(export "cabi_realloc" (func 1))
)
(note the parameters to import "$root" "foo")
Lists which dynamically have a small length are not passed inline, but I'm not sure how that would be managed otherwise.
This is all a result of flattening in the canonical ABI.
So given that, can you clarify what you mean by things should be passed inline?
Perhaps #385 solves a similar problem. At least it does with one specific definition of "inline" and "embed" (into structures).