wasefire
wasefire copied to clipboard
Sharing modules between applets
If applets are made of multiple modules with a main module (the one exporting the main function and probably defining the applet properties like its name), then modules may be shared between applets. For example, there could be an alloc module that exports its linear memory and an alloc, dealloc, and init functions. All other modules of the applet would import that memory and use those functions.
Open design questions are:
- How is dependency resolution done? Is it described in the applet or modules need to be parsed recursively from the main module?
- How is version management done? If 2 applets depend on different versions of the same module. Should we rely on semantic versioning for modules?
- How is applet management done? Would it become more of a module management with some modules (the main modules) being applets? The CLI should deal with installing/updating/etc modules based on the applet provided on the command line.
- What are the implications of having 2 layers of linking (one linker invocation for each module, then linking those modules in the interpreter)? This may break some assumptions where an applet may look like a binary with a single linking phase.
This may be related to how components work in the component model of WebAssembly, so some answers may be there.
A guideline could be:
- An applet is a WebAssembly store. This is at least useful for security to prevent state being accidentally shared between applets. But this is probably also simpler to reason regarding the consequences of a trap in one applet with respect to other applets.
- Each applet would thus instantiate its modules in its own store.