Skip to content

Emscripten: Use wasm-gc for call trampolines instead of JS type reflection #128627

Closed
@hoodmane

Description

@hoodmane

Followup to: #121698. WebAssembly in the browser is soon gaining stack switching support, but we're not allowed to stack switch through JS frames. The stack switching support used to require the wasm-js-type-reflection proposal, so in #121698 I updated the call trampoline to use js type reflection if it's present to avoid the JS frame and so the problem was fixed. However, the stack switching proposal has since been updated not to depend on type reflection, and it is going to be shipped while type reflection is still waiting for further refinement. This change means I need a different solution. Fortunately, wasm-gc is in stage 4 (shipped everywhere) and adds a webassembly instruction to query the type of a function. Unfortunately, toolchain support for wasm-gc is poor. Not even my favored assembler supports it.

Another problem is that the existing code is incompatible with memory snapshots since it calls JS initialization code that needs to happen even if restoring a memory snapshot from C code that is skipped when restoring a memory snapshot. I'll fix this at the same time.

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions