* Initial skeleton of some component model processing This commit is the first of what will likely be many to implement the component model proposal in Wasmtime. This will be structured as a series of incremental commits, most of which haven't been written yet. My hope is to make this incremental and over time to make this easier to review and easier to test each step in isolation. Here much of the skeleton of how components are going to work in Wasmtime is sketched out. This is not a complete implementation of the component model so it's not all that useful yet, but some things you can do are: * Process the type section into a representation amenable for working with in Wasmtime. * Process the module section and register core wasm modules. * Process the instance section for core wasm modules. * Process core wasm module imports. * Process core wasm instance aliasing. * Ability to compile a component with core wasm embedded. * Ability to instantiate a component with no imports. * Ability to get functions from this component. This is already starting to diverge from the previous module linking representation where a `Component` will try to avoid unnecessary metadata about the component and instead internally only have the bare minimum necessary to instantiate the module. My hope is we can avoid constructing most of the index spaces during instantiation only for it to all ge thrown away. Additionally I'm predicting that we'll need to see through processing where possible to know how to generate adapters and where they are fused. At this time you can't actually call a component's functions, and that's the next PR that I would like to make. * Add tests for the component model support This commit uses the recently updated wasm-tools crates to add tests for the component model added in the previous commit. This involved updating the `wasmtime-wast` crate for component-model changes. Currently the component support there is quite primitive, but enough to at least instantiate components and verify the internals of Wasmtime are all working correctly. Additionally some simple tests for the embedding API have also been added.
69 lines
1.6 KiB
Rust
69 lines
1.6 KiB
Rust
mod async_functions;
|
|
mod call_hook;
|
|
mod cli_tests;
|
|
#[cfg(feature = "component-model")]
|
|
mod component_model;
|
|
mod custom_signal_handler;
|
|
mod debug;
|
|
mod epoch_interruption;
|
|
mod externals;
|
|
mod fuel;
|
|
mod func;
|
|
mod funcref;
|
|
mod gc;
|
|
mod globals;
|
|
mod host_funcs;
|
|
mod iloop;
|
|
mod import_calling_export;
|
|
mod import_indexes;
|
|
mod instance;
|
|
mod invoke_func_via_table;
|
|
mod limits;
|
|
mod linker;
|
|
mod memory;
|
|
mod memory_creator;
|
|
mod module;
|
|
mod module_serialize;
|
|
mod name;
|
|
mod pooling_allocator;
|
|
mod relocs;
|
|
mod stack_overflow;
|
|
mod store;
|
|
mod table;
|
|
mod traps;
|
|
mod wast;
|
|
|
|
/// A helper to compile a module in a new store with reference types enabled.
|
|
pub(crate) fn ref_types_module(
|
|
use_epochs: bool,
|
|
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);
|
|
if use_epochs {
|
|
config.epoch_interruption(true);
|
|
}
|
|
|
|
let engine = Engine::new(&config)?;
|
|
let mut store = Store::new(&engine, ());
|
|
if use_epochs {
|
|
store.set_epoch_deadline(1);
|
|
}
|
|
|
|
let module = Module::new(&engine, source)?;
|
|
|
|
Ok((store, module))
|
|
}
|
|
|
|
/// A helper determining whether the pooling allocator tests should be skipped.
|
|
pub(crate) fn skip_pooling_allocator_tests() -> bool {
|
|
// There are a couple of issues when running the pooling allocator tests under QEMU:
|
|
// - high memory usage that may exceed the limits imposed by the environment (e.g. CI)
|
|
// - https://github.com/bytecodealliance/wasmtime/pull/2518#issuecomment-747280133
|
|
std::env::var("WASMTIME_TEST_NO_HOG_MEMORY").is_ok()
|
|
}
|