Stream: general

Topic: Module <-> Module communication


view this post on Zulip Benjamin Brittain (Mar 20 2020 at 17:00):

Are there any examples of inter-module communication?

view this post on Zulip Alex Crichton (Mar 20 2020 at 17:07):

@Benjamin Brittain do you mean in terms of like linking instances together? Or are you looking for a specific example of something like "transfer memory from A to B"

view this post on Zulip Benjamin Brittain (Mar 20 2020 at 17:15):

"transfer memory from A to B"

view this post on Zulip Alex Crichton (Mar 20 2020 at 17:17):

Ah ok, we don't currently have an example of that, but I'll look into adding one!

view this post on Zulip Alex Crichton (Mar 20 2020 at 17:17):

are you interested in wasm modules themselves doing the copy? or the host doing the copy?

view this post on Zulip Benjamin Brittain (Mar 20 2020 at 17:17):

I'd love to see both actually!

view this post on Zulip Benjamin Brittain (Mar 20 2020 at 17:18):

but mostly the module themself

view this post on Zulip Alex Crichton (Mar 20 2020 at 17:18):

mk I'll see if I can whip something up today

view this post on Zulip Benjamin Brittain (Mar 20 2020 at 17:18):

that would be super fantastic :D

view this post on Zulip Alex Crichton (Mar 20 2020 at 17:23):

@Benjamin Brittain do you have a use case in mind? Otherwise I was thinking of maybe doing something like creating a module that has a "log" function and another module which calls that log function

view this post on Zulip Alex Crichton (Mar 20 2020 at 17:23):

and the original one like reverses the message or something weird like htat

view this post on Zulip Benjamin Brittain (Mar 20 2020 at 17:31):

no actual use case in mind yet. I'm just trying to get an understanding of the current state of things. Log would be a super example though

view this post on Zulip Alex Crichton (Mar 20 2020 at 17:32):

kk sounds good

view this post on Zulip Alex Crichton (Mar 20 2020 at 19:53):

@Benjamin Brittain https://github.com/bytecodealliance/wasmtime/pull/1369

This commit adds two example programs, one for linking two modules together and one for instantiating WASI. The linkage example additionally uses WASI to get some meaningful output at this time. cc...

view this post on Zulip Benjamin Brittain (Mar 23 2020 at 12:40):

This is fantastic! Exactly what I was looking for

view this post on Zulip daubaris (Mar 23 2020 at 13:03):

@Alex Crichton I've tried to replicate the .wat modules in rust code and linking is working great with basic data types. I also saw that in the module the memory was also imported. How could one module access other module's memory using, for example, rust? I've tried basically passing the pointers around but received attempt to multiply with overflow errors..

view this post on Zulip Benjamin Brittain (Mar 23 2020 at 13:05):

I don't believe there are any mechanisms to do that right now

view this post on Zulip Alex Crichton (Mar 23 2020 at 13:47):

@daubaris it's pretty nontrivial to link two rust programs dyanmically at runtime like that together right now

view this post on Zulip Alex Crichton (Mar 23 2020 at 13:47):

it needs a lot of coordination of details like heap layout, stack, etc

view this post on Zulip Alex Crichton (Mar 23 2020 at 13:47):

C has dynamic linking story that's further along than Rust's for sure, we haven't put much effort into making it usable from rustc

view this post on Zulip Alex Crichton (Mar 23 2020 at 13:48):

you can probably get away with it with various flags and transformations though, but you'd be making a lot of it yourself

view this post on Zulip daubaris (Mar 23 2020 at 14:02):

@Alex Crichton Oh, so it is not really feasible at the moment as I understand it. Alright thanks!


Last updated: Dec 23 2024 at 12:05 UTC