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:
@@ -221,7 +221,7 @@ impl CompiledModule {
|
||||
artifacts: Vec<CompilationArtifacts>,
|
||||
isa: &dyn TargetIsa,
|
||||
profiler: &dyn ProfilingAgent,
|
||||
) -> Result<Vec<Self>, SetupError> {
|
||||
) -> Result<Vec<Arc<Self>>, SetupError> {
|
||||
maybe_parallel!(artifacts.(into_iter | into_par_iter))
|
||||
.map(|a| CompiledModule::from_artifacts(a, isa, profiler))
|
||||
.collect()
|
||||
@@ -232,7 +232,7 @@ impl CompiledModule {
|
||||
artifacts: CompilationArtifacts,
|
||||
isa: &dyn TargetIsa,
|
||||
profiler: &dyn ProfilingAgent,
|
||||
) -> Result<Self, SetupError> {
|
||||
) -> Result<Arc<Self>, SetupError> {
|
||||
// Allocate all of the compiled functions into executable memory,
|
||||
// copying over their contents.
|
||||
let (code_memory, code_range, finished_functions, trampolines) = build_code_memory(
|
||||
@@ -266,7 +266,7 @@ impl CompiledModule {
|
||||
|
||||
let finished_functions = FinishedFunctions(finished_functions);
|
||||
|
||||
Ok(Self {
|
||||
Ok(Arc::new(Self {
|
||||
module: Arc::new(artifacts.module.clone()),
|
||||
artifacts,
|
||||
code: Arc::new(ModuleCode {
|
||||
@@ -275,7 +275,7 @@ impl CompiledModule {
|
||||
}),
|
||||
finished_functions,
|
||||
trampolines,
|
||||
})
|
||||
}))
|
||||
}
|
||||
|
||||
/// Crate an `Instance` from this `CompiledModule`.
|
||||
|
||||
Reference in New Issue
Block a user