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 = [
23082308name = " panic_abort"
23092309version = " 0.0.0"
23102310dependencies = [
2311+ " cfg-if" ,
23112312 " compiler_builtins" ,
23122313 " core" ,
23132314 " libc" ,
Original file line number Diff line number Diff line change @@ -14,3 +14,4 @@ doc = false
1414core = { path = " ../libcore" }
1515libc = { version = " 0.2" , default-features = false }
1616compiler_builtins = " 0.1.0"
17+ cfg-if = " 0.1.8"
Original file line number Diff line number Diff line change 2020
2121use core:: any:: Any ;
2222
23+ // We need the definition of TryPayload for __rust_panic_cleanup.
24+ include ! ( "../libpanic_unwind/payload.rs" ) ;
25+
2326#[ 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 ) {
2528 unreachable ! ( )
2629}
2730
Original file line number Diff line number Diff line change @@ -6,8 +6,6 @@ use alloc::boxed::Box;
66use core:: any:: Any ;
77use core:: intrinsics;
88
9- pub type Payload = * mut u8 ;
10-
119pub unsafe fn cleanup ( _ptr : * mut u8 ) -> Box < dyn Any + Send > {
1210 intrinsics:: abort ( )
1311}
Original file line number Diff line number Diff line change @@ -48,8 +48,6 @@ static EXCEPTION_TYPE_INFO: TypeInfo = TypeInfo {
4848 name : b"rust_panic\0 " . as_ptr ( ) ,
4949} ;
5050
51- pub type Payload = * mut u8 ;
52-
5351struct Exception {
5452 // This needs to be an Option because the object's lifetime follows C++
5553 // 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 {
8282 }
8383}
8484
85- pub type Payload = * mut u8 ;
86-
8785pub unsafe fn cleanup ( ptr : * mut u8 ) -> Box < dyn Any + Send > {
8886 let exception = Box :: from_raw ( ptr as * mut Exception ) ;
8987 exception. cause
Original file line number Diff line number Diff line change @@ -6,8 +6,6 @@ use alloc::boxed::Box;
66use core:: any:: Any ;
77use core:: ptr;
88
9- pub type Payload = * mut u8 ;
10-
119pub unsafe fn cleanup ( _ptr : * mut u8 ) -> Box < dyn Any + Send > {
1210 extern "C" {
1311 pub fn __rust_abort ( ) -> !;
Original file line number Diff line number Diff line change @@ -35,8 +35,8 @@ use alloc::boxed::Box;
3535use core:: any:: Any ;
3636use core:: panic:: BoxMeUp ;
3737
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.
4040cfg_if:: cfg_if! {
4141 if #[ cfg( target_os = "emscripten" ) ] {
4242 #[ path = "emcc.rs" ]
@@ -62,6 +62,8 @@ cfg_if::cfg_if! {
6262 }
6363}
6464
65+ include ! ( "payload.rs" ) ;
66+
6567extern "C" {
6668 /// Handler in libstd called when a panic object is dropped outside of
6769 /// `catch_unwind`.
@@ -71,9 +73,9 @@ extern "C" {
7173mod dwarf;
7274
7375#[ 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 ) {
7779 Box :: into_raw ( imp:: cleanup ( payload) )
7880}
7981
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 {
308308 _CxxThrowException ( throw_ptr, & mut THROW_INFO as * mut _ as * mut _ ) ;
309309}
310310
311- pub type Payload = [ u64 ; 2 ] ;
312-
313311pub unsafe fn cleanup ( payload : [ u64 ; 2 ] ) -> Box < dyn Any + Send > {
314312 mem:: transmute ( raw:: TraitObject { data : payload[ 0 ] as * mut _ , vtable : payload[ 1 ] as * mut _ } )
315313}
You can’t perform that action at this time.
0 commit comments