Accessing WebAssembly reference-typed arrays from C++

  • A proper solution for this problem will also help with the WebGPU API. Mapping a GPU resource returns a JS array view, which currently requires a memcpy-roundtrip into and out of the WASM heap (for instance see here in Emscripten's WebGPU shim: https://github.com/emscripten-core/emscripten/blob/37aa752eb...).

    Ideally the array view could either be mapped directly into the WASM heap, or at least would be accessible from the C/C++/Rust side with a special pointer type (maybe WASM should get a segmented address space like back in the 286 days lol).

  • This is the weird thing about the GC proposal: it's not really adding a GC to WASM, as it is more adding an opaque object reference system similar to Java or similar, independent from linear memory (the goal of Mark Miller was to run without any linear memories at all). C and C++ and their compilers are based on the concept of a linear, addressable memory and adding in opaqueness really is like pulling teeth.

    I can't see much success for the GC proposal, tbh. It's really fighting a very strong current.