1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
//! This module provides a *very* basic panic runtime for LLVM execution
//! tests involving panics.
//!
//! Note that this is strictly for *execution testing* and is not used in
//! production! See [`crate::emit::test::PanicTestPreludeCodegen`] and
//! [`crate::emit::test::Emission::exec_panicking`] for the test harness.
//!
//! The progam entry point should be invoked via the [`trampoline`] function
//! which launches the program. Calls to [`panic_exit`] will exit the program
//! and make [`trampoline`] return prematurely. Note that the runtime will
//! perform a direct jump to the exit and no unrolling is performed. This
//! is fine for our use case since stack frames from hugr-llvm generated
//! bytecode don't require cleanup. However, using [`panic_exit`] to jump
//! over Rust frames is undefined behaviour.
//!
//! Note that the implementation relies on setjmp-longjmp (SJLJ) jumping to
//! exit the program. As SJLJ is not available in Rust, this had to be
//! implemented in C in linked into the Rust binary.
use ;
unsafe extern "C"