tanishiking / scala-wasm

Experimental WasmGC backend for Scala.js | merging into the upstream Scala.js repo https://github.com/scala-js/scala-js/pull/4988
41 stars 3 forks source link

Refactor the module structure and type definitions. #109

Closed sjrd closed 7 months ago

sjrd commented 7 months ago

All but the last commit are small-scale refactorings, which lead to the final big refactoring commit.


We refactor the module structure and type definitions so that they more closely correspond to the Structure vue of WebAssembly. Previously, they were a mix of text vue, binary vue, and some hard-coded behavior (like all structs are non-final subs).

As a consequence, we are much more explicit when it comes to adding types to the main giant rectype. We only add in it the types that are actually mutually recursive. This mostly includes the object struct types, the vtable and itable types, and the function types that appear within the vtable and itable types.

Other types, such as function types for block types and struct types used for captureData, are defined outside of the big recursive type.

This change allows to remove the hacks we were doing for the function types of imports. We previously had a special-case to redefine them outside the recursive type. Now they are naturally created as being outside the recursive type in the first place.