Skip to content

[stack-switching] GC interaction - #14140

Open
dhil wants to merge 1 commit into
bytecodealliance:mainfrom
dhil:gc-stack-switching
Open

[stack-switching] GC interaction#14140
dhil wants to merge 1 commit into
bytecodealliance:mainfrom
dhil:gc-stack-switching

Conversation

@dhil

@dhil dhil commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

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 types

This patch enables storing contref values in GC structs and arrays. The core idea behind the implementation is the same as for funcref: 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, and switch alive 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
dhil requested review from a team as code owners August 14, 2026 15:39
@dhil
dhil requested review from fitzgen and removed request for a team August 14, 2026 15:39
@dhil
dhil force-pushed the gc-stack-switching branch from b74e5c6 to c32ebbc Compare August 14, 2026 15:41
This patch adds support for using Wasm GC when using the stack
switching extension. The 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 `contref`s in GC types

This patch enables storing `contref` values in GC structs and
arrays. The core idea behind the implementation is the same as for
`funcref`: 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`, and `switch` alive 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.
@dhil
dhil force-pushed the gc-stack-switching branch from c32ebbc to 40100cd Compare August 14, 2026 15:53
@github-actions github-actions Bot added cranelift Issues related to the Cranelift code generator cranelift:area:x64 Issues related to x64 codegen wasmtime:api Related to the API of the `wasmtime` crate itself wasmtime:ref-types Issues related to reference types and GC in Wasmtime labels Aug 14, 2026
@github-actions

Copy link
Copy Markdown

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 .github/subscribe-to-label.json configuration file.

Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cranelift:area:x64 Issues related to x64 codegen cranelift Issues related to the Cranelift code generator wasmtime:api Related to the API of the `wasmtime` crate itself wasmtime:ref-types Issues related to reference types and GC in Wasmtime

Projects

None yet

1 participant