State of OCaml and web assembly

I have since improved dynamic binding support in wasi-kernel, which allows to bind to JS functions as well without needing the C stub to cross the border between OCaml and C. That is, the stub exists, but it is part of wasi-kernel and is introduced on demand.

This is how this mechanism was used in waCoq.

These glue binders are generated by this script: https://github.com/corwin-of-amber/wasi-kernel/blob/master/scripts/autogen-delegation.js.

3 Likes

Direct link because the server only allows two links :man_shrugging:

This approach seems to be very maintainable.
How is its performance compared to jsoo?

It is unfortunately not very impressive. Loading objects (i.e. Dynlink’ing .cmas) is much faster, whereas executing the code itself is pretty much on par; sometimes faster, sometimes slower. The V8 JIT is extremely good with tight loops, and the WASM runtime is not there yet, so if you have such loops in your code, you can expect the interpreted version to be slower.

1 Like

What about other JS engines, like the one in firefox (spider monkey? I
don’t remember) ? Not everyone has or wants V8 :slight_smile:

1 Like

Might be interesting to check also lightweight JS engines like:

1 Like

In my experience, Firefox tends to be slower. It will be interesting to benchmark at some point. The lightweight JS’s have no JIT so you can expect them to be the slowest. Android browsers are also weak on that front because of the memory consumption overhead that JIT incurs.

1 Like

Web Assembly GC Proposal has moved to Stage 2 according to this tweet. One step closer to a solid OCaml → WASM compiler.

9 Likes