wasmer_compiler_cranelift/
lib.rs1#![deny(missing_docs, trivial_numeric_casts, unused_extern_crates)]
8#![warn(unused_import_braces)]
9#![allow(clippy::new_without_default)]
10#![warn(
11 clippy::float_arithmetic,
12 clippy::mut_mut,
13 clippy::nonminimal_bool,
14 clippy::map_unwrap_or,
15 clippy::print_stdout,
16 clippy::unicode_not_nfc,
17 clippy::use_self
18)]
19#![cfg_attr(docsrs, feature(doc_cfg))]
20
21#[cfg(target_os = "windows")]
22compile_error!(
23 "The Cranelift compiler backend is not supported on Windows. Use the V8 backend instead."
24);
25
26#[cfg(not(feature = "std"))]
27#[macro_use]
28extern crate alloc as std;
29#[cfg(feature = "std")]
30#[macro_use]
31extern crate std;
32
33#[cfg(not(feature = "std"))]
34use hashbrown::{
35 HashMap, hash_map,
36 hash_map::Entry::{Occupied, Vacant},
37};
38#[cfg(feature = "std")]
39use std::collections::{
40 HashMap, hash_map,
41 hash_map::Entry::{Occupied, Vacant},
42};
43
44mod abi;
45mod address_map;
46mod compiler;
47mod config;
48mod debug;
49#[cfg(feature = "unwind")]
50mod dwarf;
51#[cfg(feature = "unwind")]
52mod eh;
53mod elf;
54mod func_environ;
55mod heap;
56mod table;
57mod trampoline;
58mod translator;
59
60use cranelift_codegen::ir::TrapCode;
61
62pub use crate::compiler::CraneliftCompiler;
63pub use crate::config::{Cranelift, CraneliftCallbacks, CraneliftOptLevel};
64pub use crate::debug::{ModuleInfoMemoryOffset, ModuleInfoVmctxInfo, ValueLabelsRanges};
65pub use crate::trampoline::make_trampoline_function_call;
66
67pub const VERSION: &str = env!("CARGO_PKG_VERSION");
69
70const TRAP_USER_OFFSET: u8 = 32;
73
74#[allow(clippy::identity_op, reason = "for clarity")]
76pub const TRAP_INDIRECT_CALL_TO_NULL: TrapCode = TrapCode::unwrap_user(TRAP_USER_OFFSET + 0);
77pub const TRAP_BAD_SIGNATURE: TrapCode = TrapCode::unwrap_user(TRAP_USER_OFFSET + 1);
79pub const TRAP_TABLE_OUT_OF_BOUNDS: TrapCode = TrapCode::unwrap_user(TRAP_USER_OFFSET + 2);
81pub const TRAP_HEAP_MISALIGNED: TrapCode = TrapCode::unwrap_user(TRAP_USER_OFFSET + 3);
83pub const TRAP_UNREACHABLE: TrapCode = TrapCode::unwrap_user(TRAP_USER_OFFSET + 4);
85pub const TRAP_NULL_REFERENCE: TrapCode = TrapCode::unwrap_user(TRAP_USER_OFFSET + 5);
87pub const TRAP_NULL_I31_REF: TrapCode = TrapCode::unwrap_user(TRAP_USER_OFFSET + 6);
89pub const TRAP_INTERRUPT: TrapCode = TrapCode::unwrap_user(TRAP_USER_OFFSET + 7);