Stream: general

Topic: Is it possible to instantiate two modules into one instance?


view this post on Zulip Hoping White (Aug 02 2024 at 02:32):

Is it possible to combine another module into one instance later?

view this post on Zulip bjorn3 (Aug 02 2024 at 14:40):

No, an instance is an instantiation of a single module. You can have two instances (one for each module) where one imports functions from another instance though.

view this post on Zulip Hoping White (Aug 03 2024 at 03:05):

can they share the same memory?

view this post on Zulip bjorn3 (Aug 03 2024 at 17:51):

Yes, provided that at least one of the two imports the memory and you have built both wasm modules as PIC to ensure they can put their data at different addresses. I don't know exactly how you are supposed to instantiate a PIC wasm module though.

view this post on Zulip Hoping White (Aug 05 2024 at 05:01):

I want to simulate multiple DLLs to work in Wasm. Thanks.

view this post on Zulip Joel Dice (Aug 06 2024 at 07:15):

For core Wasm, you might want to look at Emscripten's support for dynamic libraries (e.g. https://github.com/WebAssembly/tool-conventions/blob/main/DynamicLinking.md#implementation-status). The Component Model also supports composing shared libraries, and that's what componentize-py uses to generate components. componentize-py composes libc.so, libpython312.so, etc. to generate components, and the plan is to optionally support importing those libraries from the host so they don't need to be bundled.

Conventions supporting interoperatibility between tools working with WebAssembly. - WebAssembly/tool-conventions
Repository for design and specification of the Component Model - WebAssembly/component-model
Contribute to bytecodealliance/componentize-py development by creating an account on GitHub.
This would dramatically reduce binary sizes in cases where the host can provide these libraries.

Last updated: Dec 23 2024 at 13:07 UTC