Tarean 2 days ago

I think WasmGC is very hard to make work with laziness. A lazy value is always a closure on the heap.

If an expression might be unused, throw a closure which computes it on the heap

If the value is actually needed, invoke the closure. Optionally replace the closure with a black hole. A black hole is just a closure which pauses any thread which calls it, to be resumed once the first thread finishes with the expression

Once finished, replace with a closure which immediately returns the computation result. (Or often save the indirection because most concrete values also act as closures which immediately returns themselves using info table pointers trickery)

Anyway, iirc WasmGC wants very rigid types without dynamic type changes. Extra indirections could fix that, Oor maybe defunctionalizing thunks into a tagged union, but both sound expensive. Especially without being able to hook into the tracing step for indirection removal.

Also, Haskell supports finalizers so WasmGC would need that as well.

  • zozbot234 2 days ago

    > Anyway, iirc WasmGC wants very rigid types without dynamic type changes.

    You can have dynamic type changes in the current WasmGC MVP, but they are modeled as explicit downcasts from a supertype of some sort. There's not even any express support for tagged unions, structs and downcasting is all you get at the moment.

pjmlp a day ago

WasmGC is still a 1.0, there are many kind of GC semantics that it cannot handle, for example it still doesn't cover all use cases needed for languages like C# and Go, e.g. interior pointers.