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

Enhancement request: Using WebAssembly should include guide on consuming multi-value #232

Open
jzabinski-dolios opened this issue Jan 13, 2022 · 1 comment

Comments

@jzabinski-dolios
Copy link

Go supports the use of multiple results. So does WebAssembly. However, due to compiler limitations, TinyGo cannot yet produce WebAssembly that uses the supported WebAssembly syntax.

TinyGo uses a workaround of placing multiple values into linear memory for consumption by the embedder. The embedder must supply the address (a byte offset) in linear memory where the values are to be stored.

This issue contains a full explanation of how multi-value works in TinyGo, and an example of how to implement Javascript that consumes multiple values. The guide on Using WebAssembly should have a section describing this functionality.

@aykevl
Copy link
Member

aykevl commented Jan 21, 2022

However, due to compiler limitations, TinyGo cannot yet produce WebAssembly that uses the supported WebAssembly syntax.

No. These are not compiler limitations. We do this for backwards compatibility. I think you can enable multi-value using something like -llvm-features=multivalue but I haven't tested this.

In any case, if this is documented we should probably put it in https://tinygo.org/docs/concepts/compiler-internals/calling-convention/.

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

2 participants