revmc_context/arch/mod.rs
1//! Architecture-specific entry/exit trampolines for the JIT runtime.
2//!
3//! The entry trampoline ([`revmc_entry`]) saves callee-saved registers, records
4//! the stack pointer into [`EvmContext::exit_sp`](crate::EvmContext), and tail-calls
5//! the JIT-compiled function.
6//!
7//! The exit trampoline ([`revmc_exit`]) is called by builtins on error: it loads
8//! [`EvmContext::exit_result`](crate::EvmContext), restores the saved stack pointer
9//! and callee-saved registers, then returns directly to the caller of the entry
10//! trampoline — bypassing all intermediate JIT and builtin frames.
11
12use crate::EvmContext;
13
14/// Offset of `EvmContext::exit_result`.
15const EXIT_RESULT_OFFSET: usize = core::mem::offset_of!(EvmContext<'_>, exit_result);
16/// Offset of `EvmContext::exit_sp`.
17const EXIT_SP_OFFSET: usize = core::mem::offset_of!(EvmContext<'_>, exit_sp);
18
19#[cfg(target_arch = "x86_64")]
20mod x86_64;
21#[cfg(target_arch = "x86_64")]
22pub(crate) use x86_64::revmc_entry;
23#[cfg(target_arch = "x86_64")]
24pub use x86_64::*;
25
26#[cfg(target_arch = "aarch64")]
27mod aarch64;
28#[cfg(target_arch = "aarch64")]
29pub(crate) use aarch64::revmc_entry;
30#[cfg(target_arch = "aarch64")]
31pub use aarch64::*;