cfallin requested fitzgen for a review on PR #15228.
cfallin opened PR #15228 from cfallin:gc-maybe-rooted to bytecodealliance:main:
This introduces
MaybeRooted<T>, an enum of the ways that aValorRefmay hold a reference to a GC object, and makes the GC-reference variants ofVal(ExternRef,AnyRef,ExnRef) and ofRef(Extern,Any,Exn) holdOption<MaybeRooted<T>>instead ofOption<Rooted<T>>.For now
MaybeRooted<T>has only one variant,MaybeRooted::Rooted, which wraps aRooted<T>as before, so this is a pure refactor with no change in behavior. The point is to giveValroom for other kinds of GC references, as we will soon do with a followup that adds unrooted references.<!--
Please make sure you include the following information:
If this work has been discussed elsewhere, please include a link to that
conversation. If it was discussed in an issue, just mention "issue #...".Explain why this change is needed. If the details are in an issue already,
this can be brief.Our development process is documented in the Wasmtime book:
https://docs.wasmtime.dev/contributing-development-process.htmlPlease review the Bytecode Alliance's AI tool usage policy at
https://github.com/bytecodealliance/governance/blob/main/AI_TOOL_POLICY.mdPlease ensure all communication follows the code of conduct:
https://github.com/bytecodealliance/wasmtime/blob/main/CODE_OF_CONDUCT.md
-->
cfallin requested wasmtime-fuzz-reviewers for a review on PR #15228.
cfallin requested wasmtime-core-reviewers for a review on PR #15228.
cfallin updated PR #15228.
github-actions[bot] added the label fuzzing on PR #15228.
github-actions[bot] added the label wasmtime:ref-types on PR #15228.
github-actions[bot] added the label wasmtime:api on PR #15228.
github-actions[bot] added the label wasmtime:c-api on PR #15228.
github-actions[bot] commented on PR #15228:
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:
- fitzgen: fuzzing, wasmtime:ref-types
To subscribe or unsubscribe from this label, edit the <code>.github/subscribe-to-label.json</code> configuration file.
Learn more.
</details>
:thumbs_up: fitzgen submitted PR review:
LGTM, modulo feedback below.
Apologies for the delayed review, somehow got lost in my github notifications.
:speech_balloon: fitzgen created PR review comment:
Same thing here
:speech_balloon: fitzgen created PR review comment:
Can we name this
ty_instead, so that we don't in the future accidentally introduce dead code that doesn't get warned about being dead code due to the leading underscore? We've been slowly switching existing_-prefixes to suffixes due to this issue (which we didn't think of when we originally introduced all of these).
:speech_balloon: fitzgen created PR review comment:
I think we probably also want to have these methods:
pub fn to_rooted(&self, store: impl AsContextMut) -> Rooted<T>pub fn ensure_rooted(&mut self, store: impl AsContextMut)
:speech_balloon: fitzgen created PR review comment:
Should these become
.to_rooted(store)or something for future compat so we don't accidentally get panics when introducing unrooted references? (I haven't looked at the next PR yet)
:speech_balloon: fitzgen created PR review comment:
And then on
ValandRef, we probably also want
pub fn to_rooted(&self, store: impl AsContextMut) -> Selfpub fn ensure_rooted(&mut self, store: impl AsContextMut)as well
:speech_balloon: fitzgen created PR review comment:
(And similar for ~all the other
unwrap_rooted()calls in this PR)
:memo: cfallin submitted PR review.
:speech_balloon: cfallin created PR review comment:
Good thought generally! But: these actually become
.to_unrooted(store)in the next PR, which I think is probably the better option anyway (these are short-lived temporary references used to query the heap so no actual need for rooting); so to avoid rebase churn when this will change again anyway I'll leave these as-is.
:memo: cfallin submitted PR review.
:speech_balloon: cfallin created PR review comment:
Cool, these come in the followup when we have two variants, but I'll hoist them to this PR and then rebase.
cfallin updated PR #15228.
:memo: cfallin submitted PR review.
:speech_balloon: cfallin created PR review comment:
Done!
:memo: cfallin submitted PR review.
:speech_balloon: cfallin created PR review comment:
Done!
:memo: cfallin submitted PR review.
:speech_balloon: cfallin created PR review comment:
Done!
cfallin has enabled auto merge for PR #15228.
cfallin added PR #15228 GC: hold MaybeRooted<T> GC references in Val and Ref. to the merge queue
:check: cfallin merged PR #15228.
cfallin removed PR #15228 GC: hold MaybeRooted<T> GC references in Val and Ref. from the merge queue
Last updated: Nov 19 2026 at 20:05 UTC