Skip to content

Conversation

@Twey
Copy link
Contributor

@Twey Twey commented Jul 29, 2025

This PR is currently a draft, as the work needs to be ported to the other (non-sys) backends and also needs documentation in some places (not to mention some cleanups :)), but contains all public API changes and works for sys so I'm submitting it early for directional feedback.

Description

Apropos of #4634, parameterize the Store on a type of type-erased Objects. This enables building stores where the internal Object is Box<dyn Any> (instead of Box<dyn Any + Send>) to permit the storage of non-Send objects in the store.

Type defaults have been used to maintain API compatibility for the most part. However, this is still technically a breaking change, since it changes some public but less-used APIs in incompatible ways (e.g. adding type Object to AsStoreRef).

This PR focuses on function environments, as that's what we need to be non-Send, but could also be generalized to other parts of the API such as extern refs or trap handlers.

A trait Upcast<T> is introduced to wasmer-types for types that can type-erase T, and implemented for Box<dyn Any> and Box<dyn Any + Send>.

@syrusakbary
Copy link
Member

Thanks for creating the PR, we believe is a step in the right direction. We need a bit more time to review and test in other places (like browser)

@Twey
Copy link
Contributor Author

Twey commented Jul 31, 2025

Appreciate it! Currently only the sys backend is done (hence the draft) but if you approve of the direction I'll get porting the other backends.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants