Skip to content

A lightweight WebAssembly runtime that is fast, secure, and standards-compliant

Manually register-allocate in inline asm (#11595)

Alex Crichton3fa26f69b81b
diff --git a/crates/unwinder/src/arch/aarch64.rs b/crates/unwinder/src/arch/aarch64.rs
index 20ce1ea883..bc639267a8 100644
--- a/crates/unwinder/src/arch/aarch64.rs
+++ b/crates/unwinder/src/arch/aarch64.rs
@@ -57,14 +57,14 @@ pub unsafe fn resume_to_exception_handler(
) -> ! {
unsafe {
core::arch::asm!(
- "mov sp, {}",
- "mov fp, {}",
- "br {}",
- in(reg) sp,
- in(reg) fp,
- in(reg) pc,
+ "mov sp, x2",
+ "mov fp, x3",
+ "br x4",
in("x0") payload1,
in("x1") payload2,
+ in("x2") sp,
+ in("x3") fp,
+ in("x4") pc,
options(nostack, nomem, noreturn),
);
}
diff --git a/crates/unwinder/src/arch/riscv64.rs b/crates/unwinder/src/arch/riscv64.rs
index b1ddb1382a..27920501e5 100644
--- a/crates/unwinder/src/arch/riscv64.rs
+++ b/crates/unwinder/src/arch/riscv64.rs
@@ -26,14 +26,14 @@ pub unsafe fn resume_to_exception_handler(
) -> ! {
unsafe {
core::arch::asm!(
- "mv sp, {}",
- "mv fp, {}",
- "jr {}",
- in(reg) sp,
- in(reg) fp,
- in(reg) pc,
+ "mv sp, a2",
+ "mv fp, a3",
+ "jr a4",
in("a0") payload1,
in("a1") payload2,
+ in("a2") sp,
+ in("a3") fp,
+ in("a4") pc,
options(nostack, nomem, noreturn),
);
}
diff --git a/crates/unwinder/src/arch/x86.rs b/crates/unwinder/src/arch/x86.rs
index fc8b3fad5a..71b2311d0f 100644
--- a/crates/unwinder/src/arch/x86.rs
+++ b/crates/unwinder/src/arch/x86.rs
@@ -29,14 +29,14 @@ pub unsafe fn resume_to_exception_handler(
) -> ! {
unsafe {
core::arch::asm!(
- "mov rsp, {}",
- "mov rbp, {}",
- "jmp {}",
- in(reg) sp,
- in(reg) fp,
- in(reg) pc,
+ "mov rsp, rcx",
+ "mov rbp, rsi",
+ "jmp rdi",
in("rax") payload1,
in("rdx") payload2,
+ in("rcx") sp,
+ in("rsi") fp,
+ in("rdi") pc,
options(nostack, nomem, noreturn),
);
}