dhil opened PR #14140 from dhil:gc-stack-switching to bytecodealliance:main:
This patch adds support for using Wasm GC when using the stack switching extension. The noteworthy contents of this patch:
- Trace GC roots across continuations
Emit stack maps at stack-switch resume points and track GC-reference metadata for continuation payload buffers, allowing suspended stacks and bound arguments to be traced correctly. Allocate and update this metadata only for GC-capable payloads, leaving ordinary stack-switching paths largely unchanged.
- Support
contrefs in GC typesThis patch enables storing
contrefvalues in GC structs and arrays. The core idea behind the implementation is the same as forfuncref: a store-local interning table is used to map 16 bytes continuation identifiers to 4 bytes GC types.
- Fixes issue 13750
Retain Wasm type information when loading continuation payloads and mark GC-reference results as requiring stack maps. This keeps references returned by
resume,suspend, andswitchalive across subsequent GC safepoints.Added the POC as a regression test.
- Fixes issue 13021
Added the POC as a regression test.
- Fixes issue 13022
Added the POC as a regression test.
- Fixes issue 12941
The POC exits successfully with code 0 now. I've not added the POC as a regression test, because it is undistilled.
Resolves #12941. Resolves #13021. Resolves #13022. Resolves #13750.
dhil requested fitzgen for a review on PR #14140.
dhil requested wasmtime-compiler-reviewers for a review on PR #14140.
dhil requested wasmtime-core-reviewers for a review on PR #14140.
dhil updated PR #14140.
dhil updated PR #14140.
github-actions[bot] added the label cranelift on PR #14140.
github-actions[bot] added the label cranelift:area:x64 on PR #14140.
github-actions[bot] added the label wasmtime:ref-types on PR #14140.
github-actions[bot] added the label wasmtime:api on PR #14140.
github-actions[bot] commented on PR #14140:
Subscribe to Label Action
cc @fitzgen
<details>
This issue or pull request has been labeled: "cranelift", "cranelift:area:x64", "wasmtime:api", "wasmtime:ref-types"Thus the following users have been cc'd because of the following labels:
- fitzgen: wasmtime:ref-types
To subscribe or unsubscribe from this label, edit the <code>.github/subscribe-to-label.json</code> configuration file.
Learn more.
</details>
dhil updated PR #14140.
:memo: fitzgen submitted PR review:
Sorry for the delay. A few thoughts below.
:speech_balloon: fitzgen created PR review comment:
This will create a new stack slot each time we read a contref from a GC object, correct? But each stack slot is only live across one read? It seems like we should have a
get_or_create_contref_stack_slotmethod in that case, or else repeatedly reading a contref could create a whole bunch of stack slots.
:speech_balloon: fitzgen created PR review comment:
Can these offsets use constants defined in
wasmtime-environ?
:speech_balloon: fitzgen created PR review comment:
This is not the reason to use a side table, the real reason is to avoid trusting native addresses that come out of the GC heap.
:speech_balloon: fitzgen created PR review comment:
Is the generic parameter pulling its weight here? I doubt that a couple tests are going to make much of a difference compared to allocating a whole new stack...
:speech_balloon: fitzgen created PR review comment:
This should probably be
VmPtr<u8>, evem though existing stack-switching code doesn't use that yet (but it should, given the fullness of time).
Last updated: Aug 30 2026 at 09:07 UTC