module-linking: Implement outer module aliases (#2590)
This commit fully implements outer aliases of the module linking proposal. Outer aliases can now handle multiple-level-up aliases and now properly also handle closed-over-values of modules that are either imported or defined. The structure of `wasmtime::Module` was altered as part of this commit. It is now a compiled module plus two lists of "upvars", or closed over values used when instantiating the module. One list of upvars is compiled artifacts which are submodules that could be used. Another is module values that are injected via outer aliases. Serialization and such have been updated as appropriate to handle this.
This commit is contained in:
@@ -239,11 +239,31 @@ pub enum Initializer {
|
||||
args: IndexMap<String, EntityIndex>,
|
||||
},
|
||||
|
||||
/// A module is defined into the module index space, and which module is
|
||||
/// being defined is specified by the index payload.
|
||||
/// A module is being created from a set of compiled artifacts.
|
||||
CreateModule {
|
||||
/// The index of the artifact that's being convereted into a module.
|
||||
artifact_index: usize,
|
||||
/// The list of artifacts that this module value will be inheriting.
|
||||
artifacts: Vec<usize>,
|
||||
/// The list of modules that this module value will inherit.
|
||||
modules: Vec<ModuleUpvar>,
|
||||
},
|
||||
|
||||
/// A module is created from a closed-over-module value, defined when this
|
||||
/// module was created.
|
||||
DefineModule(usize),
|
||||
}
|
||||
|
||||
/// Where module values can come from when creating a new module from a compiled
|
||||
/// artifact.
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub enum ModuleUpvar {
|
||||
/// A module value is inherited from the module creating the new module.
|
||||
Inherit(usize),
|
||||
/// A module value comes from the instance-to-be-created module index space.
|
||||
Local(ModuleIndex),
|
||||
}
|
||||
|
||||
impl Module {
|
||||
/// Allocates the module data structures.
|
||||
pub fn new() -> Self {
|
||||
|
||||
Reference in New Issue
Block a user