* cranelift-wasm: translate Wasm loads into lower-level CLIF operations
Rather than using `heap_{load,store,addr}`.
* cranelift: Remove the `heap_{addr,load,store}` instructions
These are now legalized in the `cranelift-wasm` frontend.
* cranelift: Remove the `ir::Heap` entity from CLIF
* Port basic memory operation tests to .wat filetests
* Remove test for verifying CLIF heaps
* Remove `heap_addr` from replace_branching_instructions_and_cfg_predecessors.clif test
* Remove `heap_addr` from readonly.clif test
* Remove `heap_addr` from `table_addr.clif` test
* Remove `heap_addr` from the simd-fvpromote_low.clif test
* Remove `heap_addr` from simd-fvdemote.clif test
* Remove `heap_addr` from the load-op-store.clif test
* Remove the CLIF heap runtest
* Remove `heap_addr` from the global_value.clif test
* Remove `heap_addr` from fpromote.clif runtests
* Remove `heap_addr` from fdemote.clif runtests
* Remove `heap_addr` from memory.clif parser test
* Remove `heap_addr` from reject_load_readonly.clif test
* Remove `heap_addr` from reject_load_notrap.clif test
* Remove `heap_addr` from load_readonly_notrap.clif test
* Remove `static-heap-without-guard-pages.clif` test
Will be subsumed when we port `make-heap-load-store-tests.sh` to generating
`.wat` tests.
* Remove `static-heap-with-guard-pages.clif` test
Will be subsumed when we port `make-heap-load-store-tests.sh` over to `.wat`
tests.
* Remove more heap tests
These will be subsumed by porting `make-heap-load-store-tests.sh` over to `.wat`
tests.
* Remove `heap_addr` from `simple-alias.clif` test
* Remove `heap_addr` from partial-redundancy.clif test
* Remove `heap_addr` from multiple-blocks.clif test
* Remove `heap_addr` from fence.clif test
* Remove `heap_addr` from extends.clif test
* Remove runtests that rely on heaps
Heaps are not a thing in CLIF or the interpreter anymore
* Add generated load/store `.wat` tests
* Enable memory-related wasm features in `.wat` tests
* Remove CLIF heap from fcmp-mem-bug.clif test
* Add a mode for compiling `.wat` all the way to assembly in filetests
* Also generate WAT to assembly tests in `make-load-store-tests.sh`
* cargo fmt
* Reinstate `f{de,pro}mote.clif` tests without the heap bits
* Remove undefined doc link
* Remove outdated SVG and dot file from docs
* Add docs about `None` returns for base address computation helpers
* Factor out `env.heap_access_spectre_mitigation()` to a local
* Expand docs for `FuncEnvironment::heaps` trait method
* Restore f{de,pro}mote+load clif runtests with stack memory
79 lines
2.4 KiB
Rust
79 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 heap;
|
|
mod module_translator;
|
|
mod sections_translator;
|
|
mod state;
|
|
mod translation_utils;
|
|
|
|
pub use crate::environ::{
|
|
DummyEnvironment, DummyFuncEnvironment, DummyModuleInfo, ExpectedReachability, FuncEnvironment,
|
|
GlobalVariable, ModuleEnvironment, TargetEnvironment,
|
|
};
|
|
pub use crate::func_translator::FuncTranslator;
|
|
pub use crate::heap::{Heap, HeapData, HeapStyle};
|
|
pub use crate::module_translator::translate_module;
|
|
pub use crate::state::FuncTranslationState;
|
|
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");
|