wasmtime/runtime/vm/arch/
mod.rs

1//! Architecture-specific support required by Wasmtime.
2//!
3//! This crate houses any architecture-specific tidbits required when running
4//! Wasmtime. Each architecture has its own file in the `arch` folder which is
5//! referenced here.
6//!
7//! All architectures have the same interface when exposed to the rest of the
8//! crate.
9
10cfg_if::cfg_if! {
11    if #[cfg(target_arch = "x86_64")] {
12        mod x86;
13        use x86 as imp;
14    } else if #[cfg(target_arch = "aarch64")] {
15        mod aarch64;
16        use aarch64 as imp;
17    } else if #[cfg(target_arch = "s390x")] {
18        mod s390x;
19        use s390x as imp;
20    } else if #[cfg(target_arch = "riscv64")] {
21        mod riscv64;
22        use riscv64 as imp;
23    } else {
24        mod unsupported;
25        use unsupported as imp;
26    }
27}
28
29// Functions defined in this module but all the implementations delegate to each
30// `imp` module. This exists to assert that each module internally provides the
31// same set of functionality with the same types for all architectures.
32
33pub fn get_stack_pointer() -> usize {
34    imp::get_stack_pointer()
35}
36
37pub unsafe fn get_next_older_pc_from_fp(fp: usize) -> usize {
38    imp::get_next_older_pc_from_fp(fp)
39}
40
41pub const NEXT_OLDER_FP_FROM_FP_OFFSET: usize = imp::NEXT_OLDER_FP_FROM_FP_OFFSET;
42
43pub fn assert_fp_is_aligned(fp: usize) {
44    imp::assert_fp_is_aligned(fp)
45}