You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Before introducing HostModules and eventually Linking it probably makes sense to introduce the concept of a Store. See e.g. Wasmtime, wazero and the Spec
A Store is an intermediate-level abstraction that collects Wasm (function/global/memory etc) instances and host-defined state. It simplifies creating instances when there are a lot of interdependencies, but it does not resolve names like a Linker (cf. wasmtime) would do. In other words, the end user is still required to instantiate modules in the right order, but at least this way it will be the Store to keep around all the right globals/functions etc.
E.g. imagine you have modules x, y, z, with z depending on x and y (i.e. importing from names x and y); you would write something like (for instance)
// if there are any host functions independent from Wasm modulesstore.withHostFunction(...); // these could be eventually stored in a HostModule // Instantiate and register exports automatically into the store.store.instantiate("x", x);
store.instantiate("y", y);
// We can now instantiate zvarzInstance = store.instantiate("z", z);
// all imports of the type <"x", "foo"> or <"y", "bar"> are found in the store // if they are exported by x, y; so instantiation succeeds.// zInstance is ready to use.zInstance.call(...)
The API is a strawman, the following would work just as well:
// if there are any host functions independent from Wasm modulesstore.withHostFunction(...); // these could be eventutally stored in a Host Module if/when they are introduced.// Instantiate and register exports automatically into the store.Instance.builder(x).withStore(store, "x").build();
Instance.builder(y).withStore(store, "y").build();
// We can now instantiate zvarzInstance = Instance.builder(z).withStore(store).build();
// zInstance is ready to use.zInstance.call(...)
The text was updated successfully, but these errors were encountered:
Related to #482.
Before introducing HostModules and eventually Linking it probably makes sense to introduce the concept of a Store. See e.g. Wasmtime, wazero and the Spec
A Store is an intermediate-level abstraction that collects Wasm (function/global/memory etc) instances and host-defined state. It simplifies creating instances when there are a lot of interdependencies, but it does not resolve names like a Linker (cf. wasmtime) would do. In other words, the end user is still required to instantiate modules in the right order, but at least this way it will be the Store to keep around all the right globals/functions etc.
E.g. imagine you have modules x, y, z, with z depending on x and y (i.e. importing from names
x
andy
); you would write something like (for instance)The API is a strawman, the following would work just as well:
The text was updated successfully, but these errors were encountered: