alexcrichton opened PR #10902 from alexcrichton:globals-no-more-stored to bytecodealliance:main:
This commit refactors the
wasmtime::Globalto avoid the usage ofStored<T>internally. This makes conversion from internal global state to external global state a noop along the lines of previous commits. The end goal is to removeStoredentirely and enable more pervasively using external types internally within Wasmtime as well.Globals were different than the prior iterations of memories, tags, and tables. Globals have three different ways of defining them: wasm instances, the host embedder, and component flags. Representing these in all the various locations required a bit of finesse in how everything is represented and stored at rest and such. In the end there's a small amount of "type punning" in a few instance/vmctx fields related to globals now since everything is squeezed into one slot. This is required because the
VMGlobalImportstructure must have a size known to wasm-compiled code andwasmtime::Globalmust have a known layout for C code.In the end while this is more code to manage globals my hope is that the end result will be a net negative in terms of complexity by ensuring that the embedder API is additionally suitable for use internally within Wasmtime as well.
<!--
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 ensure all communication follows the code of conduct:
https://github.com/bytecodealliance/wasmtime/blob/main/CODE_OF_CONDUCT.md
-->
alexcrichton requested dicej for a review on PR #10902.
alexcrichton requested wasmtime-core-reviewers for a review on PR #10902.
alexcrichton commented on PR #10902:
Note that this is split out of https://github.com/bytecodealliance/wasmtime/pull/10870
dicej submitted PR review.
alexcrichton updated PR #10902.
alexcrichton has enabled auto merge for PR #10902.
fitzgen submitted PR review.
fitzgen created PR review comment:
We can avoid
asfor pointer-to-usize conversions now:self.definition(store).as_ptr().addr()
alexcrichton submitted PR review.
alexcrichton created PR review comment:
Oh nice, I'll do that in a follow-up
alexcrichton merged PR #10902.
Last updated: Dec 06 2025 at 06:05 UTC