Keno / julia-wasm

Running julia on wasm
https://keno.github.io/julia-wasm/website/repl.htm
333 stars 23 forks source link

JS Interop for arrays #14

Open Keno opened 5 years ago

Keno commented 5 years ago

@mdboom asked what our plan for array interop is and pointed us to the python implementation at

https://github.com/iodide-project/pyodide/blob/1f978500a02323589bd2c689865a49914fa145a5/src/hiwire.c

since our memory layout is dense, the same approach (taking a typed subarray of the heap buffer) should work and we should be able to re-use the existing data sharing mechanism to work around any GC issues. An alternative design would be to always back arrays by an appropriate TypedArray (would depend on multi-table support in wasm). I suspect the first design is better and simpler for wasm to optimize, but would be worth benchmarking.

aminya commented 4 years ago

@SimonDanisch Can JsServe help this in any way? https://github.com/SimonDanisch/JSServe.jl

AssemblyScript uses as-bind for interop. That's the best automatic interop handler I have seen. https://github.com/torch2424/as-bind It supports these types https://github.com/torch2424/as-bind#supported-data-types also see my issue here: https://github.com/torch2424/as-bind/issues/28

Can't we just use as-bind with the help of JsServe?

SimonDanisch commented 4 years ago

Not really "help"... But I do think it could be an interface, since it already has offers the semantic of calling JavaScript from Julia - which when running in wasm could be swapped out to call js functions directly