Stream: git-wasmtime

Topic: wasmtime / PR #15191 GC: implement `Frozen` references.


view this post on Zulip Wasmtime GitHub notifications bot (Nov 06 2026 at 21:54):

cfallin requested fitzgen for a review on PR #15191.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 06 2026 at 21:54):

cfallin requested wasmtime-fuzz-reviewers for a review on PR #15191.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 06 2026 at 21:54):

cfallin opened PR #15191 from cfallin:gc-frozen-refs to bytecodealliance:main:

In order to implement record/replay, we need a little more discipline around read-only vs. read-write Stores. It turns out that rooting mutates a store. This is unfortunate when we want to permit debuggers to inspect the state of a store, including its GC heap, on a read-only trace replay.

Separately, the need for a mutable store borrow to access any GC object, even on actions that are nominally/semantically read-only, makes APIs more awkward and looser about mutation than they could otherwise be. One can see artifacts of this awkwardness in e.g. the existence of a separate getter for globals that only reads non-GC values, with an immutable store.

Separately separately, rooting is expensive if all one wants to do is introspect the Store's GC heap while execution is completely frozen. Ideally one would use raw heap offsets ("pointers") and just read out the objects without setting up and tearing down rooting metadata.

All of these problems are solved in this PR with the addition of a new Frozen GC ref kind. The idea is that we:

These frozen refs are sufficient to read the whole GC heap when the store is frozen (e.g., during a debug event or at any step during a trace replay).

What's more, this actually heads to a nice generalization: we can make the rooting step explicitly opt-in everywhere by changing all GC getter APIs to return frozen refs by default. One can then take that frozen ref and turn it into a Rooted<T> or OwnedRooted<T> if one wants to actually root it during further execution, and only needs a mutable store borrow at that point to create the root. This makes the cheap option (copy a u32 and u64) the default and makes the rooting cost pay-as-you-go.

<!--
Please make sure you include the following information:

Our development process is documented in the Wasmtime book:
https://docs.wasmtime.dev/contributing-development-process.html

Please review the Bytecode Alliance's AI tool usage policy at
https://github.com/bytecodealliance/governance/blob/main/AI_TOOL_POLICY.md

Please ensure all communication follows the code of conduct:
https://github.com/bytecodealliance/wasmtime/blob/main/CODE_OF_CONDUCT.md
-->

view this post on Zulip Wasmtime GitHub notifications bot (Nov 06 2026 at 21:54):

cfallin requested wasmtime-core-reviewers for a review on PR #15191.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 07 2026 at 00:48):

github-actions[bot] added the label fuzzing on PR #15191.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 07 2026 at 00:48):

github-actions[bot] added the label wasmtime:c-api on PR #15191.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 07 2026 at 00:48):

github-actions[bot] added the label wasmtime:api on PR #15191.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 07 2026 at 00:48):

github-actions[bot] added the label wasmtime:ref-types on PR #15191.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 07 2026 at 01:45):

github-actions[bot] commented on PR #15191:

Subscribe to Label Action

cc @fitzgen

<details>
This issue or pull request has been labeled: "fuzzing", "wasmtime:api", "wasmtime:c-api", "wasmtime:ref-types"

Thus the following users have been cc'd because of the following labels:

To subscribe or unsubscribe from this label, edit the <code>.github/subscribe-to-label.json</code> configuration file.

Learn more.
</details>

view this post on Zulip Wasmtime GitHub notifications bot (Nov 07 2026 at 16:22):

cfallin updated PR #15191.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 09 2026 at 15:38):

alexcrichton commented on PR #15191:

Question at a high-level on this: I'm wary to add a new variant of Val which is pretty much the same as the preexisting ones just slightly different because it means taking/receiving is that much more complicated (have to handle both everywhere). Would it be possible to remove Frozen and make the frozen state a dynamic property of the existing GC refs/roots exposed in the API? For example Rooted<AnyRef> would dynamically be frozen-or-not. It's a slightly-more-footgunny API but arguably that's already true of our APIs with manual rooting and such.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 09 2026 at 21:05):

:memo: fitzgen submitted PR review:

I had been expecting that we would replace the Rooted<T>s inside Val and Ref with Frozen<T>s, but that isn't what you've actually done here. Is there a particular reason what I had been expecting is not viable or just that we didn't end up on the same page after that discussion?

My concern with adding Val::Frozen and Ref::Frozen variants is that the variants will no longer reflect Wasm type heirarchies, nor only types of rooted/unrooted GC refs, but a mix of the two. It feels like a pretty bad case of the implementation leaking into language semantics-level APIs.

I also wouldn't really expect enum FrozenRef to be thing, just Frozen<AnyRef>/Frozen<ExternRef>/Frozen<ExnRef>/etc... and enum Ref { Any(Frozen<AnyRef>), Exn(Frozen<ExnRef>), ... }.

And then I would expect that we have methods to convert between Rooted<T> and Frozen<T>, and OwnedRooted<T> and Frozen<T>, the same way we have methods to convert between Rooted<T> and OwnedRooted<T>.

(Also, as I type this all out, Frozen<T> seems like maybe it should actually be named Unrooted<T>? Especially since there are mumblings and issues about adding "frozen" references to Wasm proper as a post-Wasm GC follow up proposal to allow initialize-then-freeze immutability.)

But yeah, it feels like we should probably get on the same page with regards to the above before I actually dive into reviewing this PR (or not reviewing it and waiting for a different version, as the case may be).

view this post on Zulip Wasmtime GitHub notifications bot (Nov 09 2026 at 21:13):

cfallin commented on PR #15191:

These are great points: there's no particular reason not transition Val to fully frozen refs only, other than that that seemed more invasive and removed the possibility of holding a Val in host-space that kept things rooted appropriately. I don't recall talking about Val specifically in our past discussion, only the getters on the relevant APIs, which have indeed been changed to return frozen refs.

To be explicit about what we would give up: we could no longer have a dynamically-typed value binding in host-space that could keep, e.g., bindings: HashMap<..., Val> and be assured that one would get proper rooting. If someone wanted that when Val does not even have an arm for OwnedRooted, then they'd have to create a separate OwnedVal and fn root(Val) -> OwnedVal.

Maybe that's fine / maybe we could even provide that eventually if someone wants that API surface. Thinking about this from a global API-simplicity point of view, it's actually much nicer to just universally support frozen GC refs only in all type-tagged representations, in addition to the accessors. The only place that rooting happens then is when the user explicitly writes Rooted/OwnedRooted with a particular T, but they likely already know in most cases that they have an anyref/exnref/externref/... and can name the specific type they want.

I'll make that change (and @fitzgen almost all of the impl is independent of this Val design-axis so I wouldn't hold off on reading the rest of the PR on account of this at least).

view this post on Zulip Wasmtime GitHub notifications bot (Nov 09 2026 at 21:17):

alexcrichton commented on PR #15191:

I like the idea of moving all of Val to frozen refs, yeah, and I like @fitzgen's bikeshed color with Unrooted<T> myself since I feel that accurately reflects what's going on here. It'd be a good place to explicitly document that "any mutation at all anywhere invalidates all Unrooted<T> in a detectable manner"

view this post on Zulip Wasmtime GitHub notifications bot (Nov 09 2026 at 21:21):

cfallin commented on PR #15191:

And then I would expect that we have methods to convert between Rooted<T> and Frozen<T>, and OwnedRooted<T> and Frozen<T>, the same way we have methods to convert between Rooted<T> and OwnedRooted<T>.

FWIW, these already exist: see to_frozen on existing reftypes, and to_owned_rooted / to_rooted on the new frozen refs.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 09 2026 at 21:22):

cfallin commented on PR #15191:

And then I would expect that we have methods to convert between Rooted<T> and Frozen<T>, and OwnedRooted<T> and Frozen<T>, the same way we have methods to convert between Rooted<T> and OwnedRooted<T>.

FWIW, these already exist: see to_frozen on existing reftypes, and to_owned_rooted / to_rooted on the new frozen refs.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 09 2026 at 21:23):

cfallin deleted a comment on PR #15191:

And then I would expect that we have methods to convert between Rooted<T> and Frozen<T>, and OwnedRooted<T> and Frozen<T>, the same way we have methods to convert between Rooted<T> and OwnedRooted<T>.

FWIW, these already exist: see to_frozen on existing reftypes, and to_owned_rooted / to_rooted on the new frozen refs.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 09 2026 at 21:30):

fitzgen commented on PR #15191:

To be explicit about what we would give up: we could no longer have a dynamically-typed value binding in host-space that could keep, e.g., bindings: HashMap<..., Val> and be assured that one would get proper rooting. If someone wanted that when Val does not even have an arm for OwnedRooted, then they'd have to create a separate OwnedVal and fn root(Val) -> OwnedVal.

Spitballing a bit, we could maybe make Val parameterized on the type of rooting, plus a default so that you don't need to write Val<UnrootedRefs> everywhere. Something like this: https://play.rust-lang.org/?version=stable&mode=debug&edition=2024&gist=4b7983739102f0c5065eb251f178d86b

view this post on Zulip Wasmtime GitHub notifications bot (Nov 09 2026 at 21:34):

alexcrichton commented on PR #15191:

Personally I'd prefer to go too overboard on Val and its design, I'd ideally like to pick one and stick with it. In theory Val is simple enough that other embedders can copy it or customize it to their needs. Like component::Val it's a pretty unergonomic and inefficient representation which is why I wouldn't want to add too many bells and whistles to it.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 09 2026 at 21:40):

cfallin commented on PR #15191:

OK, in doing this refactor (removing rooting from Val completely) I'm running into some nontrivial complexity in e.g. StructRef::new: it allocates, so we need rooting on all GC vals; so the &[Val] param is no longer sufficient. We need to internally clone that to something that resembles the OwnedVal I sketched above.

The existing PR has an analogous footgun as well I guess: a Val is semantically not valid to hold over any GC-able op anymore.

So I think we really do need OwnedVal (or some other type trickery, though I think I agree with Alex that marker types are probably somewhat more noise than we want here aesthetically) for API correctness on any GC-allocating constructor; we can then be sure that we aren't passing in a frozen ref.

(FWIW, the prior art in SpiderMonkey here is that there is Rooted<T> and T can be anything including a JS::Value; they use C++ template traits to make the rooting work for everything including NaN-boxed values, while we'd have a bit of a harder time plumbing rootedness into a few arms of the val I guess)

view this post on Zulip Wasmtime GitHub notifications bot (Nov 09 2026 at 21:40):

cfallin edited a comment on PR #15191:

OK, in doing this refactor (removing rooting from Val completely) I'm running into some nontrivial complexity in e.g. StructRef::new: it allocates, so we need rooting on all GC vals; so the &[Val] param is no longer sufficient. We need to internally clone that to something that resembles the OwnedVal I sketched above.

The existing PR has an analogous footgun as well I guess: a Val is semantically not valid to hold over any GC-able op anymore; so StructRef::new can only accept the owned variants.

So I think we really do need OwnedVal (or some other type trickery, though I think I agree with Alex that marker types are probably somewhat more noise than we want here aesthetically) for API correctness on any GC-allocating constructor; we can then be sure that we aren't passing in a frozen ref.

(FWIW, the prior art in SpiderMonkey here is that there is Rooted<T> and T can be anything including a JS::Value; they use C++ template traits to make the rooting work for everything including NaN-boxed values, while we'd have a bit of a harder time plumbing rootedness into a few arms of the val I guess)

view this post on Zulip Wasmtime GitHub notifications bot (Nov 09 2026 at 21:47):

fitzgen commented on PR #15191:

(FWIW, the prior art in SpiderMonkey here is that there is Rooted<T> and T can be anything including a JS::Value; they use C++ template traits to make the rooting work for everything including NaN-boxed values, while we'd have a bit of a harder time plumbing rootedness into a few arms of the val I guess)

We can't exactly copy that due to the differences between Rust generics and C++ templates however.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 09 2026 at 21:52):

cfallin commented on PR #15191:

Indeed, "bit of a harder time plumbing..." was intended to capture that. I guess I was naming it as a way of thinking through API ergonomics: in principle we want something that is compositional here (rooting strategy x val-or-ref-type).

We could implement a trait (impl'd by Val and *Ref) that project out an Option<&mut VmGcRef>, which is the moral equivalent of what HeapOperations et al in the SpiderMonkey case are doing...

view this post on Zulip Wasmtime GitHub notifications bot (Nov 09 2026 at 21:55):

fitzgen commented on PR #15191:

Personally I'd prefer to go too overboard on Val and its design, I'd ideally like to pick one and stick with it.

I think it is going to be hard to choose one:

Those two desires are in direct conflict with each other, so I don't see how we can just choose one and stick with it. I think we _have_ to either add a bunch of generics/trait machinery or manually write UnrootedVal/RootedVal/OwnedVal types.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 09 2026 at 22:00):

cfallin commented on PR #15191:

To sketch one possible generics path a bit further:

In other words, put the actual GC ref, if any, outside the raw Val, and use it only as the tag.

Hmm, now that I write that out, though, maybe it really is simpler to just do UnrootedVal + RootedVal. (Additional bikeshed color I'll toss into the paint can as we're mixing: back when we introduced OwnedRooted we talked about renaming OwnedRooted to Rooted and Rooted to ScopedRooted or similar; maybe this is when we do that...)

view this post on Zulip Wasmtime GitHub notifications bot (Nov 09 2026 at 22:00):

cfallin edited a comment on PR #15191:

To sketch one possible generics path a bit further:

In other words, put the actual GC ref, if any, outside the raw Val, and use it only as the tag.

Hmm, now that I write that out, though, maybe it really is simpler to just do UnrootedVal + RootedVal. (Additional bikeshed color I'll toss into the paint can as we're mixing: back when we introduced OwnedRooted we talked about renaming OwnedRooted to Rooted and Rooted to ScopedRooted or similar; maybe this is when we do that...)

view this post on Zulip Wasmtime GitHub notifications bot (Nov 09 2026 at 22:00):

fitzgen commented on PR #15191:

We _could_ implement a trait (impl'd by Val and *Ref) that project out an Option<&mut VmGcRef>, which is the moral equivalent of what HeapOperations et al in the SpiderMonkey case are doing...

We ~sort of have this with the RootedGcRef[Impl] traits but we don't have an implementation of for Val (which would require restructuring a bit). But this would also mean that everyone currently using Val would need to start using Rooted<Val> or whatever, which is not great from an upgrade POV. But I guess it doesn't hide the fact that GC rooting is changing from them?

view this post on Zulip Wasmtime GitHub notifications bot (Nov 09 2026 at 22:02):

cfallin commented on PR #15191:

I agree with upgrade paths being somewhat of a consideration here, but IMHO we should try to get the right API first, and we're already talking about returning frozen refs by default so anyone doing heavy GC-ref traffic across the host API (are there such folks in the wild?) will need big mechanical changes regardless...

view this post on Zulip Wasmtime GitHub notifications bot (Nov 09 2026 at 22:05):

fitzgen commented on PR #15191:

The other thing about only parameterizing how Val is used, not parameterizing Val on a RootingKind or whatever like Val<RootingKind>, is that matching is going to suck because it won't forward the rooting as you traverse the value. You have to re-root the innards manually.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 09 2026 at 22:08):

fitzgen commented on PR #15191:

So, IMO, the best thing would be for actual GC refs to never be interacted with directly, only via a rooting wrapper. That is, you never have a plain AnyRef, only Rooted<AnyRef> or Unrooted<AnyRef> etc.

And then Val would be parameterized by the rooting kind, so that matching on it gives you the rooted ref, not the raw GC ref: Val<RootedRefs>/Val<UnrootedRefs>/etc. instead of Rooted<Val>/Unrooted<Val>/etc.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 09 2026 at 22:16):

cfallin commented on PR #15191:

Yep, I think I've worked my way to your viewpoint here; Val<RootingKind> rather than RootingKind<Val>. RootingKind being a sealed trait that we implement on a few marker traits (unrooted, owned-rooted (rooted?), rooted (scoped-rooted?)).

To summarize how we got here: (i) we need to semantically pin down whether rooting happens or not, when vals occur in the API; (ii) there are contexts where they need to be unrooted, and contexts where they need to be rooted; (iii) we prefer static safety where possible, so rather than have a sum-type and panic on wrong kind of rooting, we want the distinction in the types; so (iv) the main design axis left is how we spell the two (three?) different kinds of val.

@alexcrichton are you OK with all this or do you still have reservations or other ideas?

view this post on Zulip Wasmtime GitHub notifications bot (Nov 09 2026 at 22:49):

fitzgen commented on PR #15191:

(FWIW, I am +1 on renaming the various kinds of rooting at the same time if we're going to do this relatively large change, but I do have some naming bikeshedding I'd like to do there. Holding off on that to focus on the core representation stuff for now tho.)

view this post on Zulip Wasmtime GitHub notifications bot (Nov 10 2026 at 00:43):

cfallin updated PR #15191.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 10 2026 at 00:43):

cfallin requested wasmtime-default-reviewers for a review on PR #15191.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 10 2026 at 00:43):

cfallin removed the review request for wasmtime-default-reviewers from PR #15191.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 10 2026 at 00:43):

cfallin requested alexcrichton for a review on PR #15191.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 10 2026 at 00:45):

cfallin commented on PR #15191:

OK, I've pushed another commit that does Val<R> for the three different ref kinds, with conversions between them. It is... not a small refactor... but if what we argue above is true, then I think it's necessary-ish.

The one major simplification I see right now if we are willing to give a little more generality up is to represent only owned-rooted and unrooted values (i.e., drop LIFO-rooted/"scoped rooted"); the latter are a perf optimization but are not strictly necessary for expressiveness, and dropping that would get rid of the AnyRootedRef subtrait I had to add to make StructRef::new and friends work with either kind of rooted ref (which also introduces an awkwardness where type inf can't fill that in for e.g. an empty slice or slice of only primitive field values). Happy to go that way if folks want.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 10 2026 at 16:05):

alexcrichton commented on PR #15191:

The main thing I lament here is that it's not possible to use Wasmtime without being forced to deal with a bunch of GC stuff. I subjectively feel that should be possible to do so but even if you're only working with i32s you're forced to still talk about rooting and unrooting and such in Vals and everywhere. I know I've long lamented the extremely viral nature of GC, so there may just be nothing to do about that.

This is indeed a massive change, and there's quite a lot of minor tweaks skimming over various files as well. If we do land on this design @cfallin would you be ok splitting this up into perhaps first refactoring what's there already, then moving APIs to StoreContext (no mut), and then adding another rooting kind with unrooted?

Some other assorted thoughts:

Overall this does seem to be the best way to thread the needle of all the requirements we have.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 10 2026 at 16:44):

cfallin commented on PR #15191:

Yeah, I hate it too from an ergonomics perspective. Unfortunately I just think there's no other way in an engine that (i) supports GC, (ii) semantically needs to hand out different kinds of roots at different times.

(Or, well, the other way is to make Val a sum-type as this PR originally had; do we want to reconsider that in light of the complexity that unfolds here?)

I continue to personally be wary of tracking a GC epoch

Yep, I think this is unfortunately just kind of fundamental. The thing that we need is tracking of a dynamic lifetime: a pointer that is valid until something invalidates it. That is required because GC roots mutate the store, and we need to access (but not modify) the GC heap when we don't have mutable access to it. So the only ways out are:

So basically, the way out is to either not implement record/replay, or not implement debugging on record/replay. In other words, I think if we agree we want those features, we are stuck.


The remaining safety path is to encapsulate as much as possible. Maybe we could build some generic mechanism (in the same spirit as Accessor for the async stuff) that holds a T and gives out either frozen refs or mutable refs and tracks the epoch alongside, in a way that can't be violated. Something like:

struct EpochTrackedState<T> {
  inner: T,
  stamp: StateId,  // like a store ID; globally allocated
  epoch: EpochCounter,
}

impl<T> EpochTrackedState<T> {
  // ...

  fn frozen_ref(&self) -> TrackedStateFrozenRef<T> {
    TrackedStateFrozenRef { stamp: self.stamp, epoch: self.epoch } // no borrow of `self`
  }
  fn get_mut(&mut self) -> &mut T {
    self.epoch.increment();
    &mut self.inner
  }

  fn get(&self, ref: TrackedStateFrozenRef<T>) -> Option<&T> {
    assert_eq!(self.stamp, ref.stamp);
    if self.epoch != stamp.epoch { None } else { Some(&self.inner) }
  }
}

then put the whole GC state inside of that. What do you think?

view this post on Zulip Wasmtime GitHub notifications bot (Nov 10 2026 at 16:56):

cfallin edited a comment on PR #15191:

Yeah, I hate it too from an ergonomics perspective. Unfortunately I just think there's no other way in an engine that (i) supports GC, (ii) semantically needs to hand out different kinds of roots at different times.

(Or, well, the other way is to make Val a sum-type as this PR originally had; do we want to reconsider that in light of the complexity that unfolds here?)

I continue to personally be wary of tracking a GC epoch

Yep, I think this is unfortunately just kind of fundamental. The thing that we need is tracking of a dynamic lifetime: a pointer that is valid until something invalidates it. That is required because GC roots mutate the store, and we need to access (but not modify) the GC heap when we don't have mutable access to it. So the only ways out are:

So basically, the way out is to either not implement record/replay, or not implement debugging on record/replay. In other words, I think if we agree we want those features, we are stuck.


The remaining safety path is to encapsulate as much as possible. Maybe we could build some generic mechanism (in the same spirit as Accessor for the async stuff) that holds a T and gives out either frozen refs or mutable refs and tracks the epoch alongside, in a way that can't be violated. Something like:

struct EpochTrackedState<T> {
  inner: T,
  stamp: StateId,  // like a store ID; globally allocated
  epoch: EpochCounter,
}

impl<T> EpochTrackedState<T> {
  // ...

  fn frozen_ref(&self) -> TrackedStateFrozenRef<T> {
    TrackedStateFrozenRef { stamp: self.stamp, epoch: self.epoch } // no borrow of `self`
  }
  fn get_mut(&mut self) -> &mut T {
    self.epoch.increment();
    &mut self.inner
  }

  fn get(&self, ref: TrackedStateFrozenRef<T>) -> Option<&T> {
    assert_eq!(self.stamp, ref.stamp);
    if self.epoch != ref.epoch { None } else { Some(&self.inner) }
  }
}

then put the whole GC state inside of that. What do you think?

view this post on Zulip Wasmtime GitHub notifications bot (Nov 11 2026 at 06:56):

cfallin updated PR #15191.

view this post on Zulip Wasmtime GitHub notifications bot (Nov 11 2026 at 06:57):

cfallin commented on PR #15191:

OK, this has been refactored according to our discussion today, and is now stacked on top of #15228 (second commit is this PR's contribution).

view this post on Zulip Wasmtime GitHub notifications bot (Nov 11 2026 at 06:58):

cfallin edited PR #15191:

In order to implement record/replay, we need a little more discipline around read-only vs. read-write Stores. It turns out that rooting mutates a store. This is unfortunate when we want to permit debuggers to inspect the state of a store, including its GC heap, on a read-only trace replay.

Separately, the need for a mutable store borrow to access any GC object, even on actions that are nominally/semantically read-only, makes APIs more awkward and looser about mutation than they could otherwise be. One can see artifacts of this awkwardness in e.g. the existence of a separate getter for globals that only reads non-GC values, with an immutable store.

Separately separately, rooting is expensive if all one wants to do is introspect the Store's GC heap while execution is completely frozen. Ideally one would use raw heap offsets ("pointers") and just read out the objects without setting up and tearing down rooting metadata.

All of these problems are solved in this PR with the addition of a new Unrooted GC ref kind. The idea is that we:

These unrooted refs are sufficient to read the whole GC heap when the store is frozen (e.g., during a debug event or at any step during a trace replay).

What's more, this actually heads to a nice generalization: we can make the rooting step explicitly opt-in everywhere by changing all GC getter APIs to return unrooted refs by default. One can then take that unrooted ref and turn it into a Rooted<T> or OwnedRooted<T> if one wants to actually root it during further execution, and only needs a mutable store borrow at that point to create the root. This makes the cheap option (copy a u32 and u64) the default and makes the rooting cost pay-as-you-go.

<!--
Please make sure you include the following information:

Our development process is documented in the Wasmtime book:
https://docs.wasmtime.dev/contributing-development-process.html

Please review the Bytecode Alliance's AI tool usage policy at
https://github.com/bytecodealliance/governance/blob/main/AI_TOOL_POLICY.md

Please ensure all communication follows the code of conduct:
https://github.com/bytecodealliance/wasmtime/blob/main/CODE_OF_CONDUCT.md
-->


Last updated: Nov 19 2026 at 20:05 UTC