* Remove the module linking implementation in Wasmtime This commit removes the experimental implementation of the module linking WebAssembly proposal from Wasmtime. The module linking is no longer intended for core WebAssembly but is instead incorporated into the component model now at this point. This means that very large parts of Wasmtime's implementation of module linking are no longer applicable and would change greatly with an implementation of the component model. The main purpose of this is to remove Wasmtime's reliance on the support for module-linking in `wasmparser` and tooling crates. With this reliance removed we can move over to the `component-model` branch of `wasmparser` and use the updated support for the component model. Additionally given the trajectory of the component model proposal the embedding API of Wasmtime will not look like what it looks like today for WebAssembly. For example the core wasm `Instance` will not change and instead a `Component` is likely to be added instead. Some more rationale for this is in #3941, but the basic idea is that I feel that it's not going to be viable to develop support for the component model on a non-`main` branch of Wasmtime. Additionaly I don't think it's viable, for the same reasons as `wasm-tools`, to support the old module linking proposal and the new component model at the same time. This commit takes a moment to not only delete the existing module linking implementation but some abstractions are also simplified. For example module serialization is a bit simpler that there's only one module. Additionally instantiation is much simpler since the only initializer we have to deal with are imports and nothing else. Closes #3941 * Fix doc link * Update comments
78 lines
2.4 KiB
Rust
78 lines
2.4 KiB
Rust
//! Performs translation from a wasm module in binary format to the in-memory form
|
|
//! of Cranelift IR. More particularly, it translates the code of all the functions bodies and
|
|
//! interacts with an environment implementing the
|
|
//! [`ModuleEnvironment`](trait.ModuleEnvironment.html)
|
|
//! trait to deal with tables, globals and linear memory.
|
|
//!
|
|
//! The crate provides a `DummyEnvironment` struct that will allow to translate the code of the
|
|
//! functions but will fail at execution.
|
|
//!
|
|
//! The main function of this module is [`translate_module`](fn.translate_module.html).
|
|
|
|
#![deny(missing_docs, trivial_numeric_casts, unused_extern_crates)]
|
|
#![warn(unused_import_braces)]
|
|
#![cfg_attr(feature = "std", deny(unstable_features))]
|
|
#![cfg_attr(feature = "clippy", plugin(clippy(conf_file = "../../clippy.toml")))]
|
|
#![cfg_attr(feature = "cargo-clippy", allow(clippy::new_without_default))]
|
|
#![cfg_attr(
|
|
feature = "cargo-clippy",
|
|
warn(
|
|
clippy::float_arithmetic,
|
|
clippy::mut_mut,
|
|
clippy::nonminimal_bool,
|
|
clippy::map_unwrap_or,
|
|
clippy::clippy::print_stdout,
|
|
clippy::unicode_not_nfc,
|
|
clippy::use_self
|
|
)
|
|
)]
|
|
#![no_std]
|
|
|
|
#[cfg(not(feature = "std"))]
|
|
#[macro_use]
|
|
extern crate alloc as std;
|
|
#[cfg(feature = "std")]
|
|
#[macro_use]
|
|
extern crate std;
|
|
|
|
#[cfg(not(feature = "std"))]
|
|
use hashbrown::{
|
|
hash_map,
|
|
hash_map::Entry::{Occupied, Vacant},
|
|
HashMap,
|
|
};
|
|
#[cfg(feature = "std")]
|
|
use std::collections::{
|
|
hash_map,
|
|
hash_map::Entry::{Occupied, Vacant},
|
|
HashMap,
|
|
};
|
|
|
|
mod code_translator;
|
|
mod environ;
|
|
mod func_translator;
|
|
mod module_translator;
|
|
mod sections_translator;
|
|
mod state;
|
|
mod translation_utils;
|
|
|
|
pub use crate::environ::{
|
|
DummyEnvironment, FuncEnvironment, GlobalVariable, ModuleEnvironment, ReturnMode,
|
|
TargetEnvironment,
|
|
};
|
|
pub use crate::func_translator::FuncTranslator;
|
|
pub use crate::module_translator::translate_module;
|
|
pub use crate::state::func_state::FuncTranslationState;
|
|
pub use crate::state::module_state::ModuleTranslationState;
|
|
pub use crate::translation_utils::*;
|
|
pub use cranelift_frontend::FunctionBuilder;
|
|
pub use wasmtime_types::*;
|
|
|
|
// Convenience reexport of the wasmparser crate that we're linking against,
|
|
// since a number of types in `wasmparser` show up in the public API of
|
|
// `cranelift-wasm`.
|
|
pub use wasmparser;
|
|
|
|
/// Version number of this crate.
|
|
pub const VERSION: &str = env!("CARGO_PKG_VERSION");
|