Stream: git-wasmtime

Topic: wasmtime / PR #10934 Start reducing unsafety of `Componen...


view this post on Zulip Wasmtime GitHub notifications bot (Jun 05 2025 at 20:17):

alexcrichton opened PR #10934 from alexcrichton:upstream-index-changes to bytecodealliance:main:

Work recently in the wasip3-prototyping repository has focused on reducing the amount of unsafe code and improving internal abstractions to facilitate this. One major thrust that's manifested in is the removal of the usage of *mut ComponentInstance where possible and instead using an index to safely borrow from the store to get the entire instance. This commit does not fully realize this vision just yet but lays some groundwork leading up to this.

This commit specifically removes the *mut ComponentInstance pointers in lift/lower contexts in favor of directly storing a wasmtime::component::Instance. When the raw ComponentInstance is needed it's acquired from the StoreOpaque in a safe fashion that borrows the entire store for the duration of the returned borrow. This in turn required pushing instances into the store earlier during instantiation because during instantiation an instance could call out to host APIs which do lifts/lowers.

There's still more work to be done to plumb this fully into libcalls and host function invocations but I wanted to upstream the wasip3 work piecemeal a chunk at a time.

<!--
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 05 2025 at 20:17):

alexcrichton requested fitzgen for a review on PR #10934.

view this post on Zulip Wasmtime GitHub notifications bot (Jun 05 2025 at 20:17):

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

view this post on Zulip Wasmtime GitHub notifications bot (Jun 05 2025 at 20:19):

alexcrichton submitted PR review.

view this post on Zulip Wasmtime GitHub notifications bot (Jun 05 2025 at 20:19):

alexcrichton created PR review comment:

I'll note that this comment is still equally applicable today, but I don't think it's worth it trying to keep this distinction. It's just too damn useful to be able to get a safe &mut ComponentInstance and too subtle to avoid trying to do so. I opened https://github.com/bytecodealliance/wasmtime/issues/10933 to track a better solution here.

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

fitzgen submitted PR review:

Nice

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

fitzgen merged PR #10934.


Last updated: Dec 06 2025 at 06:05 UTC