This commit is intended to be the first of many in implementing the module linking proposal. At this time this builds on #2059 so it shouldn't land yet. The goal of this commit is to compile bare-bones modules which use module linking, e.g. those with nested modules. My hope with module linking is that almost everything in wasmtime only needs mild refactorings to handle it. The goal is that all per-module structures are still per-module and at the top level there's just a `Vec` containing a bunch of modules. That's implemented currently where `wasmtime::Module` contains `Arc<[CompiledModule]>` and an index of which one it's pointing to. This should enable serialization/deserialization of any module in a nested modules scenario, no matter how you got it. Tons of features of the module linking proposal are missing from this commit. For example instantiation flat out doesn't work, nor does import/export of modules or instances. That'll be coming as future commits, but the purpose here is to start laying groundwork in Wasmtime for handling lots of modules in lots of places.
49 lines
1013 B
Rust
49 lines
1013 B
Rust
mod cli_tests;
|
|
mod custom_signal_handler;
|
|
mod debug;
|
|
mod externals;
|
|
mod func;
|
|
mod fuzzing;
|
|
mod globals;
|
|
mod iloop;
|
|
mod import_calling_export;
|
|
mod import_indexes;
|
|
mod instance;
|
|
mod invoke_func_via_table;
|
|
mod linker;
|
|
mod memory_creator;
|
|
mod module_linking;
|
|
mod module_serialize;
|
|
mod name;
|
|
mod stack_overflow;
|
|
mod table;
|
|
mod traps;
|
|
mod use_after_drop;
|
|
mod wast;
|
|
|
|
// TODO(#1886): Cranelift only supports reference types on x64.
|
|
#[cfg(target_arch = "x86_64")]
|
|
mod funcref;
|
|
#[cfg(target_arch = "x86_64")]
|
|
mod gc;
|
|
|
|
/// A helper to compile a module in a new store with reference types enabled.
|
|
#[cfg(target_arch = "x86_64")]
|
|
pub(crate) fn ref_types_module(
|
|
source: &str,
|
|
) -> anyhow::Result<(wasmtime::Store, wasmtime::Module)> {
|
|
use wasmtime::*;
|
|
|
|
let _ = env_logger::try_init();
|
|
|
|
let mut config = Config::new();
|
|
config.wasm_reference_types(true);
|
|
|
|
let engine = Engine::new(&config);
|
|
let store = Store::new(&engine);
|
|
|
|
let module = Module::new(&engine, source)?;
|
|
|
|
Ok((store, module))
|
|
}
|