File tree Expand file tree Collapse file tree 12 files changed +40
-68
lines changed Expand file tree Collapse file tree 12 files changed +40
-68
lines changed Original file line number Diff line number Diff line change @@ -2308,6 +2308,7 @@ dependencies = [
2308
2308
name = " panic_abort"
2309
2309
version = " 0.0.0"
2310
2310
dependencies = [
2311
+ " cfg-if" ,
2311
2312
" compiler_builtins" ,
2312
2313
" core" ,
2313
2314
" libc" ,
Original file line number Diff line number Diff line change @@ -14,3 +14,4 @@ doc = false
14
14
core = { path = " ../libcore" }
15
15
libc = { version = " 0.2" , default-features = false }
16
16
compiler_builtins = " 0.1.0"
17
+ cfg-if = " 0.1.8"
Original file line number Diff line number Diff line change 20
20
21
21
use core:: any:: Any ;
22
22
23
+ // We need the definition of TryPayload for __rust_panic_cleanup.
24
+ include ! ( "../libpanic_unwind/payload.rs" ) ;
25
+
23
26
#[ rustc_std_internal_symbol]
24
- pub unsafe extern "C" fn __rust_panic_cleanup ( _: * mut u8 ) -> * mut ( dyn Any + Send + ' static ) {
27
+ pub unsafe extern "C" fn __rust_panic_cleanup ( _: TryPayload ) -> * mut ( dyn Any + Send + ' static ) {
25
28
unreachable ! ( )
26
29
}
27
30
Original file line number Diff line number Diff line change @@ -6,8 +6,6 @@ use alloc::boxed::Box;
6
6
use core:: any:: Any ;
7
7
use core:: intrinsics;
8
8
9
- pub type Payload = * mut u8 ;
10
-
11
9
pub unsafe fn cleanup ( _ptr : * mut u8 ) -> Box < dyn Any + Send > {
12
10
intrinsics:: abort ( )
13
11
}
Original file line number Diff line number Diff line change @@ -48,8 +48,6 @@ static EXCEPTION_TYPE_INFO: TypeInfo = TypeInfo {
48
48
name : b"rust_panic\0 " . as_ptr ( ) ,
49
49
} ;
50
50
51
- pub type Payload = * mut u8 ;
52
-
53
51
struct Exception {
54
52
// This needs to be an Option because the object's lifetime follows C++
55
53
// semantics: when catch_unwind moves the Box out of the exception it must
Original file line number Diff line number Diff line change @@ -82,8 +82,6 @@ pub unsafe fn panic(data: Box<dyn Any + Send>) -> u32 {
82
82
}
83
83
}
84
84
85
- pub type Payload = * mut u8 ;
86
-
87
85
pub unsafe fn cleanup ( ptr : * mut u8 ) -> Box < dyn Any + Send > {
88
86
let exception = Box :: from_raw ( ptr as * mut Exception ) ;
89
87
exception. cause
Original file line number Diff line number Diff line change @@ -6,8 +6,6 @@ use alloc::boxed::Box;
6
6
use core:: any:: Any ;
7
7
use core:: ptr;
8
8
9
- pub type Payload = * mut u8 ;
10
-
11
9
pub unsafe fn cleanup ( _ptr : * mut u8 ) -> Box < dyn Any + Send > {
12
10
extern "C" {
13
11
pub fn __rust_abort ( ) -> !;
Original file line number Diff line number Diff line change @@ -35,8 +35,8 @@ use alloc::boxed::Box;
35
35
use core:: any:: Any ;
36
36
use core:: panic:: BoxMeUp ;
37
37
38
- // If adding to this list, you should also look at libstd::panicking's identical
39
- // list of Payload types and likely add to there as well.
38
+ // If adding to this list, you should also look at the list of TryPayload types
39
+ // defined in payload.rs and likely add to there as well.
40
40
cfg_if:: cfg_if! {
41
41
if #[ cfg( target_os = "emscripten" ) ] {
42
42
#[ path = "emcc.rs" ]
@@ -62,6 +62,8 @@ cfg_if::cfg_if! {
62
62
}
63
63
}
64
64
65
+ include ! ( "payload.rs" ) ;
66
+
65
67
extern "C" {
66
68
/// Handler in libstd called when a panic object is dropped outside of
67
69
/// `catch_unwind`.
@@ -71,9 +73,9 @@ extern "C" {
71
73
mod dwarf;
72
74
73
75
#[ no_mangle]
74
- pub unsafe extern "C" fn __rust_panic_cleanup ( payload : * mut u8 ) -> * mut ( dyn Any + Send + ' static ) {
75
- let payload = payload as * mut imp :: Payload ;
76
- let payload = * ( payload ) ;
76
+ pub unsafe extern "C" fn __rust_panic_cleanup (
77
+ payload : TryPayload ,
78
+ ) -> * mut ( dyn Any + Send + ' static ) {
77
79
Box :: into_raw ( imp:: cleanup ( payload) )
78
80
}
79
81
Original file line number Diff line number Diff line change
1
+ // Type definition for the payload argument of the try intrinsic.
2
+ //
3
+ // This must be kept in sync with the implementations of the try intrinsic.
4
+ //
5
+ // This file is included by both panic runtimes and libstd. It is part of the
6
+ // panic runtime ABI.
7
+ cfg_if:: cfg_if! {
8
+ if #[ cfg( target_os = "emscripten" ) ] {
9
+ type TryPayload = * mut u8 ;
10
+ } else if #[ cfg( target_arch = "wasm32" ) ] {
11
+ type TryPayload = * mut u8 ;
12
+ } else if #[ cfg( target_os = "hermit" ) ] {
13
+ type TryPayload = * mut u8 ;
14
+ } else if #[ cfg( all( target_env = "msvc" , target_arch = "aarch64" ) ) ] {
15
+ type TryPayload = * mut u8 ;
16
+ } else if #[ cfg( target_env = "msvc" ) ] {
17
+ type TryPayload = [ u64 ; 2 ] ;
18
+ } else {
19
+ type TryPayload = * mut u8 ;
20
+ }
21
+ }
Original file line number Diff line number Diff line change @@ -308,8 +308,6 @@ pub unsafe fn panic(data: Box<dyn Any + Send>) -> u32 {
308
308
_CxxThrowException ( throw_ptr, & mut THROW_INFO as * mut _ as * mut _ ) ;
309
309
}
310
310
311
- pub type Payload = [ u64 ; 2 ] ;
312
-
313
311
pub unsafe fn cleanup ( payload : [ u64 ; 2 ] ) -> Box < dyn Any + Send > {
314
312
mem:: transmute ( raw:: TraitObject { data : payload[ 0 ] as * mut _ , vtable : payload[ 1 ] as * mut _ } )
315
313
}
You can’t perform that action at this time.
0 commit comments