MikeInnes / WebAssembly.jl

Other
83 stars 11 forks source link

Add support for arrays and structs #10

Open sjorn3 opened 6 years ago

sjorn3 commented 6 years ago

An array could be handled by constructing one in linear memory (e.g. in JS) and then passing this to a wasm function in the form of a pointer and length if required. Initially this would be implemented with just the simple wasm values, until structs are implemented and more complicated arrays can be supported.

Structs would passed as simple arguments to the function as flattened versions of themselves.

tshort commented 6 years ago

This should probably be in Charlotte. See https://github.com/MikeInnes/Charlotte.jl/issues/1 and https://github.com/MikeInnes/Charlotte.jl/issues/2.

sjorn3 commented 6 years ago

I realise I didn't make it clear but this was supposed to be specific to the interpreter for the time being. I could move it over to the interpreter issue if that makes more sense.

tshort commented 6 years ago

Got it.

sjorn3 commented 6 years ago

I've been looking at this a bit and got some pretty basic stuff working on the interpreter in the arrays branch. A few points to consider.

tshort commented 6 years ago

Awesome, @sjorn3! For memory allocation, https://github.com/MikeInnes/Charlotte.jl/issues/6 is a good place for discussion.

For interaction with JS, the wasm-ffi package looks really nice. We can just include that JS file, and I don't think we need to do much on the WASM side other than defining allocate and deallocate functions.