diff --git a/crates/jit/src/unwind.rs b/crates/jit/src/unwind.rs index 8bb655137d..eedb52e143 100644 --- a/crates/jit/src/unwind.rs +++ b/crates/jit/src/unwind.rs @@ -2,6 +2,9 @@ cfg_if::cfg_if! { if #[cfg(all(windows, target_arch = "x86_64"))] { mod winx64; pub use self::winx64::*; + } else if #[cfg(all(windows, target_arch = "x86"))] { + mod winx32; + pub use self::winx32::*; } else if #[cfg(unix)] { mod systemv; pub use self::systemv::*; diff --git a/crates/jit/src/unwind/winx32.rs b/crates/jit/src/unwind/winx32.rs new file mode 100644 index 0000000000..25b887ce72 --- /dev/null +++ b/crates/jit/src/unwind/winx32.rs @@ -0,0 +1,20 @@ +//! Stub unwind registry for Windows x32. + +use anyhow::{bail, Result}; +use cranelift_codegen::isa::{unwind::UnwindInfo, TargetIsa}; + +pub struct UnwindRegistry {} + +impl UnwindRegistry { + pub fn new(_base_address: usize) -> Self { + Self {} + } + + pub fn register(&mut self, _func_start: u32, _func_len: u32, _info: &UnwindInfo) -> Result<()> { + bail!("winx32 has no unwind registry") + } + + pub fn publish(&mut self, _isa: &dyn TargetIsa) -> Result<()> { + Ok(()) + } +} diff --git a/crates/runtime/src/traphandlers.rs b/crates/runtime/src/traphandlers.rs index 6b2bae92ee..f96c3c8a7e 100644 --- a/crates/runtime/src/traphandlers.rs +++ b/crates/runtime/src/traphandlers.rs @@ -224,10 +224,16 @@ cfg_if::cfg_if! { Some(info) => info, None => return EXCEPTION_CONTINUE_SEARCH, }; - let jmp_buf = info.handle_trap( - (*(*exception_info).ContextRecord).Rip as *const u8, - |handler| handler(exception_info), - ); + cfg_if::cfg_if! { + if #[cfg(target_arch = "x86_64")] { + let ip = (*(*exception_info).ContextRecord).Rip as *const u8; + } else if #[cfg(target_arch = "x86")] { + let ip = (*(*exception_info).ContextRecord).Eip as *const u8; + } else { + compile_error!("unsupported platform"); + } + } + let jmp_buf = info.handle_trap(ip, |handler| handler(exception_info)); if jmp_buf.is_null() { EXCEPTION_CONTINUE_SEARCH } else if jmp_buf as usize == 1 {