Skip to content
This repository has been archived by the owner on May 11, 2020. It is now read-only.

Allow WebAssembly functions to refer and import Go data and functions #29

Open
vibhavp opened this issue Aug 28, 2017 · 4 comments
Open

Comments

@vibhavp
Copy link
Collaborator

vibhavp commented Aug 28, 2017

Right now, a wasm.Module struct can only hold Functions that use WebAssembly bytecode. To allow interoperability between WASM and Go, it should be possible to use call and call_indirect with Go functions. Furthermore, more complex data structures like struct, map, slice and chan should be able to be passed as arguments, using an intermediate ABI around the module's linear memory.

@Spriithy
Copy link
Contributor

Hello, I'm new to your project and Wasm (but neither to VMs or Go) is there any way I could help with this issue ? Thanks :D

@vibhavp
Copy link
Collaborator Author

vibhavp commented Sep 28, 2017

Thanks for helping out!
As I understand it, the starting point for this would be to figure out a way to represent all Go types in WebAssembly (which as a bytecode format only allows i32, i64, f32 and f64). An obvious way would be to use i64 to store the raw unsafe.Pointer values, and convert them accordingly while they're in transit from or to Go functions. Another issue would be to make sure that garbage collection doesn't free up these objects, as storing pointers in a way other than unsafe.Pointer discards GC info.
Once we have these design decisions sorted out, we can sketch out a basic Go<->WebAssembly FFI.

@hajimehoshi
Copy link
Contributor

Actually life (yet another Wasm interpreter in Go) has this feature: ImportResolver. I was also wondering if wagon could have a similar feature.

@laizy
Copy link
Member

laizy commented Mar 8, 2019

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

No branches or pull requests

4 participants