Module linking
Closed this issue · 1 comments
chrisdickinson commented
While we allow multiple Wasm modules to be passed in via the manifest, we don't currently link them together like the main Extism library does. This is related to #9, in that this requires adding a step between ArrayBuffer
and WebAssembly.Instance
so that we can examine imports and exports and create appropriate trampolines.
chrisdickinson commented
I started taking a look at this this morning to shake off the rust from Thanksgiving break. Here's a grab bag of observations:
- I had initially thought that we could late-bind using trampoline objects - that is, collect all of the modules by name before instantiation, collect all of their exports, and build a single import map that implements all module names and functions by delegating calls between the module instances – basically late-binding everything. Of course, I had forgotten about shared memories, tables, and values – which means we can't fully get away with that approach! We'll ultimately need to do a little topographical sorting to get it to work.
name
becomes more important under this model. We'll want to align with how the Rust extism runtime infers name when unavailable [1].- Wasmtime's
Linker
uses different instantiation strategies for "command" and "reactor" modules, we'll want to do something similar [2]
I'll see about pushing this forward over the next couple of weeks, but it's not likely to make the 1.0 beta deadline.