File tree 1 file changed +22
-0
lines changed
crates/core_arch/src/wasm32
1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -31,3 +31,25 @@ pub use self::memory::*;
31
31
pub fn unreachable ( ) -> ! {
32
32
crate :: intrinsics:: abort ( )
33
33
}
34
+
35
+ extern "C" {
36
+ #[ link_name = "llvm.wasm.throw" ]
37
+ fn wasm_throw ( tag : i32 , ptr : * mut u8 ) -> !;
38
+ }
39
+
40
+ /// Generates the [`throw`] instruction from the [exception-handling proposal] for WASM.
41
+ ///
42
+ /// This function is unlikely to be stabilized until codegen backends have better support.
43
+ ///
44
+ /// [`throw`]: https://webassembly.github.io/exception-handling/core/syntax/instructions.html#syntax-instr-control
45
+ /// [exception-handling proposal]: https://github.com/WebAssembly/exception-handling
46
+ // FIXME: wasmtime does not currently support exception-handling, so cannot execute
47
+ // a wasm module with the throw instruction in it. once it does, we can
48
+ // reenable this attribute.
49
+ // #[cfg_attr(test, assert_instr(throw, TAG = 0, ptr = core::ptr::null_mut()))]
50
+ #[ inline]
51
+ #[ unstable( feature = "wasm_exception_handling_intrinsics" , issue = "122465" ) ]
52
+ pub unsafe fn throw < const TAG : i32 > ( ptr : * mut u8 ) -> ! {
53
+ static_assert ! ( TAG == 0 ) ; // LLVM only supports tag 0 == C++ right now.
54
+ wasm_throw ( TAG , ptr)
55
+ }
You can’t perform that action at this time.
0 commit comments