Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

State of the art of the interface types #2480

Closed
rambip opened this issue Jul 19, 2021 · 4 comments
Closed

State of the art of the interface types #2480

rambip opened this issue Jul 19, 2021 · 4 comments
Assignees
Labels
❓ question I've a question!

Comments

@rambip
Copy link

rambip commented Jul 19, 2021

I installed wasmtime to experiment with wasi recently, and I heard about the "interface types proposal" from bytecodealliance.

So I used the wasm-bindgen crate that already implement this interface from rust to wasi.

And following this tutorial, I installed the wasmtime python library, but I discovered that support for interface types have been removed ! (bytecodealliance/wasmtime#1292)

My question is: what is the current situation for wasmer around this issue ?
Is the wasi interface type proposal stable enough ?
And what are the other ways to make languages communicate via wasm ? I know about files, I/O and sockets, but can you share the ram for example ? I didn't see any example of that with wasmer and wasmtime.

@rambip rambip added the ❓ question I've a question! label Jul 19, 2021
@Hywan
Copy link
Contributor

Hywan commented Jul 19, 2021

Hello,

There is a lot of confusion in your message, and I'm glad to address them :-).

There is indeed a WebAssembly Interface Types Proposal, which is —at the time of writing— at Phase 1, i.e. very unstable, not ready to be implemented, experimental.

We have done our own implementation of this proposal in the past (see the wasmer-interface-types crate) but things have moved quite a lot since then.

Nor wasmtime, nor any Wasm runtimes, support Interface Types for the moment because it's changing constantly.

wasm-bindgen on the other side is automatic bindings between Wasm and JavaScript. It's not meant to be used in another host environment (here, JavaScript). It's a hack while waiting on something more universal like Interface Types.

@Hywan Hywan self-assigned this Jul 19, 2021
@rambip
Copy link
Author

rambip commented Jul 19, 2021

Thank's !
I looked in the wasi documentation, and I saw "iovec", A region of memory for scatter/gather reads.
So is there a way for wasmer to share memory between the host and a wasm module to do ineroperability, or maybe the best idea is to use a temporary file or a socket to share data efficiently ?

@rambip
Copy link
Author

rambip commented Jul 19, 2021

If I understand correctly, that means that the languages runtimes for wasi (for example the python module) can only communicate builtins values like i32 and f32 to the exported functions ?
So is there a way, for example, to communicate a string from python to a wasm module, with stdin/stdout ?
I can't see how these packages in these diffetent languages can be usefull if I can't send data to the wasm functions :(

@proohit
Copy link

proohit commented Jul 20, 2021

You can access memories of WASM VMs from the host environment but not vice versa (at least not implictly). WASM Modules have exactly one memory, which can also be shared across modules. You can pass around pointers in this memory at which you define your custom data types (e.g. string) and share those i32 integer pointers with other modules | (exported) functions etc. You can also pass a custom function as an import to do stuff in the host env, called from the module.

I've had a discussion about this topic with @Hywan in this issue and written some examples in my repository . There you can find examples for python using wasmer and wasmtime, go using wasmer and javascript/node using V8.

For the time being, we're stuck with this hackish solution of manipulating memory. I don't know of any tools to bridge the time, but it will become obsolete anyway when interface-types are integrated.

@wasmerio wasmerio locked and limited conversation to collaborators Oct 20, 2021

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
❓ question I've a question!
Projects
None yet
Development

No branches or pull requests

4 participants