Skip to content

Commit d835481

Browse files
committed
Switch wasm from core intrinsic to LLVM intrinsic
In preparation for changes in rust-lang/rust#148291.
1 parent 9b41a71 commit d835481

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

src/backend/itanium.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,12 @@ unsafe extern "C" fn cleanup(_code: i32, _ex: *mut Header) {
160160
);
161161
}
162162

163-
#[cfg(not(target_arch = "wasm32"))]
164163
unsafe extern "C-unwind" {
164+
#[cfg(target_arch = "wasm32")]
165+
#[link_name = "llvm.wasm.throw"]
166+
fn wasm_throw(tag: i32, ex: *mut u8) -> !;
167+
168+
#[cfg(not(target_arch = "wasm32"))]
165169
fn _Unwind_RaiseException(ex: *mut u8) -> !;
166170
}
167171

@@ -183,6 +187,6 @@ unsafe fn raise(ex: *mut u8) -> ! {
183187
#[cfg(target_arch = "wasm32")]
184188
// SAFETY: Passthrough.
185189
unsafe {
186-
core::arch::wasm32::throw::<0>(ex);
190+
wasm_throw(0, ex);
187191
}
188192
}

src/backend/wasm.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ unsafe impl ThrowByPointer for ActiveBackend {
1818
unsafe fn throw(ex: *mut Header) -> ! {
1919
// SAFETY: Wasm has no unwinder, so the pointer reaches `intercept` as-is.
2020
unsafe {
21-
core::arch::wasm32::throw::<0>(ex.cast::<u8>().wrapping_add(1));
21+
wasm_throw(0, ex.cast::<u8>().wrapping_add(1));
2222
}
2323
}
2424

@@ -34,7 +34,7 @@ unsafe impl ThrowByPointer for ActiveBackend {
3434
// safe because it's indistinguishable from not catching it in the first place due to
3535
// Wasm EH being performed by the VM.
3636
unsafe {
37-
core::arch::wasm32::throw::<0>(ex);
37+
wasm_throw(0, ex.cast());
3838
}
3939
}
4040

@@ -45,5 +45,10 @@ unsafe impl ThrowByPointer for ActiveBackend {
4545
}
4646
}
4747

48+
unsafe extern "C-unwind" {
49+
#[link_name = "llvm.wasm.throw"]
50+
fn wasm_throw(tag: i32, ex: *mut u8) -> !;
51+
}
52+
4853
#[repr(C, align(2))]
4954
pub struct Header;

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@
191191
#![cfg_attr(backend = "seh", feature(fn_ptr_trait, std_internals))]
192192
#![cfg_attr(
193193
any(backend = "wasm", all(backend = "itanium", target_arch = "wasm32")),
194-
feature(wasm_exception_handling_intrinsics)
194+
feature(link_llvm_intrinsics)
195195
)]
196196
#![deny(unsafe_op_in_unsafe_fn)]
197197
#![warn(

0 commit comments

Comments
 (0)