* Split `wasm_to_host_trampoline` into pieces In the upcoming component model supoprt for imports my plan is to reuse some of these pieces but not the entirety of the current `wasm_to_host_trampoline`. In an effort to make that diff smaller this commit splits up the function preemptively into pieces to get reused later. * Delete unused `for_each_libcall` macros Came across this when working in the object support for cranelift. * Refactor some object creation details This commit refactors some of the internals around creating an object file in the wasmtime-cranelift integration. The old `ObjectBuilder` is now named `ModuleTextBuilder` and is only used to create the text section rather than other sections too. This helps maintain the invariant that the unwind information section is placed directly after the text section without having an odd API for doing this. Additionally the unwind information creation is moved externally from the `ModuleTextBuilder` to a standalone structure. This separate structure is currently in use in the component model work I'm doing although I may change that to using the `ModuleTextBuilder` instead. In any case it seemed nice to encapsulate all of the unwinding information into one standalone structure. Finally, the insertion of native debug information has been refactored to happen in a new `append_dwarf` method to keep all the dwarf-related stuff together in one place as much as possible. * Fix a doctest * Fix a typo
73 lines
2.2 KiB
Rust
73 lines
2.2 KiB
Rust
//! Standalone environment for WebAssembly using Cranelift. Provides functions to translate
|
|
//! `get_global`, `set_global`, `memory.size`, `memory.grow`, `call_indirect` that hardcode in
|
|
//! the translation the base addresses of regions of memory that will hold the globals, tables and
|
|
//! linear memories.
|
|
|
|
#![deny(missing_docs, trivial_numeric_casts, unused_extern_crates)]
|
|
#![warn(unused_import_braces)]
|
|
#![cfg_attr(feature = "clippy", plugin(clippy(conf_file = "../../clippy.toml")))]
|
|
#![cfg_attr(
|
|
feature = "cargo-clippy",
|
|
allow(clippy::new_without_default, 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
|
|
)
|
|
)]
|
|
|
|
mod address_map;
|
|
mod builtin;
|
|
mod compilation;
|
|
mod module;
|
|
mod module_environ;
|
|
mod module_types;
|
|
pub mod obj;
|
|
mod ref_bits;
|
|
mod stack_map;
|
|
mod trap_encoding;
|
|
mod tunables;
|
|
mod vmoffsets;
|
|
|
|
pub use crate::address_map::*;
|
|
pub use crate::builtin::*;
|
|
pub use crate::compilation::*;
|
|
pub use crate::module::*;
|
|
pub use crate::module_environ::*;
|
|
pub use crate::module_types::*;
|
|
pub use crate::ref_bits::*;
|
|
pub use crate::stack_map::StackMap;
|
|
pub use crate::trap_encoding::*;
|
|
pub use crate::tunables::Tunables;
|
|
pub use crate::vmoffsets::*;
|
|
pub use object;
|
|
|
|
#[cfg(feature = "component-model")]
|
|
pub mod component;
|
|
|
|
// Reexport all of these type-level since they're quite commonly used and it's
|
|
// much easier to refer to everything through one crate rather than importing
|
|
// one of three and making sure you're using the right one.
|
|
pub use cranelift_entity::*;
|
|
pub use wasmtime_types::*;
|
|
|
|
/// WebAssembly page sizes are defined to be 64KiB.
|
|
pub const WASM_PAGE_SIZE: u32 = 0x10000;
|
|
|
|
/// The number of pages (for 32-bit modules) we can have before we run out of
|
|
/// byte index space.
|
|
pub const WASM32_MAX_PAGES: u64 = 1 << 16;
|
|
/// The number of pages (for 64-bit modules) we can have before we run out of
|
|
/// byte index space.
|
|
pub const WASM64_MAX_PAGES: u64 = 1 << 48;
|
|
|
|
/// Version number of this crate.
|
|
pub const VERSION: &str = env!("CARGO_PKG_VERSION");
|