File tree 1 file changed +19
-0
lines changed
crates/core_arch/src/wasm32
1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -31,3 +31,22 @@ 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
+ #[ cfg_attr( test, assert_instr( unreachable) ) ]
47
+ #[ inline]
48
+ #[ unstable( feature = "wasm_exception_handling_intrinsic" , issue = "none" ) ]
49
+ pub unsafe fn throw < const TAG : i32 > ( ptr : * mut u8 ) -> ! {
50
+ static_assert ! ( TAG == 0 ) ; // LLVM only supports tag 0 == C++ right now.
51
+ wasm_throw ( TAG , ptr)
52
+ }
You can’t perform that action at this time.
0 commit comments