cfallin opened issue #11841:
(carried over from this review discussion on #11769)
Currently, guest-debug instrumentation stores all local/stack values in a stackslot for observability by the debugger. This works well for primitives like integers/floats/vectors, and is fine for GC refs when the GC is not moving (i.e. tracing only observes the roots read-only) because the values also exist elsewhere in the program; but will be a problem once the GC becomes a moving GC.
cfallin added the bug label to Issue #11841.
cfallin removed the bug label from Issue #11841.
cfallin added the wasmtime:debugging label to Issue #11841.
cfallin added the wasmtime:ref-types label to Issue #11841.
github-actions[bot] commented on issue #11841:
Subscribe to Label Action
cc @fitzgen
<details>
This issue or pull request has been labeled: "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>
cfallin commented on issue #11841:
Now that I write this out, I think actually we need to root GC refs properly in the instrumentation slot; DCE could otherwise remove the parts of the original program that would keep the ref rooted.
fitzgen commented on issue #11841:
Semi-related to this issue: we could extend
ir::UserStackMapEntryto have an opaque, user-definedu32if necessary. Right now, the only way to differentiate different entries is via their type, but if we need to have different kinds of stack map entries that happen to have the sameir::Type, we could use this hypotheticalu32.But actually I think maybe all that is necessary here is to call the same underlying DFG APIs that the safepoints-insertion pass in the frontend does, so that the locals and operand stack slots that exist for the debug instrumentation have associated stack map entries recorded.
cfallin commented on issue #11841:
Ah, so I've implemented actual rooting here as part of the draft PR that follows instrumentation; it ended up being simpler to use the frame tables to walk the slots than to try to conmingle the two concepts somehow in the metadata or implementation. That commit has a
Fixes #11841that should close this once the followup happens :-)
fitzgen commented on issue #11841:
That seems like a fair amount of machinery that I think could be replaced by a call to https://docs.rs/cranelift-codegen/0.124.1/cranelift_codegen/ir/dfg/struct.DataFlowGraph.html#method.append_user_stack_map_entry at the appropriate places and then we get to reuse the existing stack maps infrastructure? Introducing new FP-indexing and pointer arithmetic and all that seems a bit extra if it isn't actually necessary in this case.
it ended up being simpler to use the frame tables to walk the slots than to try to conmingle the two concepts somehow in the metadata or implementation.
I feel like I must be misunderstanding something because I feel that the approach in that commit is the one that is mixing up two concepts: the GC's stack walking now needs to query and interpret two sources of truth (stack map metadata and debug info metadata) to find live GC references on the stack. On the flipside, I would expect that by adding stack map entries for the stack slot offsets that contain live GC refs, we keep one source of truth for stack tracing, and we do not conflate debug info and stack maps. The debugger uses debug info, the GC uses stack maps.
cfallin commented on issue #11841:
Ah, it appears that I had misremembered how stackmaps worked -- I had been imagining there was a separate stackslot and I'd have to add some new kind of entry to refer to my stackslot; but indeed not the case, I can refer to any stackslot+offset. I'll update it -- thanks!
cfallin closed issue #11841:
(carried over from this review discussion on #11769)
Currently, guest-debug instrumentation stores all local/stack values in a stackslot for observability by the debugger. This works well for primitives like integers/floats/vectors, and is fine for GC refs when the GC is not moving (i.e. tracing only observes the roots read-only) because the values also exist elsewhere in the program; but will be a problem once the GC becomes a moving GC.
cfallin commented on issue #11841:
This was closed in #11769.
Last updated: Jan 09 2026 at 13:15 UTC