8 comments

[ 5.0 ms ] story [ 30.0 ms ] thread
How is interop with native JS in WebAssembly performance-wise? If I switch between WASM and JS every few instructions, will that incur some sort of context switch? (I recall Firefox having such issues in asm.js where calls from asm.js into native JS were quite costly.)
WASM has been designed such that these calls can be made in principle very cheaply. I don't know though how much current engines have been optimised for that use case though.
How likely is it for all the JS api surface to be exposed to WASM code directly -- no js required?
I guess pretty unlikely as WASM has been designed to be a generic engine which is embeddable in other contexts than Javascript as well. You can already import JS functions into WASM code, I guess the biggest hurdle for JS interop is that WASM only knows about ints and floats, but not arbitrary JS objects.