alexcrichton edited PR #10870.
alexcrichton edited PR #10870:
This PR is a series of commits which is intended to lead up to the conclusion of removing usage of
Stored<T>from wasmtime exports. This is intended to be an internal refactoring of the implementation guts of Wasmtime that doesn't have an API-level impact on users of Wasmtime. The motivations for this change are:
- Fix issues such as https://github.com/bytecodealliance/wasmtime/issues/10869 and https://github.com/bytecodealliance/wasmtime/issues/10868. Effectively it's always been a cost that converting from an internal representation to the external representation pushes onto some internal vectors. Making this cost go away will fix the above issues.
- Enable using public exports in the internal implementation of wasmtime. Historically the internals of Wasmtime are implemented very differently than what the users of Wasmtime get to use. That creates this weird dichotomy where externally everyone gets to learn one API while internally it's completely different. Internally Wasmtime is already a bit of a mish mash of some bits using raw pointers and others using indices. The goal of this refactoring is to enable pushing more towards the indices style of internal implementation which is safer, easier to reason about, and matches the public API.
While the first bullet here is pretty concrete the second is pretty nebulous. The original motivation was myself working in the wasip3-prototyping branch and brainstorming ways to reduce the amount of unsafety. That led me to wanting to stop using
*mut ComponentInstancefor example and instead usewasmtime::component::Instancebut it was pretty awkward to do so. While none of that has to do with the core wasm bits being changed here I wanted to game out what such changes might look like. Additionally I also wanted to ensure that the chasm between the style of implementation of core wasm and components does not diverge further than it already has.This PR is a draft PR since it's pretty large and I'll be wanting to split it up over time. I'm going to peel off commits from this PR into separate PRs and land those separately, but I wanted to have this open as a sort of "north star" in case folks are interested to see where this is going.
Sequence-wise this is organized as going through each of the exported items from core wasm modules to remove their usage of
Stored<T>one at a time. This will eventually culminate in removingStored<T>forwasmtime::Instancewhich will fully migrate core wasm bits away fromStored<T>. Status-wise here's the progress
- [x]
wasmtime::Memory- [x]
wasmtime::Table- [x]
wasmtime::Tag- [x]
wasmtime::Global- [ ]
wasmtime::Func- [ ]
wasmtime::Instance- [ ]
wasmtime::component::Instance- [ ]
wasmtime::component::Func
alexcrichton commented on PR #10870:
Sorry I hit submit too soon and I've now actually filled out the description/title for anyone interested.
alexcrichton updated PR #10870.
alexcrichton commented on PR #10870:
I'll also clarify, I plan on using this to push lots of commit to, so if anyone would prefer please feel free to unsubscribe from this PR as it may be a bit noisy.
alexcrichton updated PR #10870.
alexcrichton updated PR #10870.
alexcrichton updated PR #10870.
alexcrichton updated PR #10870.
alexcrichton edited PR #10870:
This PR is a series of commits which is intended to lead up to the conclusion of removing usage of
Stored<T>from wasmtime exports. This is intended to be an internal refactoring of the implementation guts of Wasmtime that doesn't have an API-level impact on users of Wasmtime. The motivations for this change are:
- Fix issues such as https://github.com/bytecodealliance/wasmtime/issues/10869 and https://github.com/bytecodealliance/wasmtime/issues/10868. Effectively it's always been a cost that converting from an internal representation to the external representation pushes onto some internal vectors. Making this cost go away will fix the above issues.
- Enable using public exports in the internal implementation of wasmtime. Historically the internals of Wasmtime are implemented very differently than what the users of Wasmtime get to use. That creates this weird dichotomy where externally everyone gets to learn one API while internally it's completely different. Internally Wasmtime is already a bit of a mish mash of some bits using raw pointers and others using indices. The goal of this refactoring is to enable pushing more towards the indices style of internal implementation which is safer, easier to reason about, and matches the public API.
While the first bullet here is pretty concrete the second is pretty nebulous. The original motivation was myself working in the wasip3-prototyping branch and brainstorming ways to reduce the amount of unsafety. That led me to wanting to stop using
*mut ComponentInstancefor example and instead usewasmtime::component::Instancebut it was pretty awkward to do so. While none of that has to do with the core wasm bits being changed here I wanted to game out what such changes might look like. Additionally I also wanted to ensure that the chasm between the style of implementation of core wasm and components does not diverge further than it already has.This PR is a draft PR since it's pretty large and I'll be wanting to split it up over time. I'm going to peel off commits from this PR into separate PRs and land those separately, but I wanted to have this open as a sort of "north star" in case folks are interested to see where this is going.
Sequence-wise this is organized as going through each of the exported items from core wasm modules to remove their usage of
Stored<T>one at a time. This will eventually culminate in removingStored<T>forwasmtime::Instancewhich will fully migrate core wasm bits away fromStored<T>. Status-wise here's the progress
- [x]
wasmtime::Memory- [x]
wasmtime::Table- [x]
wasmtime::Tag- [x]
wasmtime::Global- [x]
wasmtime::Func- [ ]
wasmtime::Instance- [ ]
wasmtime::component::Instance- [ ]
wasmtime::component::Func
alexcrichton updated PR #10870.
alexcrichton edited PR #10870:
This PR is a series of commits which is intended to lead up to the conclusion of removing usage of
Stored<T>from wasmtime exports. This is intended to be an internal refactoring of the implementation guts of Wasmtime that doesn't have an API-level impact on users of Wasmtime. The motivations for this change are:
- Fix issues such as https://github.com/bytecodealliance/wasmtime/issues/10869 and https://github.com/bytecodealliance/wasmtime/issues/10868. Effectively it's always been a cost that converting from an internal representation to the external representation pushes onto some internal vectors. Making this cost go away will fix the above issues.
- Enable using public exports in the internal implementation of wasmtime. Historically the internals of Wasmtime are implemented very differently than what the users of Wasmtime get to use. That creates this weird dichotomy where externally everyone gets to learn one API while internally it's completely different. Internally Wasmtime is already a bit of a mish mash of some bits using raw pointers and others using indices. The goal of this refactoring is to enable pushing more towards the indices style of internal implementation which is safer, easier to reason about, and matches the public API.
While the first bullet here is pretty concrete the second is pretty nebulous. The original motivation was myself working in the wasip3-prototyping branch and brainstorming ways to reduce the amount of unsafety. That led me to wanting to stop using
*mut ComponentInstancefor example and instead usewasmtime::component::Instancebut it was pretty awkward to do so. While none of that has to do with the core wasm bits being changed here I wanted to game out what such changes might look like. Additionally I also wanted to ensure that the chasm between the style of implementation of core wasm and components does not diverge further than it already has.This PR is a draft PR since it's pretty large and I'll be wanting to split it up over time. I'm going to peel off commits from this PR into separate PRs and land those separately, but I wanted to have this open as a sort of "north star" in case folks are interested to see where this is going.
Sequence-wise this is organized as going through each of the exported items from core wasm modules to remove their usage of
Stored<T>one at a time. This will eventually culminate in removingStored<T>forwasmtime::Instancewhich will fully migrate core wasm bits away fromStored<T>. Status-wise here's the progress
- [x]
wasmtime::Memory- [x]
wasmtime::Table- [x]
wasmtime::Tag- [x]
wasmtime::Global- [x]
wasmtime::Func- [x]
wasmtime::Instance- [ ]
wasmtime::component::Instance- [ ]
wasmtime::component::Func
alexcrichton updated PR #10870.
alexcrichton updated PR #10870.
alexcrichton updated PR #10870.
alexcrichton updated PR #10870.
alexcrichton updated PR #10870.
alexcrichton updated PR #10870.
alexcrichton updated PR #10870.
alexcrichton updated PR #10870.
alexcrichton closed without merge PR #10870.
alexcrichton commented on PR #10870:
Final bits here split into https://github.com/bytecodealliance/wasmtime/pull/10908 and https://github.com/bytecodealliance/wasmtime/pull/10909, so closing now.
Last updated: Dec 06 2025 at 06:05 UTC