Garbage Compilation enabled in WebAssembly (at least in Google Chrome)

What does this mean for Julia? Julia can aready work in web browser (with WebAssembly), even with out GC standardized, but possibly it could work better with the web browsers GC used?

Phase 5 - The Feature is Standardized (WG)
[i.e. extensions of to WebAssembly]

but GC and more interesting is under (unless this is outdated):

Phase 4 - Standardize the Feature (WG)"

Viewing this in the context of this YouTube recording , this development seems promising.

And it already works on ODE solvers:

3 Likes

WebAssemblyCompiler.jl is pretty new. The SciML code works well for compilation because they keep structs concrete by parameterizing types like crazy.

Less concrete code is much tougher. WebAssemblyCompiler offers overlays to redefine problem code. I’ve been playing with compiling Observables and Makie, and that’s helpful. That code has many non-concrete types, and it’s a challenge. In addition to overlays, I also needed to unroll as much as possible to keep things type stable.

3 Likes

I found A new way to bring garbage collected programming languages efficiently to WebAssembly · V8 a more interesting article also discussing the challenges in porting languages.

1 Like

It’sn interesting link, I had not heard of emmalloc which isn’t interesting in this (GC) context, but might be for StaticCompiler.jl, from the link on it there:

The incoming branch now has a MALLOC option which can be either dlmalloc (the standard allocator from before) or emmalloc, which is a new allocator written to be small and simple. It’s about a third of the code size of dlmalloc, which can help on small programs that use malloc/free, where sometimes malloc/free is most of the binary.

WebAssembly is useful for the web, its original purpose, but also elsewhere. StaticCompiler.jl currently has a limitation of not working for Windows, but WebAssembly works everywhere, including there right? With that project, it does NOT distribute its own GC (EDIT: I thought then no GC, but actually uses WASM-GC], i.e. has same limitations as StaticCompiler (except for the portability limitation)? In theory it could distribute its own GC or just use WasmGC?

WebAssemblyCompiler should work on Windows, but I haven’t tried it. WebAssemblyCompiler does not have as many limitations as StaticCompiler. The big difference is that it uses WASM-GC, so it supports arrays (even Vector{Any}), mutable types, dicts, and other garbage-collected objects. You still need code that can be statically compiled, and currently, there are other limitations.

3 Likes