Stream: git-wasmtime

Topic: wasmtime / PR #10902 Refactor globals to no longer use `S...


view this post on Zulip Wasmtime GitHub notifications bot (Jun 02 2025 at 21:00):

alexcrichton opened PR #10902 from alexcrichton:globals-no-more-stored to bytecodealliance:main:

This commit refactors the wasmtime::Global to avoid the usage of Stored<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 remove Stored entirely 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 VMGlobalImport structure must have a size known to wasm-compiled code and wasmtime::Global must 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:

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

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 (Jun 02 2025 at 21:00):

alexcrichton requested dicej for a review on PR #10902.

view this post on Zulip Wasmtime GitHub notifications bot (Jun 02 2025 at 21:00):

alexcrichton requested wasmtime-core-reviewers for a review on PR #10902.

view this post on Zulip Wasmtime GitHub notifications bot (Jun 02 2025 at 21:01):

alexcrichton commented on PR #10902:

Note that this is split out of https://github.com/bytecodealliance/wasmtime/pull/10870

view this post on Zulip Wasmtime GitHub notifications bot (Jun 02 2025 at 21:29):

dicej submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Jun 02 2025 at 23:06):

alexcrichton updated PR #10902.

view this post on Zulip Wasmtime GitHub notifications bot (Jun 02 2025 at 23:06):

alexcrichton has enabled auto merge for PR #10902.

view this post on Zulip Wasmtime GitHub notifications bot (Jun 02 2025 at 23:34):

fitzgen submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Jun 02 2025 at 23:34):

fitzgen created PR review comment:

We can avoid as for pointer-to-usize conversions now:

        self.definition(store).as_ptr().addr()

view this post on Zulip Wasmtime GitHub notifications bot (Jun 02 2025 at 23:44):

alexcrichton submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Jun 02 2025 at 23:44):

alexcrichton created PR review comment:

Oh nice, I'll do that in a follow-up

view this post on Zulip Wasmtime GitHub notifications bot (Jun 02 2025 at 23:48):

alexcrichton merged PR #10902.


Last updated: Dec 06 2025 at 06:05 UTC