Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Canonical abi: inline passing #315

Open
oovm opened this issue Mar 2, 2024 · 2 comments
Open

Canonical abi: inline passing #315

oovm opened this issue Mar 2, 2024 · 2 comments

Comments

@oovm
Copy link

oovm commented Mar 2, 2024

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

  1. Know the layout defined by the type
  2. The layout has been filled and aligned correctly
  3. A little offset calculation instructions are needed to extract the field

or need

  1. realloc is required to ensure compliance with the language-defined layout
  2. 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.

@alexcrichton
Copy link
Collaborator

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?

@cpetig
Copy link

cpetig commented Aug 1, 2024

Perhaps #385 solves a similar problem. At least it does with one specific definition of "inline" and "embed" (into structures).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants