From a70550550f1b4bc0590f9f21ee9ac80efab6cc19 Mon Sep 17 00:00:00 2001 From: Mads Marquart Date: Thu, 12 Sep 2024 22:11:39 +0200 Subject: [PATCH] Use `extern "C-unwind"` C-unwind was added in Rust 1.71, and allows panicking/unwinding /exceptions across foreign function interfaces. Additionally, Rust decided to let handling of foreign unwinds be implementation defined behavior (instead of undefined), so we can now mark `throw` as safe, see https://github.com/rust-lang/rust/pull/128321. This has a cost in that we now have landing pads on every message send; this is strictly the correct choice, though, so we will have to bear with it. Fixes https://github.com/madsmtm/objc2/issues/539. --- .github/workflows/ci.yml | 2 +- Cargo.toml | 3 - crates/block2/CHANGELOG.md | 2 + crates/block2/Cargo.toml | 8 - crates/block2/src/abi.rs | 12 +- crates/block2/src/ffi.rs | 60 +- crates/block2/src/global.rs | 8 +- crates/block2/src/stack.rs | 12 +- crates/block2/src/traits.rs | 18 +- crates/header-translator/src/rust_type.rs | 6 +- crates/header-translator/src/stmt.rs | 8 +- crates/objc2-exception-helper/Cargo.toml | 8 - crates/objc2-exception-helper/src/lib.rs | 8 - crates/objc2/CHANGELOG.md | 2 + crates/objc2/Cargo.toml | 12 +- .../src/__macro_helpers/declared_ivars.rs | 6 +- crates/objc2/src/encode.rs | 7 - crates/objc2/src/exception.rs | 49 +- crates/objc2/src/ffi/mod.rs | 10 - crates/objc2/src/ffi/types.rs | 2 +- crates/objc2/src/ffi/various.rs | 2 +- crates/objc2/src/lib.rs | 2 +- crates/objc2/src/macros/declare_class.rs | 8 +- crates/objc2/src/macros/mod.rs | 6 +- crates/objc2/src/main_thread_marker.rs | 2 + crates/objc2/src/rc/id.rs | 6 +- crates/objc2/src/runtime/declare.rs | 16 +- .../src/runtime/method_implementation.rs | 2 - crates/objc2/src/runtime/mod.rs | 7 +- .../objc2/src/runtime/retain_release_fast.rs | 4 + crates/objc2/src/test_utils.rs | 62 +- .../src/topics/about_generated/CHANGELOG.md | 4 + crates/objc2/src/topics/alternatives.md | 2 +- crates/objc2/src/topics/layered_safety.md | 7 +- crates/objc2/tests/declare_class.rs | 20 +- crates/objc2/tests/track_caller.rs | 10 +- .../test_block/expected/apple-aarch64.s | 51 +- .../crates/test_block/expected/apple-x86_64.s | 39 +- .../expected/apple-aarch64.s | 1155 ++++++++++++----- .../expected/apple-x86_64.s | 620 +++++++-- .../expected/apple-aarch64.s | 14 +- .../test_dynamic_sel/expected/apple-aarch64.s | 18 +- .../expected/apple-aarch64.s | 74 +- .../expected/apple-armv7s.s | 233 +++- .../expected/apple-x86.s | 97 +- .../expected/apple-x86_64.s | 68 +- .../expected/gnustep-x86.s | 166 ++- .../expected/gnustep-x86_64.s | 75 +- .../expected/apple-aarch64.s | 41 +- .../expected/apple-aarch64.s | 258 ++++ .../expected/apple-armv7s.s | 740 ++++++++++- .../test_out_parameters/expected/apple-x86.s | 310 ++++- .../expected/apple-x86_64.s | 262 ++++ .../expected/gnustep-x86.s | 350 ++++- .../expected/gnustep-x86_64.s | 271 ++++ .../ui/declare_class_invalid_receiver.stderr | 28 +- .../ui/declare_class_invalid_type.stderr | 16 +- .../declare_class_mut_self_not_mutable.stderr | 12 +- crates/tests/src/block.rs | 2 +- crates/tests/src/exception.rs | 10 +- crates/tests/src/lib.rs | 2 +- .../objc2-foundation/src/array.rs | 8 +- .../objc2-foundation/src/exception.rs | 7 +- .../objc2-foundation/src/ns_consumed.rs | 2 +- .../objc2-foundation/src/tests/dictionary.rs | 53 +- generated | 2 +- 66 files changed, 4243 insertions(+), 1144 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5c99d99e0..453976bac 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -492,7 +492,7 @@ jobs: - name: Test Foundation with unstable features if: ${{ matrix.nightly }} - run: cargo test $ARGS $PUBLIC_CRATES -ptests $INTERESTING_FEATURES -pobjc2-foundation --features=catch-all,unstable-autoreleasesafe,unstable-c-unwind ${{ matrix.sdk != '10.12' && '--features=unstable-simd' || '' }} + run: cargo test $ARGS $PUBLIC_CRATES -ptests $INTERESTING_FEATURES -pobjc2-foundation --features=catch-all,unstable-autoreleasesafe ${{ matrix.sdk != '10.12' && '--features=unstable-simd' || '' }} # TODO: Re-enable this on all of Foundation once we do some form of # availability checking. diff --git a/Cargo.toml b/Cargo.toml index ea940b2bc..d26914b92 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -41,9 +41,6 @@ ptr_as_ptr = "warn" inherits = "release" # Enable LTO to allow testing the `unstable-static-sel-inlined` feature lto = true -# Don't emit unwind info; while important to get right, the control flow is -# very hard to glean from assembly output. -panic = "abort" # Release data for framework crates [workspace.metadata.release] diff --git a/crates/block2/CHANGELOG.md b/crates/block2/CHANGELOG.md index 58ee05dc6..7d996c2f8 100644 --- a/crates/block2/CHANGELOG.md +++ b/crates/block2/CHANGELOG.md @@ -73,6 +73,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). * **BREAKING**: Fixed `GlobalBlock` not having the correct variance. This may break if you were using lifetimes in your parameters, as those are now a bit too restrictive. +* **BREAKING**: Converted function signatures into using `extern "C-unwind"`. + This allows unwinding through blocks. ## 0.4.0 - 2023-12-03 diff --git a/crates/block2/Cargo.toml b/crates/block2/Cargo.toml index 913f2b86c..c142964f5 100644 --- a/crates/block2/Cargo.toml +++ b/crates/block2/Cargo.toml @@ -41,14 +41,6 @@ unstable-winobjc = ["gnustep-1-8"] # Link to ObjFW. unstable-objfw = [] -# Uses `extern "C-unwind"` on relevant function declarations. -# -# This raises MSRV to `1.71`. -# -# Warning: Enabling this is a breaking change for consumer crates, as it -# changes the signature of functions. -unstable-c-unwind = [] - # Expose private ffi functions and statics. unstable-private = [] diff --git a/crates/block2/src/abi.rs b/crates/block2/src/abi.rs index f7fcd2d4e..919bf8515 100644 --- a/crates/block2/src/abi.rs +++ b/crates/block2/src/abi.rs @@ -199,7 +199,7 @@ pub struct BlockHeader { /// If the BLOCK_USE_SRET & BLOCK_HAS_SIGNATURE flag is set, there is an /// additional hidden parameter, which is a pointer to the space on the /// stack allocated to hold the return value. - pub invoke: Option, + pub invoke: Option, /// The block's descriptor. pub(crate) descriptor: BlockDescriptorPtr, } @@ -257,13 +257,12 @@ pub(crate) struct BlockDescriptorCopyDispose { /// /// This may be NULL since macOS 11.0.1 in Apple's runtime, but this /// should not be relied on. - pub(crate) copy: - Option, + pub(crate) copy: Option, /// Helper to destroy the block after being copied. /// /// This may be NULL since macOS 11.0.1 in Apple's runtime, but this /// should not be relied on. - pub(crate) dispose: Option, + pub(crate) dispose: Option, } /// Block descriptor that has an encoding / a signature. @@ -303,13 +302,12 @@ pub(crate) struct BlockDescriptorCopyDisposeSignature { /// /// This may be NULL since macOS 11.0.1 in Apple's runtime, but this /// should not be relied on. - pub(crate) copy: - Option, + pub(crate) copy: Option, /// Helper to destroy the block after being copied. /// /// This may be NULL since macOS 11.0.1 in Apple's runtime, but this /// should not be relied on. - pub(crate) dispose: Option, + pub(crate) dispose: Option, /// Objective-C type encoding of the block. #[doc(alias = "signature")] diff --git a/crates/block2/src/ffi.rs b/crates/block2/src/ffi.rs index 68a52b2b4..0129230ae 100644 --- a/crates/block2/src/ffi.rs +++ b/crates/block2/src/ffi.rs @@ -5,30 +5,6 @@ use core::ffi::c_int; use core::ffi::c_void; use core::marker::{PhantomData, PhantomPinned}; -#[cfg(not(feature = "unstable-c-unwind"))] -#[doc(hidden)] -#[macro_export] -macro_rules! __c_unwind { - (unsafe extern "C" $($t:tt)*) => { - unsafe extern "C" $($t)* - }; - (extern "C" $($t:tt)*) => { - extern "C" $($t)* - }; -} - -#[cfg(feature = "unstable-c-unwind")] -#[doc(hidden)] -#[macro_export] -macro_rules! __c_unwind { - (unsafe extern "C" $($t:tt)*) => { - unsafe extern "C-unwind" $($t)* - }; - (extern "C" $($t:tt)*) => { - extern "C-unwind" $($t)* - }; -} - /// Type for block class ISAs. /// /// This will likely become an extern type in the future. @@ -55,26 +31,8 @@ pub struct Class { _opaque: UnsafeCell, PhantomPinned)>>, } -#[cfg(not(feature = "unstable-c-unwind"))] -macro_rules! extern_c_unwind { - ($($t:tt)*) => { - extern "C" { - $($t)* - } - }; -} - -#[cfg(feature = "unstable-c-unwind")] -macro_rules! extern_c_unwind { - ($($t:tt)*) => { - extern "C-unwind" { - $($t)* - } - }; -} - // Use `extern "C-unwind"`, runtime functions may call external routines. -extern_c_unwind! { +extern "C-unwind" { /// Class ISA used for global blocks. pub static _NSConcreteGlobalBlock: Class; @@ -126,7 +84,7 @@ pub mod private { #[cfg(any(doc, target_vendor = "apple", feature = "compiler-rt"))] use core::ffi::c_ulong; - extern_c_unwind! { + extern "C-unwind" { pub static _NSConcreteMallocBlock: Class; #[cfg(any(doc, target_vendor = "apple", feature = "compiler-rt"))] pub static _NSConcreteAutoBlock: Class; @@ -203,21 +161,15 @@ mod tests { println!("{:?}", unsafe { ptr::addr_of!(private::_NSConcreteMallocBlock) }); + println!("{:p}", _Block_copy as unsafe extern "C-unwind" fn(_) -> _); println!( "{:p}", - _Block_copy as __c_unwind!(unsafe extern "C" fn(_) -> _) - ); - println!( - "{:p}", - _Block_object_assign as __c_unwind!(unsafe extern "C" fn(_, _, _)) - ); - println!( - "{:p}", - _Block_object_dispose as __c_unwind!(unsafe extern "C" fn(_, _)) + _Block_object_assign as unsafe extern "C-unwind" fn(_, _, _) ); println!( "{:p}", - _Block_release as __c_unwind!(unsafe extern "C" fn(_)) + _Block_object_dispose as unsafe extern "C-unwind" fn(_, _) ); + println!("{:p}", _Block_release as unsafe extern "C-unwind" fn(_)); } } diff --git a/crates/block2/src/global.rs b/crates/block2/src/global.rs index e89787532..28aa5bb48 100644 --- a/crates/block2/src/global.rs +++ b/crates/block2/src/global.rs @@ -187,17 +187,17 @@ macro_rules! global_block { let mut header = $crate::GlobalBlock:: $r)? + 'static>::__DEFAULT_HEADER; header.isa = ::core::ptr::addr_of!($crate::ffi::_NSConcreteGlobalBlock); header.invoke = ::core::option::Option::Some({ - $crate::__c_unwind!(unsafe extern "C" fn inner( + unsafe extern "C-unwind" fn inner( _: *mut $crate::GlobalBlock $r)? + 'static>, $($a: $t),* ) $(-> $r)? { $body - }); + } // TODO: SAFETY ::core::mem::transmute::< - $crate::__c_unwind!(unsafe extern "C" fn(*mut $crate::GlobalBlock $r)? + 'static>, $($a: $t),*) $(-> $r)?), - $crate::__c_unwind!(unsafe extern "C" fn()), + unsafe extern "C-unwind" fn(*mut $crate::GlobalBlock $r)? + 'static>, $($a: $t),*) $(-> $r)?, + unsafe extern "C-unwind" fn(), >(inner) }); $crate::GlobalBlock::from_header(header) diff --git a/crates/block2/src/stack.rs b/crates/block2/src/stack.rs index c667d00cb..b7b92f66a 100644 --- a/crates/block2/src/stack.rs +++ b/crates/block2/src/stack.rs @@ -77,7 +77,7 @@ impl<'f, A, R, Closure> StackBlock<'f, A, R, Closure> { const SIZE: c_ulong = mem::size_of::() as _; // Drop the closure that this block contains. - crate::__c_unwind! {unsafe extern "C" fn drop_closure(block: *mut c_void) { + unsafe extern "C-unwind" fn drop_closure(block: *mut c_void) { let block: *mut Self = block.cast(); // When this function is called, the block no longer lives on the // stack, it has been moved to the heap as part of some `_Block_copy` @@ -97,7 +97,7 @@ impl<'f, A, R, Closure> StackBlock<'f, A, R, Closure> { // part of some `_Block_copy` operation, and as such it is valid to // drop here. unsafe { ptr::drop_in_place(closure) }; - }} + } const DESCRIPTOR_BASIC: BlockDescriptor = BlockDescriptor { reserved: 0, @@ -108,7 +108,7 @@ impl<'f, A, R, Closure> StackBlock<'f, A, R, Closure> { // `StackBlock::new` impl<'f, A, R, Closure: Clone> StackBlock<'f, A, R, Closure> { // Clone the closure from one block to another. - crate::__c_unwind! {unsafe extern "C" fn clone_closure(dst: *mut c_void, src: *const c_void) { + unsafe extern "C-unwind" fn clone_closure(dst: *mut c_void, src: *const c_void) { let dst: *mut Self = dst.cast(); let src: *const Self = src.cast(); // When this function is called as part of some `_Block_copy` @@ -132,7 +132,7 @@ impl<'f, A, R, Closure: Clone> StackBlock<'f, A, R, Closure> { // already `memmove`d data once more, which is unnecessary for closure // captures that implement `Copy`. unsafe { ptr::write(dst_closure, src_closure.clone()) }; - }} + } const DESCRIPTOR_WITH_CLONE: BlockDescriptorCopyDispose = BlockDescriptorCopyDispose { reserved: 0, @@ -198,10 +198,10 @@ impl<'f, A, R, Closure> StackBlock<'f, A, R, Closure> { // `RcBlock::new` impl<'f, A, R, Closure> StackBlock<'f, A, R, Closure> { - crate::__c_unwind! {unsafe extern "C" fn empty_clone_closure(_dst: *mut c_void, _src: *const c_void) { + unsafe extern "C-unwind" fn empty_clone_closure(_dst: *mut c_void, _src: *const c_void) { // We do nothing, the closure has been `memmove`'d already, and // ownership will be passed in `RcBlock::new`. - }} + } const DESCRIPTOR_WITH_DROP: BlockDescriptorCopyDispose = BlockDescriptorCopyDispose { reserved: 0, diff --git a/crates/block2/src/traits.rs b/crates/block2/src/traits.rs index 565fe5fea..13a3914b7 100644 --- a/crates/block2/src/traits.rs +++ b/crates/block2/src/traits.rs @@ -34,7 +34,7 @@ pub unsafe trait BlockFn: private::Sealed { /// Calls the given invoke function with the block and arguments. #[doc(hidden)] unsafe fn __call_block( - invoke: crate::__c_unwind!(unsafe extern "C" fn()), + invoke: unsafe extern "C-unwind" fn(), block: *mut Block, args: Self::Args, ) -> Self::Output; @@ -60,7 +60,7 @@ where type Dyn: ?Sized + BlockFn; #[doc(hidden)] - fn __get_invoke_stack_block() -> crate::__c_unwind!(unsafe extern "C" fn()); + fn __get_invoke_stack_block() -> unsafe extern "C-unwind" fn(); } macro_rules! impl_traits { @@ -77,12 +77,12 @@ macro_rules! impl_traits { #[inline] unsafe fn __call_block( - invoke: crate::__c_unwind!(unsafe extern "C" fn()), + invoke: unsafe extern "C-unwind" fn(), block: *mut Block, ($($a,)*): Self::Args, ) -> Self::Output { // Very similar to `MessageArguments::__invoke` - let invoke: unsafe extern "C" fn(*mut Block $(, $t)*) -> R = unsafe { + let invoke: unsafe extern "C-unwind" fn(*mut Block $(, $t)*) -> R = unsafe { mem::transmute(invoke) }; @@ -99,8 +99,8 @@ macro_rules! impl_traits { type Dyn = dyn Fn($($t),*) -> R + 'f; #[inline] - fn __get_invoke_stack_block() -> crate::__c_unwind!(unsafe extern "C" fn()) { - crate::__c_unwind!(unsafe extern "C" fn invoke<'f, $($t,)* R, Closure>( + fn __get_invoke_stack_block() -> unsafe extern "C-unwind" fn() { + unsafe extern "C-unwind" fn invoke<'f, $($t,)* R, Closure>( block: *mut StackBlock<'f, ($($t,)*), R, Closure>, $($a: $t,)* ) -> R @@ -109,12 +109,12 @@ macro_rules! impl_traits { { let closure = unsafe { &*ptr::addr_of!((*block).closure) }; (closure)($($a),*) - }); + } unsafe { mem::transmute::< - crate::__c_unwind!(unsafe extern "C" fn(*mut StackBlock<'f, ($($t,)*), R, Closure>, $($t,)*) -> R), - crate::__c_unwind!(unsafe extern "C" fn()), + unsafe extern "C-unwind" fn(*mut StackBlock<'f, ($($t,)*), R, Closure>, $($t,)*) -> R, + unsafe extern "C-unwind" fn(), >(invoke) } } diff --git a/crates/header-translator/src/rust_type.rs b/crates/header-translator/src/rust_type.rs index b4b9de47b..f2da9dc71 100644 --- a/crates/header-translator/src/rust_type.rs +++ b/crates/header-translator/src/rust_type.rs @@ -1279,7 +1279,11 @@ impl Ty { if *nullability != Nullability::NonNull { write!(f, "Option<")?; } - write!(f, "unsafe extern \"C\" fn(")?; + // Allow pointers that the user provides to unwind. + // + // This is not _necessarily_ safe, though in practice + // it will be for all of Apple's frameworks. + write!(f, "unsafe extern \"C-unwind\" fn(")?; for arg in arguments { write!(f, "{},", arg.plain())?; } diff --git a/crates/header-translator/src/stmt.rs b/crates/header-translator/src/stmt.rs index cb58061ce..9fbc88fe4 100644 --- a/crates/header-translator/src/stmt.rs +++ b/crates/header-translator/src/stmt.rs @@ -2370,7 +2370,9 @@ impl Stmt { body: None, safe: false, } => { - writeln!(f, "extern \"C\" {{")?; + // Functions are always C-unwind, since we don't know + // anything about them. + writeln!(f, "extern \"C-unwind\" {{")?; write!(f, " {}", self.cfg_gate_ln(config))?; write!(f, " {availability}")?; @@ -2395,14 +2397,14 @@ impl Stmt { write!(f, "{}", self.cfg_gate_ln(config))?; write!(f, "{availability}")?; writeln!(f, "#[inline]")?; - write!(f, "pub extern \"C\" fn {}(", id.name)?; + write!(f, "pub extern \"C-unwind\" fn {}(", id.name)?; for (param, arg_ty) in arguments { let param = handle_reserved(&crate::to_snake_case(param)); write!(f, "{param}: {},", arg_ty.fn_argument())?; } writeln!(f, "){} {{", result_type.fn_return())?; - writeln!(f, " extern \"C\" {{")?; + writeln!(f, " extern \"C-unwind\" {{")?; write!(f, " fn {}(", id.name)?; for (param, arg_ty) in arguments { diff --git a/crates/objc2-exception-helper/Cargo.toml b/crates/objc2-exception-helper/Cargo.toml index c2666bfa8..6c5113c18 100644 --- a/crates/objc2-exception-helper/Cargo.toml +++ b/crates/objc2-exception-helper/Cargo.toml @@ -38,14 +38,6 @@ gnustep-1-9 = ["gnustep-1-8"] gnustep-2-0 = ["gnustep-1-9"] gnustep-2-1 = ["gnustep-2-0"] -# Uses `extern "C-unwind"` on relevant function declarations. -# -# This raises MSRV to `1.71`. -# -# Warning: Enabling this is a breaking change for consumer crates, as it -# changes the signature of functions. -unstable-c-unwind = [] - [build-dependencies] cc = "1.0.80" diff --git a/crates/objc2-exception-helper/src/lib.rs b/crates/objc2-exception-helper/src/lib.rs index 236776459..f0b8ffb07 100644 --- a/crates/objc2-exception-helper/src/lib.rs +++ b/crates/objc2-exception-helper/src/lib.rs @@ -18,9 +18,6 @@ extern crate std; use core::ffi::c_void; -#[cfg(not(feature = "unstable-c-unwind"))] -type TryCatchClosure = extern "C" fn(*mut c_void); -#[cfg(feature = "unstable-c-unwind")] type TryCatchClosure = extern "C-unwind" fn(*mut c_void); // `try_catch` is deliberately `extern "C"`, we just prevented the unwind. @@ -59,11 +56,6 @@ mod tests { static VALUE: SyncPtr = SyncPtr(&VALUE.0 as *const *mut c_void as *mut c_void); - #[cfg(not(feature = "unstable-c-unwind"))] - extern "C" fn check_value(value: *mut c_void) { - assert_eq!(VALUE.0, value); - } - #[cfg(feature = "unstable-c-unwind")] extern "C-unwind" fn check_value(value: *mut c_void) { assert_eq!(VALUE.0, value); } diff --git a/crates/objc2/CHANGELOG.md b/crates/objc2/CHANGELOG.md index 328410d48..d720de4f7 100644 --- a/crates/objc2/CHANGELOG.md +++ b/crates/objc2/CHANGELOG.md @@ -120,6 +120,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). ### Fixed * Remove an incorrect assertion when adding protocols to classes in an unexpected order. +* **BREAKING**: Converted function signatures into using `extern "C-unwind"` + where applicable. This allows Rust and Objective-C unwinding to interoperate. ## 0.5.2 - 2024-05-21 diff --git a/crates/objc2/Cargo.toml b/crates/objc2/Cargo.toml index 66188f6f7..62e16f224 100644 --- a/crates/objc2/Cargo.toml +++ b/crates/objc2/Cargo.toml @@ -75,16 +75,6 @@ unstable-static-class-inlined = ["unstable-static-class"] # Uses nightly features to make autorelease pools fully sound unstable-autoreleasesafe = [] -# Uses `extern "C-unwind"` to make method calls that throw safe. -# -# This raises MSRV to `1.71`. -# -# You must manually enable `objc2-exception-helper/unstable-c-unwind` to use this. -# -# Warning: Enabling this is a breaking change for consumer crates, as it -# changes the signature of functions. -unstable-c-unwind = [] - # Enable some new features available on ARM64 on: # - macOS 13.0 # - iOS 16.0 @@ -154,7 +144,7 @@ harness = false [package.metadata.docs.rs] default-target = "aarch64-apple-darwin" -features = ["unstable-c-unwind", "exception"] +features = ["exception"] targets = [ "aarch64-apple-darwin", "x86_64-apple-darwin", diff --git a/crates/objc2/src/__macro_helpers/declared_ivars.rs b/crates/objc2/src/__macro_helpers/declared_ivars.rs index 0e6ef1937..54382beb7 100644 --- a/crates/objc2/src/__macro_helpers/declared_ivars.rs +++ b/crates/objc2/src/__macro_helpers/declared_ivars.rs @@ -141,7 +141,7 @@ where { // Add dealloc if the class or the ivars need dropping. if mem::needs_drop::() || mem::needs_drop::() { - let func: unsafe extern "C" fn(_, _) = dealloc::; + let func: unsafe extern "C-unwind" fn(_, _) = dealloc::; // SAFETY: The function signature is correct, and method contract is // upheld inside `dealloc`. unsafe { builder.add_method(sel!(dealloc), func) }; @@ -156,9 +156,7 @@ where /// - /// - /// - -/// -/// TODO: Change this to `extern "C-unwind"`, unwinding in dealloc is allowed. -unsafe extern "C" fn dealloc(this: NonNull, cmd: Sel) +unsafe extern "C-unwind" fn dealloc(this: NonNull, cmd: Sel) where T::Super: ClassType, { diff --git a/crates/objc2/src/encode.rs b/crates/objc2/src/encode.rs index 32d10fc4c..e18298200 100644 --- a/crates/objc2/src/encode.rs +++ b/crates/objc2/src/encode.rs @@ -419,11 +419,6 @@ macro_rules! encode_args_impl { // // SAFETY: We're transmuting an `unsafe` function pointer to // another `unsafe` function pointer. - #[cfg(not(feature = "unstable-c-unwind"))] - let msg_send_fn: unsafe extern "C" fn(*mut AnyObject, Sel $(, $T)*) -> R = unsafe { - mem::transmute(msg_send_fn) - }; - #[cfg(feature = "unstable-c-unwind")] let msg_send_fn: unsafe extern "C-unwind" fn(*mut AnyObject, Sel $(, $T)*) -> R = unsafe { mem::transmute(msg_send_fn) }; @@ -866,7 +861,6 @@ macro_rules! encode_fn_pointer_impl { }; ($($Arg: ident),*) => { encode_fn_pointer_impl!(# "C"; $($Arg),*); - #[cfg(feature = "unstable-c-unwind")] encode_fn_pointer_impl!(# "C-unwind"; $($Arg),*); }; } @@ -988,7 +982,6 @@ mod tests { >::ENCODING, Encoding::Pointer(&Encoding::Unknown) ); - #[cfg(feature = "unstable-c-unwind")] assert_eq!( ::ENCODING, Encoding::Pointer(&Encoding::Unknown) diff --git a/crates/objc2/src/exception.rs b/crates/objc2/src/exception.rs index fe2d90c2c..8c7d2c4e0 100644 --- a/crates/objc2/src/exception.rs +++ b/crates/objc2/src/exception.rs @@ -219,21 +219,14 @@ impl RefUnwindSafe for Exception {} /// /// This is the Objective-C equivalent of Rust's [`panic!`]. /// -/// -/// # Safety -/// -/// This unwinds from Objective-C, and the exception must be caught using an -/// Objective-C exception handler like [`catch`] (and specifically not -/// [`catch_unwind`]). -/// -/// This also invokes undefined behaviour unless `C-unwind` is used, which it -/// only is if the `unstable-c-unwind` feature flag is enabled (raises MSRV to -/// 1.71). +/// This unwinds from Objective-C, and the exception should be caught using an +/// Objective-C exception handler like [`catch`]. It _may_ be caught by +/// [`catch_unwind`], though the error message is unlikely to be great. /// /// [`catch_unwind`]: std::panic::catch_unwind #[inline] #[cfg(feature = "exception")] // For consistency, not strictly required -pub unsafe fn throw(exception: Retained) -> ! { +pub fn throw(exception: Retained) -> ! { // We consume the exception object since we can't make any guarantees // about its mutability. let ptr: *const AnyObject = &exception.0; @@ -245,23 +238,6 @@ pub unsafe fn throw(exception: Retained) -> ! { #[cfg(feature = "exception")] unsafe fn try_no_ret(closure: F) -> Result<(), Option>> { - #[cfg(not(feature = "unstable-c-unwind"))] - let f = { - extern "C" fn try_objc_execute_closure(closure: &mut Option) - where - F: FnOnce(), - { - // This is always passed Some, so it's safe to unwrap - let closure = closure.take().unwrap(); - closure(); - } - - let f: extern "C" fn(&mut Option) = try_objc_execute_closure; - let f: extern "C" fn(*mut c_void) = unsafe { mem::transmute(f) }; - f - }; - - #[cfg(feature = "unstable-c-unwind")] let f = { extern "C-unwind" fn try_objc_execute_closure(closure: &mut Option) where @@ -327,10 +303,6 @@ unsafe fn try_no_ret(closure: F) -> Result<(), Option( closure: impl FnOnce() -> R + UnwindSafe, @@ -351,6 +323,7 @@ mod tests { use alloc::format; use alloc::string::ToString; use core::panic::AssertUnwindSafe; + use std::panic::catch_unwind; use super::*; use crate::msg_send_id; @@ -372,7 +345,6 @@ mod tests { all(target_vendor = "apple", target_os = "macos", target_arch = "x86"), ignore = "`NULL` exceptions are invalid on 32-bit / w. fragile runtime" )] - #[cfg_attr(feature = "gnustep-1-7", ignore = "requires C-unwind")] fn test_catch_null() { let s = "Hello".to_string(); let result = unsafe { @@ -408,7 +380,6 @@ mod tests { } #[test] - #[cfg_attr(feature = "gnustep-1-7", ignore = "requires C-unwind")] fn test_throw_catch_object() { let obj = NSObject::new(); // TODO: Investigate why this is required on GNUStep! @@ -423,4 +394,14 @@ mod tests { assert!(ptr::eq(&*obj, ptr)); } + + #[test] + #[ignore = "currently aborts"] + fn throw_catch_unwind() { + let obj = NSObject::new(); + let obj: Retained = unsafe { Retained::cast(obj) }; + + let result = catch_unwind(|| throw(obj)); + let _ = result.unwrap_err(); + } } diff --git a/crates/objc2/src/ffi/mod.rs b/crates/objc2/src/ffi/mod.rs index 2a3c001bb..04ba4e336 100644 --- a/crates/objc2/src/ffi/mod.rs +++ b/crates/objc2/src/ffi/mod.rs @@ -225,16 +225,6 @@ macro_rules! extern_c_unwind { ) $(-> $r:ty)?; )+ } => { - #[cfg(not(feature = "unstable-c-unwind"))] - generate_linking_tests! { - extern "C" {$( - $(#[$m])* - $v fn $name($($(#[$a_m])* $a: $t),*) $(-> $r)?; - )+} - mod test_linkable_unwind; - } - - #[cfg(feature = "unstable-c-unwind")] generate_linking_tests! { extern "C-unwind" {$( $(#[$m])* diff --git a/crates/objc2/src/ffi/types.rs b/crates/objc2/src/ffi/types.rs index 2aaf78726..4cfa45227 100644 --- a/crates/objc2/src/ffi/types.rs +++ b/crates/objc2/src/ffi/types.rs @@ -85,7 +85,7 @@ pub type NSInteger = isize; /// ``` /// use objc2::ffi::NSUInteger; /// -/// extern "C" { +/// extern "C-unwind" { /// fn some_external_function() -> NSUInteger; /// } /// ``` diff --git a/crates/objc2/src/ffi/various.rs b/crates/objc2/src/ffi/various.rs index f217aa31d..4eaa150b2 100644 --- a/crates/objc2/src/ffi/various.rs +++ b/crates/objc2/src/ffi/various.rs @@ -56,7 +56,7 @@ extern_c! { #[cfg(any(doc, target_vendor = "apple", feature = "unstable-objfw"))] pub fn objc_setEnumerationMutationHandler( - handler: Option, + handler: Option, ); #[cfg(any(doc, not(feature = "unstable-objfw")))] diff --git a/crates/objc2/src/lib.rs b/crates/objc2/src/lib.rs index 867466072..58157726c 100644 --- a/crates/objc2/src/lib.rs +++ b/crates/objc2/src/lib.rs @@ -154,7 +154,7 @@ // Note: `doc_notable_trait` doesn't really make sense for us, it's only shown // for functions returning a specific trait. #![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg, doc_cfg_hide))] -#![cfg_attr(docsrs, doc(cfg_hide(doc, feature = "unstable-c-unwind")))] +#![cfg_attr(docsrs, doc(cfg_hide(doc)))] #![warn(missing_docs)] #![warn(clippy::missing_errors_doc)] #![warn(clippy::missing_panics_doc)] diff --git a/crates/objc2/src/macros/declare_class.rs b/crates/objc2/src/macros/declare_class.rs index 245fa1529..d52794eda 100644 --- a/crates/objc2/src/macros/declare_class.rs +++ b/crates/objc2/src/macros/declare_class.rs @@ -969,7 +969,7 @@ macro_rules! __declare_class_method_out_inner { } => { $($m_checked)* #[allow(clippy::diverging_sub_expression)] - $($qualifiers)* extern "C" fn $name( + $($qualifiers)* extern "C-unwind" fn $name( $($params_prefix)* $($params_converted)* ) $(-> <$ret as $crate::__macro_helpers::ConvertReturn>::__Inner)? { @@ -1002,7 +1002,7 @@ macro_rules! __declare_class_method_out_inner { } => { $($m_checked)* #[allow(clippy::diverging_sub_expression)] - $($qualifiers)* extern "C" fn $name( + $($qualifiers)* extern "C-unwind" fn $name( $($params_prefix)* $($params_converted)* ) -> $crate::__macro_helpers::IdReturnValue { @@ -1047,7 +1047,7 @@ macro_rules! __declare_class_method_out_inner { ($($body_prefix:tt)*) } => { $($m_checked)* - $($qualifiers)* extern "C" fn $name() { + $($qualifiers)* extern "C-unwind" fn $name() { $crate::__macro_helpers::compile_error!("`#[method_id(...)]` must have a return type") } }; @@ -1165,7 +1165,7 @@ macro_rules! __fn_ptr { ($($output:tt)*) $(,)? ) => { - $($qualifiers)* extern "C" fn($($output)*) -> _ + $($qualifiers)* extern "C-unwind" fn($($output)*) -> _ }; ( ($($qualifiers:tt)*) diff --git a/crates/objc2/src/macros/mod.rs b/crates/objc2/src/macros/mod.rs index dbeac7b38..6290437a9 100644 --- a/crates/objc2/src/macros/mod.rs +++ b/crates/objc2/src/macros/mod.rs @@ -831,9 +831,9 @@ macro_rules! __class_inner { /// /// # Panics /// -/// Panics if the `"catch-all"` feature is enabled and the Objective-C method -/// throws an exception. Exceptions may still cause UB unless you enable the -/// `"unstable-c-unwind"` feature (raises MSRV to 1.71). +/// Unwinds if the underlying method throws and exception. If the +/// `"catch-all"` Cargo feature is enabled, the Objective-C exception is +/// converted into a Rust panic, with potentially a bit better stack trace. /// /// Panics if `debug_assertions` are enabled and the Objective-C method's /// encoding does not match the encoding of the given arguments and return. diff --git a/crates/objc2/src/main_thread_marker.rs b/crates/objc2/src/main_thread_marker.rs index 266d9e9d5..fd5122743 100644 --- a/crates/objc2/src/main_thread_marker.rs +++ b/crates/objc2/src/main_thread_marker.rs @@ -18,6 +18,8 @@ fn is_main_thread() -> bool { // `pthread_main_np` is included via. `libSystem` when `libstd` is // linked. All of this is done to avoid a dependency on the `libc` // crate. + // + // `extern "C"` is safe because this will never unwind. #[cfg_attr(not(feature = "std"), link(name = "c", kind = "dylib"))] extern "C" { fn pthread_main_np() -> core::ffi::c_int; diff --git a/crates/objc2/src/rc/id.rs b/crates/objc2/src/rc/id.rs index 111891660..f2039722d 100644 --- a/crates/objc2/src/rc/id.rs +++ b/crates/objc2/src/rc/id.rs @@ -486,7 +486,7 @@ impl Retained { // "call {}", // sym objc2::ffi::objc_retainAutoreleasedReturnValue, // inout("rax") obj, - // clobber_abi("C"), + // clobber_abi("C-unwind"), // ); } @@ -604,7 +604,7 @@ impl Retained { /// /// let mut builder = ClassBuilder::new("ExampleObject", class!(NSObject)).unwrap(); /// - /// extern "C" fn get(cls: &AnyClass, _cmd: Sel) -> *mut AnyObject { + /// extern "C-unwind" fn get(cls: &AnyClass, _cmd: Sel) -> *mut AnyObject { /// let obj: Retained = unsafe { msg_send_id![cls, new] }; /// Retained::autorelease_return(obj) /// } @@ -612,7 +612,7 @@ impl Retained { /// unsafe { /// builder.add_class_method( /// sel!(get), - /// get as extern "C" fn(_, _) -> _, + /// get as extern "C-unwind" fn(_, _) -> _, /// ); /// } /// diff --git a/crates/objc2/src/runtime/declare.rs b/crates/objc2/src/runtime/declare.rs index d3ea272ce..06fcf3ee9 100644 --- a/crates/objc2/src/runtime/declare.rs +++ b/crates/objc2/src/runtime/declare.rs @@ -73,7 +73,7 @@ impl Log2Alignment for T { /// // We "cheat" a bit here, and use `AnyObject` instead of `NSObject`, /// // since only the former is allowed to be a mutable receiver (which is /// // always safe in `init` methods, but not in others). -/// unsafe extern "C" fn init_with_number( +/// unsafe extern "C-unwind" fn init_with_number( /// this: &mut AnyObject, /// _cmd: Sel, /// number: u32, @@ -89,12 +89,12 @@ impl Log2Alignment for T { /// unsafe { /// builder.add_method( /// sel!(initWithNumber:), -/// init_with_number as unsafe extern "C" fn(_, _, _) -> _, +/// init_with_number as unsafe extern "C-unwind" fn(_, _, _) -> _, /// ); /// } /// /// // Add convenience method for getting a new instance with the number -/// extern "C" fn with_number( +/// extern "C-unwind" fn with_number( /// cls: &AnyClass, /// _cmd: Sel, /// number: u32, @@ -110,28 +110,28 @@ impl Log2Alignment for T { /// unsafe { /// builder.add_class_method( /// sel!(withNumber:), -/// with_number as extern "C" fn(_, _, _) -> _, +/// with_number as extern "C-unwind" fn(_, _, _) -> _, /// ); /// } /// /// // Add an Objective-C method for setting the number -/// extern "C" fn my_number_set(this: &NSObject, _cmd: Sel, number: u32) { +/// extern "C-unwind" fn my_number_set(this: &NSObject, _cmd: Sel, number: u32) { /// let ivar = AnyClass::get("MyNumber").unwrap().instance_variable("_number").unwrap(); /// // SAFETY: The ivar is added with the same type above /// unsafe { ivar.load::>(this) }.set(number); /// } /// unsafe { -/// builder.add_method(sel!(setNumber:), my_number_set as extern "C" fn(_, _, _)); +/// builder.add_method(sel!(setNumber:), my_number_set as extern "C-unwind" fn(_, _, _)); /// } /// /// // Add an Objective-C method for getting the number -/// extern "C" fn my_number_get(this: &NSObject, _cmd: Sel) -> u32 { +/// extern "C-unwind" fn my_number_get(this: &NSObject, _cmd: Sel) -> u32 { /// let ivar = AnyClass::get("MyNumber").unwrap().instance_variable("_number").unwrap(); /// // SAFETY: The ivar is added with the same type above /// unsafe { ivar.load::>(this) }.get() /// } /// unsafe { -/// builder.add_method(sel!(number), my_number_get as extern "C" fn(_, _) -> _); +/// builder.add_method(sel!(number), my_number_get as extern "C-unwind" fn(_, _) -> _); /// } /// /// builder.register() diff --git a/crates/objc2/src/runtime/method_implementation.rs b/crates/objc2/src/runtime/method_implementation.rs index 1c80ba24a..c61036767 100644 --- a/crates/objc2/src/runtime/method_implementation.rs +++ b/crates/objc2/src/runtime/method_implementation.rs @@ -90,9 +90,7 @@ macro_rules! method_impl { ($($t:ident),*) => { method_impl_inner!((unsafe) "C"; $($t),*); method_impl_inner!("C"; $($t),*); - #[cfg(feature = "unstable-c-unwind")] method_impl_inner!((unsafe) "C-unwind"; $($t),*); - #[cfg(feature = "unstable-c-unwind")] method_impl_inner!("C-unwind"; $($t),*); }; } diff --git a/crates/objc2/src/runtime/mod.rs b/crates/objc2/src/runtime/mod.rs index a6ff96a34..e856d4e63 100644 --- a/crates/objc2/src/runtime/mod.rs +++ b/crates/objc2/src/runtime/mod.rs @@ -124,11 +124,6 @@ macro_rules! standard_pointer_impls { }; } -#[cfg(not(feature = "unstable-c-unwind"))] -type InnerImp = unsafe extern "C" fn(); -#[cfg(feature = "unstable-c-unwind")] -type InnerImp = unsafe extern "C-unwind" fn(); - /// A pointer to the start of a method implementation. /// /// The first argument is a pointer to the receiver, the second argument is @@ -143,7 +138,7 @@ type InnerImp = unsafe extern "C-unwind" fn(); /// Also note that this is non-null! If you require an Imp that can be null, /// use `Option`. #[doc(alias = "IMP")] -pub type Imp = InnerImp; +pub type Imp = unsafe extern "C-unwind" fn(); /// A method selector. /// diff --git a/crates/objc2/src/runtime/retain_release_fast.rs b/crates/objc2/src/runtime/retain_release_fast.rs index 5d023d497..fe6fade4b 100644 --- a/crates/objc2/src/runtime/retain_release_fast.rs +++ b/crates/objc2/src/runtime/retain_release_fast.rs @@ -72,6 +72,8 @@ pub(crate) unsafe fn objc_retain_fast(obj: *mut AnyObject) -> *mut AnyObject { // As per the ARM64 calling convention, the return value is put in `x0`. // // That the function itself is safe to call is upheld by the caller. + // + // TODO: Unwinding. unsafe { let result; core::arch::asm!( @@ -105,6 +107,8 @@ pub(crate) unsafe fn objc_release_fast(obj: *mut AnyObject) { // SAFETY: See the file header. // // That the function itself is safe to call is upheld by the caller. + // + // TODO: Unwinding. unsafe { core::arch::asm!( "bl _objc_release_{obj:x}", diff --git a/crates/objc2/src/test_utils.rs b/crates/objc2/src/test_utils.rs index 314d68a32..527f12164 100644 --- a/crates/objc2/src/test_utils.rs +++ b/crates/objc2/src/test_utils.rs @@ -60,11 +60,11 @@ pub(crate) fn custom_class() -> &'static AnyClass { REGISTER_CUSTOM_CLASS.call_once(|| { // The runtime will call this method, so it has to be implemented - extern "C" fn custom_obj_class_initialize(_this: &AnyClass, _cmd: Sel) {} + extern "C-unwind" fn custom_obj_class_initialize(_this: &AnyClass, _cmd: Sel) {} let mut builder = ClassBuilder::root( "CustomObject", - custom_obj_class_initialize as extern "C" fn(_, _), + custom_obj_class_initialize as extern "C-unwind" fn(_, _), ) .unwrap(); let proto = custom_protocol(); @@ -72,29 +72,29 @@ pub(crate) fn custom_class() -> &'static AnyClass { builder.add_protocol(proto); builder.add_ivar::("_foo"); - unsafe extern "C" fn custom_obj_release(this: *mut AnyObject, _cmd: Sel) { + unsafe extern "C-unwind" fn custom_obj_release(this: *mut AnyObject, _cmd: Sel) { unsafe { #[allow(deprecated)] ffi::object_dispose(this); } } - extern "C" fn custom_obj_set_foo(this: &AnyObject, _cmd: Sel, foo: u32) { + extern "C-unwind" fn custom_obj_set_foo(this: &AnyObject, _cmd: Sel, foo: u32) { let ivar = this.class().instance_variable("_foo").unwrap(); unsafe { *ivar.load_ptr::(this) = foo } } - extern "C" fn custom_obj_get_foo(this: &AnyObject, _cmd: Sel) -> u32 { + extern "C-unwind" fn custom_obj_get_foo(this: &AnyObject, _cmd: Sel) -> u32 { let ivar = this.class().instance_variable("_foo").unwrap(); unsafe { *ivar.load::(this) } } - extern "C" fn custom_obj_get_foo_reference(this: &AnyObject, _cmd: Sel) -> &u32 { + extern "C-unwind" fn custom_obj_get_foo_reference(this: &AnyObject, _cmd: Sel) -> &u32 { let ivar = this.class().instance_variable("_foo").unwrap(); unsafe { ivar.load::(this) } } - extern "C" fn custom_obj_get_struct(_this: &AnyObject, _cmd: Sel) -> CustomStruct { + extern "C-unwind" fn custom_obj_get_struct(_this: &AnyObject, _cmd: Sel) -> CustomStruct { CustomStruct { a: 1, b: 2, @@ -103,20 +103,20 @@ pub(crate) fn custom_class() -> &'static AnyClass { } } - extern "C" fn custom_obj_class_method(_this: &AnyClass, _cmd: Sel) -> u32 { + extern "C-unwind" fn custom_obj_class_method(_this: &AnyClass, _cmd: Sel) -> u32 { 7 } - extern "C" fn get_nsinteger(_this: &AnyObject, _cmd: Sel) -> ffi::NSInteger { + extern "C-unwind" fn get_nsinteger(_this: &AnyObject, _cmd: Sel) -> ffi::NSInteger { 5 } - extern "C" fn custom_obj_set_bar(this: &AnyObject, _cmd: Sel, bar: u32) { + extern "C-unwind" fn custom_obj_set_bar(this: &AnyObject, _cmd: Sel, bar: u32) { let ivar = this.class().instance_variable("_bar").unwrap(); unsafe { *ivar.load_ptr::(this) = bar } } - extern "C" fn custom_obj_add_number_to_number( + extern "C-unwind" fn custom_obj_add_number_to_number( _this: &AnyClass, _cmd: Sel, fst: i32, @@ -125,7 +125,7 @@ pub(crate) fn custom_class() -> &'static AnyClass { fst + snd } - extern "C" fn custom_obj_multiple_colon( + extern "C-unwind" fn custom_obj_multiple_colon( _obj: &AnyObject, _cmd: Sel, arg1: i32, @@ -136,7 +136,7 @@ pub(crate) fn custom_class() -> &'static AnyClass { arg1 * arg2 * arg3 * arg4 } - extern "C" fn custom_obj_multiple_colon_class( + extern "C-unwind" fn custom_obj_multiple_colon_class( _cls: &AnyClass, _cmd: Sel, arg1: i32, @@ -150,43 +150,43 @@ pub(crate) fn custom_class() -> &'static AnyClass { unsafe { // On GNUStep 2.0, it is required to have `dealloc` methods for some reason if cfg!(all(feature = "gnustep-2-0", not(feature = "gnustep-2-1"))) { - unsafe extern "C" fn forward_to_dealloc(this: *mut AnyObject, _cmd: Sel) { + unsafe extern "C-unwind" fn forward_to_dealloc(this: *mut AnyObject, _cmd: Sel) { unsafe { msg_send![this, dealloc] } } - let release: unsafe extern "C" fn(_, _) = forward_to_dealloc; + let release: unsafe extern "C-unwind" fn(_, _) = forward_to_dealloc; builder.add_method(sel!(release), release); - let release: unsafe extern "C" fn(_, _) = custom_obj_release; + let release: unsafe extern "C-unwind" fn(_, _) = custom_obj_release; builder.add_method(sel!(dealloc), release); } else { - let release: unsafe extern "C" fn(_, _) = custom_obj_release; + let release: unsafe extern "C-unwind" fn(_, _) = custom_obj_release; builder.add_method(sel!(release), release); } - let set_foo: extern "C" fn(_, _, _) = custom_obj_set_foo; + let set_foo: extern "C-unwind" fn(_, _, _) = custom_obj_set_foo; builder.add_method(sel!(setFoo:), set_foo); - let get_foo: extern "C" fn(_, _) -> _ = custom_obj_get_foo; + let get_foo: extern "C-unwind" fn(_, _) -> _ = custom_obj_get_foo; builder.add_method(sel!(foo), get_foo); - let get_foo_reference: extern "C" fn(_, _) -> _ = custom_obj_get_foo_reference; + let get_foo_reference: extern "C-unwind" fn(_, _) -> _ = custom_obj_get_foo_reference; builder.add_method(sel!(fooReference), get_foo_reference); - let get_struct: extern "C" fn(_, _) -> CustomStruct = custom_obj_get_struct; + let get_struct: extern "C-unwind" fn(_, _) -> CustomStruct = custom_obj_get_struct; builder.add_method(sel!(customStruct), get_struct); - let class_method: extern "C" fn(_, _) -> _ = custom_obj_class_method; + let class_method: extern "C-unwind" fn(_, _) -> _ = custom_obj_class_method; builder.add_class_method(sel!(classFoo), class_method); - let get_nsinteger: extern "C" fn(_, _) -> _ = get_nsinteger; + let get_nsinteger: extern "C-unwind" fn(_, _) -> _ = get_nsinteger; builder.add_method(sel!(getNSInteger), get_nsinteger); - let protocol_instance_method: extern "C" fn(_, _, _) = custom_obj_set_bar; + let protocol_instance_method: extern "C-unwind" fn(_, _, _) = custom_obj_set_bar; builder.add_method(sel!(setBar:), protocol_instance_method); - let protocol_class_method: extern "C" fn(_, _, _, _) -> _ = + let protocol_class_method: extern "C-unwind" fn(_, _, _, _) -> _ = custom_obj_add_number_to_number; builder.add_class_method(sel!(addNumber:toNumber:), protocol_class_method); - let f: extern "C" fn(_, _, _, _, _, _) -> _ = custom_obj_multiple_colon; + let f: extern "C-unwind" fn(_, _, _, _, _, _) -> _ = custom_obj_multiple_colon; builder.add_method(sel!(test::test::), f); - let f: extern "C" fn(_, _, _, _, _, _) -> _ = custom_obj_multiple_colon_class; + let f: extern "C-unwind" fn(_, _, _, _, _, _) -> _ = custom_obj_multiple_colon_class; builder.add_class_method(sel!(test::test::), f); } @@ -241,19 +241,19 @@ pub(crate) fn custom_subclass() -> &'static AnyClass { let superclass = custom_class(); let mut builder = ClassBuilder::new("CustomSubclassObject", superclass).unwrap(); - extern "C" fn custom_subclass_get_foo(this: &AnyObject, _cmd: Sel) -> u32 { + extern "C-unwind" fn custom_subclass_get_foo(this: &AnyObject, _cmd: Sel) -> u32 { let foo: u32 = unsafe { msg_send![super(this, custom_class()), foo] }; foo + 2 } - extern "C" fn custom_subclass_class_method(_cls: &AnyClass, _cmd: Sel) -> u32 { + extern "C-unwind" fn custom_subclass_class_method(_cls: &AnyClass, _cmd: Sel) -> u32 { 9 } unsafe { - let get_foo: extern "C" fn(_, _) -> _ = custom_subclass_get_foo; + let get_foo: extern "C-unwind" fn(_, _) -> _ = custom_subclass_get_foo; builder.add_method(sel!(foo), get_foo); - let class_method: extern "C" fn(_, _) -> _ = custom_subclass_class_method; + let class_method: extern "C-unwind" fn(_, _) -> _ = custom_subclass_class_method; builder.add_class_method(sel!(classFoo), class_method); } diff --git a/crates/objc2/src/topics/about_generated/CHANGELOG.md b/crates/objc2/src/topics/about_generated/CHANGELOG.md index 192fb3911..ff8e096d2 100644 --- a/crates/objc2/src/topics/about_generated/CHANGELOG.md +++ b/crates/objc2/src/topics/about_generated/CHANGELOG.md @@ -67,6 +67,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - `UIDocumentProperties::metadata` - `UIDocumentProperties::setMetadata` +### Fixed +* **BREAKING**: Converted function signatures into using `extern "C-unwind"`. + This allows Rust and Objective-C unwinding to interoperate. + ## 0.2.2 - 2024-05-21 diff --git a/crates/objc2/src/topics/alternatives.md b/crates/objc2/src/topics/alternatives.md index b9c7cbd3b..d160afca3 100644 --- a/crates/objc2/src/topics/alternatives.md +++ b/crates/objc2/src/topics/alternatives.md @@ -47,7 +47,7 @@ And then exposed to Rust like this: use libc::free; use std::ffi::{c_char, c_void, CStr, CString}; -extern "C" { +extern "C-unwind" { fn copy_current_locale_identifier() -> *const c_char; } diff --git a/crates/objc2/src/topics/layered_safety.md b/crates/objc2/src/topics/layered_safety.md index 308221094..a36ce5d5b 100644 --- a/crates/objc2/src/topics/layered_safety.md +++ b/crates/objc2/src/topics/layered_safety.md @@ -52,8 +52,7 @@ the cost. Doing the Rust equivalent of Objective-C's `NSUInteger hash_code = [obj hash];`. -```rust, ignore -# // Fails with `unstable-c-unwind`, so disabled for now. +```rust use std::mem::transmute; use std::ffi::c_char; use objc2::ffi::{objc_msgSend, sel_registerName, NSUInteger}; @@ -64,8 +63,8 @@ let obj: *const AnyObject; let sel = unsafe { sel_registerName(b"hash\0".as_ptr() as *const c_char).unwrap() }; let msg_send_fn = unsafe { transmute::< - unsafe extern "C" fn(), - unsafe extern "C" fn(*const AnyObject, Sel) -> NSUInteger, + unsafe extern "C-unwind" fn(), + unsafe extern "C-unwind" fn(*const AnyObject, Sel) -> NSUInteger, >(objc_msgSend) }; let hash_code = unsafe { msg_send_fn(obj, sel) }; diff --git a/crates/objc2/tests/declare_class.rs b/crates/objc2/tests/declare_class.rs index 742c7a90e..0ecfffa9c 100644 --- a/crates/objc2/tests/declare_class.rs +++ b/crates/objc2/tests/declare_class.rs @@ -416,7 +416,10 @@ extern_methods!( #[test] #[should_panic = "`&mut Retained<_>` is not supported in `declare_class!` yet"] -#[ignore = "unwinds through FFI boundary, requires C-unwind"] +#[cfg_attr( + feature = "gnustep-1-7", + ignore = "unwinding seems to not work properly here" +)] fn out_param1() { let mut param = OutParam::new(); OutParam::unsupported1(&mut param); @@ -424,14 +427,20 @@ fn out_param1() { #[test] #[should_panic = "`Option<&mut Retained<_>>` is not supported in `declare_class!` yet"] -#[ignore = "unwinds through FFI boundary, requires C-unwind"] +#[cfg_attr( + feature = "gnustep-1-7", + ignore = "unwinding seems to not work properly here" +)] fn out_param2() { OutParam::unsupported2(None); } #[test] #[should_panic = "`&mut Option>` is not supported in `declare_class!` yet"] -#[ignore = "unwinds through FFI boundary, requires C-unwind"] +#[cfg_attr( + feature = "gnustep-1-7", + ignore = "unwinding seems to not work properly here" +)] fn out_param3() { let mut param = Some(OutParam::new()); OutParam::unsupported3(&mut param); @@ -439,7 +448,10 @@ fn out_param3() { #[test] #[should_panic = "`Option<&mut Option>>` is not supported in `declare_class!` yet"] -#[ignore = "unwinds through FFI boundary, requires C-unwind"] +#[cfg_attr( + feature = "gnustep-1-7", + ignore = "unwinding seems to not work properly here" +)] fn out_param4() { OutParam::unsupported4(None); } diff --git a/crates/objc2/tests/track_caller.rs b/crates/objc2/tests/track_caller.rs index 678f3d3f2..73d63fee6 100644 --- a/crates/objc2/tests/track_caller.rs +++ b/crates/objc2/tests/track_caller.rs @@ -1,8 +1,4 @@ -#![cfg(all( - target_pointer_width = "64", - feature = "unstable-c-unwind", - not(feature = "catch-all") -))] +#![cfg(all(target_pointer_width = "64", not(feature = "catch-all")))] #![allow(dead_code)] //! Test that our use of #[track_caller] is making the correct line number //! show up. @@ -14,7 +10,9 @@ use std::sync::Mutex; use objc2::encode::Encode; use objc2::rc::{self, Allocated, Retained}; use objc2::runtime::{self, NSObject}; -use objc2::{class, declare_class, msg_send, msg_send_id, ClassType, DeclaredClass}; +use objc2::{ + class, declare_class, msg_send, msg_send_id, AllocAnyThread, ClassType, DeclaredClass, +}; #[path = "../src/rc/test_object.rs"] #[allow(dead_code)] diff --git a/crates/test-assembly/crates/test_block/expected/apple-aarch64.s b/crates/test-assembly/crates/test_block/expected/apple-aarch64.s index da786e1e3..fb2558389 100644 --- a/crates/test-assembly/crates/test_block/expected/apple-aarch64.s +++ b/crates/test-assembly/crates/test_block/expected/apple-aarch64.s @@ -113,9 +113,9 @@ Lloh4: Lloh5: add x8, x8, SYM(<_ as block2[CRATE_ID]::traits::IntoBlock<(_,), _>>::__get_invoke_stack_block::invoke::, 0)@PAGEOFF Lloh6: - adrp x9, l_anon.[ID].2@PAGE + adrp x9, l_anon.[ID].0@PAGE Lloh7: - add x9, x9, l_anon.[ID].2@PAGEOFF + add x9, x9, l_anon.[ID].0@PAGEOFF stp x8, x9, [sp, #16] mov x0, sp bl __Block_copy @@ -145,9 +145,9 @@ Lloh10: Lloh11: add x8, x8, SYM(<_ as block2[CRATE_ID]::traits::IntoBlock<(_,), _>>::__get_invoke_stack_block::invoke::, 0)@PAGEOFF Lloh12: - adrp x9, l_anon.[ID].1@PAGE + adrp x9, l_anon.[ID].4@PAGE Lloh13: - add x9, x9, l_anon.[ID].1@PAGEOFF + add x9, x9, l_anon.[ID].4@PAGEOFF stp x8, x9, [sp, #16] mov x0, sp bl __Block_copy @@ -178,9 +178,9 @@ Lloh17: add x10, x10, SYM(<_ as block2[CRATE_ID]::traits::IntoBlock<(_,), _>>::__get_invoke_stack_block::invoke::, 0)@PAGEOFF stp x8, x9, [sp, #8] Lloh18: - adrp x8, l_anon.[ID].0@PAGE + adrp x8, l_anon.[ID].3@PAGE Lloh19: - add x8, x8, l_anon.[ID].0@PAGEOFF + add x8, x8, l_anon.[ID].3@PAGEOFF stp x10, x8, [sp, #24] str x0, [sp, #40] add x0, sp, #8 @@ -212,9 +212,9 @@ Lloh22: Lloh23: add x8, x8, SYM(<_ as block2[CRATE_ID]::traits::IntoBlock<(_,), _>>::__get_invoke_stack_block::invoke::, 0)@PAGEOFF Lloh24: - adrp x9, l_anon.[ID].3@PAGE + adrp x9, l_anon.[ID].1@PAGE Lloh25: - add x9, x9, l_anon.[ID].3@PAGEOFF + add x9, x9, l_anon.[ID].1@PAGEOFF stp x8, x9, [sp, #16] mov x0, sp bl _needs_block @@ -244,9 +244,9 @@ Lloh29: add x10, x10, SYM(<_ as block2[CRATE_ID]::traits::IntoBlock<(_,), _>>::__get_invoke_stack_block::invoke::, 0)@PAGEOFF stp x8, x9, [sp, #8] Lloh30: - adrp x8, l_anon.[ID].4@PAGE + adrp x8, l_anon.[ID].2@PAGE Lloh31: - add x8, x8, l_anon.[ID].4@PAGEOFF + add x8, x8, l_anon.[ID].2@PAGEOFF stp x10, x8, [sp, #24] str x0, [sp, #40] add x0, sp, #8 @@ -280,9 +280,9 @@ Lloh34: Lloh35: add x8, x8, SYM(<_ as block2[CRATE_ID]::traits::IntoBlock<(_,), _>>::__get_invoke_stack_block::invoke::, 0)@PAGEOFF Lloh36: - adrp x9, l_anon.[ID].1@PAGE + adrp x9, l_anon.[ID].4@PAGE Lloh37: - add x9, x9, l_anon.[ID].1@PAGEOFF + add x9, x9, l_anon.[ID].4@PAGEOFF stp x8, x9, [sp, #16] mov x0, sp bl __Block_copy @@ -304,32 +304,31 @@ LBB19_2: .section __DATA,__const .p2align 3, 0x0 l_anon.[ID].0: - .asciz "\000\000\000\000\000\000\000\000(\000\000\000\000\000\000" - .quad SYM(>::empty_clone_closure, 0) - .quad SYM(>::drop_closure, 0) - - .section __TEXT,__literal16,16byte_literals - .p2align 3, 0x0 -l_anon.[ID].1: - .asciz "\000\000\000\000\000\000\000\000 \000\000\000\000\000\000" - - .section __DATA,__const - .p2align 3, 0x0 -l_anon.[ID].2: .asciz "\000\000\000\000\000\000\000\000 \000\000\000\000\000\000" .quad SYM(>::clone_closure, 0) .quad SYM(>::drop_closure, 0) .p2align 3, 0x0 -l_anon.[ID].3: +l_anon.[ID].1: .asciz "\000\000\000\000\000\000\000\000 \000\000\000\000\000\000" .quad SYM(>::clone_closure, 0) .quad SYM(>::drop_closure, 0) .p2align 3, 0x0 -l_anon.[ID].4: +l_anon.[ID].2: .asciz "\000\000\000\000\000\000\000\000(\000\000\000\000\000\000" .quad SYM(>::clone_closure, 0) .quad SYM(>::drop_closure, 0) + .p2align 3, 0x0 +l_anon.[ID].3: + .asciz "\000\000\000\000\000\000\000\000(\000\000\000\000\000\000" + .quad SYM(>::empty_clone_closure, 0) + .quad SYM(>::drop_closure, 0) + + .section __TEXT,__literal16,16byte_literals + .p2align 3, 0x0 +l_anon.[ID].4: + .asciz "\000\000\000\000\000\000\000\000 \000\000\000\000\000\000" + .subsections_via_symbols diff --git a/crates/test-assembly/crates/test_block/expected/apple-x86_64.s b/crates/test-assembly/crates/test_block/expected/apple-x86_64.s index a36807e98..15b0fa466 100644 --- a/crates/test-assembly/crates/test_block/expected/apple-x86_64.s +++ b/crates/test-assembly/crates/test_block/expected/apple-x86_64.s @@ -146,7 +146,7 @@ _stack_block_to_rc: mov qword ptr [rbp - 24], 33554432 lea rax, [rip + SYM(<_ as block2[CRATE_ID]::traits::IntoBlock<(_,), _>>::__get_invoke_stack_block::invoke::, 0)] mov qword ptr [rbp - 16], rax - lea rax, [rip + l_anon.[ID].2] + lea rax, [rip + l_anon.[ID].0] mov qword ptr [rbp - 8], rax lea rdi, [rbp - 32] call __Block_copy @@ -169,7 +169,7 @@ _rc_block: mov qword ptr [rbp - 24], 0 lea rax, [rip + SYM(<_ as block2[CRATE_ID]::traits::IntoBlock<(_,), _>>::__get_invoke_stack_block::invoke::, 0)] mov qword ptr [rbp - 16], rax - lea rax, [rip + L_anon.[ID].1] + lea rax, [rip + L_anon.[ID].4] mov qword ptr [rbp - 8], rax lea rdi, [rbp - 32] call __Block_copy @@ -192,7 +192,7 @@ _rc_block_drop: mov qword ptr [rbp - 32], 33554432 lea rax, [rip + SYM(<_ as block2[CRATE_ID]::traits::IntoBlock<(_,), _>>::__get_invoke_stack_block::invoke::, 0)] mov qword ptr [rbp - 24], rax - lea rax, [rip + l_anon.[ID].0] + lea rax, [rip + l_anon.[ID].3] mov qword ptr [rbp - 16], rax mov qword ptr [rbp - 8], rdi lea rdi, [rbp - 40] @@ -216,7 +216,7 @@ _create_and_use_stack_block: mov qword ptr [rbp - 24], 33554432 lea rax, [rip + SYM(<_ as block2[CRATE_ID]::traits::IntoBlock<(_,), _>>::__get_invoke_stack_block::invoke::, 0)] mov qword ptr [rbp - 16], rax - lea rax, [rip + l_anon.[ID].3] + lea rax, [rip + l_anon.[ID].1] mov qword ptr [rbp - 8], rax lea rdi, [rbp - 32] call _needs_block @@ -237,7 +237,7 @@ _create_and_use_stack_block_drop: mov qword ptr [rbp - 40], 33554432 lea rax, [rip + SYM(<_ as block2[CRATE_ID]::traits::IntoBlock<(_,), _>>::__get_invoke_stack_block::invoke::, 0)] mov qword ptr [rbp - 32], rax - lea rax, [rip + l_anon.[ID].4] + lea rax, [rip + l_anon.[ID].2] mov qword ptr [rbp - 24], rax mov qword ptr [rbp - 16], rdi lea rdi, [rbp - 48] @@ -263,7 +263,7 @@ _create_and_use_rc_block: mov qword ptr [rbp - 32], 0 lea rax, [rip + SYM(<_ as block2[CRATE_ID]::traits::IntoBlock<(_,), _>>::__get_invoke_stack_block::invoke::, 0)] mov qword ptr [rbp - 24], rax - lea rax, [rip + L_anon.[ID].1] + lea rax, [rip + L_anon.[ID].4] mov qword ptr [rbp - 16], rax lea rdi, [rbp - 40] call __Block_copy @@ -284,32 +284,31 @@ LBB19_2: .section __DATA,__const .p2align 3, 0x0 l_anon.[ID].0: - .asciz "\000\000\000\000\000\000\000\000(\000\000\000\000\000\000" - .quad SYM(>::empty_clone_closure, 0) - .quad SYM(>::drop_closure, 0) - - .section __TEXT,__literal16,16byte_literals - .p2align 3, 0x0 -L_anon.[ID].1: - .asciz "\000\000\000\000\000\000\000\000 \000\000\000\000\000\000" - - .section __DATA,__const - .p2align 3, 0x0 -l_anon.[ID].2: .asciz "\000\000\000\000\000\000\000\000 \000\000\000\000\000\000" .quad SYM(>::clone_closure, 0) .quad SYM(>::drop_closure, 0) .p2align 3, 0x0 -l_anon.[ID].3: +l_anon.[ID].1: .asciz "\000\000\000\000\000\000\000\000 \000\000\000\000\000\000" .quad SYM(>::clone_closure, 0) .quad SYM(>::drop_closure, 0) .p2align 3, 0x0 -l_anon.[ID].4: +l_anon.[ID].2: .asciz "\000\000\000\000\000\000\000\000(\000\000\000\000\000\000" .quad SYM(>::clone_closure, 0) .quad SYM(>::drop_closure, 0) + .p2align 3, 0x0 +l_anon.[ID].3: + .asciz "\000\000\000\000\000\000\000\000(\000\000\000\000\000\000" + .quad SYM(>::empty_clone_closure, 0) + .quad SYM(>::drop_closure, 0) + + .section __TEXT,__literal16,16byte_literals + .p2align 3, 0x0 +L_anon.[ID].4: + .asciz "\000\000\000\000\000\000\000\000 \000\000\000\000\000\000" + .subsections_via_symbols diff --git a/crates/test-assembly/crates/test_declare_class/expected/apple-aarch64.s b/crates/test-assembly/crates/test_declare_class/expected/apple-aarch64.s index b5325e7db..d540c5b72 100644 --- a/crates/test-assembly/crates/test_declare_class/expected/apple-aarch64.s +++ b/crates/test-assembly/crates/test_declare_class/expected/apple-aarch64.s @@ -1,6 +1,7 @@ .section __TEXT,__text,regular,pure_instructions .p2align 2 SYM(objc2[CRATE_ID]::__macro_helpers::declared_ivars::dealloc::, 0): +Lfunc_begin0: sub sp, sp, #64 stp x22, x21, [sp, #16] stp x20, x19, [sp, #32] @@ -13,7 +14,7 @@ Lloh0: Lloh1: ldr x8, [x8, SYM(test_declare_class[CRATE_ID]::_::__OBJC2_DROP_FLAG_OFFSET, 0)@PAGEOFF] ldrb w8, [x0, x8] - cbz w8, LBB0_5 + cbz w8, LBB0_6 cmp w8, #255 b.ne LBB0_3 bl SYM(::drop, 0) @@ -24,11 +25,13 @@ Lloh3: ldr x8, [x8, SYM(test_declare_class[CRATE_ID]::_::__OBJC2_IVAR_OFFSET, 0)@PAGEOFF] add x8, x20, x8 ldp x0, x21, [x8] +Ltmp0: bl _objc_release - cbz x21, LBB0_5 +Ltmp1: + cbz x21, LBB0_6 mov x0, x21 bl _objc_release -LBB0_5: +LBB0_6: Lloh4: adrp x8, L_OBJC_CLASSLIST_REFERENCES_$_NSObject@GOTPAGE Lloh5: @@ -44,12 +47,67 @@ Lloh6: ldp x22, x21, [sp, #16] add sp, sp, #64 ret +LBB0_7: +Ltmp2: + mov x19, x0 + cbz x21, LBB0_9 +Ltmp3: + mov x0, x21 + bl _objc_release +Ltmp4: +LBB0_9: + mov x0, x19 + bl __Unwind_Resume +LBB0_10: +Ltmp5: + bl SYM(core::panicking::panic_in_cleanup::GENERATED_ID, 0) .loh AdrpLdr Lloh0, Lloh1 .loh AdrpLdr Lloh2, Lloh3 .loh AdrpLdrGotLdr Lloh4, Lloh5, Lloh6 +Lfunc_end0: + .section __TEXT,__gcc_except_tab + .p2align 2, 0x0 +GCC_except_table0: +Lexception0: + .byte 255 + .byte 155 + .uleb128 Lttbase0-Lttbaseref0 +Lttbaseref0: + .byte 1 + .uleb128 Lcst_end0-Lcst_begin0 +Lcst_begin0: + .uleb128 Lfunc_begin0-Lfunc_begin0 + .uleb128 Ltmp0-Lfunc_begin0 + .byte 0 + .byte 0 + .uleb128 Ltmp0-Lfunc_begin0 + .uleb128 Ltmp1-Ltmp0 + .uleb128 Ltmp2-Lfunc_begin0 + .byte 0 + .uleb128 Ltmp1-Lfunc_begin0 + .uleb128 Ltmp3-Ltmp1 + .byte 0 + .byte 0 + .uleb128 Ltmp3-Lfunc_begin0 + .uleb128 Ltmp4-Ltmp3 + .uleb128 Ltmp5-Lfunc_begin0 + .byte 1 + .uleb128 Ltmp4-Lfunc_begin0 + .uleb128 Lfunc_end0-Ltmp4 + .byte 0 + .byte 0 +Lcst_end0: + .byte 127 + .byte 0 + .p2align 2, 0x0 +Lttbase0: + .byte 0 + .p2align 2, 0x0 + .section __TEXT,__text,regular,pure_instructions .p2align 2 SYM(::call_once::<::class::{closure#0}>::{closure#0}, 0): +Lfunc_begin1: sub sp, sp, #48 stp x20, x19, [sp, #16] stp x29, x30, [sp, #32] @@ -57,7 +115,7 @@ SYM(::call_once::<::drop::GENERATED_ID, 0) +Ltmp24: + mov x0, x19 + bl __Unwind_Resume +LBB1_19: +Ltmp25: + bl SYM(core::panicking::panic_in_cleanup::GENERATED_ID, 0) .loh AdrpAdd Lloh10, Lloh11 .loh AdrpLdrGotLdr Lloh7, Lloh8, Lloh9 - .loh AdrpAdd Lloh40, Lloh41 - .loh AdrpAdd Lloh38, Lloh39 - .loh AdrpLdr Lloh36, Lloh37 - .loh AdrpAdd Lloh34, Lloh35 - .loh AdrpAdd Lloh32, Lloh33 - .loh AdrpLdr Lloh30, Lloh31 - .loh AdrpAdd Lloh28, Lloh29 - .loh AdrpAdd Lloh26, Lloh27 - .loh AdrpLdr Lloh24, Lloh25 - .loh AdrpAdd Lloh22, Lloh23 - .loh AdrpAdd Lloh20, Lloh21 - .loh AdrpLdr Lloh18, Lloh19 .loh AdrpAdd Lloh16, Lloh17 .loh AdrpAdd Lloh14, Lloh15 .loh AdrpLdr Lloh12, Lloh13 + .loh AdrpAdd Lloh22, Lloh23 + .loh AdrpAdd Lloh20, Lloh21 + .loh AdrpLdr Lloh18, Lloh19 + .loh AdrpAdd Lloh28, Lloh29 + .loh AdrpAdd Lloh26, Lloh27 + .loh AdrpLdr Lloh24, Lloh25 + .loh AdrpAdd Lloh34, Lloh35 + .loh AdrpAdd Lloh32, Lloh33 + .loh AdrpLdr Lloh30, Lloh31 .loh AdrpAdd Lloh42, Lloh43 - .loh AdrpAdd Lloh50, Lloh51 - .loh AdrpAdd Lloh48, Lloh49 + .loh AdrpAdd Lloh40, Lloh41 + .loh AdrpAdd Lloh38, Lloh39 + .loh AdrpLdr Lloh36, Lloh37 + .loh AdrpAdd Lloh44, Lloh45 .loh AdrpAdd Lloh46, Lloh47 - .loh AdrpLdr Lloh44, Lloh45 + .loh AdrpAdd Lloh54, Lloh55 .loh AdrpAdd Lloh52, Lloh53 + .loh AdrpAdd Lloh50, Lloh51 + .loh AdrpLdr Lloh48, Lloh49 .loh AdrpAdd Lloh56, Lloh57 - .loh AdrpAdd Lloh54, Lloh55 + .loh AdrpAdd Lloh60, Lloh61 + .loh AdrpAdd Lloh58, Lloh59 +Lfunc_end1: + .section __TEXT,__gcc_except_tab + .p2align 2, 0x0 +GCC_except_table1: +Lexception1: + .byte 255 + .byte 155 + .uleb128 Lttbase1-Lttbaseref1 +Lttbaseref1: + .byte 1 + .uleb128 Lcst_end1-Lcst_begin1 +Lcst_begin1: + .uleb128 Lfunc_begin1-Lfunc_begin1 + .uleb128 Ltmp6-Lfunc_begin1 + .byte 0 + .byte 0 + .uleb128 Ltmp6-Lfunc_begin1 + .uleb128 Ltmp21-Ltmp6 + .uleb128 Ltmp22-Lfunc_begin1 + .byte 0 + .uleb128 Ltmp21-Lfunc_begin1 + .uleb128 Ltmp23-Ltmp21 + .byte 0 + .byte 0 + .uleb128 Ltmp23-Lfunc_begin1 + .uleb128 Ltmp24-Ltmp23 + .uleb128 Ltmp25-Lfunc_begin1 + .byte 1 + .uleb128 Ltmp24-Lfunc_begin1 + .uleb128 Lfunc_end1-Ltmp24 + .byte 0 + .byte 0 +Lcst_end1: + .byte 127 + .byte 0 + .p2align 2, 0x0 +Lttbase1: + .byte 0 + .p2align 2, 0x0 + .section __TEXT,__text,regular,pure_instructions .p2align 2 SYM(::call_once::<::class::{closure#0}>::{closure#0}, 0): +Lfunc_begin2: sub sp, sp, #96 stp x20, x19, [sp, #64] stp x29, x30, [sp, #80] @@ -253,167 +386,270 @@ SYM(::call_once::<, 0)@PAGE -Lloh69: +Lloh73: add x5, x5, SYM(objc2[CRATE_ID]::__macro_helpers::declared_ivars::dealloc::, 0)@PAGEOFF add x0, sp, #24 mov w2, #8 mov x3, #0 bl SYM(objc2::runtime::declare::ClassBuilder::add_method_inner::GENERATED_ID, 0) +Ltmp27: ldr x8, [sp, #24] str x8, [sp, #8] -Lloh70: +Lloh74: adrp x8, L_OBJC_SELECTOR_REFERENCES_init@GOTPAGE -Lloh71: +Lloh75: ldr x8, [x8, L_OBJC_SELECTOR_REFERENCES_init@GOTPAGEOFF] -Lloh72: +Lloh76: ldr x1, [x8] -Lloh73: +Ltmp32: +Lloh77: adrp x4, l_anon.[ID].18@PAGE -Lloh74: +Lloh78: add x4, x4, l_anon.[ID].18@PAGEOFF -Lloh75: +Lloh79: adrp x5, _init_drop_ivars@PAGE -Lloh76: +Lloh80: add x5, x5, _init_drop_ivars@PAGEOFF add x0, sp, #8 mov w2, #8 mov x3, #0 bl SYM(objc2::runtime::declare::ClassBuilder::add_method_inner::GENERATED_ID, 0) +Ltmp33: ldr x8, [sp, #8] str x8, [sp, #16] mov w8, #16 -Lloh77: +Lloh81: adrp x9, l_anon.[ID].8@PAGE -Lloh78: +Lloh82: add x9, x9, l_anon.[ID].8@PAGEOFF stp x8, x9, [sp, #32] mov w8, #27 strb w8, [sp, #24] -Lloh79: - adrp x20, l_anon.[ID].4@PAGE -Lloh80: - add x20, x20, l_anon.[ID].4@PAGEOFF +Ltmp38: +Lloh83: + adrp x1, l_anon.[ID].4@PAGE +Lloh84: + add x1, x1, l_anon.[ID].4@PAGEOFF add x0, sp, #16 add x5, sp, #24 - mov x1, x20 mov w2, #5 mov w3, #16 mov w4, #3 bl SYM(objc2::runtime::declare::ClassBuilder::add_ivar_inner_mono::GENERATED_ID, 0) -Lloh81: +Ltmp39: +Ltmp40: +Lloh85: adrp x1, l_anon.[ID].5@PAGE -Lloh82: +Lloh86: add x1, x1, l_anon.[ID].5@PAGEOFF -Lloh83: +Lloh87: adrp x5, l_anon.[ID].6@PAGE -Lloh84: +Lloh88: add x5, x5, l_anon.[ID].6@PAGEOFF add x0, sp, #16 mov w2, #9 mov w3, #1 mov w4, #0 bl SYM(objc2::runtime::declare::ClassBuilder::add_ivar_inner_mono::GENERATED_ID, 0) +Ltmp41: ldr x19, [sp, #16] mov x0, x19 bl _objc_registerClassPair +Lloh89: + adrp x1, l_anon.[ID].4@PAGE +Lloh90: + add x1, x1, l_anon.[ID].4@PAGEOFF mov x0, x19 - mov x1, x20 mov w2, #5 bl SYM(objc2::runtime::AnyClass::instance_variable::GENERATED_ID, 0) - cbz x0, LBB2_7 + cbz x0, LBB2_11 bl _ivar_getOffset mov x20, x0 -Lloh85: +Lloh91: adrp x1, l_anon.[ID].5@PAGE -Lloh86: +Lloh92: add x1, x1, l_anon.[ID].5@PAGEOFF mov x0, x19 mov w2, #9 bl SYM(objc2::runtime::AnyClass::instance_variable::GENERATED_ID, 0) - cbz x0, LBB2_8 + cbz x0, LBB2_12 bl _ivar_getOffset -Lloh87: +Lloh93: adrp x8, __MergedGlobals@PAGE+32 str x19, [x8, __MergedGlobals@PAGEOFF+32] -Lloh88: +Lloh94: adrp x8, SYM(test_declare_class[CRATE_ID]::_::__OBJC2_IVAR_OFFSET, 0)@PAGE str x20, [x8, SYM(test_declare_class[CRATE_ID]::_::__OBJC2_IVAR_OFFSET, 0)@PAGEOFF] -Lloh89: +Lloh95: adrp x8, SYM(test_declare_class[CRATE_ID]::_::__OBJC2_DROP_FLAG_OFFSET, 0)@PAGE str x0, [x8, SYM(test_declare_class[CRATE_ID]::_::__OBJC2_DROP_FLAG_OFFSET, 0)@PAGEOFF] ldp x29, x30, [sp, #80] ldp x20, x19, [sp, #64] add sp, sp, #96 ret -LBB2_5: -Lloh90: +LBB2_9: +Lloh96: adrp x0, l_anon.[ID].12@PAGE -Lloh91: +Lloh97: add x0, x0, l_anon.[ID].12@PAGEOFF bl SYM(core::option::unwrap_failed::GENERATED_ID, 0) -LBB2_6: -Lloh92: +LBB2_10: +Lloh98: adrp x0, l_anon.[ID].10@PAGE -Lloh93: +Lloh99: add x0, x0, l_anon.[ID].10@PAGEOFF -Lloh94: +Lloh100: adrp x2, l_anon.[ID].25@PAGE -Lloh95: +Lloh101: add x2, x2, l_anon.[ID].25@PAGEOFF mov w1, #9 bl SYM(objc2::__macro_helpers::declare_class::failed_declaring_class::GENERATED_ID, 0) -LBB2_7: +LBB2_11: bl SYM(objc2::__macro_helpers::declared_ivars::register_with_ivars::get_ivar_failed::GENERATED_ID, 0) -LBB2_8: +LBB2_12: bl SYM(objc2::__macro_helpers::declared_ivars::register_with_ivars::get_drop_flag_failed::GENERATED_ID, 0) - .loh AdrpAdd Lloh61, Lloh62 - .loh AdrpLdrGotLdr Lloh58, Lloh59, Lloh60 - .loh AdrpAdd Lloh83, Lloh84 - .loh AdrpAdd Lloh81, Lloh82 +LBB2_13: +Ltmp34: + mov x19, x0 +Ltmp35: + add x0, sp, #8 + bl SYM(::drop::GENERATED_ID, 0) +Ltmp36: + b LBB2_18 +LBB2_14: +Ltmp37: + bl SYM(core::panicking::panic_in_cleanup::GENERATED_ID, 0) +LBB2_15: +Ltmp28: + mov x19, x0 +Ltmp29: + add x0, sp, #24 + bl SYM(::drop::GENERATED_ID, 0) +Ltmp30: + b LBB2_18 +LBB2_16: +Ltmp31: + bl SYM(core::panicking::panic_in_cleanup::GENERATED_ID, 0) +LBB2_17: +Ltmp42: + mov x19, x0 +Ltmp43: + add x0, sp, #16 + bl SYM(::drop::GENERATED_ID, 0) +Ltmp44: +LBB2_18: + mov x0, x19 + bl __Unwind_Resume +LBB2_19: +Ltmp45: + bl SYM(core::panicking::panic_in_cleanup::GENERATED_ID, 0) + .loh AdrpAdd Lloh65, Lloh66 + .loh AdrpLdrGotLdr Lloh62, Lloh63, Lloh64 + .loh AdrpAdd Lloh72, Lloh73 + .loh AdrpAdd Lloh70, Lloh71 + .loh AdrpLdrGotLdr Lloh67, Lloh68, Lloh69 .loh AdrpAdd Lloh79, Lloh80 .loh AdrpAdd Lloh77, Lloh78 - .loh AdrpAdd Lloh75, Lloh76 - .loh AdrpAdd Lloh73, Lloh74 - .loh AdrpLdrGotLdr Lloh70, Lloh71, Lloh72 - .loh AdrpAdd Lloh68, Lloh69 - .loh AdrpAdd Lloh66, Lloh67 - .loh AdrpLdrGotLdr Lloh63, Lloh64, Lloh65 + .loh AdrpLdrGotLdr Lloh74, Lloh75, Lloh76 + .loh AdrpAdd Lloh83, Lloh84 + .loh AdrpAdd Lloh81, Lloh82 + .loh AdrpAdd Lloh87, Lloh88 .loh AdrpAdd Lloh85, Lloh86 - .loh AdrpAdrp Lloh88, Lloh89 - .loh AdrpAdrp Lloh87, Lloh88 - .loh AdrpAdd Lloh90, Lloh91 - .loh AdrpAdd Lloh94, Lloh95 - .loh AdrpAdd Lloh92, Lloh93 + .loh AdrpAdd Lloh89, Lloh90 + .loh AdrpAdd Lloh91, Lloh92 + .loh AdrpAdrp Lloh94, Lloh95 + .loh AdrpAdrp Lloh93, Lloh94 + .loh AdrpAdd Lloh96, Lloh97 + .loh AdrpAdd Lloh100, Lloh101 + .loh AdrpAdd Lloh98, Lloh99 +Lfunc_end2: + .section __TEXT,__gcc_except_tab + .p2align 2, 0x0 +GCC_except_table2: +Lexception2: + .byte 255 + .byte 155 + .uleb128 Lttbase2-Lttbaseref2 +Lttbaseref2: + .byte 1 + .uleb128 Lcst_end2-Lcst_begin2 +Lcst_begin2: + .uleb128 Lfunc_begin2-Lfunc_begin2 + .uleb128 Ltmp26-Lfunc_begin2 + .byte 0 + .byte 0 + .uleb128 Ltmp26-Lfunc_begin2 + .uleb128 Ltmp27-Ltmp26 + .uleb128 Ltmp28-Lfunc_begin2 + .byte 0 + .uleb128 Ltmp32-Lfunc_begin2 + .uleb128 Ltmp33-Ltmp32 + .uleb128 Ltmp34-Lfunc_begin2 + .byte 0 + .uleb128 Ltmp38-Lfunc_begin2 + .uleb128 Ltmp41-Ltmp38 + .uleb128 Ltmp42-Lfunc_begin2 + .byte 0 + .uleb128 Ltmp41-Lfunc_begin2 + .uleb128 Ltmp35-Ltmp41 + .byte 0 + .byte 0 + .uleb128 Ltmp35-Lfunc_begin2 + .uleb128 Ltmp36-Ltmp35 + .uleb128 Ltmp37-Lfunc_begin2 + .byte 1 + .uleb128 Ltmp29-Lfunc_begin2 + .uleb128 Ltmp30-Ltmp29 + .uleb128 Ltmp31-Lfunc_begin2 + .byte 1 + .uleb128 Ltmp43-Lfunc_begin2 + .uleb128 Ltmp44-Ltmp43 + .uleb128 Ltmp45-Lfunc_begin2 + .byte 1 + .uleb128 Ltmp44-Lfunc_begin2 + .uleb128 Lfunc_end2-Ltmp44 + .byte 0 + .byte 0 +Lcst_end2: + .byte 127 + .byte 0 + .p2align 2, 0x0 +Lttbase2: + .byte 0 + .p2align 2, 0x0 + .section __TEXT,__text,regular,pure_instructions .p2align 2 SYM(::call_once::<::class::{closure#0}>::{closure#0}, 0): +Lfunc_begin3: sub sp, sp, #96 stp x20, x19, [sp, #64] stp x29, x30, [sp, #80] @@ -421,110 +657,189 @@ SYM(::call_once::<::drop::GENERATED_ID, 0) +Ltmp56: + b LBB3_12 +LBB3_10: +Ltmp57: + bl SYM(core::panicking::panic_in_cleanup::GENERATED_ID, 0) +LBB3_11: +Ltmp48: + mov x19, x0 +Ltmp49: + add x0, sp, #8 + bl SYM(::drop::GENERATED_ID, 0) +Ltmp50: +LBB3_12: + mov x0, x19 + bl __Unwind_Resume +LBB3_13: +Ltmp51: + bl SYM(core::panicking::panic_in_cleanup::GENERATED_ID, 0) + .loh AdrpAdd Lloh105, Lloh106 + .loh AdrpLdrGotLdr Lloh102, Lloh103, Lloh104 + .loh AdrpAdd Lloh112, Lloh113 .loh AdrpAdd Lloh110, Lloh111 - .loh AdrpAdd Lloh108, Lloh109 - .loh AdrpAdd Lloh106, Lloh107 - .loh AdrpAdd Lloh104, Lloh105 - .loh AdrpLdrGotLdr Lloh101, Lloh102, Lloh103 - .loh AdrpAdrp Lloh112, Lloh113 + .loh AdrpLdrGotLdr Lloh107, Lloh108, Lloh109 + .loh AdrpAdd Lloh116, Lloh117 .loh AdrpAdd Lloh114, Lloh115 .loh AdrpAdd Lloh118, Lloh119 - .loh AdrpAdd Lloh116, Lloh117 + .loh AdrpAdrp Lloh120, Lloh121 + .loh AdrpAdd Lloh122, Lloh123 + .loh AdrpAdd Lloh126, Lloh127 + .loh AdrpAdd Lloh124, Lloh125 +Lfunc_end3: + .section __TEXT,__gcc_except_tab + .p2align 2, 0x0 +GCC_except_table3: +Lexception3: + .byte 255 + .byte 155 + .uleb128 Lttbase3-Lttbaseref3 +Lttbaseref3: + .byte 1 + .uleb128 Lcst_end3-Lcst_begin3 +Lcst_begin3: + .uleb128 Lfunc_begin3-Lfunc_begin3 + .uleb128 Ltmp46-Lfunc_begin3 + .byte 0 + .byte 0 + .uleb128 Ltmp46-Lfunc_begin3 + .uleb128 Ltmp47-Ltmp46 + .uleb128 Ltmp48-Lfunc_begin3 + .byte 0 + .uleb128 Ltmp52-Lfunc_begin3 + .uleb128 Ltmp53-Ltmp52 + .uleb128 Ltmp54-Lfunc_begin3 + .byte 0 + .uleb128 Ltmp53-Lfunc_begin3 + .uleb128 Ltmp55-Ltmp53 + .byte 0 + .byte 0 + .uleb128 Ltmp55-Lfunc_begin3 + .uleb128 Ltmp56-Ltmp55 + .uleb128 Ltmp57-Lfunc_begin3 + .byte 1 + .uleb128 Ltmp49-Lfunc_begin3 + .uleb128 Ltmp50-Ltmp49 + .uleb128 Ltmp51-Lfunc_begin3 + .byte 1 + .uleb128 Ltmp50-Lfunc_begin3 + .uleb128 Lfunc_end3-Ltmp50 + .byte 0 + .byte 0 +Lcst_end3: + .byte 127 + .byte 0 + .p2align 2, 0x0 +Lttbase3: + .byte 0 + .p2align 2, 0x0 + .section __TEXT,__text,regular,pure_instructions .p2align 2 SYM(<::call_once<::class::{closure#0}>::{closure#0} as core[CRATE_ID]::ops::function::FnOnce<(&std[CRATE_ID]::sync::once::OnceState,)>>::call_once::{shim:vtable#0}, 0): sub sp, sp, #32 @@ -567,16 +882,16 @@ SYM(<::call_once<::drop, 0) .p2align 2 @@ -639,16 +954,16 @@ SYM( .globl _access_drop_ivars_class .p2align 2 _access_drop_ivars_class: -Lloh134: +Lloh142: adrp x8, __MergedGlobals@PAGE+40 -Lloh135: +Lloh143: add x8, x8, __MergedGlobals@PAGEOFF+40 ldapr x8, [x8] cmp x8, #3 b.ne LBB10_2 -Lloh136: +Lloh144: adrp x8, __MergedGlobals@PAGE+32 -Lloh137: +Lloh145: ldr x0, [x8, __MergedGlobals@PAGEOFF+32] ret LBB10_2: @@ -659,60 +974,60 @@ LBB10_2: strb w8, [sp, #7] add x8, sp, #7 str x8, [sp, #8] -Lloh138: +Lloh146: adrp x0, __MergedGlobals@PAGE+40 -Lloh139: +Lloh147: add x0, x0, __MergedGlobals@PAGEOFF+40 -Lloh140: +Lloh148: adrp x3, l_anon.[ID].1@PAGE -Lloh141: +Lloh149: add x3, x3, l_anon.[ID].1@PAGEOFF -Lloh142: +Lloh150: adrp x4, l_anon.[ID].25@PAGE -Lloh143: +Lloh151: add x4, x4, l_anon.[ID].25@PAGEOFF add x2, sp, #8 mov w1, #0 bl SYM(std::sys::sync::once::queue::Once::call::GENERATED_ID, 0) ldp x29, x30, [sp, #16] add sp, sp, #32 -Lloh144: +Lloh152: adrp x8, __MergedGlobals@PAGE+32 -Lloh145: +Lloh153: ldr x0, [x8, __MergedGlobals@PAGEOFF+32] ret - .loh AdrpAdd Lloh134, Lloh135 - .loh AdrpLdr Lloh136, Lloh137 - .loh AdrpLdr Lloh144, Lloh145 .loh AdrpAdd Lloh142, Lloh143 - .loh AdrpAdd Lloh140, Lloh141 - .loh AdrpAdd Lloh138, Lloh139 + .loh AdrpLdr Lloh144, Lloh145 + .loh AdrpLdr Lloh152, Lloh153 + .loh AdrpAdd Lloh150, Lloh151 + .loh AdrpAdd Lloh148, Lloh149 + .loh AdrpAdd Lloh146, Lloh147 .globl _access_drop_ivars .p2align 2 _access_drop_ivars: -Lloh146: +Lloh154: adrp x8, SYM(test_declare_class[CRATE_ID]::_::__OBJC2_IVAR_OFFSET, 0)@PAGE -Lloh147: +Lloh155: ldr x8, [x8, SYM(test_declare_class[CRATE_ID]::_::__OBJC2_IVAR_OFFSET, 0)@PAGEOFF] add x8, x0, x8 ldp x0, x1, [x8] ret - .loh AdrpLdr Lloh146, Lloh147 + .loh AdrpLdr Lloh154, Lloh155 .globl SYM(::class, 0) .p2align 2 SYM(::class, 0): -Lloh148: +Lloh156: adrp x8, __MergedGlobals@PAGE+8 -Lloh149: +Lloh157: add x8, x8, __MergedGlobals@PAGEOFF+8 ldapr x8, [x8] cmp x8, #3 b.ne LBB12_2 -Lloh150: +Lloh158: adrp x8, __MergedGlobals@PAGE -Lloh151: +Lloh159: ldr x0, [x8, __MergedGlobals@PAGEOFF] ret LBB12_2: @@ -723,48 +1038,48 @@ LBB12_2: strb w8, [sp, #7] add x8, sp, #7 str x8, [sp, #8] -Lloh152: +Lloh160: adrp x0, __MergedGlobals@PAGE+8 -Lloh153: +Lloh161: add x0, x0, __MergedGlobals@PAGEOFF+8 -Lloh154: +Lloh162: adrp x3, l_anon.[ID].0@PAGE -Lloh155: +Lloh163: add x3, x3, l_anon.[ID].0@PAGEOFF -Lloh156: +Lloh164: adrp x4, l_anon.[ID].15@PAGE -Lloh157: +Lloh165: add x4, x4, l_anon.[ID].15@PAGEOFF add x2, sp, #8 mov w1, #0 bl SYM(std::sys::sync::once::queue::Once::call::GENERATED_ID, 0) ldp x29, x30, [sp, #16] add sp, sp, #32 -Lloh158: +Lloh166: adrp x8, __MergedGlobals@PAGE -Lloh159: +Lloh167: ldr x0, [x8, __MergedGlobals@PAGEOFF] ret - .loh AdrpAdd Lloh148, Lloh149 - .loh AdrpLdr Lloh150, Lloh151 - .loh AdrpLdr Lloh158, Lloh159 .loh AdrpAdd Lloh156, Lloh157 - .loh AdrpAdd Lloh154, Lloh155 - .loh AdrpAdd Lloh152, Lloh153 + .loh AdrpLdr Lloh158, Lloh159 + .loh AdrpLdr Lloh166, Lloh167 + .loh AdrpAdd Lloh164, Lloh165 + .loh AdrpAdd Lloh162, Lloh163 + .loh AdrpAdd Lloh160, Lloh161 .globl _get_class .p2align 2 _get_class: -Lloh160: +Lloh168: adrp x8, __MergedGlobals@PAGE+8 -Lloh161: +Lloh169: add x8, x8, __MergedGlobals@PAGEOFF+8 ldapr x8, [x8] cmp x8, #3 b.ne LBB13_2 -Lloh162: +Lloh170: adrp x8, __MergedGlobals@PAGE -Lloh163: +Lloh171: ldr x0, [x8, __MergedGlobals@PAGEOFF] ret LBB13_2: @@ -775,34 +1090,34 @@ LBB13_2: strb w8, [sp, #7] add x8, sp, #7 str x8, [sp, #8] -Lloh164: +Lloh172: adrp x0, __MergedGlobals@PAGE+8 -Lloh165: +Lloh173: add x0, x0, __MergedGlobals@PAGEOFF+8 -Lloh166: +Lloh174: adrp x3, l_anon.[ID].0@PAGE -Lloh167: +Lloh175: add x3, x3, l_anon.[ID].0@PAGEOFF -Lloh168: +Lloh176: adrp x4, l_anon.[ID].15@PAGE -Lloh169: +Lloh177: add x4, x4, l_anon.[ID].15@PAGEOFF add x2, sp, #8 mov w1, #0 bl SYM(std::sys::sync::once::queue::Once::call::GENERATED_ID, 0) ldp x29, x30, [sp, #16] add sp, sp, #32 -Lloh170: +Lloh178: adrp x8, __MergedGlobals@PAGE -Lloh171: +Lloh179: ldr x0, [x8, __MergedGlobals@PAGEOFF] ret - .loh AdrpAdd Lloh160, Lloh161 - .loh AdrpLdr Lloh162, Lloh163 - .loh AdrpLdr Lloh170, Lloh171 .loh AdrpAdd Lloh168, Lloh169 - .loh AdrpAdd Lloh166, Lloh167 - .loh AdrpAdd Lloh164, Lloh165 + .loh AdrpLdr Lloh170, Lloh171 + .loh AdrpLdr Lloh178, Lloh179 + .loh AdrpAdd Lloh176, Lloh177 + .loh AdrpAdd Lloh174, Lloh175 + .loh AdrpAdd Lloh172, Lloh173 .globl _method_simple .p2align 2 @@ -821,23 +1136,23 @@ _method_id: sub sp, sp, #32 stp x29, x30, [sp, #16] add x29, sp, #16 -Lloh172: +Lloh180: adrp x8, __MergedGlobals@PAGE+8 -Lloh173: +Lloh181: add x8, x8, __MergedGlobals@PAGEOFF+8 ldapr x8, [x8] cmp x8, #3 b.ne LBB16_2 LBB16_1: -Lloh174: +Lloh182: adrp x8, __MergedGlobals@PAGE -Lloh175: +Lloh183: ldr x0, [x8, __MergedGlobals@PAGEOFF] -Lloh176: +Lloh184: adrp x8, L_OBJC_SELECTOR_REFERENCES_new@GOTPAGE -Lloh177: +Lloh185: ldr x8, [x8, L_OBJC_SELECTOR_REFERENCES_new@GOTPAGEOFF] -Lloh178: +Lloh186: ldr x1, [x8] bl _objc_msgSend bl _objc_autoreleaseReturnValue @@ -849,73 +1164,129 @@ LBB16_2: strb w8, [sp, #7] add x8, sp, #7 str x8, [sp, #8] -Lloh179: +Lloh187: adrp x0, __MergedGlobals@PAGE+8 -Lloh180: +Lloh188: add x0, x0, __MergedGlobals@PAGEOFF+8 -Lloh181: +Lloh189: adrp x3, l_anon.[ID].0@PAGE -Lloh182: +Lloh190: add x3, x3, l_anon.[ID].0@PAGEOFF -Lloh183: +Lloh191: adrp x4, l_anon.[ID].15@PAGE -Lloh184: +Lloh192: add x4, x4, l_anon.[ID].15@PAGEOFF add x2, sp, #8 mov w1, #0 bl SYM(std::sys::sync::once::queue::Once::call::GENERATED_ID, 0) b LBB16_1 - .loh AdrpAdd Lloh172, Lloh173 - .loh AdrpLdrGotLdr Lloh176, Lloh177, Lloh178 - .loh AdrpAdrp Lloh174, Lloh176 - .loh AdrpLdr Lloh174, Lloh175 - .loh AdrpAdd Lloh183, Lloh184 - .loh AdrpAdd Lloh181, Lloh182 - .loh AdrpAdd Lloh179, Lloh180 + .loh AdrpAdd Lloh180, Lloh181 + .loh AdrpLdrGotLdr Lloh184, Lloh185, Lloh186 + .loh AdrpAdrp Lloh182, Lloh184 + .loh AdrpLdr Lloh182, Lloh183 + .loh AdrpAdd Lloh191, Lloh192 + .loh AdrpAdd Lloh189, Lloh190 + .loh AdrpAdd Lloh187, Lloh188 .globl _method_id_with_param .p2align 2 _method_id_with_param: +Lfunc_begin4: stp x20, x19, [sp, #-32]! stp x29, x30, [sp, #16] add x29, sp, #16 - mov x19, x2 + mov x20, x2 bl SYM(objc2::runtime::nsobject::NSObject::new::GENERATED_ID, 0) - cbz w19, LBB17_2 mov x19, x0 + cbz w20, LBB17_3 +Ltmp58: bl SYM(objc2::runtime::nsobject::NSObject::new::GENERATED_ID, 0) +Ltmp59: mov x20, x0 mov x0, x19 bl _objc_release - mov x0, x20 -LBB17_2: + mov x19, x20 +LBB17_3: + mov x0, x19 ldp x29, x30, [sp, #16] ldp x20, x19, [sp], #32 b _objc_autoreleaseReturnValue +LBB17_4: +Ltmp60: + mov x20, x0 +Ltmp61: + mov x0, x19 + bl _objc_release +Ltmp62: + mov x0, x20 + bl __Unwind_Resume +LBB17_6: +Ltmp63: + bl SYM(core::panicking::panic_in_cleanup::GENERATED_ID, 0) +Lfunc_end4: + .section __TEXT,__gcc_except_tab + .p2align 2, 0x0 +GCC_except_table17: +Lexception4: + .byte 255 + .byte 155 + .uleb128 Lttbase4-Lttbaseref4 +Lttbaseref4: + .byte 1 + .uleb128 Lcst_end4-Lcst_begin4 +Lcst_begin4: + .uleb128 Lfunc_begin4-Lfunc_begin4 + .uleb128 Ltmp58-Lfunc_begin4 + .byte 0 + .byte 0 + .uleb128 Ltmp58-Lfunc_begin4 + .uleb128 Ltmp59-Ltmp58 + .uleb128 Ltmp60-Lfunc_begin4 + .byte 0 + .uleb128 Ltmp59-Lfunc_begin4 + .uleb128 Ltmp61-Ltmp59 + .byte 0 + .byte 0 + .uleb128 Ltmp61-Lfunc_begin4 + .uleb128 Ltmp62-Ltmp61 + .uleb128 Ltmp63-Lfunc_begin4 + .byte 1 + .uleb128 Ltmp62-Lfunc_begin4 + .uleb128 Lfunc_end4-Ltmp62 + .byte 0 + .byte 0 +Lcst_end4: + .byte 127 + .byte 0 + .p2align 2, 0x0 +Lttbase4: + .byte 0 + .p2align 2, 0x0 + .section __TEXT,__text,regular,pure_instructions .globl _copyWithZone .p2align 2 _copyWithZone: sub sp, sp, #32 stp x29, x30, [sp, #16] add x29, sp, #16 -Lloh185: +Lloh193: adrp x8, __MergedGlobals@PAGE+8 -Lloh186: +Lloh194: add x8, x8, __MergedGlobals@PAGEOFF+8 ldapr x8, [x8] cmp x8, #3 b.ne LBB18_2 LBB18_1: -Lloh187: +Lloh195: adrp x8, __MergedGlobals@PAGE -Lloh188: +Lloh196: ldr x0, [x8, __MergedGlobals@PAGEOFF] -Lloh189: +Lloh197: adrp x8, L_OBJC_SELECTOR_REFERENCES_new@GOTPAGE -Lloh190: +Lloh198: ldr x8, [x8, L_OBJC_SELECTOR_REFERENCES_new@GOTPAGEOFF] -Lloh191: +Lloh199: ldr x1, [x8] bl _objc_msgSend ldp x29, x30, [sp, #16] @@ -926,43 +1297,43 @@ LBB18_2: strb w8, [sp, #7] add x8, sp, #7 str x8, [sp, #8] -Lloh192: +Lloh200: adrp x0, __MergedGlobals@PAGE+8 -Lloh193: +Lloh201: add x0, x0, __MergedGlobals@PAGEOFF+8 -Lloh194: +Lloh202: adrp x3, l_anon.[ID].0@PAGE -Lloh195: +Lloh203: add x3, x3, l_anon.[ID].0@PAGEOFF -Lloh196: +Lloh204: adrp x4, l_anon.[ID].15@PAGE -Lloh197: +Lloh205: add x4, x4, l_anon.[ID].15@PAGEOFF add x2, sp, #8 mov w1, #0 bl SYM(std::sys::sync::once::queue::Once::call::GENERATED_ID, 0) b LBB18_1 - .loh AdrpAdd Lloh185, Lloh186 - .loh AdrpLdrGotLdr Lloh189, Lloh190, Lloh191 - .loh AdrpAdrp Lloh187, Lloh189 - .loh AdrpLdr Lloh187, Lloh188 - .loh AdrpAdd Lloh196, Lloh197 - .loh AdrpAdd Lloh194, Lloh195 - .loh AdrpAdd Lloh192, Lloh193 + .loh AdrpAdd Lloh193, Lloh194 + .loh AdrpLdrGotLdr Lloh197, Lloh198, Lloh199 + .loh AdrpAdrp Lloh195, Lloh197 + .loh AdrpLdr Lloh195, Lloh196 + .loh AdrpAdd Lloh204, Lloh205 + .loh AdrpAdd Lloh202, Lloh203 + .loh AdrpAdd Lloh200, Lloh201 .globl SYM(::class, 0) .p2align 2 SYM(::class, 0): -Lloh198: +Lloh206: adrp x8, __MergedGlobals@PAGE+24 -Lloh199: +Lloh207: add x8, x8, __MergedGlobals@PAGEOFF+24 ldapr x8, [x8] cmp x8, #3 b.ne LBB19_2 -Lloh200: +Lloh208: adrp x8, __MergedGlobals@PAGE+16 -Lloh201: +Lloh209: ldr x0, [x8, __MergedGlobals@PAGEOFF+16] ret LBB19_2: @@ -973,42 +1344,42 @@ LBB19_2: strb w8, [sp, #7] add x8, sp, #7 str x8, [sp, #8] -Lloh202: +Lloh210: adrp x0, __MergedGlobals@PAGE+24 -Lloh203: +Lloh211: add x0, x0, __MergedGlobals@PAGEOFF+24 -Lloh204: +Lloh212: adrp x3, l_anon.[ID].2@PAGE -Lloh205: +Lloh213: add x3, x3, l_anon.[ID].2@PAGEOFF -Lloh206: +Lloh214: adrp x4, l_anon.[ID].24@PAGE -Lloh207: +Lloh215: add x4, x4, l_anon.[ID].24@PAGEOFF add x2, sp, #8 mov w1, #0 bl SYM(std::sys::sync::once::queue::Once::call::GENERATED_ID, 0) ldp x29, x30, [sp, #16] add sp, sp, #32 -Lloh208: +Lloh216: adrp x8, __MergedGlobals@PAGE+16 -Lloh209: +Lloh217: ldr x0, [x8, __MergedGlobals@PAGEOFF+16] ret - .loh AdrpAdd Lloh198, Lloh199 - .loh AdrpLdr Lloh200, Lloh201 - .loh AdrpLdr Lloh208, Lloh209 .loh AdrpAdd Lloh206, Lloh207 - .loh AdrpAdd Lloh204, Lloh205 - .loh AdrpAdd Lloh202, Lloh203 + .loh AdrpLdr Lloh208, Lloh209 + .loh AdrpLdr Lloh216, Lloh217 + .loh AdrpAdd Lloh214, Lloh215 + .loh AdrpAdd Lloh212, Lloh213 + .loh AdrpAdd Lloh210, Lloh211 .globl _init_forgetable_ivars .p2align 2 _init_forgetable_ivars: cbz x0, LBB20_2 -Lloh210: +Lloh218: adrp x8, SYM(test_declare_class[CRATE_ID]::_::__OBJC2_IVAR_OFFSET, 1)@PAGE -Lloh211: +Lloh219: ldr x8, [x8, SYM(test_declare_class[CRATE_ID]::_::__OBJC2_IVAR_OFFSET, 1)@PAGEOFF] add x8, x0, x8 mov w9, #43 @@ -1019,15 +1390,15 @@ LBB20_2: sub sp, sp, #32 stp x29, x30, [sp, #16] add x29, sp, #16 -Lloh212: +Lloh220: adrp x8, L_OBJC_SELECTOR_REFERENCES_7f51a873b0d59f00@PAGE -Lloh213: +Lloh221: ldr x1, [x8, L_OBJC_SELECTOR_REFERENCES_7f51a873b0d59f00@PAGEOFF] -Lloh214: +Lloh222: adrp x8, L_OBJC_CLASSLIST_REFERENCES_$_NSObject@GOTPAGE -Lloh215: +Lloh223: ldr x8, [x8, L_OBJC_CLASSLIST_REFERENCES_$_NSObject@GOTPAGEOFF] -Lloh216: +Lloh224: ldr x8, [x8] stp x0, x8, [sp] mov x0, sp @@ -1035,24 +1406,24 @@ Lloh216: ldp x29, x30, [sp, #16] add sp, sp, #32 ret - .loh AdrpLdr Lloh210, Lloh211 - .loh AdrpLdrGotLdr Lloh214, Lloh215, Lloh216 - .loh AdrpAdrp Lloh212, Lloh214 - .loh AdrpLdr Lloh212, Lloh213 + .loh AdrpLdr Lloh218, Lloh219 + .loh AdrpLdrGotLdr Lloh222, Lloh223, Lloh224 + .loh AdrpAdrp Lloh220, Lloh222 + .loh AdrpLdr Lloh220, Lloh221 .globl SYM(::class, 0) .p2align 2 SYM(::class, 0): -Lloh217: +Lloh225: adrp x8, __MergedGlobals@PAGE+40 -Lloh218: +Lloh226: add x8, x8, __MergedGlobals@PAGEOFF+40 ldapr x8, [x8] cmp x8, #3 b.ne LBB21_2 -Lloh219: +Lloh227: adrp x8, __MergedGlobals@PAGE+32 -Lloh220: +Lloh228: ldr x0, [x8, __MergedGlobals@PAGEOFF+32] ret LBB21_2: @@ -1063,93 +1434,181 @@ LBB21_2: strb w8, [sp, #7] add x8, sp, #7 str x8, [sp, #8] -Lloh221: +Lloh229: adrp x0, __MergedGlobals@PAGE+40 -Lloh222: +Lloh230: add x0, x0, __MergedGlobals@PAGEOFF+40 -Lloh223: +Lloh231: adrp x3, l_anon.[ID].1@PAGE -Lloh224: +Lloh232: add x3, x3, l_anon.[ID].1@PAGEOFF -Lloh225: +Lloh233: adrp x4, l_anon.[ID].25@PAGE -Lloh226: +Lloh234: add x4, x4, l_anon.[ID].25@PAGEOFF add x2, sp, #8 mov w1, #0 bl SYM(std::sys::sync::once::queue::Once::call::GENERATED_ID, 0) ldp x29, x30, [sp, #16] add sp, sp, #32 -Lloh227: +Lloh235: adrp x8, __MergedGlobals@PAGE+32 -Lloh228: +Lloh236: ldr x0, [x8, __MergedGlobals@PAGEOFF+32] ret - .loh AdrpAdd Lloh217, Lloh218 - .loh AdrpLdr Lloh219, Lloh220 - .loh AdrpLdr Lloh227, Lloh228 .loh AdrpAdd Lloh225, Lloh226 - .loh AdrpAdd Lloh223, Lloh224 - .loh AdrpAdd Lloh221, Lloh222 + .loh AdrpLdr Lloh227, Lloh228 + .loh AdrpLdr Lloh235, Lloh236 + .loh AdrpAdd Lloh233, Lloh234 + .loh AdrpAdd Lloh231, Lloh232 + .loh AdrpAdd Lloh229, Lloh230 .globl _init_drop_ivars .p2align 2 _init_drop_ivars: +Lfunc_begin5: sub sp, sp, #64 stp x22, x21, [sp, #16] stp x20, x19, [sp, #32] stp x29, x30, [sp, #48] add x29, sp, #48 mov x19, x0 +Ltmp64: bl SYM(objc2::runtime::nsobject::NSObject::new::GENERATED_ID, 0) +Ltmp65: +Ltmp67: mov x20, x0 bl SYM(objc2::runtime::nsobject::NSObject::new::GENERATED_ID, 0) +Ltmp68: + mov x21, x0 adrp x22, SYM(test_declare_class[CRATE_ID]::_::__OBJC2_DROP_FLAG_OFFSET, 0)@PAGE - cbz x19, LBB22_2 -Lloh229: + cbz x19, LBB22_4 +Lloh237: adrp x8, SYM(test_declare_class[CRATE_ID]::_::__OBJC2_IVAR_OFFSET, 0)@PAGE -Lloh230: +Lloh238: ldr x8, [x8, SYM(test_declare_class[CRATE_ID]::_::__OBJC2_IVAR_OFFSET, 0)@PAGEOFF] add x8, x19, x8 - stp x20, x0, [x8] + stp x20, x21, [x8] ldr x8, [x22, SYM(test_declare_class[CRATE_ID]::_::__OBJC2_DROP_FLAG_OFFSET, 0)@PAGEOFF] mov w9, #15 strb w9, [x19, x8] - b LBB22_3 -LBB22_2: - mov x21, x0 + b LBB22_6 +LBB22_4: +Ltmp75: mov x0, x20 bl _objc_release +Ltmp76: mov x0, x21 bl _objc_release -LBB22_3: -Lloh231: +LBB22_6: +Lloh239: adrp x8, L_OBJC_SELECTOR_REFERENCES_802cb9c5fa0b19dd@PAGE -Lloh232: +Lloh240: ldr x1, [x8, L_OBJC_SELECTOR_REFERENCES_802cb9c5fa0b19dd@PAGEOFF] -Lloh233: +Lloh241: adrp x8, L_OBJC_CLASSLIST_REFERENCES_$_NSObject@GOTPAGE -Lloh234: +Lloh242: ldr x8, [x8, L_OBJC_CLASSLIST_REFERENCES_$_NSObject@GOTPAGEOFF] -Lloh235: +Lloh243: ldr x8, [x8] stp x19, x8, [sp] mov x0, sp bl _objc_msgSendSuper - cbz x0, LBB22_5 + cbz x0, LBB22_8 ldr x8, [x22, SYM(test_declare_class[CRATE_ID]::_::__OBJC2_DROP_FLAG_OFFSET, 0)@PAGEOFF] mov w9, #255 strb w9, [x0, x8] -LBB22_5: +LBB22_8: ldp x29, x30, [sp, #48] ldp x20, x19, [sp, #32] ldp x22, x21, [sp, #16] add sp, sp, #64 ret - .loh AdrpLdr Lloh229, Lloh230 - .loh AdrpLdrGotLdr Lloh233, Lloh234, Lloh235 - .loh AdrpAdrp Lloh231, Lloh233 - .loh AdrpLdr Lloh231, Lloh232 +LBB22_9: +Ltmp77: + mov x20, x0 +Ltmp78: + mov x0, x21 + bl _objc_release +Ltmp79: + b LBB22_14 +LBB22_10: +Ltmp80: + bl SYM(core::panicking::panic_in_cleanup::GENERATED_ID, 0) +LBB22_11: +Ltmp69: + mov x8, x20 + mov x20, x0 +Ltmp70: + mov x0, x8 + bl _objc_release +Ltmp71: + b LBB22_13 +LBB22_12: +Ltmp66: + mov x20, x0 +LBB22_13: +Ltmp72: + mov x0, x19 + bl _objc_release +Ltmp73: +LBB22_14: + mov x0, x20 + bl __Unwind_Resume +LBB22_15: +Ltmp74: + bl SYM(core::panicking::panic_in_cleanup::GENERATED_ID, 0) + .loh AdrpLdr Lloh237, Lloh238 + .loh AdrpLdrGotLdr Lloh241, Lloh242, Lloh243 + .loh AdrpAdrp Lloh239, Lloh241 + .loh AdrpLdr Lloh239, Lloh240 +Lfunc_end5: + .section __TEXT,__gcc_except_tab + .p2align 2, 0x0 +GCC_except_table22: +Lexception5: + .byte 255 + .byte 155 + .uleb128 Lttbase5-Lttbaseref5 +Lttbaseref5: + .byte 1 + .uleb128 Lcst_end5-Lcst_begin5 +Lcst_begin5: + .uleb128 Ltmp64-Lfunc_begin5 + .uleb128 Ltmp65-Ltmp64 + .uleb128 Ltmp66-Lfunc_begin5 + .byte 0 + .uleb128 Ltmp67-Lfunc_begin5 + .uleb128 Ltmp68-Ltmp67 + .uleb128 Ltmp69-Lfunc_begin5 + .byte 0 + .uleb128 Ltmp75-Lfunc_begin5 + .uleb128 Ltmp76-Ltmp75 + .uleb128 Ltmp77-Lfunc_begin5 + .byte 0 + .uleb128 Ltmp76-Lfunc_begin5 + .uleb128 Ltmp78-Ltmp76 + .byte 0 + .byte 0 + .uleb128 Ltmp78-Lfunc_begin5 + .uleb128 Ltmp79-Ltmp78 + .uleb128 Ltmp80-Lfunc_begin5 + .byte 1 + .uleb128 Ltmp70-Lfunc_begin5 + .uleb128 Ltmp73-Ltmp70 + .uleb128 Ltmp74-Lfunc_begin5 + .byte 1 + .uleb128 Ltmp73-Lfunc_begin5 + .uleb128 Lfunc_end5-Ltmp73 + .byte 0 + .byte 0 +Lcst_end5: + .byte 127 + .byte 0 + .p2align 2, 0x0 +Lttbase5: + .byte 0 + .p2align 2, 0x0 .section __DATA,__const .p2align 3, 0x0 diff --git a/crates/test-assembly/crates/test_declare_class/expected/apple-x86_64.s b/crates/test-assembly/crates/test_declare_class/expected/apple-x86_64.s index 89b983e49..368a1b829 100644 --- a/crates/test-assembly/crates/test_declare_class/expected/apple-x86_64.s +++ b/crates/test-assembly/crates/test_declare_class/expected/apple-x86_64.s @@ -2,6 +2,7 @@ .intel_syntax noprefix .p2align 4, 0x90 SYM(objc2[CRATE_ID]::__macro_helpers::declared_ivars::dealloc::, 0): +Lfunc_begin0: push rbp mov rbp, rsp push r15 @@ -13,7 +14,7 @@ SYM(objc2[CRATE_ID]::__macro_helpers::declared_ivars::dealloc::::drop, 0) @@ -21,12 +22,14 @@ LBB0_3: mov rax, qword ptr [rip + SYM(test_declare_class[CRATE_ID]::_::__OBJC2_IVAR_OFFSET, 0)] mov rdi, qword ptr [r14 + rax] mov r15, qword ptr [r14 + rax + 8] +Ltmp0: call _objc_release +Ltmp1: test r15, r15 - je LBB0_5 + je LBB0_6 mov rdi, r15 call _objc_release -LBB0_5: +LBB0_6: mov rax, qword ptr [rip + L_OBJC_CLASSLIST_REFERENCES_$_NSObject@GOTPCREL] mov rax, qword ptr [rax] mov qword ptr [rbp - 40], r14 @@ -40,111 +43,229 @@ LBB0_5: pop r15 pop rbp ret +LBB0_7: +Ltmp2: + mov rbx, rax + test r15, r15 + je LBB0_9 +Ltmp3: + mov rdi, r15 + call _objc_release +Ltmp4: +LBB0_9: + mov rdi, rbx + call __Unwind_Resume +LBB0_10: +Ltmp5: + call SYM(core::panicking::panic_in_cleanup::GENERATED_ID, 0) +Lfunc_end0: + .section __TEXT,__gcc_except_tab + .p2align 2, 0x0 +GCC_except_table0: +Lexception0: + .byte 255 + .byte 155 + .uleb128 Lttbase0-Lttbaseref0 +Lttbaseref0: + .byte 1 + .uleb128 Lcst_end0-Lcst_begin0 +Lcst_begin0: + .uleb128 Lfunc_begin0-Lfunc_begin0 + .uleb128 Ltmp0-Lfunc_begin0 + .byte 0 + .byte 0 + .uleb128 Ltmp0-Lfunc_begin0 + .uleb128 Ltmp1-Ltmp0 + .uleb128 Ltmp2-Lfunc_begin0 + .byte 0 + .uleb128 Ltmp1-Lfunc_begin0 + .uleb128 Ltmp3-Ltmp1 + .byte 0 + .byte 0 + .uleb128 Ltmp3-Lfunc_begin0 + .uleb128 Ltmp4-Ltmp3 + .uleb128 Ltmp5-Lfunc_begin0 + .byte 1 + .uleb128 Ltmp4-Lfunc_begin0 + .uleb128 Lfunc_end0-Ltmp4 + .byte 0 + .byte 0 +Lcst_end0: + .byte 127 + .byte 0 + .p2align 2, 0x0 +Lttbase0: + .byte 0 + .p2align 2, 0x0 + .section __TEXT,__text,regular,pure_instructions .p2align 4, 0x90 SYM(::call_once::<::class::{closure#0}>::{closure#0}, 0): +Lfunc_begin1: push rbp mov rbp, rsp - push r15 - push r14 push rbx push rax mov rax, qword ptr [rdi] cmp byte ptr [rax], 0 mov byte ptr [rax], 0 - je LBB1_7 + je LBB1_18 mov rax, qword ptr [rip + L_OBJC_CLASSLIST_REFERENCES_$_NSObject@GOTPCREL] mov rdx, qword ptr [rax] lea rdi, [rip + l_anon.[ID].13] mov esi, 7 call SYM(objc2::runtime::declare::ClassBuilder::new::GENERATED_ID, 0) test rax, rax - je LBB1_8 - mov qword ptr [rbp - 32], rax + je LBB1_19 + mov qword ptr [rbp - 16], rax mov rsi, qword ptr [rip + L_OBJC_SELECTOR_REFERENCES_518803e84ea38a73] +Ltmp6: lea r8, [rip + l_anon.[ID].16] lea r9, [rip + _get_class] - lea rbx, [rbp - 32] + lea rdi, [rbp - 16] mov edx, 8 - mov rdi, rbx xor ecx, ecx call SYM(objc2::runtime::declare::ClassBuilder::add_class_method_inner::GENERATED_ID, 0) +Ltmp7: mov rsi, qword ptr [rip + L_OBJC_SELECTOR_REFERENCES_05fa1b2ffc15d267] +Ltmp8: lea r8, [rip + l_anon.[ID].3] lea r9, [rip + _method_simple] + lea rdi, [rbp - 16] mov edx, 8 - mov rdi, rbx xor ecx, ecx call SYM(objc2::runtime::declare::ClassBuilder::add_method_inner::GENERATED_ID, 0) +Ltmp9: mov rsi, qword ptr [rip + L_OBJC_SELECTOR_REFERENCES_58736195c9ca7c7f] - lea r14, [rip + l_anon.[ID].17] +Ltmp10: + lea rdx, [rip + l_anon.[ID].17] lea r9, [rip + _method_bool] + lea rdi, [rbp - 16] mov ecx, 1 - mov rdi, rbx - mov rdx, r14 - mov r8, r14 + mov r8, rdx call SYM(objc2::runtime::declare::ClassBuilder::add_method_inner::GENERATED_ID, 0) +Ltmp11: mov rsi, qword ptr [rip + L_OBJC_SELECTOR_REFERENCES_61b74dbf9c375668] - lea r15, [rip + l_anon.[ID].18] +Ltmp12: + lea r8, [rip + l_anon.[ID].18] lea r9, [rip + _method_id] + lea rdi, [rbp - 16] mov edx, 8 - mov rdi, rbx xor ecx, ecx - mov r8, r15 call SYM(objc2::runtime::declare::ClassBuilder::add_method_inner::GENERATED_ID, 0) +Ltmp13: mov rsi, qword ptr [rip + L_OBJC_SELECTOR_REFERENCES_96586542870e42e5] +Ltmp14: + lea rdx, [rip + l_anon.[ID].17] + lea r8, [rip + l_anon.[ID].18] lea r9, [rip + _method_id_with_param] + lea rdi, [rbp - 16] mov ecx, 1 - mov rdi, rbx - mov rdx, r14 - mov r8, r15 call SYM(objc2::runtime::declare::ClassBuilder::add_method_inner::GENERATED_ID, 0) +Ltmp15: +Ltmp16: lea rdi, [rip + L_anon.[ID].19] mov esi, 8 call SYM(objc2::runtime::AnyProtocol::get::GENERATED_ID, 0) +Ltmp17: test rax, rax - je LBB1_4 - mov rdi, qword ptr [rbp - 32] + je LBB1_10 + mov rdi, qword ptr [rbp - 16] mov rsi, rax call _class_addProtocol -LBB1_4: +LBB1_10: +Ltmp18: lea rdi, [rip + l_anon.[ID].20] mov esi, 9 call SYM(objc2::runtime::AnyProtocol::get::GENERATED_ID, 0) +Ltmp19: test rax, rax - je LBB1_6 - mov rdi, qword ptr [rbp - 32] + je LBB1_13 + mov rdi, qword ptr [rbp - 16] mov rsi, rax call _class_addProtocol -LBB1_6: +LBB1_13: mov rsi, qword ptr [rip + L_OBJC_SELECTOR_REFERENCES_f4e71677dafa88a8] +Ltmp20: lea rdx, [rip + l_anon.[ID].23] lea r8, [rip + l_anon.[ID].18] lea r9, [rip + _copyWithZone] - lea rdi, [rbp - 32] + lea rdi, [rbp - 16] mov ecx, 1 call SYM(objc2::runtime::declare::ClassBuilder::add_method_inner::GENERATED_ID, 0) - mov rbx, qword ptr [rbp - 32] +Ltmp21: + mov rbx, qword ptr [rbp - 16] mov rdi, rbx call _objc_registerClassPair mov qword ptr [rip + SYM(test_declare_class[CRATE_ID]::_::__OBJC2_CLASS, 0).0], rbx add rsp, 8 pop rbx - pop r14 - pop r15 pop rbp ret -LBB1_7: +LBB1_18: lea rdi, [rip + l_anon.[ID].12] call SYM(core::option::unwrap_failed::GENERATED_ID, 0) -LBB1_8: +LBB1_19: lea rdi, [rip + l_anon.[ID].13] lea rdx, [rip + l_anon.[ID].15] mov esi, 7 call SYM(objc2::__macro_helpers::declare_class::failed_declaring_class::GENERATED_ID, 0) +LBB1_15: +Ltmp22: + mov rbx, rax +Ltmp23: + lea rdi, [rbp - 16] + call SYM(::drop::GENERATED_ID, 0) +Ltmp24: + mov rdi, rbx + call __Unwind_Resume +LBB1_17: +Ltmp25: + call SYM(core::panicking::panic_in_cleanup::GENERATED_ID, 0) +Lfunc_end1: + .section __TEXT,__gcc_except_tab + .p2align 2, 0x0 +GCC_except_table1: +Lexception1: + .byte 255 + .byte 155 + .uleb128 Lttbase1-Lttbaseref1 +Lttbaseref1: + .byte 1 + .uleb128 Lcst_end1-Lcst_begin1 +Lcst_begin1: + .uleb128 Lfunc_begin1-Lfunc_begin1 + .uleb128 Ltmp6-Lfunc_begin1 + .byte 0 + .byte 0 + .uleb128 Ltmp6-Lfunc_begin1 + .uleb128 Ltmp21-Ltmp6 + .uleb128 Ltmp22-Lfunc_begin1 + .byte 0 + .uleb128 Ltmp21-Lfunc_begin1 + .uleb128 Ltmp23-Ltmp21 + .byte 0 + .byte 0 + .uleb128 Ltmp23-Lfunc_begin1 + .uleb128 Ltmp24-Ltmp23 + .uleb128 Ltmp25-Lfunc_begin1 + .byte 1 + .uleb128 Ltmp24-Lfunc_begin1 + .uleb128 Lfunc_end1-Ltmp24 + .byte 0 + .byte 0 +Lcst_end1: + .byte 127 + .byte 0 + .p2align 2, 0x0 +Lttbase1: + .byte 0 + .p2align 2, 0x0 + .section __TEXT,__text,regular,pure_instructions .p2align 4, 0x90 SYM(::call_once::<::class::{closure#0}>::{closure#0}, 0): +Lfunc_begin2: push rbp mov rbp, rsp push r14 @@ -153,61 +274,67 @@ SYM(::call_once::<, 0)] lea rdi, [rbp - 72] mov edx, 8 xor ecx, ecx call SYM(objc2::runtime::declare::ClassBuilder::add_method_inner::GENERATED_ID, 0) +Ltmp27: mov rax, qword ptr [rbp - 72] - mov qword ptr [rbp - 24], rax + mov qword ptr [rbp - 32], rax mov rax, qword ptr [rip + L_OBJC_SELECTOR_REFERENCES_init@GOTPCREL] mov rsi, qword ptr [rax] +Ltmp32: lea r8, [rip + l_anon.[ID].18] lea r9, [rip + _init_drop_ivars] - lea rdi, [rbp - 24] + lea rdi, [rbp - 32] mov edx, 8 xor ecx, ecx call SYM(objc2::runtime::declare::ClassBuilder::add_method_inner::GENERATED_ID, 0) - mov rax, qword ptr [rbp - 24] - mov qword ptr [rbp - 32], rax +Ltmp33: + mov rax, qword ptr [rbp - 32] + mov qword ptr [rbp - 24], rax mov qword ptr [rbp - 64], 16 lea rax, [rip + l_anon.[ID].8] mov qword ptr [rbp - 56], rax mov byte ptr [rbp - 72], 27 - lea r14, [rip + l_anon.[ID].4] - lea rbx, [rbp - 32] +Ltmp38: + lea rsi, [rip + l_anon.[ID].4] + lea rdi, [rbp - 24] lea r9, [rbp - 72] mov edx, 5 mov ecx, 16 - mov rdi, rbx - mov rsi, r14 mov r8d, 3 call SYM(objc2::runtime::declare::ClassBuilder::add_ivar_inner_mono::GENERATED_ID, 0) +Ltmp39: +Ltmp40: lea rsi, [rip + l_anon.[ID].5] lea r9, [rip + l_anon.[ID].6] + lea rdi, [rbp - 24] mov edx, 9 mov ecx, 1 - mov rdi, rbx xor r8d, r8d call SYM(objc2::runtime::declare::ClassBuilder::add_ivar_inner_mono::GENERATED_ID, 0) - mov rbx, qword ptr [rbp - 32] +Ltmp41: + mov rbx, qword ptr [rbp - 24] mov rdi, rbx call _objc_registerClassPair + lea rsi, [rip + l_anon.[ID].4] mov edx, 5 mov rdi, rbx - mov rsi, r14 call SYM(objc2::runtime::AnyClass::instance_variable::GENERATED_ID, 0) test rax, rax je LBB2_7 @@ -219,7 +346,7 @@ SYM(::call_once::<::call_once::<::drop::GENERATED_ID, 0) +Ltmp36: + jmp LBB2_9 +LBB2_15: +Ltmp37: + call SYM(core::panicking::panic_in_cleanup::GENERATED_ID, 0) +LBB2_8: +Ltmp28: + mov rbx, rax +Ltmp29: + lea rdi, [rbp - 72] + call SYM(::drop::GENERATED_ID, 0) +Ltmp30: + jmp LBB2_9 +LBB2_19: +Ltmp31: + call SYM(core::panicking::panic_in_cleanup::GENERATED_ID, 0) +LBB2_13: +Ltmp42: + mov rbx, rax +Ltmp43: + lea rdi, [rbp - 24] + call SYM(::drop::GENERATED_ID, 0) +Ltmp44: +LBB2_9: + mov rdi, rbx + call __Unwind_Resume +LBB2_12: +Ltmp45: + call SYM(core::panicking::panic_in_cleanup::GENERATED_ID, 0) +Lfunc_end2: + .section __TEXT,__gcc_except_tab + .p2align 2, 0x0 +GCC_except_table2: +Lexception2: + .byte 255 + .byte 155 + .uleb128 Lttbase2-Lttbaseref2 +Lttbaseref2: + .byte 1 + .uleb128 Lcst_end2-Lcst_begin2 +Lcst_begin2: + .uleb128 Lfunc_begin2-Lfunc_begin2 + .uleb128 Ltmp26-Lfunc_begin2 + .byte 0 + .byte 0 + .uleb128 Ltmp26-Lfunc_begin2 + .uleb128 Ltmp27-Ltmp26 + .uleb128 Ltmp28-Lfunc_begin2 + .byte 0 + .uleb128 Ltmp32-Lfunc_begin2 + .uleb128 Ltmp33-Ltmp32 + .uleb128 Ltmp34-Lfunc_begin2 + .byte 0 + .uleb128 Ltmp38-Lfunc_begin2 + .uleb128 Ltmp41-Ltmp38 + .uleb128 Ltmp42-Lfunc_begin2 + .byte 0 + .uleb128 Ltmp41-Lfunc_begin2 + .uleb128 Ltmp35-Ltmp41 + .byte 0 + .byte 0 + .uleb128 Ltmp35-Lfunc_begin2 + .uleb128 Ltmp36-Ltmp35 + .uleb128 Ltmp37-Lfunc_begin2 + .byte 1 + .uleb128 Ltmp29-Lfunc_begin2 + .uleb128 Ltmp30-Ltmp29 + .uleb128 Ltmp31-Lfunc_begin2 + .byte 1 + .uleb128 Ltmp43-Lfunc_begin2 + .uleb128 Ltmp44-Ltmp43 + .uleb128 Ltmp45-Lfunc_begin2 + .byte 1 + .uleb128 Ltmp44-Lfunc_begin2 + .uleb128 Lfunc_end2-Ltmp44 + .byte 0 + .byte 0 +Lcst_end2: + .byte 127 + .byte 0 + .p2align 2, 0x0 +Lttbase2: + .byte 0 + .p2align 2, 0x0 + .section __TEXT,__text,regular,pure_instructions .p2align 4, 0x90 SYM(::call_once::<::class::{closure#0}>::{closure#0}, 0): +Lfunc_begin3: push rbp mov rbp, rsp - push r14 push rbx - sub rsp, 64 + sub rsp, 56 mov rax, qword ptr [rdi] cmp byte ptr [rax], 0 mov byte ptr [rax], 0 - je LBB3_4 + je LBB3_12 mov rax, qword ptr [rip + L_OBJC_CLASSLIST_REFERENCES_$_NSObject@GOTPCREL] mov rdx, qword ptr [rax] lea rdi, [rip + l_anon.[ID].9] mov esi, 15 call SYM(objc2::runtime::declare::ClassBuilder::new::GENERATED_ID, 0) test rax, rax - je LBB3_5 - mov qword ptr [rbp - 24], rax + je LBB3_13 + mov qword ptr [rbp - 16], rax mov rax, qword ptr [rip + L_OBJC_SELECTOR_REFERENCES_init@GOTPCREL] mov rsi, qword ptr [rax] +Ltmp46: lea r8, [rip + l_anon.[ID].18] lea r9, [rip + _init_forgetable_ivars] - lea rdi, [rbp - 24] + lea rdi, [rbp - 16] mov edx, 8 xor ecx, ecx call SYM(objc2::runtime::declare::ClassBuilder::add_method_inner::GENERATED_ID, 0) - mov rax, qword ptr [rbp - 24] - mov qword ptr [rbp - 32], rax - mov qword ptr [rbp - 64], 8 +Ltmp47: + mov rax, qword ptr [rbp - 16] + mov qword ptr [rbp - 24], rax + mov qword ptr [rbp - 56], 8 lea rax, [rip + l_anon.[ID].7] - mov qword ptr [rbp - 56], rax - mov byte ptr [rbp - 72], 27 - lea r14, [rip + l_anon.[ID].4] - lea rdi, [rbp - 32] - lea r9, [rbp - 72] + mov qword ptr [rbp - 48], rax + mov byte ptr [rbp - 64], 27 +Ltmp52: + lea rsi, [rip + l_anon.[ID].4] + lea rdi, [rbp - 24] + lea r9, [rbp - 64] mov edx, 5 mov ecx, 8 - mov rsi, r14 mov r8d, 2 call SYM(objc2::runtime::declare::ClassBuilder::add_ivar_inner_mono::GENERATED_ID, 0) - mov rbx, qword ptr [rbp - 32] +Ltmp53: + mov rbx, qword ptr [rbp - 24] mov rdi, rbx call _objc_registerClassPair + lea rsi, [rip + l_anon.[ID].4] mov edx, 5 mov rdi, rbx - mov rsi, r14 call SYM(objc2::runtime::AnyClass::instance_variable::GENERATED_ID, 0) test rax, rax - je LBB3_6 + je LBB3_5 mov rdi, rax call _ivar_getOffset mov qword ptr [rip + SYM(test_declare_class[CRATE_ID]::_::__OBJC2_CLASS, 2).0], rbx mov qword ptr [rip + SYM(test_declare_class[CRATE_ID]::_::__OBJC2_IVAR_OFFSET, 1)], rax - add rsp, 64 + add rsp, 56 pop rbx - pop r14 pop rbp ret -LBB3_4: +LBB3_12: lea rdi, [rip + l_anon.[ID].12] call SYM(core::option::unwrap_failed::GENERATED_ID, 0) -LBB3_5: +LBB3_13: lea rdi, [rip + l_anon.[ID].9] lea rdx, [rip + l_anon.[ID].24] mov esi, 15 call SYM(objc2::__macro_helpers::declare_class::failed_declaring_class::GENERATED_ID, 0) -LBB3_6: +LBB3_5: call SYM(objc2::__macro_helpers::declared_ivars::register_with_ivars::get_ivar_failed::GENERATED_ID, 0) +LBB3_7: +Ltmp54: + mov rbx, rax +Ltmp55: + lea rdi, [rbp - 24] + call SYM(::drop::GENERATED_ID, 0) +Ltmp56: + jmp LBB3_8 +LBB3_6: +Ltmp57: + call SYM(core::panicking::panic_in_cleanup::GENERATED_ID, 0) +LBB3_9: +Ltmp48: + mov rbx, rax +Ltmp49: + lea rdi, [rbp - 16] + call SYM(::drop::GENERATED_ID, 0) +Ltmp50: +LBB3_8: + mov rdi, rbx + call __Unwind_Resume +LBB3_10: +Ltmp51: + call SYM(core::panicking::panic_in_cleanup::GENERATED_ID, 0) +Lfunc_end3: + .section __TEXT,__gcc_except_tab + .p2align 2, 0x0 +GCC_except_table3: +Lexception3: + .byte 255 + .byte 155 + .uleb128 Lttbase3-Lttbaseref3 +Lttbaseref3: + .byte 1 + .uleb128 Lcst_end3-Lcst_begin3 +Lcst_begin3: + .uleb128 Lfunc_begin3-Lfunc_begin3 + .uleb128 Ltmp46-Lfunc_begin3 + .byte 0 + .byte 0 + .uleb128 Ltmp46-Lfunc_begin3 + .uleb128 Ltmp47-Ltmp46 + .uleb128 Ltmp48-Lfunc_begin3 + .byte 0 + .uleb128 Ltmp52-Lfunc_begin3 + .uleb128 Ltmp53-Ltmp52 + .uleb128 Ltmp54-Lfunc_begin3 + .byte 0 + .uleb128 Ltmp53-Lfunc_begin3 + .uleb128 Ltmp55-Ltmp53 + .byte 0 + .byte 0 + .uleb128 Ltmp55-Lfunc_begin3 + .uleb128 Ltmp56-Ltmp55 + .uleb128 Ltmp57-Lfunc_begin3 + .byte 1 + .uleb128 Ltmp49-Lfunc_begin3 + .uleb128 Ltmp50-Ltmp49 + .uleb128 Ltmp51-Lfunc_begin3 + .byte 1 + .uleb128 Ltmp50-Lfunc_begin3 + .uleb128 Lfunc_end3-Ltmp50 + .byte 0 + .byte 0 +Lcst_end3: + .byte 127 + .byte 0 + .p2align 2, 0x0 +Lttbase3: + .byte 0 + .p2align 2, 0x0 + .section __TEXT,__text,regular,pure_instructions .p2align 4, 0x90 SYM(<::call_once<::class::{closure#0}>::{closure#0} as core[CRATE_ID]::ops::function::FnOnce<(&std[CRATE_ID]::sync::once::OnceState,)>>::call_once::{shim:vtable#0}, 0): push rbp @@ -541,6 +833,7 @@ LBB16_1: .globl _method_id_with_param .p2align 4, 0x90 _method_id_with_param: +Lfunc_begin4: push rbp mov rbp, rsp push r14 @@ -549,19 +842,73 @@ _method_id_with_param: call SYM(objc2::runtime::nsobject::NSObject::new::GENERATED_ID, 0) mov rbx, rax test r14b, r14b - je LBB17_2 + je LBB17_3 +Ltmp58: call SYM(objc2::runtime::nsobject::NSObject::new::GENERATED_ID, 0) +Ltmp59: mov r14, rax mov rdi, rbx call _objc_release mov rbx, r14 -LBB17_2: +LBB17_3: mov rdi, rbx pop rbx pop r14 pop rbp jmp _objc_autoreleaseReturnValue +LBB17_5: +Ltmp60: + mov r14, rax +Ltmp61: + mov rdi, rbx + call _objc_release +Ltmp62: + mov rdi, r14 + call __Unwind_Resume +LBB17_4: +Ltmp63: + call SYM(core::panicking::panic_in_cleanup::GENERATED_ID, 0) +Lfunc_end4: + .section __TEXT,__gcc_except_tab + .p2align 2, 0x0 +GCC_except_table17: +Lexception4: + .byte 255 + .byte 155 + .uleb128 Lttbase4-Lttbaseref4 +Lttbaseref4: + .byte 1 + .uleb128 Lcst_end4-Lcst_begin4 +Lcst_begin4: + .uleb128 Lfunc_begin4-Lfunc_begin4 + .uleb128 Ltmp58-Lfunc_begin4 + .byte 0 + .byte 0 + .uleb128 Ltmp58-Lfunc_begin4 + .uleb128 Ltmp59-Ltmp58 + .uleb128 Ltmp60-Lfunc_begin4 + .byte 0 + .uleb128 Ltmp59-Lfunc_begin4 + .uleb128 Ltmp61-Ltmp59 + .byte 0 + .byte 0 + .uleb128 Ltmp61-Lfunc_begin4 + .uleb128 Ltmp62-Ltmp61 + .uleb128 Ltmp63-Lfunc_begin4 + .byte 1 + .uleb128 Ltmp62-Lfunc_begin4 + .uleb128 Lfunc_end4-Ltmp62 + .byte 0 + .byte 0 +Lcst_end4: + .byte 127 + .byte 0 + .p2align 2, 0x0 +Lttbase4: + .byte 0 + .p2align 2, 0x0 + .section __TEXT,__text,regular,pure_instructions .globl _copyWithZone .p2align 4, 0x90 _copyWithZone: @@ -669,49 +1016,138 @@ LBB21_1: .globl _init_drop_ivars .p2align 4, 0x90 _init_drop_ivars: +Lfunc_begin5: push rbp mov rbp, rsp push r15 push r14 + push r12 push rbx - sub rsp, 24 + sub rsp, 16 mov rbx, rdi +Ltmp64: call SYM(objc2::runtime::nsobject::NSObject::new::GENERATED_ID, 0) - mov r14, rax - call SYM(objc2::runtime::nsobject::NSObject::new::GENERATED_ID, 0) +Ltmp65: +Ltmp67: mov r15, rax + call SYM(objc2::runtime::nsobject::NSObject::new::GENERATED_ID, 0) +Ltmp68: + mov r12, rax test rbx, rbx - je LBB22_1 + je LBB22_3 mov rax, qword ptr [rip + SYM(test_declare_class[CRATE_ID]::_::__OBJC2_IVAR_OFFSET, 0)] - mov qword ptr [rbx + rax], r14 - mov qword ptr [rbx + rax + 8], r15 + mov qword ptr [rbx + rax], r15 + mov qword ptr [rbx + rax + 8], r12 mov rax, qword ptr [rip + SYM(test_declare_class[CRATE_ID]::_::__OBJC2_DROP_FLAG_OFFSET, 0)] mov byte ptr [rbx + rax], 15 - jmp LBB22_3 -LBB22_1: - mov rdi, r14 - call _objc_release + jmp LBB22_9 +LBB22_3: +Ltmp75: mov rdi, r15 call _objc_release -LBB22_3: +Ltmp76: + mov rdi, r12 + call _objc_release +LBB22_9: mov rsi, qword ptr [rip + L_OBJC_SELECTOR_REFERENCES_802cb9c5fa0b19dd] mov rax, qword ptr [rip + L_OBJC_CLASSLIST_REFERENCES_$_NSObject@GOTPCREL] mov rax, qword ptr [rax] - mov qword ptr [rbp - 40], rbx - mov qword ptr [rbp - 32], rax - lea rdi, [rbp - 40] + mov qword ptr [rbp - 48], rbx + mov qword ptr [rbp - 40], rax + lea rdi, [rbp - 48] call _objc_msgSendSuper test rax, rax - je LBB22_5 + je LBB22_11 mov rcx, qword ptr [rip + SYM(test_declare_class[CRATE_ID]::_::__OBJC2_DROP_FLAG_OFFSET, 0)] mov byte ptr [rax + rcx], -1 -LBB22_5: - add rsp, 24 +LBB22_11: + add rsp, 16 pop rbx + pop r12 pop r14 pop r15 pop rbp ret +LBB22_6: +Ltmp77: + mov r14, rax +Ltmp78: + mov rdi, r12 + call _objc_release +Ltmp79: + jmp LBB22_15 +LBB22_7: +Ltmp80: + call SYM(core::panicking::panic_in_cleanup::GENERATED_ID, 0) +LBB22_5: +Ltmp69: + mov r14, rax +Ltmp70: + mov rdi, r15 + call _objc_release +Ltmp71: + jmp LBB22_14 +LBB22_13: +Ltmp66: + mov r14, rax +LBB22_14: +Ltmp72: + mov rdi, rbx + call _objc_release +Ltmp73: +LBB22_15: + mov rdi, r14 + call __Unwind_Resume +LBB22_12: +Ltmp74: + call SYM(core::panicking::panic_in_cleanup::GENERATED_ID, 0) +Lfunc_end5: + .section __TEXT,__gcc_except_tab + .p2align 2, 0x0 +GCC_except_table22: +Lexception5: + .byte 255 + .byte 155 + .uleb128 Lttbase5-Lttbaseref5 +Lttbaseref5: + .byte 1 + .uleb128 Lcst_end5-Lcst_begin5 +Lcst_begin5: + .uleb128 Ltmp64-Lfunc_begin5 + .uleb128 Ltmp65-Ltmp64 + .uleb128 Ltmp66-Lfunc_begin5 + .byte 0 + .uleb128 Ltmp67-Lfunc_begin5 + .uleb128 Ltmp68-Ltmp67 + .uleb128 Ltmp69-Lfunc_begin5 + .byte 0 + .uleb128 Ltmp75-Lfunc_begin5 + .uleb128 Ltmp76-Ltmp75 + .uleb128 Ltmp77-Lfunc_begin5 + .byte 0 + .uleb128 Ltmp76-Lfunc_begin5 + .uleb128 Ltmp78-Ltmp76 + .byte 0 + .byte 0 + .uleb128 Ltmp78-Lfunc_begin5 + .uleb128 Ltmp79-Ltmp78 + .uleb128 Ltmp80-Lfunc_begin5 + .byte 1 + .uleb128 Ltmp70-Lfunc_begin5 + .uleb128 Ltmp73-Ltmp70 + .uleb128 Ltmp74-Lfunc_begin5 + .byte 1 + .uleb128 Ltmp73-Lfunc_begin5 + .uleb128 Lfunc_end5-Ltmp73 + .byte 0 + .byte 0 +Lcst_end5: + .byte 127 + .byte 0 + .p2align 2, 0x0 +Lttbase5: + .byte 0 + .p2align 2, 0x0 .section __DATA,__const .p2align 3, 0x0 diff --git a/crates/test-assembly/crates/test_dynamic_class/expected/apple-aarch64.s b/crates/test-assembly/crates/test_dynamic_class/expected/apple-aarch64.s index e8921fb62..054070d54 100644 --- a/crates/test-assembly/crates/test_dynamic_class/expected/apple-aarch64.s +++ b/crates/test-assembly/crates/test_dynamic_class/expected/apple-aarch64.s @@ -228,12 +228,8 @@ Lloh69: add x2, x2, l_anon.[ID].9@PAGEOFF mov x22, x8 bl SYM(objc2::__macro_helpers::cache::CachedClass::fetch::GENERATED_ID, 0) - stp x19, x20, [x22] - stp x21, x0, [x22, #16] - ldp x29, x30, [sp, #32] - ldp x20, x19, [sp, #16] - ldp x22, x21, [sp], #48 - ret + mov x8, x22 + b LBB4_4 .loh AdrpLdr Lloh32, Lloh33 .loh AdrpLdr Lloh34, Lloh35 .loh AdrpLdr Lloh36, Lloh37 @@ -304,10 +300,8 @@ Lloh81: add x2, x2, l_anon.[ID].2@PAGEOFF mov x20, x8 bl SYM(objc2::__macro_helpers::cache::CachedClass::fetch::GENERATED_ID, 0) - stp x19, x0, [x20] - ldp x29, x30, [sp, #16] - ldp x20, x19, [sp], #32 - ret + mov x8, x20 + b LBB5_2 .loh AdrpAdd Lloh74, Lloh75 .loh AdrpAdd Lloh72, Lloh73 .loh AdrpAdd Lloh70, Lloh71 diff --git a/crates/test-assembly/crates/test_dynamic_sel/expected/apple-aarch64.s b/crates/test-assembly/crates/test_dynamic_sel/expected/apple-aarch64.s index e66c18761..e94103737 100644 --- a/crates/test-assembly/crates/test_dynamic_sel/expected/apple-aarch64.s +++ b/crates/test-assembly/crates/test_dynamic_sel/expected/apple-aarch64.s @@ -89,9 +89,7 @@ Lloh21: bl SYM(objc2::__macro_helpers::cache::CachedSel::fetch::GENERATED_ID, 0) mov x1, x0 mov x0, x19 - ldp x29, x30, [sp, #16] - ldp x20, x19, [sp], #32 - ret + b LBB2_2 .loh AdrpLdrGot Lloh12, Lloh13 .loh AdrpAdd Lloh16, Lloh17 .loh AdrpLdrGot Lloh14, Lloh15 @@ -245,12 +243,8 @@ Lloh63: add x1, x1, l_anon.[ID].4@PAGEOFF mov x22, x8 bl SYM(objc2::__macro_helpers::cache::CachedSel::fetch::GENERATED_ID, 0) - stp x19, x20, [x22] - stp x21, x0, [x22, #16] - ldp x29, x30, [sp, #32] - ldp x20, x19, [sp, #16] - ldp x22, x21, [sp], #48 - ret + mov x8, x22 + b LBB5_4 .loh AdrpLdr Lloh34, Lloh35 .loh AdrpLdr Lloh36, Lloh37 .loh AdrpLdr Lloh38, Lloh39 @@ -309,10 +303,8 @@ Lloh71: add x1, x1, l_anon.[ID].0@PAGEOFF mov x20, x8 bl SYM(objc2::__macro_helpers::cache::CachedSel::fetch::GENERATED_ID, 0) - stp x19, x0, [x20] - ldp x29, x30, [sp, #16] - ldp x20, x19, [sp], #32 - ret + mov x8, x20 + b LBB6_2 .loh AdrpAdd Lloh66, Lloh67 .loh AdrpAdd Lloh64, Lloh65 .loh AdrpAdd Lloh70, Lloh71 diff --git a/crates/test-assembly/crates/test_fast_enumeration/expected/apple-aarch64.s b/crates/test-assembly/crates/test_fast_enumeration/expected/apple-aarch64.s index 851520a0d..4a0d12539 100644 --- a/crates/test-assembly/crates/test_fast_enumeration/expected/apple-aarch64.s +++ b/crates/test-assembly/crates/test_fast_enumeration/expected/apple-aarch64.s @@ -241,6 +241,7 @@ LBB4_7: .globl _iter_retained .p2align 2 _iter_retained: +Lfunc_begin0: sub sp, sp, #304 stp x24, x23, [sp, #240] stp x22, x21, [sp, #256] @@ -276,16 +277,16 @@ Lloh15: b.lo LBB5_5 LBB5_1: ldr x1, [x20] - cbz x1, LBB5_11 + cbz x1, LBB5_12 add x2, x22, #152 add x3, x22, #24 mov w4, #16 bl _objc_msgSend stp xzr, x0, [sp, #224] - cbz x0, LBB5_12 + cbz x0, LBB5_13 LBB5_3: ldr x8, [sp, #168] - cbz x8, LBB5_13 + cbz x8, LBB5_14 mov x8, #0 LBB5_5: ldr x9, [sp, #176] @@ -295,25 +296,27 @@ LBB5_5: tbz w10, #0, LBB5_9 ldr x10, [sp, #16] cmp x10, x9 - b.ne LBB5_14 + b.ne LBB5_15 LBB5_8: ldr x9, [sp, #168] add x10, x8, #1 str x10, [sp, #224] ldr x0, [x9, x8, lsl #3] cbnz x0, LBB5_10 - b LBB5_12 + b LBB5_13 LBB5_9: stp x23, x9, [sp, #8] ldr x9, [sp, #168] add x10, x8, #1 str x10, [sp, #224] ldr x0, [x9, x8, lsl #3] - cbz x0, LBB5_12 + cbz x0, LBB5_13 LBB5_10: bl _objc_retain mov x21, x0 +Ltmp1: bl _use_obj +Ltmp2: mov x0, x21 bl _objc_release ldr x0, [sp, #24] @@ -321,7 +324,7 @@ LBB5_10: cmp x8, x9 b.hs LBB5_1 b LBB5_5 -LBB5_11: +LBB5_12: mov x21, x0 mov x0, x20 mov x1, x19 @@ -334,19 +337,70 @@ LBB5_11: bl _objc_msgSend stp xzr, x0, [sp, #224] cbnz x0, LBB5_3 -LBB5_12: +LBB5_13: ldp x29, x30, [sp, #288] ldp x20, x19, [sp, #272] ldp x22, x21, [sp, #256] ldp x24, x23, [sp, #240] add sp, sp, #304 ret -LBB5_13: - bl SYM(objc2_foundation::iter::items_ptr_null::GENERATED_ID, 0) LBB5_14: + bl SYM(objc2_foundation::iter::items_ptr_null::GENERATED_ID, 0) +LBB5_15: bl SYM(objc2_foundation::iter::mutation_detected::GENERATED_ID, 0) +LBB5_16: +Ltmp3: + mov x19, x0 +Ltmp4: + mov x0, x21 + bl _objc_release +Ltmp5: + mov x0, x19 + bl __Unwind_Resume +LBB5_18: +Ltmp6: + bl SYM(core::panicking::panic_in_cleanup::GENERATED_ID, 0) .loh AdrpLdrGot Lloh14, Lloh15 .loh AdrpAdd Lloh12, Lloh13 +Lfunc_end0: + .section __TEXT,__gcc_except_tab + .p2align 2, 0x0 +GCC_except_table5: +Lexception0: + .byte 255 + .byte 155 + .uleb128 Lttbase0-Lttbaseref0 +Lttbaseref0: + .byte 1 + .uleb128 Lcst_end0-Lcst_begin0 +Lcst_begin0: + .uleb128 Lfunc_begin0-Lfunc_begin0 + .uleb128 Ltmp1-Lfunc_begin0 + .byte 0 + .byte 0 + .uleb128 Ltmp1-Lfunc_begin0 + .uleb128 Ltmp2-Ltmp1 + .uleb128 Ltmp3-Lfunc_begin0 + .byte 0 + .uleb128 Ltmp2-Lfunc_begin0 + .uleb128 Ltmp4-Ltmp2 + .byte 0 + .byte 0 + .uleb128 Ltmp4-Lfunc_begin0 + .uleb128 Ltmp5-Ltmp4 + .uleb128 Ltmp6-Lfunc_begin0 + .byte 1 + .uleb128 Ltmp5-Lfunc_begin0 + .uleb128 Lfunc_end0-Ltmp5 + .byte 0 + .byte 0 +Lcst_end0: + .byte 127 + .byte 0 + .p2align 2, 0x0 +Lttbase0: + .byte 0 + .p2align 2, 0x0 .section __TEXT,__const l_anon.[ID].0: diff --git a/crates/test-assembly/crates/test_fast_enumeration/expected/apple-armv7s.s b/crates/test-assembly/crates/test_fast_enumeration/expected/apple-armv7s.s index ae8b38022..b9325f904 100644 --- a/crates/test-assembly/crates/test_fast_enumeration/expected/apple-armv7s.s +++ b/crates/test-assembly/crates/test_fast_enumeration/expected/apple-armv7s.s @@ -254,111 +254,229 @@ LBB4_7: .p2align 2 .code 32 _iter_retained: +Lfunc_begin0: push {r4, r5, r6, r7, lr} add r7, sp, #12 push {r8, r10, r11} - sub sp, sp, #128 - bfc sp, #0, #3 - add r1, sp, #8 + sub r4, sp, #64 + bfc r4, #0, #4 + mov sp, r4 + vst1.64 {d8, d9, d10, d11}, [r4:128]! + vst1.64 {d12, d13, d14, d15}, [r4:128] + sub sp, sp, #192 + add r1, sp, #16 add r2, r1, #88 vmov.i32 q8, #0x0 vst1.64 {d16, d17}, [r2]! - mov r11, #0 - add r4, r1, #12 - mov r5, r4 - vst1.32 {d16, d17}, [r5]! - vst1.32 {d16, d17}, [r5]! - vst1.32 {d16, d17}, [r5]! - vst1.32 {d16, d17}, [r5]! - str r11, [r2] - str r11, [sp, #8] - str r0, [sp, #16] - str r11, [r5] - str r11, [sp, #88] - str r11, [sp, #92] - str r11, [sp, #116] - str r11, [sp, #120] - movw r10, :lower16:(LSYM(objc2_foundation::generated::__NSEnumerator::NSFastEnumeration::countByEnumeratingWithState_objects_count::CACHED_SEL::GENERATED_ID, 0)$non_lazy_ptr-(LPC5_0+8)) - movt r10, :upper16:(LSYM(objc2_foundation::generated::__NSEnumerator::NSFastEnumeration::countByEnumeratingWithState_objects_count::CACHED_SEL::GENERATED_ID, 0)$non_lazy_ptr-(LPC5_0+8)) + mov r4, r0 + add r0, r1, #12 + str r0, [sp, #12] + vst1.32 {d16, d17}, [r0]! + vst1.32 {d16, d17}, [r0]! + vst1.32 {d16, d17}, [r0]! + vst1.32 {d16, d17}, [r0]! + mov r1, #0 + str r1, [r2] + str r1, [sp, #16] + str r4, [sp, #24] + str r0, [sp, #8] + str r1, [r0] + str r1, [sp, #96] + str r1, [sp, #100] + str r1, [sp, #124] + str r1, [sp, #128] + movw r0, :lower16:(L_rust_eh_personality$non_lazy_ptr-(LPC5_2+8)) + movt r0, :upper16:(L_rust_eh_personality$non_lazy_ptr-(LPC5_2+8)) +LPC5_2: + ldr r0, [pc, r0] + str r0, [sp, #164] + ldr r0, LCPI5_0 LPC5_0: - ldr r10, [pc, r10] - mov r8, #16 + add r0, pc, r0 + str r0, [sp, #168] + str r7, [sp, #172] + str sp, [sp, #180] + ldr r0, LCPI5_1 +LPC5_1: + add r0, pc, r0 + str r0, [sp, #176] + add r0, sp, #140 + bl __Unwind_SjLj_Register + mov r0, r4 + mvn r5, #0 mov r2, #0 mov r1, #0 cmp r1, r2 blo LBB5_4 LBB5_1: - ldr r1, [r10] + movw r1, :lower16:(LSYM(objc2_foundation::generated::__NSEnumerator::NSFastEnumeration::countByEnumeratingWithState_objects_count::CACHED_SEL::GENERATED_ID, 0)$non_lazy_ptr-(LPC5_3+8)) + movt r1, :upper16:(LSYM(objc2_foundation::generated::__NSEnumerator::NSFastEnumeration::countByEnumeratingWithState_objects_count::CACHED_SEL::GENERATED_ID, 0)$non_lazy_ptr-(LPC5_3+8)) +LPC5_3: + ldr r1, [pc, r1] + ldr r1, [r1] cmp r1, #0 - beq LBB5_10 + beq LBB5_11 LBB5_2: - str r8, [sp] - mov r2, r5 - mov r3, r4 + str r5, [sp, #144] + mov r2, #16 + str r2, [sp] + ldr r2, [sp, #8] + ldr r3, [sp, #12] bl _objc_msgSend - str r0, [sp, #120] - str r11, [sp, #116] - cmp r0, #0 - beq LBB5_11 - ldr r0, [sp, #88] + str r0, [sp, #128] mov r1, #0 + str r1, [sp, #124] cmp r0, #0 beq LBB5_12 + ldr r0, [sp, #96] + cmp r0, #0 + beq LBB5_13 LBB5_4: - ldr r0, [sp, #92] + ldr r0, [sp, #100] cmp r0, #0 beq LBB5_8 ldr r0, [r0] - ldr r2, [sp, #8] + ldr r2, [sp, #16] cmp r2, #0 beq LBB5_7 - ldr r2, [sp, #12] + ldr r2, [sp, #20] cmp r2, r0 beq LBB5_8 - b LBB5_13 + b LBB5_14 LBB5_7: mov r2, #1 - str r2, [sp, #8] - str r0, [sp, #12] + str r2, [sp, #16] + str r0, [sp, #20] LBB5_8: - ldr r0, [sp, #88] + ldr r0, [sp, #96] add r2, r1, #1 - str r2, [sp, #116] + str r2, [sp, #124] ldr r0, [r0, r1, lsl #2] cmp r0, #0 - beq LBB5_11 + beq LBB5_12 + str r5, [sp, #144] bl _objc_retain - mov r6, r0 + str r0, [sp, #136] + ldr r0, [sp, #136] + mov r1, #1 + str r1, [sp, #144] +Ltmp0: bl _use_obj - mov r0, r6 +Ltmp1: + ldr r0, [sp, #136] + mvn r1, #0 + str r1, [sp, #144] bl _objc_release - ldr r0, [sp, #16] - ldr r1, [sp, #116] - ldr r2, [sp, #120] + ldr r0, [sp, #24] + ldr r1, [sp, #124] + ldr r2, [sp, #128] + mvn r5, #0 cmp r1, r2 bhs LBB5_1 b LBB5_4 -LBB5_10: - mov r6, r0 - mov r0, r10 - movw r1, :lower16:(l_anon.[ID].0-(LPC5_1+8)) - movt r1, :upper16:(l_anon.[ID].0-(LPC5_1+8)) -LPC5_1: +LBB5_11: + str r5, [sp, #144] + mov r4, r0 + movw r0, :lower16:(LSYM(objc2_foundation::generated::__NSEnumerator::NSFastEnumeration::countByEnumeratingWithState_objects_count::CACHED_SEL::GENERATED_ID, 0)$non_lazy_ptr-(LPC5_4+8)) + movt r0, :upper16:(LSYM(objc2_foundation::generated::__NSEnumerator::NSFastEnumeration::countByEnumeratingWithState_objects_count::CACHED_SEL::GENERATED_ID, 0)$non_lazy_ptr-(LPC5_4+8)) +LPC5_4: + ldr r0, [pc, r0] + movw r1, :lower16:(l_anon.[ID].0-(LPC5_5+8)) + movt r1, :upper16:(l_anon.[ID].0-(LPC5_5+8)) +LPC5_5: add r1, pc, r1 bl SYM(objc2::__macro_helpers::cache::CachedSel::fetch::GENERATED_ID, 0) mov r1, r0 - mov r0, r6 + mov r0, r4 b LBB5_2 -LBB5_11: +LBB5_12: + add r0, sp, #140 + bl __Unwind_SjLj_Unregister + add r4, sp, #192 + vld1.64 {d8, d9, d10, d11}, [r4:128]! + vld1.64 {d12, d13, d14, d15}, [r4:128] sub sp, r7, #24 pop {r8, r10, r11} pop {r4, r5, r6, r7, pc} -LBB5_12: +LBB5_13: + mvn r0, #0 + str r0, [sp, #144] mov lr, pc b SYM(objc2_foundation::iter::items_ptr_null::GENERATED_ID, 0) -LBB5_13: +LBB5_14: + mvn r0, #0 + str r0, [sp, #144] mov lr, pc b SYM(objc2_foundation::iter::mutation_detected::GENERATED_ID, 0) +LBB5_15: + lsl r0, r0, #2 + adr r1, LJTI5_0 + ldr r0, [r0, r1] + add pc, r0, r1 + .p2align 2 +LJTI5_0: + .data_region jt32 + .long LBB5_17-LJTI5_0 + .long LBB5_20-LJTI5_0 + .end_data_region +LBB5_17: +Ltmp2: + ldr r0, [sp, #148] + str r0, [sp, #12] + ldr r0, [sp, #136] + mov r1, #2 + str r1, [sp, #144] +Ltmp3: + bl _objc_release +Ltmp4: + b LBB5_21 +LBB5_18: + ldr r0, [sp, #144] + cmp r0, #2 + bls LBB5_15 + trap +LBB5_20: +Ltmp5: + ldr r0, [sp, #148] + ldr r0, [sp, #152] + mov lr, pc + b SYM(core::panicking::panic_in_cleanup::GENERATED_ID, 0) +LBB5_21: + mvn r0, #0 + str r0, [sp, #144] + ldr r0, [sp, #12] + mov lr, pc + b __Unwind_SjLj_Resume + .p2align 2 + .data_region +LCPI5_0: + .long Lexception0-(LPC5_0+8) +LCPI5_1: + .long LBB5_18-(LPC5_1+8) + .end_data_region +Lfunc_end0: + .section __TEXT,__gcc_except_tab + .p2align 2, 0x0 +GCC_except_table5: +Lexception0: + .byte 255 + .byte 155 + .uleb128 Lttbase0-Lttbaseref0 +Lttbaseref0: + .byte 3 + .uleb128 Lcst_end0-Lcst_begin0 +Lcst_begin0: + .byte 0 + .byte 0 + .byte 1 + .byte 1 +Lcst_end0: + .byte 127 + .byte 0 + .p2align 2, 0x0 +Lttbase0: + .byte 0 + .p2align 2, 0x0 .section __TEXT,__const l_anon.[ID].0: @@ -369,5 +487,8 @@ l_anon.[ID].0: LSYM(objc2_foundation::generated::__NSEnumerator::NSFastEnumeration::countByEnumeratingWithState_objects_count::CACHED_SEL::GENERATED_ID, 0)$non_lazy_ptr: .indirect_symbol SYM(objc2_foundation::generated::__NSEnumerator::NSFastEnumeration::countByEnumeratingWithState_objects_count::CACHED_SEL::GENERATED_ID, 0) .long 0 +L_rust_eh_personality$non_lazy_ptr: + .indirect_symbol _rust_eh_personality + .long 0 .subsections_via_symbols diff --git a/crates/test-assembly/crates/test_fast_enumeration/expected/apple-x86.s b/crates/test-assembly/crates/test_fast_enumeration/expected/apple-x86.s index 6167da2b3..f5b5b3146 100644 --- a/crates/test-assembly/crates/test_fast_enumeration/expected/apple-x86.s +++ b/crates/test-assembly/crates/test_fast_enumeration/expected/apple-x86.s @@ -280,12 +280,13 @@ LBB4_7: .globl _iter_retained .p2align 4, 0x90 _iter_retained: +Lfunc_begin0: push ebp mov ebp, esp push ebx push edi push esi - sub esp, 124 + sub esp, 140 call L5$pb L5$pb: pop eax @@ -323,19 +324,17 @@ LBB5_2: test eax, eax je LBB5_3 LBB5_4: - sub esp, 12 - push 16 lea ecx, [ebp - 120] - push ecx - push ebx - push eax - push esi + mov dword ptr [esp + 12], ecx + mov dword ptr [esp + 8], ebx + mov dword ptr [esp + 4], eax + mov dword ptr [esp], esi + mov dword ptr [esp + 16], 16 call _objc_msgSend - add esp, 32 mov dword ptr [ebp - 20], eax mov dword ptr [ebp - 24], 0 test eax, eax - je LBB5_13 + je LBB5_18 xor eax, eax cmp dword ptr [ebp - 52], 0 je LBB5_6 @@ -359,19 +358,16 @@ LBB5_12: mov dword ptr [ebp - 24], edx mov eax, dword ptr [ecx + 4*eax] test eax, eax - je LBB5_13 - sub esp, 12 - push eax + je LBB5_18 + mov dword ptr [esp], eax call _objc_retain - add esp, 16 mov esi, eax - sub esp, 12 - push eax +Ltmp0: + mov dword ptr [esp], eax call _use_obj - add esp, 4 - push esi +Ltmp1: + mov dword ptr [esp], esi call _objc_release - add esp, 16 mov esi, dword ptr [ebp - 124] mov eax, dword ptr [ebp - 24] mov ecx, dword ptr [ebp - 20] @@ -379,14 +375,13 @@ LBB5_12: jae LBB5_2 jmp LBB5_11 LBB5_3: - sub esp, 8 - push dword ptr [ebp - 16] - push edi + mov eax, dword ptr [ebp - 16] + mov dword ptr [esp + 4], eax + mov dword ptr [esp], edi call SYM(objc2::__macro_helpers::cache::CachedSel::fetch::GENERATED_ID, 0) - add esp, 16 jmp LBB5_4 -LBB5_13: - add esp, 124 +LBB5_18: + add esp, 140 pop esi pop edi pop ebx @@ -396,6 +391,57 @@ LBB5_6: call SYM(objc2_foundation::iter::items_ptr_null::GENERATED_ID, 0) LBB5_10: call SYM(objc2_foundation::iter::mutation_detected::GENERATED_ID, 0) +LBB5_16: +Ltmp2: + mov edi, eax +Ltmp3: + mov dword ptr [esp], esi + call _objc_release +Ltmp4: + mov dword ptr [esp], edi + call __Unwind_Resume +LBB5_15: +Ltmp5: + call SYM(core::panicking::panic_in_cleanup::GENERATED_ID, 0) +Lfunc_end0: + .section __TEXT,__gcc_except_tab + .p2align 2, 0x0 +GCC_except_table5: +Lexception0: + .byte 255 + .byte 155 + .uleb128 Lttbase0-Lttbaseref0 +Lttbaseref0: + .byte 1 + .uleb128 Lcst_end0-Lcst_begin0 +Lcst_begin0: + .uleb128 Lfunc_begin0-Lfunc_begin0 + .uleb128 Ltmp0-Lfunc_begin0 + .byte 0 + .byte 0 + .uleb128 Ltmp0-Lfunc_begin0 + .uleb128 Ltmp1-Ltmp0 + .uleb128 Ltmp2-Lfunc_begin0 + .byte 0 + .uleb128 Ltmp1-Lfunc_begin0 + .uleb128 Ltmp3-Ltmp1 + .byte 0 + .byte 0 + .uleb128 Ltmp3-Lfunc_begin0 + .uleb128 Ltmp4-Ltmp3 + .uleb128 Ltmp5-Lfunc_begin0 + .byte 1 + .uleb128 Ltmp4-Lfunc_begin0 + .uleb128 Lfunc_end0-Ltmp4 + .byte 0 + .byte 0 +Lcst_end0: + .byte 127 + .byte 0 + .p2align 2, 0x0 +Lttbase0: + .byte 0 + .p2align 2, 0x0 .section __TEXT,__const l_anon.[ID].0: @@ -405,5 +451,8 @@ l_anon.[ID].0: LSYM(objc2_foundation::generated::__NSEnumerator::NSFastEnumeration::countByEnumeratingWithState_objects_count::CACHED_SEL::GENERATED_ID, 0)$non_lazy_ptr: .indirect_symbol SYM(objc2_foundation::generated::__NSEnumerator::NSFastEnumeration::countByEnumeratingWithState_objects_count::CACHED_SEL::GENERATED_ID, 0) .long 0 +L_rust_eh_personality$non_lazy_ptr: + .indirect_symbol _rust_eh_personality + .long 0 .subsections_via_symbols diff --git a/crates/test-assembly/crates/test_fast_enumeration/expected/apple-x86_64.s b/crates/test-assembly/crates/test_fast_enumeration/expected/apple-x86_64.s index ec5be4a4f..07773c543 100644 --- a/crates/test-assembly/crates/test_fast_enumeration/expected/apple-x86_64.s +++ b/crates/test-assembly/crates/test_fast_enumeration/expected/apple-x86_64.s @@ -287,6 +287,7 @@ LBB4_7: .globl _iter_retained .p2align 4, 0x90 _iter_retained: +Lfunc_begin0: push rbp mov rbp, rsp push r15 @@ -344,9 +345,9 @@ LBB5_4: mov qword ptr [rbp - 48], rax mov qword ptr [rbp - 56], 0 test rax, rax - je LBB5_15 + je LBB5_19 cmp qword ptr [rbp - 112], 0 - je LBB5_13 + je LBB5_17 xor eax, eax LBB5_7: mov rcx, qword ptr [rbp - 104] @@ -357,7 +358,7 @@ LBB5_7: je LBB5_9 cmp qword ptr [rbp - 264], rcx je LBB5_11 - jmp LBB5_14 + jmp LBB5_18 .p2align 4, 0x90 LBB5_9: mov qword ptr [rbp - 272], 1 @@ -368,11 +369,13 @@ LBB5_11: mov qword ptr [rbp - 56], rdx mov rdi, qword ptr [rcx + 8*rax] test rdi, rdi - je LBB5_15 + je LBB5_19 call _objc_retain mov r13, rax +Ltmp0: mov rdi, rax call _use_obj +Ltmp1: mov rdi, r13 call _objc_release mov rdi, qword ptr [rbp - 256] @@ -389,7 +392,7 @@ LBB5_3: mov rdi, r13 mov rsi, rax jmp LBB5_4 -LBB5_15: +LBB5_19: add rsp, 232 pop rbx pop r12 @@ -398,10 +401,61 @@ LBB5_15: pop r15 pop rbp ret -LBB5_13: +LBB5_17: call SYM(objc2_foundation::iter::items_ptr_null::GENERATED_ID, 0) -LBB5_14: +LBB5_18: call SYM(objc2_foundation::iter::mutation_detected::GENERATED_ID, 0) +LBB5_15: +Ltmp2: + mov rbx, rax +Ltmp3: + mov rdi, r13 + call _objc_release +Ltmp4: + mov rdi, rbx + call __Unwind_Resume +LBB5_14: +Ltmp5: + call SYM(core::panicking::panic_in_cleanup::GENERATED_ID, 0) +Lfunc_end0: + .section __TEXT,__gcc_except_tab + .p2align 2, 0x0 +GCC_except_table5: +Lexception0: + .byte 255 + .byte 155 + .uleb128 Lttbase0-Lttbaseref0 +Lttbaseref0: + .byte 1 + .uleb128 Lcst_end0-Lcst_begin0 +Lcst_begin0: + .uleb128 Lfunc_begin0-Lfunc_begin0 + .uleb128 Ltmp0-Lfunc_begin0 + .byte 0 + .byte 0 + .uleb128 Ltmp0-Lfunc_begin0 + .uleb128 Ltmp1-Ltmp0 + .uleb128 Ltmp2-Lfunc_begin0 + .byte 0 + .uleb128 Ltmp1-Lfunc_begin0 + .uleb128 Ltmp3-Ltmp1 + .byte 0 + .byte 0 + .uleb128 Ltmp3-Lfunc_begin0 + .uleb128 Ltmp4-Ltmp3 + .uleb128 Ltmp5-Lfunc_begin0 + .byte 1 + .uleb128 Ltmp4-Lfunc_begin0 + .uleb128 Lfunc_end0-Ltmp4 + .byte 0 + .byte 0 +Lcst_end0: + .byte 127 + .byte 0 + .p2align 2, 0x0 +Lttbase0: + .byte 0 + .p2align 2, 0x0 .section __TEXT,__const l_anon.[ID].0: diff --git a/crates/test-assembly/crates/test_fast_enumeration/expected/gnustep-x86.s b/crates/test-assembly/crates/test_fast_enumeration/expected/gnustep-x86.s index 313858dca..0d7279120 100644 --- a/crates/test-assembly/crates/test_fast_enumeration/expected/gnustep-x86.s +++ b/crates/test-assembly/crates/test_fast_enumeration/expected/gnustep-x86.s @@ -315,41 +315,42 @@ iter_noop: .p2align 4, 0x90 .type iter_retained,@function iter_retained: +.Lfunc_begin0: push ebp push ebx push edi push esi - sub esp, 124 + sub esp, 140 call .L5$pb .L5$pb: pop ebx - mov ebp, dword ptr [esp + 144] + mov ebp, dword ptr [esp + 160] xorps xmm0, xmm0 xor ecx, ecx - mov dword ptr [esp + 112], 0 -.Ltmp3: - add ebx, offset _GLOBAL_OFFSET_TABLE_+(.Ltmp3-.L5$pb) - movsd qword ptr [esp + 104], xmm0 - movsd qword ptr [esp + 96], xmm0 - movsd qword ptr [esp + 20], xmm0 - movsd qword ptr [esp + 28], xmm0 + mov dword ptr [esp + 128], 0 +.Ltmp9: + add ebx, offset _GLOBAL_OFFSET_TABLE_+(.Ltmp9-.L5$pb) + movsd qword ptr [esp + 120], xmm0 + movsd qword ptr [esp + 112], xmm0 movsd qword ptr [esp + 36], xmm0 movsd qword ptr [esp + 44], xmm0 movsd qword ptr [esp + 52], xmm0 movsd qword ptr [esp + 60], xmm0 movsd qword ptr [esp + 68], xmm0 movsd qword ptr [esp + 76], xmm0 - mov dword ptr [esp + 8], 0 + movsd qword ptr [esp + 84], xmm0 + movsd qword ptr [esp + 92], xmm0 + mov dword ptr [esp + 24], 0 mov edi, dword ptr [ebx + SYM(objc2_foundation::generated::__NSEnumerator::NSFastEnumeration::countByEnumeratingWithState_objects_count::CACHED_SEL::GENERATED_ID, 0)@GOT] lea eax, [ebx + .Lanon.[ID].0@GOTOFF] - mov dword ptr [esp + 4], eax + mov dword ptr [esp + 20], eax xor eax, eax - mov dword ptr [esp + 16], ebp - mov dword ptr [esp + 84], 0 - mov dword ptr [esp + 88], 0 - mov dword ptr [esp + 92], 0 - mov dword ptr [esp + 116], 0 - mov dword ptr [esp + 120], 0 + mov dword ptr [esp + 32], ebp + mov dword ptr [esp + 100], 0 + mov dword ptr [esp + 104], 0 + mov dword ptr [esp + 108], 0 + mov dword ptr [esp + 132], 0 + mov dword ptr [esp + 136], 0 cmp eax, ecx jb .LBB5_11 .p2align 4, 0x90 @@ -358,76 +359,69 @@ iter_retained: test esi, esi je .LBB5_3 .LBB5_4: - sub esp, 8 - push esi - push ebp + mov dword ptr [esp + 4], esi + mov dword ptr [esp], ebp call objc_msg_lookup@PLT - add esp, 4 - push 16 lea ecx, [esp + 36] - push ecx - lea ecx, [esp + 104] - push ecx - push esi - push ebp + lea edx, [esp + 100] + mov dword ptr [esp + 4], esi + mov dword ptr [esp], ebp + mov dword ptr [esp + 16], 16 + mov dword ptr [esp + 12], ecx + mov dword ptr [esp + 8], edx call eax - add esp, 32 test eax, eax - mov dword ptr [esp + 120], eax - mov dword ptr [esp + 116], 0 - je .LBB5_13 + mov dword ptr [esp + 136], eax + mov dword ptr [esp + 132], 0 + je .LBB5_18 xor eax, eax - cmp dword ptr [esp + 88], 0 + cmp dword ptr [esp + 104], 0 je .LBB5_6 .LBB5_11: - mov ecx, dword ptr [esp + 92] + mov ecx, dword ptr [esp + 108] test ecx, ecx je .LBB5_12 mov ecx, dword ptr [ecx] - test byte ptr [esp + 8], 1 + test byte ptr [esp + 24], 1 je .LBB5_8 - cmp dword ptr [esp + 12], ecx + cmp dword ptr [esp + 28], ecx je .LBB5_12 jmp .LBB5_10 .p2align 4, 0x90 .LBB5_8: - mov dword ptr [esp + 8], 1 - mov dword ptr [esp + 12], ecx + mov dword ptr [esp + 24], 1 + mov dword ptr [esp + 28], ecx .LBB5_12: - mov ecx, dword ptr [esp + 88] + mov ecx, dword ptr [esp + 104] lea edx, [eax + 1] - mov dword ptr [esp + 116], edx + mov dword ptr [esp + 132], edx mov eax, dword ptr [ecx + 4*eax] test eax, eax - je .LBB5_13 - sub esp, 12 - push eax + je .LBB5_18 + mov dword ptr [esp], eax call objc_retain@PLT - add esp, 16 mov esi, eax - sub esp, 12 - push eax +.Ltmp3: + mov dword ptr [esp], eax call use_obj@PLT - add esp, 4 - push esi +.Ltmp4: + mov dword ptr [esp], esi call objc_release@PLT - add esp, 16 - mov ebp, dword ptr [esp + 16] - mov eax, dword ptr [esp + 116] - mov ecx, dword ptr [esp + 120] + mov ebp, dword ptr [esp + 32] + mov eax, dword ptr [esp + 132] + mov ecx, dword ptr [esp + 136] cmp eax, ecx jae .LBB5_2 jmp .LBB5_11 .LBB5_3: - sub esp, 8 - push dword ptr [esp + 12] - push edi + mov eax, dword ptr [esp + 20] + mov dword ptr [esp], edi + mov dword ptr [esp + 4], eax call SYM(objc2::__macro_helpers::cache::CachedSel::fetch::GENERATED_ID, 0)@PLT - add esp, 16 mov esi, eax jmp .LBB5_4 -.LBB5_13: - add esp, 124 +.LBB5_18: + add esp, 140 pop esi pop edi pop ebx @@ -437,8 +431,58 @@ iter_retained: call SYM(objc2_foundation::iter::items_ptr_null::GENERATED_ID, 0)@PLT .LBB5_10: call SYM(objc2_foundation::iter::mutation_detected::GENERATED_ID, 0)@PLT +.LBB5_16: +.Ltmp5: + mov edi, eax +.Ltmp6: + mov dword ptr [esp], esi + call objc_release@PLT +.Ltmp7: + mov dword ptr [esp], edi + call _Unwind_Resume@PLT +.LBB5_15: +.Ltmp8: + call SYM(core::panicking::panic_in_cleanup::GENERATED_ID, 0)@PLT .Lfunc_end5: .size iter_retained, .Lfunc_end5-iter_retained + .section .gcc_except_table.iter_retained,"a",@progbits + .p2align 2, 0x0 +GCC_except_table5: +.Lexception0: + .byte 255 + .byte 155 + .uleb128 .Lttbase0-.Lttbaseref0 +.Lttbaseref0: + .byte 1 + .uleb128 .Lcst_end0-.Lcst_begin0 +.Lcst_begin0: + .uleb128 .Lfunc_begin0-.Lfunc_begin0 + .uleb128 .Ltmp3-.Lfunc_begin0 + .byte 0 + .byte 0 + .uleb128 .Ltmp3-.Lfunc_begin0 + .uleb128 .Ltmp4-.Ltmp3 + .uleb128 .Ltmp5-.Lfunc_begin0 + .byte 0 + .uleb128 .Ltmp4-.Lfunc_begin0 + .uleb128 .Ltmp6-.Ltmp4 + .byte 0 + .byte 0 + .uleb128 .Ltmp6-.Lfunc_begin0 + .uleb128 .Ltmp7-.Ltmp6 + .uleb128 .Ltmp8-.Lfunc_begin0 + .byte 1 + .uleb128 .Ltmp7-.Lfunc_begin0 + .uleb128 .Lfunc_end5-.Ltmp7 + .byte 0 + .byte 0 +.Lcst_end0: + .byte 127 + .byte 0 + .p2align 2, 0x0 +.Lttbase0: + .byte 0 + .p2align 2, 0x0 .type .Lanon.[ID].0,@object .section .rodata..Lanon.[ID].0,"a",@progbits @@ -446,4 +490,12 @@ iter_retained: .asciz "countByEnumeratingWithState:objects:count:" .size .Lanon.[ID].0, 43 + .hidden DW.ref.rust_eh_personality + .weak DW.ref.rust_eh_personality + .section .data.DW.ref.rust_eh_personality,"awG",@progbits,DW.ref.rust_eh_personality,comdat + .p2align 2, 0x0 + .type DW.ref.rust_eh_personality,@object + .size DW.ref.rust_eh_personality, 4 +DW.ref.rust_eh_personality: + .long rust_eh_personality .section ".note.GNU-stack","",@progbits diff --git a/crates/test-assembly/crates/test_fast_enumeration/expected/gnustep-x86_64.s b/crates/test-assembly/crates/test_fast_enumeration/expected/gnustep-x86_64.s index 24aac37d2..685ae775d 100644 --- a/crates/test-assembly/crates/test_fast_enumeration/expected/gnustep-x86_64.s +++ b/crates/test-assembly/crates/test_fast_enumeration/expected/gnustep-x86_64.s @@ -274,6 +274,7 @@ iter_noop: .p2align 4, 0x90 .type iter_retained,@function iter_retained: +.Lfunc_begin0: push rbp push r15 push r14 @@ -325,9 +326,9 @@ iter_retained: mov qword ptr [rsp + 224], rax mov qword ptr [rsp + 216], 0 test rax, rax - je .LBB5_15 + je .LBB5_19 cmp qword ptr [rsp + 160], 0 - je .LBB5_13 + je .LBB5_17 xor eax, eax .LBB5_7: mov rcx, qword ptr [rsp + 168] @@ -338,7 +339,7 @@ iter_retained: je .LBB5_9 cmp qword ptr [rsp + 8], rcx je .LBB5_11 - jmp .LBB5_14 + jmp .LBB5_18 .p2align 4, 0x90 .LBB5_9: mov qword ptr [rsp], 1 @@ -349,11 +350,13 @@ iter_retained: mov qword ptr [rsp + 216], rdx mov rdi, qword ptr [rcx + 8*rax] test rdi, rdi - je .LBB5_15 + je .LBB5_19 call r12 mov r13, rax +.Ltmp0: mov rdi, rax call rbx +.Ltmp1: mov rdi, r13 call r14 mov r13, qword ptr [rsp + 16] @@ -368,7 +371,7 @@ iter_retained: call qword ptr [rip + SYM(objc2::__macro_helpers::cache::CachedSel::fetch::GENERATED_ID, 0)@GOTPCREL] mov rbp, rax jmp .LBB5_4 -.LBB5_15: +.LBB5_19: add rsp, 232 pop rbx pop r12 @@ -377,12 +380,62 @@ iter_retained: pop r15 pop rbp ret -.LBB5_13: +.LBB5_17: call qword ptr [rip + SYM(objc2_foundation::iter::items_ptr_null::GENERATED_ID, 0)@GOTPCREL] -.LBB5_14: +.LBB5_18: call qword ptr [rip + SYM(objc2_foundation::iter::mutation_detected::GENERATED_ID, 0)@GOTPCREL] +.LBB5_15: +.Ltmp2: + mov rbx, rax +.Ltmp3: + mov rdi, r13 + call qword ptr [rip + objc_release@GOTPCREL] +.Ltmp4: + mov rdi, rbx + call _Unwind_Resume@PLT +.LBB5_14: +.Ltmp5: + call qword ptr [rip + SYM(core::panicking::panic_in_cleanup::GENERATED_ID, 0)@GOTPCREL] .Lfunc_end5: .size iter_retained, .Lfunc_end5-iter_retained + .section .gcc_except_table.iter_retained,"a",@progbits + .p2align 2, 0x0 +GCC_except_table5: +.Lexception0: + .byte 255 + .byte 155 + .uleb128 .Lttbase0-.Lttbaseref0 +.Lttbaseref0: + .byte 1 + .uleb128 .Lcst_end0-.Lcst_begin0 +.Lcst_begin0: + .uleb128 .Lfunc_begin0-.Lfunc_begin0 + .uleb128 .Ltmp0-.Lfunc_begin0 + .byte 0 + .byte 0 + .uleb128 .Ltmp0-.Lfunc_begin0 + .uleb128 .Ltmp1-.Ltmp0 + .uleb128 .Ltmp2-.Lfunc_begin0 + .byte 0 + .uleb128 .Ltmp1-.Lfunc_begin0 + .uleb128 .Ltmp3-.Ltmp1 + .byte 0 + .byte 0 + .uleb128 .Ltmp3-.Lfunc_begin0 + .uleb128 .Ltmp4-.Ltmp3 + .uleb128 .Ltmp5-.Lfunc_begin0 + .byte 1 + .uleb128 .Ltmp4-.Lfunc_begin0 + .uleb128 .Lfunc_end5-.Ltmp4 + .byte 0 + .byte 0 +.Lcst_end0: + .byte 127 + .byte 0 + .p2align 2, 0x0 +.Lttbase0: + .byte 0 + .p2align 2, 0x0 .type .Lanon.[ID].0,@object .section .rodata..Lanon.[ID].0,"a",@progbits @@ -390,4 +443,12 @@ iter_retained: .asciz "countByEnumeratingWithState:objects:count:" .size .Lanon.[ID].0, 43 + .hidden DW.ref.rust_eh_personality + .weak DW.ref.rust_eh_personality + .section .data.DW.ref.rust_eh_personality,"awG",@progbits,DW.ref.rust_eh_personality,comdat + .p2align 3, 0x0 + .type DW.ref.rust_eh_personality,@object + .size DW.ref.rust_eh_personality, 8 +DW.ref.rust_eh_personality: + .quad rust_eh_personality .section ".note.GNU-stack","",@progbits diff --git a/crates/test-assembly/crates/test_msg_send_error/expected/apple-aarch64.s b/crates/test-assembly/crates/test_msg_send_error/expected/apple-aarch64.s index a4ac79a71..5e912030e 100644 --- a/crates/test-assembly/crates/test_msg_send_error/expected/apple-aarch64.s +++ b/crates/test-assembly/crates/test_msg_send_error/expected/apple-aarch64.s @@ -54,15 +54,14 @@ _error_bool: mov x8, x0 mov x0, #0 tbz w8, #0, LBB2_2 +LBB2_1: ldp x29, x30, [sp, #16] add sp, sp, #32 ret LBB2_2: ldr x0, [sp, #8] bl SYM(objc2[CRATE_ID]::__macro_helpers::msg_send::encountered_error::, 0) - ldp x29, x30, [sp, #16] - add sp, sp, #32 - ret + b LBB2_1 .globl _error_new .p2align 2 @@ -73,13 +72,14 @@ _error_new: str xzr, [sp, #8] add x2, sp, #8 bl _objc_msgSend - cbz x0, LBB3_2 + cbz x0, LBB3_3 mov x1, x0 mov x0, #0 +LBB3_2: ldp x29, x30, [sp, #16] add sp, sp, #32 ret -LBB3_2: +LBB3_3: ldr x0, [sp, #8] Lloh6: adrp x1, l_anon.[ID].4@PAGE @@ -88,9 +88,7 @@ Lloh7: bl SYM(objc2[CRATE_ID]::__macro_helpers::msg_send_id::encountered_error::, 0) mov x1, x0 mov w0, #1 - ldp x29, x30, [sp, #16] - add sp, sp, #32 - ret + b LBB3_2 .loh AdrpAdd Lloh6, Lloh7 .globl _error_init @@ -102,13 +100,14 @@ _error_init: str xzr, [sp, #8] add x2, sp, #8 bl _objc_msgSend - cbz x0, LBB4_2 + cbz x0, LBB4_3 mov x1, x0 mov x0, #0 +LBB4_2: ldp x29, x30, [sp, #16] add sp, sp, #32 ret -LBB4_2: +LBB4_3: ldr x0, [sp, #8] Lloh8: adrp x1, l_anon.[ID].5@PAGE @@ -117,9 +116,7 @@ Lloh9: bl SYM(objc2[CRATE_ID]::__macro_helpers::msg_send_id::encountered_error::, 0) mov x1, x0 mov w0, #1 - ldp x29, x30, [sp, #16] - add sp, sp, #32 - ret + b LBB4_2 .loh AdrpAdd Lloh8, Lloh9 .globl _error_copy @@ -131,13 +128,14 @@ _error_copy: str xzr, [sp, #8] add x2, sp, #8 bl _objc_msgSend - cbz x0, LBB5_2 + cbz x0, LBB5_3 mov x1, x0 mov x0, #0 +LBB5_2: ldp x29, x30, [sp, #16] add sp, sp, #32 ret -LBB5_2: +LBB5_3: ldr x0, [sp, #8] Lloh10: adrp x1, l_anon.[ID].6@PAGE @@ -146,9 +144,7 @@ Lloh11: bl SYM(objc2[CRATE_ID]::__macro_helpers::msg_send_id::encountered_error::, 0) mov x1, x0 mov w0, #1 - ldp x29, x30, [sp, #16] - add sp, sp, #32 - ret + b LBB5_2 .loh AdrpAdd Lloh10, Lloh11 .globl _error_autoreleased @@ -164,13 +160,14 @@ _error_autoreleased: mov x29, x29 ; InlineAsm End bl _objc_retainAutoreleasedReturnValue - cbz x0, LBB6_2 + cbz x0, LBB6_3 mov x1, x0 mov x0, #0 +LBB6_2: ldp x29, x30, [sp, #16] add sp, sp, #32 ret -LBB6_2: +LBB6_3: ldr x0, [sp, #8] Lloh12: adrp x1, l_anon.[ID].7@PAGE @@ -179,9 +176,7 @@ Lloh13: bl SYM(objc2[CRATE_ID]::__macro_helpers::msg_send_id::encountered_error::, 0) mov x1, x0 mov w0, #1 - ldp x29, x30, [sp, #16] - add sp, sp, #32 - ret + b LBB6_2 .loh AdrpAdd Lloh12, Lloh13 .section __TEXT,__const diff --git a/crates/test-assembly/crates/test_out_parameters/expected/apple-aarch64.s b/crates/test-assembly/crates/test_out_parameters/expected/apple-aarch64.s index a7234e21b..9e1644a02 100644 --- a/crates/test-assembly/crates/test_out_parameters/expected/apple-aarch64.s +++ b/crates/test-assembly/crates/test_out_parameters/expected/apple-aarch64.s @@ -137,110 +137,368 @@ _call_with_none2: .globl _call_with_none3 .p2align 2 _call_with_none3: +Lfunc_begin0: sub sp, sp, #48 stp x20, x19, [sp, #16] stp x29, x30, [sp, #32] add x29, sp, #32 str xzr, [sp, #8] +Ltmp0: add x2, sp, #8 bl _objc_msgSend +Ltmp1: mov x19, x0 ldr x0, [sp, #8] +Ltmp2: bl _objc_retain +Ltmp3: ldr x1, [sp, #8] mov x0, x19 ldp x29, x30, [sp, #32] ldp x20, x19, [sp, #16] add sp, sp, #48 ret +LBB7_3: +Ltmp4: + mov x19, x0 + ldr x0, [sp, #8] + cbz x0, LBB7_5 +Ltmp5: + bl _objc_release +Ltmp6: +LBB7_5: + mov x0, x19 + bl __Unwind_Resume +LBB7_6: +Ltmp7: + bl SYM(core::panicking::panic_in_cleanup::GENERATED_ID, 0) +Lfunc_end0: + .section __TEXT,__gcc_except_tab + .p2align 2, 0x0 +GCC_except_table7: +Lexception0: + .byte 255 + .byte 155 + .uleb128 Lttbase0-Lttbaseref0 +Lttbaseref0: + .byte 1 + .uleb128 Lcst_end0-Lcst_begin0 +Lcst_begin0: + .uleb128 Ltmp0-Lfunc_begin0 + .uleb128 Ltmp3-Ltmp0 + .uleb128 Ltmp4-Lfunc_begin0 + .byte 0 + .uleb128 Ltmp5-Lfunc_begin0 + .uleb128 Ltmp6-Ltmp5 + .uleb128 Ltmp7-Lfunc_begin0 + .byte 1 + .uleb128 Ltmp6-Lfunc_begin0 + .uleb128 Lfunc_end0-Ltmp6 + .byte 0 + .byte 0 +Lcst_end0: + .byte 127 + .byte 0 + .p2align 2, 0x0 +Lttbase0: + .byte 0 + .p2align 2, 0x0 + .section __TEXT,__text,regular,pure_instructions .globl _call_with_none4 .p2align 2 _call_with_none4: +Lfunc_begin1: sub sp, sp, #48 stp x20, x19, [sp, #16] stp x29, x30, [sp, #32] add x29, sp, #32 str xzr, [sp, #8] +Ltmp8: add x2, sp, #8 bl _objc_msgSend +Ltmp9: mov x19, x0 ldr x0, [sp, #8] +Ltmp10: bl _objc_retain +Ltmp11: ldr x1, [sp, #8] mov x0, x19 ldp x29, x30, [sp, #32] ldp x20, x19, [sp, #16] add sp, sp, #48 ret +LBB8_3: +Ltmp12: + mov x19, x0 + ldr x0, [sp, #8] + cbz x0, LBB8_5 +Ltmp13: + bl _objc_release +Ltmp14: +LBB8_5: + mov x0, x19 + bl __Unwind_Resume +LBB8_6: +Ltmp15: + bl SYM(core::panicking::panic_in_cleanup::GENERATED_ID, 0) +Lfunc_end1: + .section __TEXT,__gcc_except_tab + .p2align 2, 0x0 +GCC_except_table8: +Lexception1: + .byte 255 + .byte 155 + .uleb128 Lttbase1-Lttbaseref1 +Lttbaseref1: + .byte 1 + .uleb128 Lcst_end1-Lcst_begin1 +Lcst_begin1: + .uleb128 Ltmp8-Lfunc_begin1 + .uleb128 Ltmp11-Ltmp8 + .uleb128 Ltmp12-Lfunc_begin1 + .byte 0 + .uleb128 Ltmp13-Lfunc_begin1 + .uleb128 Ltmp14-Ltmp13 + .uleb128 Ltmp15-Lfunc_begin1 + .byte 1 + .uleb128 Ltmp14-Lfunc_begin1 + .uleb128 Lfunc_end1-Ltmp14 + .byte 0 + .byte 0 +Lcst_end1: + .byte 127 + .byte 0 + .p2align 2, 0x0 +Lttbase1: + .byte 0 + .p2align 2, 0x0 + .section __TEXT,__text,regular,pure_instructions .globl _call_with_some1 .p2align 2 _call_with_some1: +Lfunc_begin2: sub sp, sp, #48 stp x20, x19, [sp, #16] stp x29, x30, [sp, #32] add x29, sp, #32 mov x19, x2 str x2, [sp, #8] +Ltmp16: add x2, sp, #8 bl _objc_msgSend +Ltmp17: mov x20, x0 ldr x0, [sp, #8] +Ltmp18: bl _objc_retain +Ltmp19: +Ltmp20: mov x0, x19 bl _objc_release +Ltmp21: ldr x1, [sp, #8] mov x0, x20 ldp x29, x30, [sp, #32] ldp x20, x19, [sp, #16] add sp, sp, #48 ret +LBB9_4: +Ltmp22: + mov x19, x0 + ldr x0, [sp, #8] +Ltmp23: + bl _objc_release +Ltmp24: + mov x0, x19 + bl __Unwind_Resume +LBB9_6: +Ltmp25: + bl SYM(core::panicking::panic_in_cleanup::GENERATED_ID, 0) +Lfunc_end2: + .section __TEXT,__gcc_except_tab + .p2align 2, 0x0 +GCC_except_table9: +Lexception2: + .byte 255 + .byte 155 + .uleb128 Lttbase2-Lttbaseref2 +Lttbaseref2: + .byte 1 + .uleb128 Lcst_end2-Lcst_begin2 +Lcst_begin2: + .uleb128 Ltmp16-Lfunc_begin2 + .uleb128 Ltmp21-Ltmp16 + .uleb128 Ltmp22-Lfunc_begin2 + .byte 0 + .uleb128 Ltmp23-Lfunc_begin2 + .uleb128 Ltmp24-Ltmp23 + .uleb128 Ltmp25-Lfunc_begin2 + .byte 1 + .uleb128 Ltmp24-Lfunc_begin2 + .uleb128 Lfunc_end2-Ltmp24 + .byte 0 + .byte 0 +Lcst_end2: + .byte 127 + .byte 0 + .p2align 2, 0x0 +Lttbase2: + .byte 0 + .p2align 2, 0x0 + .section __TEXT,__text,regular,pure_instructions .globl _call_with_some2 .p2align 2 _call_with_some2: +Lfunc_begin3: sub sp, sp, #48 stp x20, x19, [sp, #16] stp x29, x30, [sp, #32] add x29, sp, #32 mov x19, x2 str x2, [sp, #8] +Ltmp26: add x2, sp, #8 bl _objc_msgSend +Ltmp27: mov x20, x0 ldr x0, [sp, #8] +Ltmp28: bl _objc_retain +Ltmp29: +Ltmp30: mov x0, x19 bl _objc_release +Ltmp31: ldr x1, [sp, #8] mov x0, x20 ldp x29, x30, [sp, #32] ldp x20, x19, [sp, #16] add sp, sp, #48 ret +LBB10_4: +Ltmp32: + mov x19, x0 + ldr x0, [sp, #8] + cbz x0, LBB10_6 +Ltmp33: + bl _objc_release +Ltmp34: +LBB10_6: + mov x0, x19 + bl __Unwind_Resume +LBB10_7: +Ltmp35: + bl SYM(core::panicking::panic_in_cleanup::GENERATED_ID, 0) +Lfunc_end3: + .section __TEXT,__gcc_except_tab + .p2align 2, 0x0 +GCC_except_table10: +Lexception3: + .byte 255 + .byte 155 + .uleb128 Lttbase3-Lttbaseref3 +Lttbaseref3: + .byte 1 + .uleb128 Lcst_end3-Lcst_begin3 +Lcst_begin3: + .uleb128 Ltmp26-Lfunc_begin3 + .uleb128 Ltmp31-Ltmp26 + .uleb128 Ltmp32-Lfunc_begin3 + .byte 0 + .uleb128 Ltmp33-Lfunc_begin3 + .uleb128 Ltmp34-Ltmp33 + .uleb128 Ltmp35-Lfunc_begin3 + .byte 1 + .uleb128 Ltmp34-Lfunc_begin3 + .uleb128 Lfunc_end3-Ltmp34 + .byte 0 + .byte 0 +Lcst_end3: + .byte 127 + .byte 0 + .p2align 2, 0x0 +Lttbase3: + .byte 0 + .p2align 2, 0x0 + .section __TEXT,__text,regular,pure_instructions .globl _call_with_some3 .p2align 2 _call_with_some3: +Lfunc_begin4: sub sp, sp, #48 stp x20, x19, [sp, #16] stp x29, x30, [sp, #32] add x29, sp, #32 mov x19, x2 str x2, [sp, #8] +Ltmp36: add x2, sp, #8 bl _objc_msgSend +Ltmp37: mov x20, x0 ldr x0, [sp, #8] +Ltmp38: bl _objc_retain +Ltmp39: +Ltmp40: mov x0, x19 bl _objc_release +Ltmp41: ldr x1, [sp, #8] mov x0, x20 ldp x29, x30, [sp, #32] ldp x20, x19, [sp, #16] add sp, sp, #48 ret +LBB11_4: +Ltmp42: + mov x19, x0 + ldr x0, [sp, #8] + cbz x0, LBB11_6 +Ltmp43: + bl _objc_release +Ltmp44: +LBB11_6: + mov x0, x19 + bl __Unwind_Resume +LBB11_7: +Ltmp45: + bl SYM(core::panicking::panic_in_cleanup::GENERATED_ID, 0) +Lfunc_end4: + .section __TEXT,__gcc_except_tab + .p2align 2, 0x0 +GCC_except_table11: +Lexception4: + .byte 255 + .byte 155 + .uleb128 Lttbase4-Lttbaseref4 +Lttbaseref4: + .byte 1 + .uleb128 Lcst_end4-Lcst_begin4 +Lcst_begin4: + .uleb128 Ltmp36-Lfunc_begin4 + .uleb128 Ltmp41-Ltmp36 + .uleb128 Ltmp42-Lfunc_begin4 + .byte 0 + .uleb128 Ltmp43-Lfunc_begin4 + .uleb128 Ltmp44-Ltmp43 + .uleb128 Ltmp45-Lfunc_begin4 + .byte 1 + .uleb128 Ltmp44-Lfunc_begin4 + .uleb128 Lfunc_end4-Ltmp44 + .byte 0 + .byte 0 +Lcst_end4: + .byte 127 + .byte 0 + .p2align 2, 0x0 +Lttbase4: + .byte 0 + .p2align 2, 0x0 .subsections_via_symbols diff --git a/crates/test-assembly/crates/test_out_parameters/expected/apple-armv7s.s b/crates/test-assembly/crates/test_out_parameters/expected/apple-armv7s.s index bf13c8f53..8dd882993 100644 --- a/crates/test-assembly/crates/test_out_parameters/expected/apple-armv7s.s +++ b/crates/test-assembly/crates/test_out_parameters/expected/apple-armv7s.s @@ -127,101 +127,715 @@ _call_with_none2: .p2align 2 .code 32 _call_with_none3: - push {r4, r7, lr} - add r7, sp, #4 - sub sp, sp, #4 - mov r2, #0 - str r2, [sp] - mov r2, sp +Lfunc_begin0: + push {r4, r5, r6, r7, lr} + add r7, sp, #12 + push {r8, r10, r11} + sub r4, sp, #64 + bfc r4, #0, #4 + mov sp, r4 + vst1.64 {d8, d9, d10, d11}, [r4:128]! + vst1.64 {d12, d13, d14, d15}, [r4:128] + sub sp, sp, #64 + mov r4, r1 + mov r5, r0 + mov r0, #0 + movw r1, :lower16:(L_rust_eh_personality$non_lazy_ptr-(LPC7_2+8)) + movt r1, :upper16:(L_rust_eh_personality$non_lazy_ptr-(LPC7_2+8)) +LPC7_2: + ldr r1, [pc, r1] + str r0, [sp, #8] + str r1, [sp, #36] + ldr r0, LCPI7_0 +LPC7_0: + add r0, pc, r0 + str r0, [sp, #40] + str r7, [sp, #44] + str sp, [sp, #52] + ldr r0, LCPI7_1 +LPC7_1: + add r0, pc, r0 + str r0, [sp, #48] + mov r0, #1 + str r0, [sp, #16] + add r0, sp, #12 + bl __Unwind_SjLj_Register +Ltmp0: + add r2, sp, #8 + mov r0, r5 + mov r1, r4 bl _objc_msgSend - mov r4, r0 - ldr r0, [sp] + str r0, [sp, #4] +Ltmp1: + ldr r0, [sp, #8] + mov r1, #2 + str r1, [sp, #16] +Ltmp2: bl _objc_retain - ldr r1, [sp] - mov r0, r4 - sub sp, r7, #4 - pop {r4, r7, pc} +Ltmp3: + ldr r4, [sp, #8] + add r0, sp, #12 + bl __Unwind_SjLj_Unregister + ldr r0, [sp, #4] + mov r1, r4 + add r4, sp, #64 + vld1.64 {d8, d9, d10, d11}, [r4:128]! + vld1.64 {d12, d13, d14, d15}, [r4:128] + sub sp, r7, #24 + pop {r8, r10, r11} + pop {r4, r5, r6, r7, pc} +LBB7_3: + lsl r0, r0, #2 + adr r1, LJTI7_0 + ldr r0, [r0, r1] + add pc, r0, r1 + .p2align 2 +LJTI7_0: + .data_region jt32 + .long LBB7_5-LJTI7_0 + .long LBB7_5-LJTI7_0 + .long LBB7_10-LJTI7_0 + .end_data_region +LBB7_5: +Ltmp4: + ldr r0, [sp, #20] + str r0, [sp, #4] + ldr r0, [sp, #8] + cmp r0, #0 + beq LBB7_9 + mov r1, #3 + str r1, [sp, #16] +Ltmp5: + bl _objc_release +Ltmp6: + b LBB7_9 +LBB7_7: + ldr r0, [sp, #16] + cmp r0, #3 + bls LBB7_3 + trap +LBB7_9: + mvn r0, #0 + str r0, [sp, #16] + ldr r0, [sp, #4] + mov lr, pc + b __Unwind_SjLj_Resume +LBB7_10: +Ltmp7: + ldr r0, [sp, #20] + ldr r0, [sp, #24] + mov lr, pc + b SYM(core::panicking::panic_in_cleanup::GENERATED_ID, 0) + .p2align 2 + .data_region +LCPI7_0: + .long Lexception0-(LPC7_0+8) +LCPI7_1: + .long LBB7_7-(LPC7_1+8) + .end_data_region +Lfunc_end0: + .section __TEXT,__gcc_except_tab + .p2align 2, 0x0 +GCC_except_table7: +Lexception0: + .byte 255 + .byte 155 + .uleb128 Lttbase0-Lttbaseref0 +Lttbaseref0: + .byte 3 + .uleb128 Lcst_end0-Lcst_begin0 +Lcst_begin0: + .byte 0 + .byte 0 + .byte 1 + .byte 0 + .byte 2 + .byte 1 +Lcst_end0: + .byte 127 + .byte 0 + .p2align 2, 0x0 +Lttbase0: + .byte 0 + .p2align 2, 0x0 + .section __TEXT,__text,regular,pure_instructions .globl _call_with_none4 .p2align 2 .code 32 _call_with_none4: - push {r4, r7, lr} - add r7, sp, #4 - sub sp, sp, #4 - mov r2, #0 - str r2, [sp] - mov r2, sp +Lfunc_begin1: + push {r4, r5, r6, r7, lr} + add r7, sp, #12 + push {r8, r10, r11} + sub r4, sp, #64 + bfc r4, #0, #4 + mov sp, r4 + vst1.64 {d8, d9, d10, d11}, [r4:128]! + vst1.64 {d12, d13, d14, d15}, [r4:128] + sub sp, sp, #64 + mov r4, r1 + mov r5, r0 + mov r0, #0 + movw r1, :lower16:(L_rust_eh_personality$non_lazy_ptr-(LPC8_2+8)) + movt r1, :upper16:(L_rust_eh_personality$non_lazy_ptr-(LPC8_2+8)) +LPC8_2: + ldr r1, [pc, r1] + str r0, [sp, #8] + str r1, [sp, #36] + ldr r0, LCPI8_0 +LPC8_0: + add r0, pc, r0 + str r0, [sp, #40] + str r7, [sp, #44] + str sp, [sp, #52] + ldr r0, LCPI8_1 +LPC8_1: + add r0, pc, r0 + str r0, [sp, #48] + mov r0, #1 + str r0, [sp, #16] + add r0, sp, #12 + bl __Unwind_SjLj_Register +Ltmp8: + add r2, sp, #8 + mov r0, r5 + mov r1, r4 bl _objc_msgSend - mov r4, r0 - ldr r0, [sp] + str r0, [sp, #4] +Ltmp9: + ldr r0, [sp, #8] + mov r1, #2 + str r1, [sp, #16] +Ltmp10: bl _objc_retain - ldr r1, [sp] - mov r0, r4 - sub sp, r7, #4 - pop {r4, r7, pc} +Ltmp11: + ldr r4, [sp, #8] + add r0, sp, #12 + bl __Unwind_SjLj_Unregister + ldr r0, [sp, #4] + mov r1, r4 + add r4, sp, #64 + vld1.64 {d8, d9, d10, d11}, [r4:128]! + vld1.64 {d12, d13, d14, d15}, [r4:128] + sub sp, r7, #24 + pop {r8, r10, r11} + pop {r4, r5, r6, r7, pc} +LBB8_3: + lsl r0, r0, #2 + adr r1, LJTI8_0 + ldr r0, [r0, r1] + add pc, r0, r1 + .p2align 2 +LJTI8_0: + .data_region jt32 + .long LBB8_5-LJTI8_0 + .long LBB8_5-LJTI8_0 + .long LBB8_10-LJTI8_0 + .end_data_region +LBB8_5: +Ltmp12: + ldr r0, [sp, #20] + str r0, [sp, #4] + ldr r0, [sp, #8] + cmp r0, #0 + beq LBB8_9 + mov r1, #3 + str r1, [sp, #16] +Ltmp13: + bl _objc_release +Ltmp14: + b LBB8_9 +LBB8_7: + ldr r0, [sp, #16] + cmp r0, #3 + bls LBB8_3 + trap +LBB8_9: + mvn r0, #0 + str r0, [sp, #16] + ldr r0, [sp, #4] + mov lr, pc + b __Unwind_SjLj_Resume +LBB8_10: +Ltmp15: + ldr r0, [sp, #20] + ldr r0, [sp, #24] + mov lr, pc + b SYM(core::panicking::panic_in_cleanup::GENERATED_ID, 0) + .p2align 2 + .data_region +LCPI8_0: + .long Lexception1-(LPC8_0+8) +LCPI8_1: + .long LBB8_7-(LPC8_1+8) + .end_data_region +Lfunc_end1: + .section __TEXT,__gcc_except_tab + .p2align 2, 0x0 +GCC_except_table8: +Lexception1: + .byte 255 + .byte 155 + .uleb128 Lttbase1-Lttbaseref1 +Lttbaseref1: + .byte 3 + .uleb128 Lcst_end1-Lcst_begin1 +Lcst_begin1: + .byte 0 + .byte 0 + .byte 1 + .byte 0 + .byte 2 + .byte 1 +Lcst_end1: + .byte 127 + .byte 0 + .p2align 2, 0x0 +Lttbase1: + .byte 0 + .p2align 2, 0x0 + .section __TEXT,__text,regular,pure_instructions .globl _call_with_some1 .p2align 2 .code 32 _call_with_some1: - push {r4, r5, r7, lr} - add r7, sp, #8 - sub sp, sp, #4 - mov r4, r2 - str r2, [sp] - mov r2, sp - bl _objc_msgSend +Lfunc_begin2: + push {r4, r5, r6, r7, lr} + add r7, sp, #12 + push {r8, r10, r11} + sub r4, sp, #64 + bfc r4, #0, #4 + mov sp, r4 + vst1.64 {d8, d9, d10, d11}, [r4:128]! + vst1.64 {d12, d13, d14, d15}, [r4:128] + sub sp, sp, #64 + mov r4, r1 mov r5, r0 - ldr r0, [sp] + movw r0, :lower16:(L_rust_eh_personality$non_lazy_ptr-(LPC9_2+8)) + movt r0, :upper16:(L_rust_eh_personality$non_lazy_ptr-(LPC9_2+8)) +LPC9_2: + ldr r0, [pc, r0] + str r2, [sp, #4] + str r2, [sp, #8] + str r0, [sp, #36] + ldr r0, LCPI9_0 +LPC9_0: + add r0, pc, r0 + str r0, [sp, #40] + str r7, [sp, #44] + str sp, [sp, #52] + ldr r0, LCPI9_1 +LPC9_1: + add r0, pc, r0 + str r0, [sp, #48] + mov r0, #1 + str r0, [sp, #16] + add r0, sp, #12 + bl __Unwind_SjLj_Register +Ltmp16: + add r2, sp, #8 + mov r0, r5 + mov r1, r4 + bl _objc_msgSend + str r0, [sp] +Ltmp17: + ldr r0, [sp, #8] + mov r1, #2 + str r1, [sp, #16] +Ltmp18: bl _objc_retain - mov r0, r4 +Ltmp19: + mov r0, #3 + str r0, [sp, #16] +Ltmp20: + ldr r0, [sp, #4] bl _objc_release - ldr r1, [sp] - mov r0, r5 - sub sp, r7, #8 - pop {r4, r5, r7, pc} +Ltmp21: + ldr r4, [sp, #8] + add r0, sp, #12 + bl __Unwind_SjLj_Unregister + ldr r0, [sp] + mov r1, r4 + add r4, sp, #64 + vld1.64 {d8, d9, d10, d11}, [r4:128]! + vld1.64 {d12, d13, d14, d15}, [r4:128] + sub sp, r7, #24 + pop {r8, r10, r11} + pop {r4, r5, r6, r7, pc} +LBB9_4: + lsl r0, r0, #2 + adr r1, LJTI9_0 + ldr r0, [r0, r1] + add pc, r0, r1 + .p2align 2 +LJTI9_0: + .data_region jt32 + .long LBB9_6-LJTI9_0 + .long LBB9_6-LJTI9_0 + .long LBB9_6-LJTI9_0 + .long LBB9_10-LJTI9_0 + .end_data_region +LBB9_6: +Ltmp22: + ldr r0, [sp, #20] + str r0, [sp, #4] + ldr r0, [sp, #8] + mov r1, #4 + str r1, [sp, #16] +Ltmp23: + bl _objc_release +Ltmp24: + b LBB9_9 +LBB9_7: + ldr r0, [sp, #16] + cmp r0, #4 + bls LBB9_4 + trap +LBB9_9: + mvn r0, #0 + str r0, [sp, #16] + ldr r0, [sp, #4] + mov lr, pc + b __Unwind_SjLj_Resume +LBB9_10: +Ltmp25: + ldr r0, [sp, #20] + ldr r0, [sp, #24] + mov lr, pc + b SYM(core::panicking::panic_in_cleanup::GENERATED_ID, 0) + .p2align 2 + .data_region +LCPI9_0: + .long Lexception2-(LPC9_0+8) +LCPI9_1: + .long LBB9_7-(LPC9_1+8) + .end_data_region +Lfunc_end2: + .section __TEXT,__gcc_except_tab + .p2align 2, 0x0 +GCC_except_table9: +Lexception2: + .byte 255 + .byte 155 + .uleb128 Lttbase2-Lttbaseref2 +Lttbaseref2: + .byte 3 + .uleb128 Lcst_end2-Lcst_begin2 +Lcst_begin2: + .byte 0 + .byte 0 + .byte 1 + .byte 0 + .byte 2 + .byte 0 + .byte 3 + .byte 1 +Lcst_end2: + .byte 127 + .byte 0 + .p2align 2, 0x0 +Lttbase2: + .byte 0 + .p2align 2, 0x0 + .section __TEXT,__text,regular,pure_instructions .globl _call_with_some2 .p2align 2 .code 32 _call_with_some2: - push {r4, r5, r7, lr} - add r7, sp, #8 - sub sp, sp, #4 - mov r4, r2 - str r2, [sp] - mov r2, sp - bl _objc_msgSend +Lfunc_begin3: + push {r4, r5, r6, r7, lr} + add r7, sp, #12 + push {r8, r10, r11} + sub r4, sp, #64 + bfc r4, #0, #4 + mov sp, r4 + vst1.64 {d8, d9, d10, d11}, [r4:128]! + vst1.64 {d12, d13, d14, d15}, [r4:128] + sub sp, sp, #64 + mov r4, r1 mov r5, r0 - ldr r0, [sp] + movw r0, :lower16:(L_rust_eh_personality$non_lazy_ptr-(LPC10_2+8)) + movt r0, :upper16:(L_rust_eh_personality$non_lazy_ptr-(LPC10_2+8)) +LPC10_2: + ldr r0, [pc, r0] + str r2, [sp, #4] + str r2, [sp, #8] + str r0, [sp, #36] + ldr r0, LCPI10_0 +LPC10_0: + add r0, pc, r0 + str r0, [sp, #40] + str r7, [sp, #44] + str sp, [sp, #52] + ldr r0, LCPI10_1 +LPC10_1: + add r0, pc, r0 + str r0, [sp, #48] + mov r0, #1 + str r0, [sp, #16] + add r0, sp, #12 + bl __Unwind_SjLj_Register +Ltmp26: + add r2, sp, #8 + mov r0, r5 + mov r1, r4 + bl _objc_msgSend + str r0, [sp] +Ltmp27: + ldr r0, [sp, #8] + mov r1, #2 + str r1, [sp, #16] +Ltmp28: bl _objc_retain - mov r0, r4 +Ltmp29: + mov r0, #3 + str r0, [sp, #16] +Ltmp30: + ldr r0, [sp, #4] bl _objc_release - ldr r1, [sp] - mov r0, r5 - sub sp, r7, #8 - pop {r4, r5, r7, pc} +Ltmp31: + ldr r4, [sp, #8] + add r0, sp, #12 + bl __Unwind_SjLj_Unregister + ldr r0, [sp] + mov r1, r4 + add r4, sp, #64 + vld1.64 {d8, d9, d10, d11}, [r4:128]! + vld1.64 {d12, d13, d14, d15}, [r4:128] + sub sp, r7, #24 + pop {r8, r10, r11} + pop {r4, r5, r6, r7, pc} +LBB10_4: + lsl r0, r0, #2 + adr r1, LJTI10_0 + ldr r0, [r0, r1] + add pc, r0, r1 + .p2align 2 +LJTI10_0: + .data_region jt32 + .long LBB10_6-LJTI10_0 + .long LBB10_6-LJTI10_0 + .long LBB10_6-LJTI10_0 + .long LBB10_11-LJTI10_0 + .end_data_region +LBB10_6: +Ltmp32: + ldr r0, [sp, #20] + str r0, [sp, #4] + ldr r0, [sp, #8] + cmp r0, #0 + beq LBB10_10 + mov r1, #4 + str r1, [sp, #16] +Ltmp33: + bl _objc_release +Ltmp34: + b LBB10_10 +LBB10_8: + ldr r0, [sp, #16] + cmp r0, #4 + bls LBB10_4 + trap +LBB10_10: + mvn r0, #0 + str r0, [sp, #16] + ldr r0, [sp, #4] + mov lr, pc + b __Unwind_SjLj_Resume +LBB10_11: +Ltmp35: + ldr r0, [sp, #20] + ldr r0, [sp, #24] + mov lr, pc + b SYM(core::panicking::panic_in_cleanup::GENERATED_ID, 0) + .p2align 2 + .data_region +LCPI10_0: + .long Lexception3-(LPC10_0+8) +LCPI10_1: + .long LBB10_8-(LPC10_1+8) + .end_data_region +Lfunc_end3: + .section __TEXT,__gcc_except_tab + .p2align 2, 0x0 +GCC_except_table10: +Lexception3: + .byte 255 + .byte 155 + .uleb128 Lttbase3-Lttbaseref3 +Lttbaseref3: + .byte 3 + .uleb128 Lcst_end3-Lcst_begin3 +Lcst_begin3: + .byte 0 + .byte 0 + .byte 1 + .byte 0 + .byte 2 + .byte 0 + .byte 3 + .byte 1 +Lcst_end3: + .byte 127 + .byte 0 + .p2align 2, 0x0 +Lttbase3: + .byte 0 + .p2align 2, 0x0 + .section __TEXT,__text,regular,pure_instructions .globl _call_with_some3 .p2align 2 .code 32 _call_with_some3: - push {r4, r5, r7, lr} - add r7, sp, #8 - sub sp, sp, #4 - mov r4, r2 - str r2, [sp] - mov r2, sp - bl _objc_msgSend +Lfunc_begin4: + push {r4, r5, r6, r7, lr} + add r7, sp, #12 + push {r8, r10, r11} + sub r4, sp, #64 + bfc r4, #0, #4 + mov sp, r4 + vst1.64 {d8, d9, d10, d11}, [r4:128]! + vst1.64 {d12, d13, d14, d15}, [r4:128] + sub sp, sp, #64 + mov r4, r1 mov r5, r0 - ldr r0, [sp] + movw r0, :lower16:(L_rust_eh_personality$non_lazy_ptr-(LPC11_2+8)) + movt r0, :upper16:(L_rust_eh_personality$non_lazy_ptr-(LPC11_2+8)) +LPC11_2: + ldr r0, [pc, r0] + str r2, [sp, #4] + str r2, [sp, #8] + str r0, [sp, #36] + ldr r0, LCPI11_0 +LPC11_0: + add r0, pc, r0 + str r0, [sp, #40] + str r7, [sp, #44] + str sp, [sp, #52] + ldr r0, LCPI11_1 +LPC11_1: + add r0, pc, r0 + str r0, [sp, #48] + mov r0, #1 + str r0, [sp, #16] + add r0, sp, #12 + bl __Unwind_SjLj_Register +Ltmp36: + add r2, sp, #8 + mov r0, r5 + mov r1, r4 + bl _objc_msgSend + str r0, [sp] +Ltmp37: + ldr r0, [sp, #8] + mov r1, #2 + str r1, [sp, #16] +Ltmp38: bl _objc_retain - mov r0, r4 +Ltmp39: + mov r0, #3 + str r0, [sp, #16] +Ltmp40: + ldr r0, [sp, #4] bl _objc_release - ldr r1, [sp] - mov r0, r5 - sub sp, r7, #8 - pop {r4, r5, r7, pc} +Ltmp41: + ldr r4, [sp, #8] + add r0, sp, #12 + bl __Unwind_SjLj_Unregister + ldr r0, [sp] + mov r1, r4 + add r4, sp, #64 + vld1.64 {d8, d9, d10, d11}, [r4:128]! + vld1.64 {d12, d13, d14, d15}, [r4:128] + sub sp, r7, #24 + pop {r8, r10, r11} + pop {r4, r5, r6, r7, pc} +LBB11_4: + lsl r0, r0, #2 + adr r1, LJTI11_0 + ldr r0, [r0, r1] + add pc, r0, r1 + .p2align 2 +LJTI11_0: + .data_region jt32 + .long LBB11_6-LJTI11_0 + .long LBB11_6-LJTI11_0 + .long LBB11_6-LJTI11_0 + .long LBB11_11-LJTI11_0 + .end_data_region +LBB11_6: +Ltmp42: + ldr r0, [sp, #20] + str r0, [sp, #4] + ldr r0, [sp, #8] + cmp r0, #0 + beq LBB11_10 + mov r1, #4 + str r1, [sp, #16] +Ltmp43: + bl _objc_release +Ltmp44: + b LBB11_10 +LBB11_8: + ldr r0, [sp, #16] + cmp r0, #4 + bls LBB11_4 + trap +LBB11_10: + mvn r0, #0 + str r0, [sp, #16] + ldr r0, [sp, #4] + mov lr, pc + b __Unwind_SjLj_Resume +LBB11_11: +Ltmp45: + ldr r0, [sp, #20] + ldr r0, [sp, #24] + mov lr, pc + b SYM(core::panicking::panic_in_cleanup::GENERATED_ID, 0) + .p2align 2 + .data_region +LCPI11_0: + .long Lexception4-(LPC11_0+8) +LCPI11_1: + .long LBB11_8-(LPC11_1+8) + .end_data_region +Lfunc_end4: + .section __TEXT,__gcc_except_tab + .p2align 2, 0x0 +GCC_except_table11: +Lexception4: + .byte 255 + .byte 155 + .uleb128 Lttbase4-Lttbaseref4 +Lttbaseref4: + .byte 3 + .uleb128 Lcst_end4-Lcst_begin4 +Lcst_begin4: + .byte 0 + .byte 0 + .byte 1 + .byte 0 + .byte 2 + .byte 0 + .byte 3 + .byte 1 +Lcst_end4: + .byte 127 + .byte 0 + .p2align 2, 0x0 +Lttbase4: + .byte 0 + .p2align 2, 0x0 + + .section __DATA,__nl_symbol_ptr,non_lazy_symbol_pointers + .p2align 2, 0x0 +L_rust_eh_personality$non_lazy_ptr: + .indirect_symbol _rust_eh_personality + .long 0 .subsections_via_symbols diff --git a/crates/test-assembly/crates/test_out_parameters/expected/apple-x86.s b/crates/test-assembly/crates/test_out_parameters/expected/apple-x86.s index 5b060aa7a..8224f07bd 100644 --- a/crates/test-assembly/crates/test_out_parameters/expected/apple-x86.s +++ b/crates/test-assembly/crates/test_out_parameters/expected/apple-x86.s @@ -236,64 +236,165 @@ _call_with_none2: .globl _call_with_none3 .p2align 4, 0x90 _call_with_none3: +Lfunc_begin0: push ebp mov ebp, esp push esi - push eax + sub esp, 20 mov eax, dword ptr [ebp + 8] mov ecx, dword ptr [ebp + 12] mov dword ptr [ebp - 8], 0 - sub esp, 4 +Ltmp0: lea edx, [ebp - 8] - push edx - push ecx - push eax + mov dword ptr [esp + 8], edx + mov dword ptr [esp + 4], ecx + mov dword ptr [esp], eax call _objc_msgSend - add esp, 16 +Ltmp1: mov esi, eax - sub esp, 12 - push dword ptr [ebp - 8] + mov eax, dword ptr [ebp - 8] +Ltmp2: + mov dword ptr [esp], eax call _objc_retain - add esp, 16 +Ltmp3: mov edx, dword ptr [ebp - 8] mov eax, esi - add esp, 4 + add esp, 20 pop esi pop ebp ret +LBB7_3: +Ltmp4: + mov esi, eax + mov eax, dword ptr [ebp - 8] + test eax, eax + je LBB7_5 +Ltmp5: + mov dword ptr [esp], eax + call _objc_release +Ltmp6: +LBB7_5: + mov dword ptr [esp], esi + call __Unwind_Resume +LBB7_6: +Ltmp7: + call SYM(core::panicking::panic_in_cleanup::GENERATED_ID, 0) +Lfunc_end0: + .section __TEXT,__gcc_except_tab + .p2align 2, 0x0 +GCC_except_table7: +Lexception0: + .byte 255 + .byte 155 + .uleb128 Lttbase0-Lttbaseref0 +Lttbaseref0: + .byte 1 + .uleb128 Lcst_end0-Lcst_begin0 +Lcst_begin0: + .uleb128 Ltmp0-Lfunc_begin0 + .uleb128 Ltmp3-Ltmp0 + .uleb128 Ltmp4-Lfunc_begin0 + .byte 0 + .uleb128 Ltmp5-Lfunc_begin0 + .uleb128 Ltmp6-Ltmp5 + .uleb128 Ltmp7-Lfunc_begin0 + .byte 1 + .uleb128 Ltmp6-Lfunc_begin0 + .uleb128 Lfunc_end0-Ltmp6 + .byte 0 + .byte 0 +Lcst_end0: + .byte 127 + .byte 0 + .p2align 2, 0x0 +Lttbase0: + .byte 0 + .p2align 2, 0x0 + .section __TEXT,__text,regular,pure_instructions .globl _call_with_none4 .p2align 4, 0x90 _call_with_none4: +Lfunc_begin1: push ebp mov ebp, esp push esi - push eax + sub esp, 20 mov eax, dword ptr [ebp + 8] mov ecx, dword ptr [ebp + 12] mov dword ptr [ebp - 8], 0 - sub esp, 4 +Ltmp8: lea edx, [ebp - 8] - push edx - push ecx - push eax + mov dword ptr [esp + 8], edx + mov dword ptr [esp + 4], ecx + mov dword ptr [esp], eax call _objc_msgSend - add esp, 16 +Ltmp9: mov esi, eax - sub esp, 12 - push dword ptr [ebp - 8] + mov eax, dword ptr [ebp - 8] +Ltmp10: + mov dword ptr [esp], eax call _objc_retain - add esp, 16 +Ltmp11: mov edx, dword ptr [ebp - 8] mov eax, esi - add esp, 4 + add esp, 20 pop esi pop ebp ret +LBB8_3: +Ltmp12: + mov esi, eax + mov eax, dword ptr [ebp - 8] + test eax, eax + je LBB8_5 +Ltmp13: + mov dword ptr [esp], eax + call _objc_release +Ltmp14: +LBB8_5: + mov dword ptr [esp], esi + call __Unwind_Resume +LBB8_6: +Ltmp15: + call SYM(core::panicking::panic_in_cleanup::GENERATED_ID, 0) +Lfunc_end1: + .section __TEXT,__gcc_except_tab + .p2align 2, 0x0 +GCC_except_table8: +Lexception1: + .byte 255 + .byte 155 + .uleb128 Lttbase1-Lttbaseref1 +Lttbaseref1: + .byte 1 + .uleb128 Lcst_end1-Lcst_begin1 +Lcst_begin1: + .uleb128 Ltmp8-Lfunc_begin1 + .uleb128 Ltmp11-Ltmp8 + .uleb128 Ltmp12-Lfunc_begin1 + .byte 0 + .uleb128 Ltmp13-Lfunc_begin1 + .uleb128 Ltmp14-Ltmp13 + .uleb128 Ltmp15-Lfunc_begin1 + .byte 1 + .uleb128 Ltmp14-Lfunc_begin1 + .uleb128 Lfunc_end1-Ltmp14 + .byte 0 + .byte 0 +Lcst_end1: + .byte 127 + .byte 0 + .p2align 2, 0x0 +Lttbase1: + .byte 0 + .p2align 2, 0x0 + .section __TEXT,__text,regular,pure_instructions .globl _call_with_some1 .p2align 4, 0x90 _call_with_some1: +Lfunc_begin2: push ebp mov ebp, esp push edi @@ -302,17 +403,23 @@ _call_with_some1: mov edi, dword ptr [ebp + 16] mov eax, dword ptr [ebp + 8] mov ecx, dword ptr [ebp + 12] +Ltmp16: lea edx, [ebp + 16] mov dword ptr [esp + 8], edx mov dword ptr [esp + 4], ecx mov dword ptr [esp], eax call _objc_msgSend +Ltmp17: mov esi, eax mov eax, dword ptr [ebp + 16] +Ltmp18: mov dword ptr [esp], eax call _objc_retain +Ltmp19: +Ltmp20: mov dword ptr [esp], edi call _objc_release +Ltmp21: mov edx, dword ptr [ebp + 16] mov eax, esi add esp, 16 @@ -320,30 +427,82 @@ _call_with_some1: pop edi pop ebp ret +LBB9_5: +Ltmp22: + mov esi, eax + mov eax, dword ptr [ebp + 16] +Ltmp23: + mov dword ptr [esp], eax + call _objc_release +Ltmp24: + mov dword ptr [esp], esi + call __Unwind_Resume +LBB9_4: +Ltmp25: + call SYM(core::panicking::panic_in_cleanup::GENERATED_ID, 0) +Lfunc_end2: + .section __TEXT,__gcc_except_tab + .p2align 2, 0x0 +GCC_except_table9: +Lexception2: + .byte 255 + .byte 155 + .uleb128 Lttbase2-Lttbaseref2 +Lttbaseref2: + .byte 1 + .uleb128 Lcst_end2-Lcst_begin2 +Lcst_begin2: + .uleb128 Ltmp16-Lfunc_begin2 + .uleb128 Ltmp21-Ltmp16 + .uleb128 Ltmp22-Lfunc_begin2 + .byte 0 + .uleb128 Ltmp23-Lfunc_begin2 + .uleb128 Ltmp24-Ltmp23 + .uleb128 Ltmp25-Lfunc_begin2 + .byte 1 + .uleb128 Ltmp24-Lfunc_begin2 + .uleb128 Lfunc_end2-Ltmp24 + .byte 0 + .byte 0 +Lcst_end2: + .byte 127 + .byte 0 + .p2align 2, 0x0 +Lttbase2: + .byte 0 + .p2align 2, 0x0 + .section __TEXT,__text,regular,pure_instructions .globl _call_with_some2 .p2align 4, 0x90 _call_with_some2: +Lfunc_begin3: push ebp mov ebp, esp push edi push esi sub esp, 16 + mov edi, dword ptr [ebp + 16] mov eax, dword ptr [ebp + 8] mov ecx, dword ptr [ebp + 12] - mov edi, dword ptr [ebp + 16] mov dword ptr [ebp - 12], edi +Ltmp26: lea edx, [ebp - 12] mov dword ptr [esp + 8], edx mov dword ptr [esp + 4], ecx mov dword ptr [esp], eax call _objc_msgSend +Ltmp27: mov esi, eax mov eax, dword ptr [ebp - 12] +Ltmp28: mov dword ptr [esp], eax call _objc_retain +Ltmp29: +Ltmp30: mov dword ptr [esp], edi call _objc_release +Ltmp31: mov edx, dword ptr [ebp - 12] mov eax, esi add esp, 16 @@ -351,30 +510,85 @@ _call_with_some2: pop edi pop ebp ret +LBB10_4: +Ltmp32: + mov esi, eax + mov eax, dword ptr [ebp - 12] + test eax, eax + je LBB10_6 +Ltmp33: + mov dword ptr [esp], eax + call _objc_release +Ltmp34: +LBB10_6: + mov dword ptr [esp], esi + call __Unwind_Resume +LBB10_7: +Ltmp35: + call SYM(core::panicking::panic_in_cleanup::GENERATED_ID, 0) +Lfunc_end3: + .section __TEXT,__gcc_except_tab + .p2align 2, 0x0 +GCC_except_table10: +Lexception3: + .byte 255 + .byte 155 + .uleb128 Lttbase3-Lttbaseref3 +Lttbaseref3: + .byte 1 + .uleb128 Lcst_end3-Lcst_begin3 +Lcst_begin3: + .uleb128 Ltmp26-Lfunc_begin3 + .uleb128 Ltmp31-Ltmp26 + .uleb128 Ltmp32-Lfunc_begin3 + .byte 0 + .uleb128 Ltmp33-Lfunc_begin3 + .uleb128 Ltmp34-Ltmp33 + .uleb128 Ltmp35-Lfunc_begin3 + .byte 1 + .uleb128 Ltmp34-Lfunc_begin3 + .uleb128 Lfunc_end3-Ltmp34 + .byte 0 + .byte 0 +Lcst_end3: + .byte 127 + .byte 0 + .p2align 2, 0x0 +Lttbase3: + .byte 0 + .p2align 2, 0x0 + .section __TEXT,__text,regular,pure_instructions .globl _call_with_some3 .p2align 4, 0x90 _call_with_some3: +Lfunc_begin4: push ebp mov ebp, esp push edi push esi sub esp, 16 + mov edi, dword ptr [ebp + 16] mov eax, dword ptr [ebp + 8] mov ecx, dword ptr [ebp + 12] - mov edi, dword ptr [ebp + 16] mov dword ptr [ebp - 12], edi +Ltmp36: lea edx, [ebp - 12] mov dword ptr [esp + 8], edx mov dword ptr [esp + 4], ecx mov dword ptr [esp], eax call _objc_msgSend +Ltmp37: mov esi, eax mov eax, dword ptr [ebp - 12] +Ltmp38: mov dword ptr [esp], eax call _objc_retain +Ltmp39: +Ltmp40: mov dword ptr [esp], edi call _objc_release +Ltmp41: mov edx, dword ptr [ebp - 12] mov eax, esi add esp, 16 @@ -382,5 +596,57 @@ _call_with_some3: pop edi pop ebp ret +LBB11_4: +Ltmp42: + mov esi, eax + mov eax, dword ptr [ebp - 12] + test eax, eax + je LBB11_6 +Ltmp43: + mov dword ptr [esp], eax + call _objc_release +Ltmp44: +LBB11_6: + mov dword ptr [esp], esi + call __Unwind_Resume +LBB11_7: +Ltmp45: + call SYM(core::panicking::panic_in_cleanup::GENERATED_ID, 0) +Lfunc_end4: + .section __TEXT,__gcc_except_tab + .p2align 2, 0x0 +GCC_except_table11: +Lexception4: + .byte 255 + .byte 155 + .uleb128 Lttbase4-Lttbaseref4 +Lttbaseref4: + .byte 1 + .uleb128 Lcst_end4-Lcst_begin4 +Lcst_begin4: + .uleb128 Ltmp36-Lfunc_begin4 + .uleb128 Ltmp41-Ltmp36 + .uleb128 Ltmp42-Lfunc_begin4 + .byte 0 + .uleb128 Ltmp43-Lfunc_begin4 + .uleb128 Ltmp44-Ltmp43 + .uleb128 Ltmp45-Lfunc_begin4 + .byte 1 + .uleb128 Ltmp44-Lfunc_begin4 + .uleb128 Lfunc_end4-Ltmp44 + .byte 0 + .byte 0 +Lcst_end4: + .byte 127 + .byte 0 + .p2align 2, 0x0 +Lttbase4: + .byte 0 + .p2align 2, 0x0 + + .section __IMPORT,__pointers,non_lazy_symbol_pointers +L_rust_eh_personality$non_lazy_ptr: + .indirect_symbol _rust_eh_personality + .long 0 .subsections_via_symbols diff --git a/crates/test-assembly/crates/test_out_parameters/expected/apple-x86_64.s b/crates/test-assembly/crates/test_out_parameters/expected/apple-x86_64.s index 424aa7640..bddf9c8be 100644 --- a/crates/test-assembly/crates/test_out_parameters/expected/apple-x86_64.s +++ b/crates/test-assembly/crates/test_out_parameters/expected/apple-x86_64.s @@ -172,46 +172,151 @@ _call_with_none2: .globl _call_with_none3 .p2align 4, 0x90 _call_with_none3: +Lfunc_begin0: push rbp mov rbp, rsp push rbx push rax mov qword ptr [rbp - 16], 0 +Ltmp0: lea rdx, [rbp - 16] call _objc_msgSend +Ltmp1: mov rbx, rax mov rdi, qword ptr [rbp - 16] +Ltmp2: call _objc_retain +Ltmp3: mov rdx, qword ptr [rbp - 16] mov rax, rbx add rsp, 8 pop rbx pop rbp ret +LBB7_3: +Ltmp4: + mov rbx, rax + mov rdi, qword ptr [rbp - 16] + test rdi, rdi + je LBB7_5 +Ltmp5: + call _objc_release +Ltmp6: +LBB7_5: + mov rdi, rbx + call __Unwind_Resume +LBB7_6: +Ltmp7: + call SYM(core::panicking::panic_in_cleanup::GENERATED_ID, 0) +Lfunc_end0: + .section __TEXT,__gcc_except_tab + .p2align 2, 0x0 +GCC_except_table7: +Lexception0: + .byte 255 + .byte 155 + .uleb128 Lttbase0-Lttbaseref0 +Lttbaseref0: + .byte 1 + .uleb128 Lcst_end0-Lcst_begin0 +Lcst_begin0: + .uleb128 Ltmp0-Lfunc_begin0 + .uleb128 Ltmp3-Ltmp0 + .uleb128 Ltmp4-Lfunc_begin0 + .byte 0 + .uleb128 Ltmp5-Lfunc_begin0 + .uleb128 Ltmp6-Ltmp5 + .uleb128 Ltmp7-Lfunc_begin0 + .byte 1 + .uleb128 Ltmp6-Lfunc_begin0 + .uleb128 Lfunc_end0-Ltmp6 + .byte 0 + .byte 0 +Lcst_end0: + .byte 127 + .byte 0 + .p2align 2, 0x0 +Lttbase0: + .byte 0 + .p2align 2, 0x0 + .section __TEXT,__text,regular,pure_instructions .globl _call_with_none4 .p2align 4, 0x90 _call_with_none4: +Lfunc_begin1: push rbp mov rbp, rsp push rbx push rax mov qword ptr [rbp - 16], 0 +Ltmp8: lea rdx, [rbp - 16] call _objc_msgSend +Ltmp9: mov rbx, rax mov rdi, qword ptr [rbp - 16] +Ltmp10: call _objc_retain +Ltmp11: mov rdx, qword ptr [rbp - 16] mov rax, rbx add rsp, 8 pop rbx pop rbp ret +LBB8_3: +Ltmp12: + mov rbx, rax + mov rdi, qword ptr [rbp - 16] + test rdi, rdi + je LBB8_5 +Ltmp13: + call _objc_release +Ltmp14: +LBB8_5: + mov rdi, rbx + call __Unwind_Resume +LBB8_6: +Ltmp15: + call SYM(core::panicking::panic_in_cleanup::GENERATED_ID, 0) +Lfunc_end1: + .section __TEXT,__gcc_except_tab + .p2align 2, 0x0 +GCC_except_table8: +Lexception1: + .byte 255 + .byte 155 + .uleb128 Lttbase1-Lttbaseref1 +Lttbaseref1: + .byte 1 + .uleb128 Lcst_end1-Lcst_begin1 +Lcst_begin1: + .uleb128 Ltmp8-Lfunc_begin1 + .uleb128 Ltmp11-Ltmp8 + .uleb128 Ltmp12-Lfunc_begin1 + .byte 0 + .uleb128 Ltmp13-Lfunc_begin1 + .uleb128 Ltmp14-Ltmp13 + .uleb128 Ltmp15-Lfunc_begin1 + .byte 1 + .uleb128 Ltmp14-Lfunc_begin1 + .uleb128 Lfunc_end1-Ltmp14 + .byte 0 + .byte 0 +Lcst_end1: + .byte 127 + .byte 0 + .p2align 2, 0x0 +Lttbase1: + .byte 0 + .p2align 2, 0x0 + .section __TEXT,__text,regular,pure_instructions .globl _call_with_some1 .p2align 4, 0x90 _call_with_some1: +Lfunc_begin2: push rbp mov rbp, rsp push r14 @@ -219,13 +324,19 @@ _call_with_some1: sub rsp, 16 mov rbx, rdx mov qword ptr [rbp - 24], rdx +Ltmp16: lea rdx, [rbp - 24] call _objc_msgSend +Ltmp17: mov r14, rax mov rdi, qword ptr [rbp - 24] +Ltmp18: call _objc_retain +Ltmp19: +Ltmp20: mov rdi, rbx call _objc_release +Ltmp21: mov rdx, qword ptr [rbp - 24] mov rax, r14 add rsp, 16 @@ -233,10 +344,55 @@ _call_with_some1: pop r14 pop rbp ret +LBB9_5: +Ltmp22: + mov rbx, rax + mov rdi, qword ptr [rbp - 24] +Ltmp23: + call _objc_release +Ltmp24: + mov rdi, rbx + call __Unwind_Resume +LBB9_4: +Ltmp25: + call SYM(core::panicking::panic_in_cleanup::GENERATED_ID, 0) +Lfunc_end2: + .section __TEXT,__gcc_except_tab + .p2align 2, 0x0 +GCC_except_table9: +Lexception2: + .byte 255 + .byte 155 + .uleb128 Lttbase2-Lttbaseref2 +Lttbaseref2: + .byte 1 + .uleb128 Lcst_end2-Lcst_begin2 +Lcst_begin2: + .uleb128 Ltmp16-Lfunc_begin2 + .uleb128 Ltmp21-Ltmp16 + .uleb128 Ltmp22-Lfunc_begin2 + .byte 0 + .uleb128 Ltmp23-Lfunc_begin2 + .uleb128 Ltmp24-Ltmp23 + .uleb128 Ltmp25-Lfunc_begin2 + .byte 1 + .uleb128 Ltmp24-Lfunc_begin2 + .uleb128 Lfunc_end2-Ltmp24 + .byte 0 + .byte 0 +Lcst_end2: + .byte 127 + .byte 0 + .p2align 2, 0x0 +Lttbase2: + .byte 0 + .p2align 2, 0x0 + .section __TEXT,__text,regular,pure_instructions .globl _call_with_some2 .p2align 4, 0x90 _call_with_some2: +Lfunc_begin3: push rbp mov rbp, rsp push r14 @@ -244,13 +400,19 @@ _call_with_some2: sub rsp, 16 mov rbx, rdx mov qword ptr [rbp - 24], rdx +Ltmp26: lea rdx, [rbp - 24] call _objc_msgSend +Ltmp27: mov r14, rax mov rdi, qword ptr [rbp - 24] +Ltmp28: call _objc_retain +Ltmp29: +Ltmp30: mov rdi, rbx call _objc_release +Ltmp31: mov rdx, qword ptr [rbp - 24] mov rax, r14 add rsp, 16 @@ -258,10 +420,58 @@ _call_with_some2: pop r14 pop rbp ret +LBB10_4: +Ltmp32: + mov rbx, rax + mov rdi, qword ptr [rbp - 24] + test rdi, rdi + je LBB10_6 +Ltmp33: + call _objc_release +Ltmp34: +LBB10_6: + mov rdi, rbx + call __Unwind_Resume +LBB10_7: +Ltmp35: + call SYM(core::panicking::panic_in_cleanup::GENERATED_ID, 0) +Lfunc_end3: + .section __TEXT,__gcc_except_tab + .p2align 2, 0x0 +GCC_except_table10: +Lexception3: + .byte 255 + .byte 155 + .uleb128 Lttbase3-Lttbaseref3 +Lttbaseref3: + .byte 1 + .uleb128 Lcst_end3-Lcst_begin3 +Lcst_begin3: + .uleb128 Ltmp26-Lfunc_begin3 + .uleb128 Ltmp31-Ltmp26 + .uleb128 Ltmp32-Lfunc_begin3 + .byte 0 + .uleb128 Ltmp33-Lfunc_begin3 + .uleb128 Ltmp34-Ltmp33 + .uleb128 Ltmp35-Lfunc_begin3 + .byte 1 + .uleb128 Ltmp34-Lfunc_begin3 + .uleb128 Lfunc_end3-Ltmp34 + .byte 0 + .byte 0 +Lcst_end3: + .byte 127 + .byte 0 + .p2align 2, 0x0 +Lttbase3: + .byte 0 + .p2align 2, 0x0 + .section __TEXT,__text,regular,pure_instructions .globl _call_with_some3 .p2align 4, 0x90 _call_with_some3: +Lfunc_begin4: push rbp mov rbp, rsp push r14 @@ -269,13 +479,19 @@ _call_with_some3: sub rsp, 16 mov rbx, rdx mov qword ptr [rbp - 24], rdx +Ltmp36: lea rdx, [rbp - 24] call _objc_msgSend +Ltmp37: mov r14, rax mov rdi, qword ptr [rbp - 24] +Ltmp38: call _objc_retain +Ltmp39: +Ltmp40: mov rdi, rbx call _objc_release +Ltmp41: mov rdx, qword ptr [rbp - 24] mov rax, r14 add rsp, 16 @@ -283,5 +499,51 @@ _call_with_some3: pop r14 pop rbp ret +LBB11_4: +Ltmp42: + mov rbx, rax + mov rdi, qword ptr [rbp - 24] + test rdi, rdi + je LBB11_6 +Ltmp43: + call _objc_release +Ltmp44: +LBB11_6: + mov rdi, rbx + call __Unwind_Resume +LBB11_7: +Ltmp45: + call SYM(core::panicking::panic_in_cleanup::GENERATED_ID, 0) +Lfunc_end4: + .section __TEXT,__gcc_except_tab + .p2align 2, 0x0 +GCC_except_table11: +Lexception4: + .byte 255 + .byte 155 + .uleb128 Lttbase4-Lttbaseref4 +Lttbaseref4: + .byte 1 + .uleb128 Lcst_end4-Lcst_begin4 +Lcst_begin4: + .uleb128 Ltmp36-Lfunc_begin4 + .uleb128 Ltmp41-Ltmp36 + .uleb128 Ltmp42-Lfunc_begin4 + .byte 0 + .uleb128 Ltmp43-Lfunc_begin4 + .uleb128 Ltmp44-Ltmp43 + .uleb128 Ltmp45-Lfunc_begin4 + .byte 1 + .uleb128 Ltmp44-Lfunc_begin4 + .uleb128 Lfunc_end4-Ltmp44 + .byte 0 + .byte 0 +Lcst_end4: + .byte 127 + .byte 0 + .p2align 2, 0x0 +Lttbase4: + .byte 0 + .p2align 2, 0x0 .subsections_via_symbols diff --git a/crates/test-assembly/crates/test_out_parameters/expected/gnustep-x86.s b/crates/test-assembly/crates/test_out_parameters/expected/gnustep-x86.s index 53d959578..5d3961161 100644 --- a/crates/test-assembly/crates/test_out_parameters/expected/gnustep-x86.s +++ b/crates/test-assembly/crates/test_out_parameters/expected/gnustep-x86.s @@ -319,34 +319,37 @@ call_with_none2: .p2align 4, 0x90 .type call_with_none3,@function call_with_none3: +.Lfunc_begin0: push ebx push edi push esi sub esp, 16 - mov esi, dword ptr [esp + 32] mov edi, dword ptr [esp + 36] + mov esi, dword ptr [esp + 32] call .L7$pb .L7$pb: pop ebx mov dword ptr [esp + 12], 0 +.Ltmp17: + add ebx, offset _GLOBAL_OFFSET_TABLE_+(.Ltmp17-.L7$pb) .Ltmp7: - add ebx, offset _GLOBAL_OFFSET_TABLE_+(.Ltmp7-.L7$pb) - sub esp, 8 - push edi - push esi + mov dword ptr [esp + 4], edi + mov dword ptr [esp], esi call objc_msg_lookup@PLT - add esp, 12 - lea ecx, [esp + 16] - push ecx - push edi - push esi +.Ltmp8: +.Ltmp9: + lea ecx, [esp + 12] + mov dword ptr [esp + 4], edi + mov dword ptr [esp], esi + mov dword ptr [esp + 8], ecx call eax - add esp, 16 +.Ltmp10: mov esi, eax - sub esp, 12 - push dword ptr [esp + 24] + mov eax, dword ptr [esp + 12] +.Ltmp11: + mov dword ptr [esp], eax call objc_retain@PLT - add esp, 16 +.Ltmp12: mov edx, dword ptr [esp + 12] mov eax, esi add esp, 16 @@ -354,42 +357,91 @@ call_with_none3: pop edi pop ebx ret +.LBB7_4: +.Ltmp13: + mov esi, eax + mov eax, dword ptr [esp + 12] + test eax, eax + je .LBB7_6 +.Ltmp14: + mov dword ptr [esp], eax + call objc_release@PLT +.Ltmp15: +.LBB7_6: + mov dword ptr [esp], esi + call _Unwind_Resume@PLT +.LBB7_7: +.Ltmp16: + call SYM(core::panicking::panic_in_cleanup::GENERATED_ID, 0)@PLT .Lfunc_end7: .size call_with_none3, .Lfunc_end7-call_with_none3 + .section .gcc_except_table.call_with_none3,"a",@progbits + .p2align 2, 0x0 +GCC_except_table7: +.Lexception0: + .byte 255 + .byte 155 + .uleb128 .Lttbase0-.Lttbaseref0 +.Lttbaseref0: + .byte 1 + .uleb128 .Lcst_end0-.Lcst_begin0 +.Lcst_begin0: + .uleb128 .Ltmp7-.Lfunc_begin0 + .uleb128 .Ltmp12-.Ltmp7 + .uleb128 .Ltmp13-.Lfunc_begin0 + .byte 0 + .uleb128 .Ltmp14-.Lfunc_begin0 + .uleb128 .Ltmp15-.Ltmp14 + .uleb128 .Ltmp16-.Lfunc_begin0 + .byte 1 + .uleb128 .Ltmp15-.Lfunc_begin0 + .uleb128 .Lfunc_end7-.Ltmp15 + .byte 0 + .byte 0 +.Lcst_end0: + .byte 127 + .byte 0 + .p2align 2, 0x0 +.Lttbase0: + .byte 0 + .p2align 2, 0x0 .section .text.call_with_none4,"ax",@progbits .globl call_with_none4 .p2align 4, 0x90 .type call_with_none4,@function call_with_none4: +.Lfunc_begin1: push ebx push edi push esi sub esp, 16 - mov esi, dword ptr [esp + 32] mov edi, dword ptr [esp + 36] + mov esi, dword ptr [esp + 32] call .L8$pb .L8$pb: pop ebx mov dword ptr [esp + 12], 0 -.Ltmp8: - add ebx, offset _GLOBAL_OFFSET_TABLE_+(.Ltmp8-.L8$pb) - sub esp, 8 - push edi - push esi +.Ltmp28: + add ebx, offset _GLOBAL_OFFSET_TABLE_+(.Ltmp28-.L8$pb) +.Ltmp18: + mov dword ptr [esp + 4], edi + mov dword ptr [esp], esi call objc_msg_lookup@PLT - add esp, 12 - lea ecx, [esp + 16] - push ecx - push edi - push esi +.Ltmp19: +.Ltmp20: + lea ecx, [esp + 12] + mov dword ptr [esp + 4], edi + mov dword ptr [esp], esi + mov dword ptr [esp + 8], ecx call eax - add esp, 16 +.Ltmp21: mov esi, eax - sub esp, 12 - push dword ptr [esp + 24] + mov eax, dword ptr [esp + 12] +.Ltmp22: + mov dword ptr [esp], eax call objc_retain@PLT - add esp, 16 +.Ltmp23: mov edx, dword ptr [esp + 12] mov eax, esi add esp, 16 @@ -397,41 +449,96 @@ call_with_none4: pop edi pop ebx ret +.LBB8_4: +.Ltmp24: + mov esi, eax + mov eax, dword ptr [esp + 12] + test eax, eax + je .LBB8_6 +.Ltmp25: + mov dword ptr [esp], eax + call objc_release@PLT +.Ltmp26: +.LBB8_6: + mov dword ptr [esp], esi + call _Unwind_Resume@PLT +.LBB8_7: +.Ltmp27: + call SYM(core::panicking::panic_in_cleanup::GENERATED_ID, 0)@PLT .Lfunc_end8: .size call_with_none4, .Lfunc_end8-call_with_none4 + .section .gcc_except_table.call_with_none4,"a",@progbits + .p2align 2, 0x0 +GCC_except_table8: +.Lexception1: + .byte 255 + .byte 155 + .uleb128 .Lttbase1-.Lttbaseref1 +.Lttbaseref1: + .byte 1 + .uleb128 .Lcst_end1-.Lcst_begin1 +.Lcst_begin1: + .uleb128 .Ltmp18-.Lfunc_begin1 + .uleb128 .Ltmp23-.Ltmp18 + .uleb128 .Ltmp24-.Lfunc_begin1 + .byte 0 + .uleb128 .Ltmp25-.Lfunc_begin1 + .uleb128 .Ltmp26-.Ltmp25 + .uleb128 .Ltmp27-.Lfunc_begin1 + .byte 1 + .uleb128 .Ltmp26-.Lfunc_begin1 + .uleb128 .Lfunc_end8-.Ltmp26 + .byte 0 + .byte 0 +.Lcst_end1: + .byte 127 + .byte 0 + .p2align 2, 0x0 +.Lttbase1: + .byte 0 + .p2align 2, 0x0 .section .text.call_with_some1,"ax",@progbits .globl call_with_some1 .p2align 4, 0x90 .type call_with_some1,@function call_with_some1: +.Lfunc_begin2: push ebp push ebx push edi push esi sub esp, 12 - mov esi, dword ptr [esp + 32] - mov ebp, dword ptr [esp + 36] mov edi, dword ptr [esp + 40] + mov ebp, dword ptr [esp + 36] + mov esi, dword ptr [esp + 32] call .L9$pb .L9$pb: pop ebx -.Ltmp9: - add ebx, offset _GLOBAL_OFFSET_TABLE_+(.Ltmp9-.L9$pb) +.Ltmp41: + add ebx, offset _GLOBAL_OFFSET_TABLE_+(.Ltmp41-.L9$pb) +.Ltmp29: mov dword ptr [esp + 4], ebp mov dword ptr [esp], esi call objc_msg_lookup@PLT +.Ltmp30: +.Ltmp31: lea ecx, [esp + 40] mov dword ptr [esp + 4], ebp mov dword ptr [esp], esi mov dword ptr [esp + 8], ecx call eax +.Ltmp32: mov esi, eax mov eax, dword ptr [esp + 40] +.Ltmp33: mov dword ptr [esp], eax call objc_retain@PLT +.Ltmp34: +.Ltmp35: mov dword ptr [esp], edi call objc_release@PLT +.Ltmp36: mov edx, dword ptr [esp + 40] mov eax, esi add esp, 12 @@ -440,42 +547,94 @@ call_with_some1: pop ebx pop ebp ret +.LBB9_6: +.Ltmp37: + mov esi, eax + mov eax, dword ptr [esp + 40] +.Ltmp38: + mov dword ptr [esp], eax + call objc_release@PLT +.Ltmp39: + mov dword ptr [esp], esi + call _Unwind_Resume@PLT +.LBB9_5: +.Ltmp40: + call SYM(core::panicking::panic_in_cleanup::GENERATED_ID, 0)@PLT .Lfunc_end9: .size call_with_some1, .Lfunc_end9-call_with_some1 + .section .gcc_except_table.call_with_some1,"a",@progbits + .p2align 2, 0x0 +GCC_except_table9: +.Lexception2: + .byte 255 + .byte 155 + .uleb128 .Lttbase2-.Lttbaseref2 +.Lttbaseref2: + .byte 1 + .uleb128 .Lcst_end2-.Lcst_begin2 +.Lcst_begin2: + .uleb128 .Ltmp29-.Lfunc_begin2 + .uleb128 .Ltmp36-.Ltmp29 + .uleb128 .Ltmp37-.Lfunc_begin2 + .byte 0 + .uleb128 .Ltmp38-.Lfunc_begin2 + .uleb128 .Ltmp39-.Ltmp38 + .uleb128 .Ltmp40-.Lfunc_begin2 + .byte 1 + .uleb128 .Ltmp39-.Lfunc_begin2 + .uleb128 .Lfunc_end9-.Ltmp39 + .byte 0 + .byte 0 +.Lcst_end2: + .byte 127 + .byte 0 + .p2align 2, 0x0 +.Lttbase2: + .byte 0 + .p2align 2, 0x0 .section .text.call_with_some2,"ax",@progbits .globl call_with_some2 .p2align 4, 0x90 .type call_with_some2,@function call_with_some2: +.Lfunc_begin3: push ebp push ebx push edi push esi sub esp, 28 - mov esi, dword ptr [esp + 48] - mov ebp, dword ptr [esp + 52] mov edi, dword ptr [esp + 56] + mov ebp, dword ptr [esp + 52] + mov esi, dword ptr [esp + 48] call .L10$pb .L10$pb: pop ebx -.Ltmp10: - add ebx, offset _GLOBAL_OFFSET_TABLE_+(.Ltmp10-.L10$pb) +.Ltmp54: + add ebx, offset _GLOBAL_OFFSET_TABLE_+(.Ltmp54-.L10$pb) mov dword ptr [esp + 24], edi +.Ltmp42: mov dword ptr [esp + 4], ebp mov dword ptr [esp], esi call objc_msg_lookup@PLT +.Ltmp43: +.Ltmp44: lea ecx, [esp + 24] mov dword ptr [esp + 4], ebp mov dword ptr [esp], esi mov dword ptr [esp + 8], ecx call eax +.Ltmp45: mov esi, eax mov eax, dword ptr [esp + 24] +.Ltmp46: mov dword ptr [esp], eax call objc_retain@PLT +.Ltmp47: +.Ltmp48: mov dword ptr [esp], edi call objc_release@PLT +.Ltmp49: mov edx, dword ptr [esp + 24] mov eax, esi add esp, 28 @@ -484,42 +643,97 @@ call_with_some2: pop ebx pop ebp ret +.LBB10_5: +.Ltmp50: + mov esi, eax + mov eax, dword ptr [esp + 24] + test eax, eax + je .LBB10_7 +.Ltmp51: + mov dword ptr [esp], eax + call objc_release@PLT +.Ltmp52: +.LBB10_7: + mov dword ptr [esp], esi + call _Unwind_Resume@PLT +.LBB10_8: +.Ltmp53: + call SYM(core::panicking::panic_in_cleanup::GENERATED_ID, 0)@PLT .Lfunc_end10: .size call_with_some2, .Lfunc_end10-call_with_some2 + .section .gcc_except_table.call_with_some2,"a",@progbits + .p2align 2, 0x0 +GCC_except_table10: +.Lexception3: + .byte 255 + .byte 155 + .uleb128 .Lttbase3-.Lttbaseref3 +.Lttbaseref3: + .byte 1 + .uleb128 .Lcst_end3-.Lcst_begin3 +.Lcst_begin3: + .uleb128 .Ltmp42-.Lfunc_begin3 + .uleb128 .Ltmp49-.Ltmp42 + .uleb128 .Ltmp50-.Lfunc_begin3 + .byte 0 + .uleb128 .Ltmp51-.Lfunc_begin3 + .uleb128 .Ltmp52-.Ltmp51 + .uleb128 .Ltmp53-.Lfunc_begin3 + .byte 1 + .uleb128 .Ltmp52-.Lfunc_begin3 + .uleb128 .Lfunc_end10-.Ltmp52 + .byte 0 + .byte 0 +.Lcst_end3: + .byte 127 + .byte 0 + .p2align 2, 0x0 +.Lttbase3: + .byte 0 + .p2align 2, 0x0 .section .text.call_with_some3,"ax",@progbits .globl call_with_some3 .p2align 4, 0x90 .type call_with_some3,@function call_with_some3: +.Lfunc_begin4: push ebp push ebx push edi push esi sub esp, 28 - mov esi, dword ptr [esp + 48] - mov ebp, dword ptr [esp + 52] mov edi, dword ptr [esp + 56] + mov ebp, dword ptr [esp + 52] + mov esi, dword ptr [esp + 48] call .L11$pb .L11$pb: pop ebx -.Ltmp11: - add ebx, offset _GLOBAL_OFFSET_TABLE_+(.Ltmp11-.L11$pb) +.Ltmp67: + add ebx, offset _GLOBAL_OFFSET_TABLE_+(.Ltmp67-.L11$pb) mov dword ptr [esp + 24], edi +.Ltmp55: mov dword ptr [esp + 4], ebp mov dword ptr [esp], esi call objc_msg_lookup@PLT +.Ltmp56: +.Ltmp57: lea ecx, [esp + 24] mov dword ptr [esp + 4], ebp mov dword ptr [esp], esi mov dword ptr [esp + 8], ecx call eax +.Ltmp58: mov esi, eax mov eax, dword ptr [esp + 24] +.Ltmp59: mov dword ptr [esp], eax call objc_retain@PLT +.Ltmp60: +.Ltmp61: mov dword ptr [esp], edi call objc_release@PLT +.Ltmp62: mov edx, dword ptr [esp + 24] mov eax, esi add esp, 28 @@ -528,7 +742,61 @@ call_with_some3: pop ebx pop ebp ret +.LBB11_5: +.Ltmp63: + mov esi, eax + mov eax, dword ptr [esp + 24] + test eax, eax + je .LBB11_7 +.Ltmp64: + mov dword ptr [esp], eax + call objc_release@PLT +.Ltmp65: +.LBB11_7: + mov dword ptr [esp], esi + call _Unwind_Resume@PLT +.LBB11_8: +.Ltmp66: + call SYM(core::panicking::panic_in_cleanup::GENERATED_ID, 0)@PLT .Lfunc_end11: .size call_with_some3, .Lfunc_end11-call_with_some3 + .section .gcc_except_table.call_with_some3,"a",@progbits + .p2align 2, 0x0 +GCC_except_table11: +.Lexception4: + .byte 255 + .byte 155 + .uleb128 .Lttbase4-.Lttbaseref4 +.Lttbaseref4: + .byte 1 + .uleb128 .Lcst_end4-.Lcst_begin4 +.Lcst_begin4: + .uleb128 .Ltmp55-.Lfunc_begin4 + .uleb128 .Ltmp62-.Ltmp55 + .uleb128 .Ltmp63-.Lfunc_begin4 + .byte 0 + .uleb128 .Ltmp64-.Lfunc_begin4 + .uleb128 .Ltmp65-.Ltmp64 + .uleb128 .Ltmp66-.Lfunc_begin4 + .byte 1 + .uleb128 .Ltmp65-.Lfunc_begin4 + .uleb128 .Lfunc_end11-.Ltmp65 + .byte 0 + .byte 0 +.Lcst_end4: + .byte 127 + .byte 0 + .p2align 2, 0x0 +.Lttbase4: + .byte 0 + .p2align 2, 0x0 + .hidden DW.ref.rust_eh_personality + .weak DW.ref.rust_eh_personality + .section .data.DW.ref.rust_eh_personality,"awG",@progbits,DW.ref.rust_eh_personality,comdat + .p2align 2, 0x0 + .type DW.ref.rust_eh_personality,@object + .size DW.ref.rust_eh_personality, 4 +DW.ref.rust_eh_personality: + .long rust_eh_personality .section ".note.GNU-stack","",@progbits diff --git a/crates/test-assembly/crates/test_out_parameters/expected/gnustep-x86_64.s b/crates/test-assembly/crates/test_out_parameters/expected/gnustep-x86_64.s index 003909ece..1cdc2cd03 100644 --- a/crates/test-assembly/crates/test_out_parameters/expected/gnustep-x86_64.s +++ b/crates/test-assembly/crates/test_out_parameters/expected/gnustep-x86_64.s @@ -255,62 +255,167 @@ call_with_none2: .p2align 4, 0x90 .type call_with_none3,@function call_with_none3: +.Lfunc_begin0: push r14 push rbx push rax mov rbx, rsi mov r14, rdi mov qword ptr [rsp], 0 +.Ltmp0: call qword ptr [rip + objc_msg_lookup@GOTPCREL] +.Ltmp1: +.Ltmp2: mov rdx, rsp mov rdi, r14 mov rsi, rbx call rax +.Ltmp3: mov rbx, rax mov rdi, qword ptr [rsp] +.Ltmp4: call qword ptr [rip + objc_retain@GOTPCREL] +.Ltmp5: mov rdx, qword ptr [rsp] mov rax, rbx add rsp, 8 pop rbx pop r14 ret +.LBB7_4: +.Ltmp6: + mov rbx, rax + mov rdi, qword ptr [rsp] + test rdi, rdi + je .LBB7_6 +.Ltmp7: + call qword ptr [rip + objc_release@GOTPCREL] +.Ltmp8: +.LBB7_6: + mov rdi, rbx + call _Unwind_Resume@PLT +.LBB7_7: +.Ltmp9: + call qword ptr [rip + SYM(core::panicking::panic_in_cleanup::GENERATED_ID, 0)@GOTPCREL] .Lfunc_end7: .size call_with_none3, .Lfunc_end7-call_with_none3 + .section .gcc_except_table.call_with_none3,"a",@progbits + .p2align 2, 0x0 +GCC_except_table7: +.Lexception0: + .byte 255 + .byte 155 + .uleb128 .Lttbase0-.Lttbaseref0 +.Lttbaseref0: + .byte 1 + .uleb128 .Lcst_end0-.Lcst_begin0 +.Lcst_begin0: + .uleb128 .Ltmp0-.Lfunc_begin0 + .uleb128 .Ltmp5-.Ltmp0 + .uleb128 .Ltmp6-.Lfunc_begin0 + .byte 0 + .uleb128 .Ltmp7-.Lfunc_begin0 + .uleb128 .Ltmp8-.Ltmp7 + .uleb128 .Ltmp9-.Lfunc_begin0 + .byte 1 + .uleb128 .Ltmp8-.Lfunc_begin0 + .uleb128 .Lfunc_end7-.Ltmp8 + .byte 0 + .byte 0 +.Lcst_end0: + .byte 127 + .byte 0 + .p2align 2, 0x0 +.Lttbase0: + .byte 0 + .p2align 2, 0x0 .section .text.call_with_none4,"ax",@progbits .globl call_with_none4 .p2align 4, 0x90 .type call_with_none4,@function call_with_none4: +.Lfunc_begin1: push r14 push rbx push rax mov rbx, rsi mov r14, rdi mov qword ptr [rsp], 0 +.Ltmp10: call qword ptr [rip + objc_msg_lookup@GOTPCREL] +.Ltmp11: +.Ltmp12: mov rdx, rsp mov rdi, r14 mov rsi, rbx call rax +.Ltmp13: mov rbx, rax mov rdi, qword ptr [rsp] +.Ltmp14: call qword ptr [rip + objc_retain@GOTPCREL] +.Ltmp15: mov rdx, qword ptr [rsp] mov rax, rbx add rsp, 8 pop rbx pop r14 ret +.LBB8_4: +.Ltmp16: + mov rbx, rax + mov rdi, qword ptr [rsp] + test rdi, rdi + je .LBB8_6 +.Ltmp17: + call qword ptr [rip + objc_release@GOTPCREL] +.Ltmp18: +.LBB8_6: + mov rdi, rbx + call _Unwind_Resume@PLT +.LBB8_7: +.Ltmp19: + call qword ptr [rip + SYM(core::panicking::panic_in_cleanup::GENERATED_ID, 0)@GOTPCREL] .Lfunc_end8: .size call_with_none4, .Lfunc_end8-call_with_none4 + .section .gcc_except_table.call_with_none4,"a",@progbits + .p2align 2, 0x0 +GCC_except_table8: +.Lexception1: + .byte 255 + .byte 155 + .uleb128 .Lttbase1-.Lttbaseref1 +.Lttbaseref1: + .byte 1 + .uleb128 .Lcst_end1-.Lcst_begin1 +.Lcst_begin1: + .uleb128 .Ltmp10-.Lfunc_begin1 + .uleb128 .Ltmp15-.Ltmp10 + .uleb128 .Ltmp16-.Lfunc_begin1 + .byte 0 + .uleb128 .Ltmp17-.Lfunc_begin1 + .uleb128 .Ltmp18-.Ltmp17 + .uleb128 .Ltmp19-.Lfunc_begin1 + .byte 1 + .uleb128 .Ltmp18-.Lfunc_begin1 + .uleb128 .Lfunc_end8-.Ltmp18 + .byte 0 + .byte 0 +.Lcst_end1: + .byte 127 + .byte 0 + .p2align 2, 0x0 +.Lttbase1: + .byte 0 + .p2align 2, 0x0 .section .text.call_with_some1,"ax",@progbits .globl call_with_some1 .p2align 4, 0x90 .type call_with_some1,@function call_with_some1: +.Lfunc_begin2: push r15 push r14 push rbx @@ -319,16 +424,24 @@ call_with_some1: mov r14, rsi mov r15, rdi mov qword ptr [rsp + 8], rdx +.Ltmp20: call qword ptr [rip + objc_msg_lookup@GOTPCREL] +.Ltmp21: +.Ltmp22: lea rdx, [rsp + 8] mov rdi, r15 mov rsi, r14 call rax +.Ltmp23: mov r14, rax mov rdi, qword ptr [rsp + 8] +.Ltmp24: call qword ptr [rip + objc_retain@GOTPCREL] +.Ltmp25: +.Ltmp26: mov rdi, rbx call qword ptr [rip + objc_release@GOTPCREL] +.Ltmp27: mov rdx, qword ptr [rsp + 8] mov rax, r14 add rsp, 16 @@ -336,14 +449,57 @@ call_with_some1: pop r14 pop r15 ret +.LBB9_6: +.Ltmp28: + mov rbx, rax + mov rdi, qword ptr [rsp + 8] +.Ltmp29: + call qword ptr [rip + objc_release@GOTPCREL] +.Ltmp30: + mov rdi, rbx + call _Unwind_Resume@PLT +.LBB9_5: +.Ltmp31: + call qword ptr [rip + SYM(core::panicking::panic_in_cleanup::GENERATED_ID, 0)@GOTPCREL] .Lfunc_end9: .size call_with_some1, .Lfunc_end9-call_with_some1 + .section .gcc_except_table.call_with_some1,"a",@progbits + .p2align 2, 0x0 +GCC_except_table9: +.Lexception2: + .byte 255 + .byte 155 + .uleb128 .Lttbase2-.Lttbaseref2 +.Lttbaseref2: + .byte 1 + .uleb128 .Lcst_end2-.Lcst_begin2 +.Lcst_begin2: + .uleb128 .Ltmp20-.Lfunc_begin2 + .uleb128 .Ltmp27-.Ltmp20 + .uleb128 .Ltmp28-.Lfunc_begin2 + .byte 0 + .uleb128 .Ltmp29-.Lfunc_begin2 + .uleb128 .Ltmp30-.Ltmp29 + .uleb128 .Ltmp31-.Lfunc_begin2 + .byte 1 + .uleb128 .Ltmp30-.Lfunc_begin2 + .uleb128 .Lfunc_end9-.Ltmp30 + .byte 0 + .byte 0 +.Lcst_end2: + .byte 127 + .byte 0 + .p2align 2, 0x0 +.Lttbase2: + .byte 0 + .p2align 2, 0x0 .section .text.call_with_some2,"ax",@progbits .globl call_with_some2 .p2align 4, 0x90 .type call_with_some2,@function call_with_some2: +.Lfunc_begin3: push r15 push r14 push rbx @@ -352,16 +508,24 @@ call_with_some2: mov r14, rsi mov r15, rdi mov qword ptr [rsp + 8], rdx +.Ltmp32: call qword ptr [rip + objc_msg_lookup@GOTPCREL] +.Ltmp33: +.Ltmp34: lea rdx, [rsp + 8] mov rdi, r15 mov rsi, r14 call rax +.Ltmp35: mov r14, rax mov rdi, qword ptr [rsp + 8] +.Ltmp36: call qword ptr [rip + objc_retain@GOTPCREL] +.Ltmp37: +.Ltmp38: mov rdi, rbx call qword ptr [rip + objc_release@GOTPCREL] +.Ltmp39: mov rdx, qword ptr [rsp + 8] mov rax, r14 add rsp, 16 @@ -369,14 +533,60 @@ call_with_some2: pop r14 pop r15 ret +.LBB10_5: +.Ltmp40: + mov rbx, rax + mov rdi, qword ptr [rsp + 8] + test rdi, rdi + je .LBB10_7 +.Ltmp41: + call qword ptr [rip + objc_release@GOTPCREL] +.Ltmp42: +.LBB10_7: + mov rdi, rbx + call _Unwind_Resume@PLT +.LBB10_8: +.Ltmp43: + call qword ptr [rip + SYM(core::panicking::panic_in_cleanup::GENERATED_ID, 0)@GOTPCREL] .Lfunc_end10: .size call_with_some2, .Lfunc_end10-call_with_some2 + .section .gcc_except_table.call_with_some2,"a",@progbits + .p2align 2, 0x0 +GCC_except_table10: +.Lexception3: + .byte 255 + .byte 155 + .uleb128 .Lttbase3-.Lttbaseref3 +.Lttbaseref3: + .byte 1 + .uleb128 .Lcst_end3-.Lcst_begin3 +.Lcst_begin3: + .uleb128 .Ltmp32-.Lfunc_begin3 + .uleb128 .Ltmp39-.Ltmp32 + .uleb128 .Ltmp40-.Lfunc_begin3 + .byte 0 + .uleb128 .Ltmp41-.Lfunc_begin3 + .uleb128 .Ltmp42-.Ltmp41 + .uleb128 .Ltmp43-.Lfunc_begin3 + .byte 1 + .uleb128 .Ltmp42-.Lfunc_begin3 + .uleb128 .Lfunc_end10-.Ltmp42 + .byte 0 + .byte 0 +.Lcst_end3: + .byte 127 + .byte 0 + .p2align 2, 0x0 +.Lttbase3: + .byte 0 + .p2align 2, 0x0 .section .text.call_with_some3,"ax",@progbits .globl call_with_some3 .p2align 4, 0x90 .type call_with_some3,@function call_with_some3: +.Lfunc_begin4: push r15 push r14 push rbx @@ -385,16 +595,24 @@ call_with_some3: mov r14, rsi mov r15, rdi mov qword ptr [rsp + 8], rdx +.Ltmp44: call qword ptr [rip + objc_msg_lookup@GOTPCREL] +.Ltmp45: +.Ltmp46: lea rdx, [rsp + 8] mov rdi, r15 mov rsi, r14 call rax +.Ltmp47: mov r14, rax mov rdi, qword ptr [rsp + 8] +.Ltmp48: call qword ptr [rip + objc_retain@GOTPCREL] +.Ltmp49: +.Ltmp50: mov rdi, rbx call qword ptr [rip + objc_release@GOTPCREL] +.Ltmp51: mov rdx, qword ptr [rsp + 8] mov rax, r14 add rsp, 16 @@ -402,7 +620,60 @@ call_with_some3: pop r14 pop r15 ret +.LBB11_5: +.Ltmp52: + mov rbx, rax + mov rdi, qword ptr [rsp + 8] + test rdi, rdi + je .LBB11_7 +.Ltmp53: + call qword ptr [rip + objc_release@GOTPCREL] +.Ltmp54: +.LBB11_7: + mov rdi, rbx + call _Unwind_Resume@PLT +.LBB11_8: +.Ltmp55: + call qword ptr [rip + SYM(core::panicking::panic_in_cleanup::GENERATED_ID, 0)@GOTPCREL] .Lfunc_end11: .size call_with_some3, .Lfunc_end11-call_with_some3 + .section .gcc_except_table.call_with_some3,"a",@progbits + .p2align 2, 0x0 +GCC_except_table11: +.Lexception4: + .byte 255 + .byte 155 + .uleb128 .Lttbase4-.Lttbaseref4 +.Lttbaseref4: + .byte 1 + .uleb128 .Lcst_end4-.Lcst_begin4 +.Lcst_begin4: + .uleb128 .Ltmp44-.Lfunc_begin4 + .uleb128 .Ltmp51-.Ltmp44 + .uleb128 .Ltmp52-.Lfunc_begin4 + .byte 0 + .uleb128 .Ltmp53-.Lfunc_begin4 + .uleb128 .Ltmp54-.Ltmp53 + .uleb128 .Ltmp55-.Lfunc_begin4 + .byte 1 + .uleb128 .Ltmp54-.Lfunc_begin4 + .uleb128 .Lfunc_end11-.Ltmp54 + .byte 0 + .byte 0 +.Lcst_end4: + .byte 127 + .byte 0 + .p2align 2, 0x0 +.Lttbase4: + .byte 0 + .p2align 2, 0x0 + .hidden DW.ref.rust_eh_personality + .weak DW.ref.rust_eh_personality + .section .data.DW.ref.rust_eh_personality,"awG",@progbits,DW.ref.rust_eh_personality,comdat + .p2align 3, 0x0 + .type DW.ref.rust_eh_personality,@object + .size DW.ref.rust_eh_personality, 8 +DW.ref.rust_eh_personality: + .quad rust_eh_personality .section ".note.GNU-stack","",@progbits diff --git a/crates/test-ui/ui/declare_class_invalid_receiver.stderr b/crates/test-ui/ui/declare_class_invalid_receiver.stderr index f3d536cb7..a1d3eaa10 100644 --- a/crates/test-ui/ui/declare_class_invalid_receiver.stderr +++ b/crates/test-ui/ui/declare_class_invalid_receiver.stderr @@ -10,7 +10,7 @@ error[E0277]: the trait bound `Box: MessageReceiver` is not satisf | | ); | | ^ | | | - | |_the trait `MessageReceiver` is not implemented for `Box`, which is required by `extern "C" fn(Box, objc2::runtime::Sel): MethodImplementation` + | |_the trait `MessageReceiver` is not implemented for `Box`, which is required by `extern "C-unwind" fn(Box, objc2::runtime::Sel): MethodImplementation` | required by a bound introduced by this call | = help: the following other types implement trait `MessageReceiver`: @@ -21,7 +21,7 @@ error[E0277]: the trait bound `Box: MessageReceiver` is not satisf *const T *mut T NonNull - = note: required for `extern "C" fn(Box, objc2::runtime::Sel)` to implement `MethodImplementation` + = note: required for `extern "C-unwind" fn(Box, objc2::runtime::Sel)` to implement `MethodImplementation` note: required by a bound in `ClassBuilderHelper::::add_method` --> $WORKSPACE/crates/objc2/src/__macro_helpers/declare_class.rs | @@ -44,7 +44,7 @@ error[E0277]: the trait bound `Retained: MessageReceiver` is not s | | ); | | ^ | | | - | |_the trait `MessageReceiver` is not implemented for `Retained`, which is required by `extern "C" fn(Retained, objc2::runtime::Sel): MethodImplementation` + | |_the trait `MessageReceiver` is not implemented for `Retained`, which is required by `extern "C-unwind" fn(Retained, objc2::runtime::Sel): MethodImplementation` | required by a bound introduced by this call | = help: the following other types implement trait `MessageReceiver`: @@ -55,7 +55,7 @@ error[E0277]: the trait bound `Retained: MessageReceiver` is not s *const T *mut T NonNull - = note: required for `extern "C" fn(Retained, objc2::runtime::Sel)` to implement `MethodImplementation` + = note: required for `extern "C-unwind" fn(Retained, objc2::runtime::Sel)` to implement `MethodImplementation` note: required by a bound in `ClassBuilderHelper::::add_method` --> $WORKSPACE/crates/objc2/src/__macro_helpers/declare_class.rs | @@ -78,7 +78,7 @@ error[E0277]: the trait bound `CustomObject: MessageReceiver` is not satisfied | | ); | | ^ | | | - | |_the trait `MessageReceiver` is not implemented for `CustomObject`, which is required by `extern "C" fn(CustomObject, objc2::runtime::Sel): MethodImplementation` + | |_the trait `MessageReceiver` is not implemented for `CustomObject`, which is required by `extern "C-unwind" fn(CustomObject, objc2::runtime::Sel): MethodImplementation` | required by a bound introduced by this call | = help: the following other types implement trait `MessageReceiver`: @@ -89,7 +89,7 @@ error[E0277]: the trait bound `CustomObject: MessageReceiver` is not satisfied *const T *mut T NonNull - = note: required for `extern "C" fn(CustomObject, objc2::runtime::Sel)` to implement `MethodImplementation` + = note: required for `extern "C-unwind" fn(CustomObject, objc2::runtime::Sel)` to implement `MethodImplementation` note: required by a bound in `ClassBuilderHelper::::add_method` --> $WORKSPACE/crates/objc2/src/__macro_helpers/declare_class.rs | @@ -100,7 +100,7 @@ note: required by a bound in `ClassBuilderHelper::::add_method` | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `ClassBuilderHelper::::add_method` = note: this error originates in the macro `$crate::__declare_class_register_out` which comes from the expansion of the macro `declare_class` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0271]: type mismatch resolving `::Callee == CustomObject` +error[E0271]: type mismatch resolving `::Callee == CustomObject` --> ui/declare_class_invalid_receiver.rs | | / declare_class!( @@ -125,7 +125,7 @@ note: required by a bound in `ClassBuilderHelper::::add_method` | ^^^^^^^^^^ required by this bound in `ClassBuilderHelper::::add_method` = note: this error originates in the macro `$crate::__declare_class_register_out` which comes from the expansion of the macro `declare_class` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0271]: type mismatch resolving `::Callee == CustomObject` +error[E0271]: type mismatch resolving `::Callee == CustomObject` --> ui/declare_class_invalid_receiver.rs | | / declare_class!( @@ -162,7 +162,7 @@ error[E0277]: the trait bound `Box: MessageReceiver` is not satisf | | ); | | ^ | | | - | |_the trait `MessageReceiver` is not implemented for `Box`, which is required by `extern "C" fn(Box, objc2::runtime::Sel) -> IdReturnValue: MethodImplementation` + | |_the trait `MessageReceiver` is not implemented for `Box`, which is required by `extern "C-unwind" fn(Box, objc2::runtime::Sel) -> IdReturnValue: MethodImplementation` | required by a bound introduced by this call | = help: the following other types implement trait `MessageReceiver`: @@ -173,7 +173,7 @@ error[E0277]: the trait bound `Box: MessageReceiver` is not satisf *const T *mut T NonNull - = note: required for `extern "C" fn(Box, objc2::runtime::Sel) -> IdReturnValue` to implement `MethodImplementation` + = note: required for `extern "C-unwind" fn(Box, objc2::runtime::Sel) -> IdReturnValue` to implement `MethodImplementation` note: required by a bound in `ClassBuilderHelper::::add_method` --> $WORKSPACE/crates/objc2/src/__macro_helpers/declare_class.rs | @@ -196,7 +196,7 @@ error[E0277]: the trait bound `Retained: MessageReceiver` is not s | | ); | | ^ | | | - | |_the trait `MessageReceiver` is not implemented for `Retained`, which is required by `extern "C" fn(Retained, objc2::runtime::Sel) -> IdReturnValue: MethodImplementation` + | |_the trait `MessageReceiver` is not implemented for `Retained`, which is required by `extern "C-unwind" fn(Retained, objc2::runtime::Sel) -> IdReturnValue: MethodImplementation` | required by a bound introduced by this call | = help: the following other types implement trait `MessageReceiver`: @@ -207,7 +207,7 @@ error[E0277]: the trait bound `Retained: MessageReceiver` is not s *const T *mut T NonNull - = note: required for `extern "C" fn(Retained, objc2::runtime::Sel) -> IdReturnValue` to implement `MethodImplementation` + = note: required for `extern "C-unwind" fn(Retained, objc2::runtime::Sel) -> IdReturnValue` to implement `MethodImplementation` note: required by a bound in `ClassBuilderHelper::::add_method` --> $WORKSPACE/crates/objc2/src/__macro_helpers/declare_class.rs | @@ -230,7 +230,7 @@ error[E0277]: the trait bound `CustomObject: MessageReceiver` is not satisfied | | ); | | ^ | | | - | |_the trait `MessageReceiver` is not implemented for `CustomObject`, which is required by `extern "C" fn(CustomObject, objc2::runtime::Sel) -> IdReturnValue: MethodImplementation` + | |_the trait `MessageReceiver` is not implemented for `CustomObject`, which is required by `extern "C-unwind" fn(CustomObject, objc2::runtime::Sel) -> IdReturnValue: MethodImplementation` | required by a bound introduced by this call | = help: the following other types implement trait `MessageReceiver`: @@ -241,7 +241,7 @@ error[E0277]: the trait bound `CustomObject: MessageReceiver` is not satisfied *const T *mut T NonNull - = note: required for `extern "C" fn(CustomObject, objc2::runtime::Sel) -> IdReturnValue` to implement `MethodImplementation` + = note: required for `extern "C-unwind" fn(CustomObject, objc2::runtime::Sel) -> IdReturnValue` to implement `MethodImplementation` note: required by a bound in `ClassBuilderHelper::::add_method` --> $WORKSPACE/crates/objc2/src/__macro_helpers/declare_class.rs | diff --git a/crates/test-ui/ui/declare_class_invalid_type.stderr b/crates/test-ui/ui/declare_class_invalid_type.stderr index 2dd2eb48e..62c72846e 100644 --- a/crates/test-ui/ui/declare_class_invalid_type.stderr +++ b/crates/test-ui/ui/declare_class_invalid_type.stderr @@ -184,7 +184,7 @@ error[E0277]: the trait bound `Retained: Encode` is not satisfied | | ); | | ^ | | | - | |_the trait `Encode` is not implemented for `Retained`, which is required by `extern "C" fn(&AnyClass, objc2::runtime::Sel) -> Retained: MethodImplementation` + | |_the trait `Encode` is not implemented for `Retained`, which is required by `extern "C-unwind" fn(&AnyClass, objc2::runtime::Sel) -> Retained: MethodImplementation` | required by a bound introduced by this call | = help: the following other types implement trait `Encode`: @@ -198,7 +198,7 @@ error[E0277]: the trait bound `Retained: Encode` is not satisfied AtomicI8 and $N others = note: required for `Retained` to implement `EncodeReturn` - = note: required for `extern "C" fn(&AnyClass, objc2::runtime::Sel) -> Retained` to implement `MethodImplementation` + = note: required for `extern "C-unwind" fn(&AnyClass, objc2::runtime::Sel) -> Retained` to implement `MethodImplementation` note: required by a bound in `ClassBuilderHelper::::add_class_method` --> $WORKSPACE/crates/objc2/src/__macro_helpers/declare_class.rs | @@ -247,7 +247,7 @@ error[E0277]: the trait bound `Vec<()>: Encode` is not satisfied | | ); | | ^ | | | - | |_the trait `Encode` is not implemented for `Vec<()>`, which is required by `extern "C" fn(&AnyClass, objc2::runtime::Sel) -> Vec<()>: MethodImplementation` + | |_the trait `Encode` is not implemented for `Vec<()>`, which is required by `extern "C-unwind" fn(&AnyClass, objc2::runtime::Sel) -> Vec<()>: MethodImplementation` | required by a bound introduced by this call | = help: the following other types implement trait `Encode`: @@ -261,7 +261,7 @@ error[E0277]: the trait bound `Vec<()>: Encode` is not satisfied AtomicI8 and $N others = note: required for `Vec<()>` to implement `EncodeReturn` - = note: required for `extern "C" fn(&AnyClass, objc2::runtime::Sel) -> Vec<()>` to implement `MethodImplementation` + = note: required for `extern "C-unwind" fn(&AnyClass, objc2::runtime::Sel) -> Vec<()>` to implement `MethodImplementation` note: required by a bound in `ClassBuilderHelper::::add_class_method` --> $WORKSPACE/crates/objc2/src/__macro_helpers/declare_class.rs | @@ -310,7 +310,7 @@ error[E0277]: the trait bound `Box: Encode` is not satisfied | | ); | | ^ | | | - | |_the trait `Encode` is not implemented for `Box`, which is required by `extern "C" fn(&CustomObject, objc2::runtime::Sel, Box): MethodImplementation` + | |_the trait `Encode` is not implemented for `Box`, which is required by `extern "C-unwind" fn(&CustomObject, objc2::runtime::Sel, Box): MethodImplementation` | required by a bound introduced by this call | = help: the following other types implement trait `Encode`: @@ -324,7 +324,7 @@ error[E0277]: the trait bound `Box: Encode` is not satisfied AtomicI8 and $N others = note: required for `Box` to implement `EncodeArgument` - = note: required for `extern "C" fn(&CustomObject, objc2::runtime::Sel, Box)` to implement `MethodImplementation` + = note: required for `extern "C-unwind" fn(&CustomObject, objc2::runtime::Sel, Box)` to implement `MethodImplementation` note: required by a bound in `ClassBuilderHelper::::add_method` --> $WORKSPACE/crates/objc2/src/__macro_helpers/declare_class.rs | @@ -373,7 +373,7 @@ error[E0277]: the trait bound `CustomObject: Encode` is not satisfied | | ); | | ^ | | | - | |_the trait `Encode` is not implemented for `CustomObject`, which is required by `extern "C" fn(&CustomObject, objc2::runtime::Sel, CustomObject): MethodImplementation` + | |_the trait `Encode` is not implemented for `CustomObject`, which is required by `extern "C-unwind" fn(&CustomObject, objc2::runtime::Sel, CustomObject): MethodImplementation` | required by a bound introduced by this call | = help: the following other types implement trait `Encode`: @@ -387,7 +387,7 @@ error[E0277]: the trait bound `CustomObject: Encode` is not satisfied AtomicI8 and $N others = note: required for `CustomObject` to implement `EncodeArgument` - = note: required for `extern "C" fn(&CustomObject, objc2::runtime::Sel, CustomObject)` to implement `MethodImplementation` + = note: required for `extern "C-unwind" fn(&CustomObject, objc2::runtime::Sel, CustomObject)` to implement `MethodImplementation` note: required by a bound in `ClassBuilderHelper::::add_method` --> $WORKSPACE/crates/objc2/src/__macro_helpers/declare_class.rs | diff --git a/crates/test-ui/ui/declare_class_mut_self_not_mutable.stderr b/crates/test-ui/ui/declare_class_mut_self_not_mutable.stderr index 330ae51eb..78601ed30 100644 --- a/crates/test-ui/ui/declare_class_mut_self_not_mutable.stderr +++ b/crates/test-ui/ui/declare_class_mut_self_not_mutable.stderr @@ -10,7 +10,7 @@ error[E0277]: the trait bound `&mut CustomObject: MessageReceiver` is not satisf | | ); | | ^ | | | - | |_the trait `MessageReceiver` is not implemented for `&mut CustomObject`, which is required by `extern "C" fn(&mut CustomObject, objc2::runtime::Sel) -> &mut CustomObject: MethodImplementation` + | |_the trait `MessageReceiver` is not implemented for `&mut CustomObject`, which is required by `extern "C-unwind" fn(&mut CustomObject, objc2::runtime::Sel) -> &mut CustomObject: MethodImplementation` | required by a bound introduced by this call | = help: the following other types implement trait `MessageReceiver`: @@ -22,7 +22,7 @@ error[E0277]: the trait bound `&mut CustomObject: MessageReceiver` is not satisf *mut T NonNull = note: `MessageReceiver` is implemented for `&CustomObject`, but not for `&mut CustomObject` - = note: required for `extern "C" fn(&mut CustomObject, objc2::runtime::Sel) -> &mut CustomObject` to implement `MethodImplementation` + = note: required for `extern "C-unwind" fn(&mut CustomObject, objc2::runtime::Sel) -> &mut CustomObject` to implement `MethodImplementation` note: required by a bound in `ClassBuilderHelper::::add_method` --> $WORKSPACE/crates/objc2/src/__macro_helpers/declare_class.rs | @@ -45,7 +45,7 @@ error[E0277]: the trait bound `&mut CustomObject: MessageReceiver` is not satisf | | ); | | ^ | | | - | |_the trait `MessageReceiver` is not implemented for `&mut CustomObject`, which is required by `extern "C" fn(&mut CustomObject, objc2::runtime::Sel): MethodImplementation` + | |_the trait `MessageReceiver` is not implemented for `&mut CustomObject`, which is required by `extern "C-unwind" fn(&mut CustomObject, objc2::runtime::Sel): MethodImplementation` | required by a bound introduced by this call | = help: the following other types implement trait `MessageReceiver`: @@ -57,7 +57,7 @@ error[E0277]: the trait bound `&mut CustomObject: MessageReceiver` is not satisf *mut T NonNull = note: `MessageReceiver` is implemented for `&CustomObject`, but not for `&mut CustomObject` - = note: required for `extern "C" fn(&mut CustomObject, objc2::runtime::Sel)` to implement `MethodImplementation` + = note: required for `extern "C-unwind" fn(&mut CustomObject, objc2::runtime::Sel)` to implement `MethodImplementation` note: required by a bound in `ClassBuilderHelper::::add_method` --> $WORKSPACE/crates/objc2/src/__macro_helpers/declare_class.rs | @@ -80,7 +80,7 @@ error[E0277]: the trait bound `&mut CustomObject: MessageReceiver` is not satisf | | ); | | ^ | | | - | |_the trait `MessageReceiver` is not implemented for `&mut CustomObject`, which is required by `extern "C" fn(&mut CustomObject, objc2::runtime::Sel) -> IdReturnValue: MethodImplementation` + | |_the trait `MessageReceiver` is not implemented for `&mut CustomObject`, which is required by `extern "C-unwind" fn(&mut CustomObject, objc2::runtime::Sel) -> IdReturnValue: MethodImplementation` | required by a bound introduced by this call | = help: the following other types implement trait `MessageReceiver`: @@ -92,7 +92,7 @@ error[E0277]: the trait bound `&mut CustomObject: MessageReceiver` is not satisf *mut T NonNull = note: `MessageReceiver` is implemented for `&CustomObject`, but not for `&mut CustomObject` - = note: required for `extern "C" fn(&mut CustomObject, objc2::runtime::Sel) -> IdReturnValue` to implement `MethodImplementation` + = note: required for `extern "C-unwind" fn(&mut CustomObject, objc2::runtime::Sel) -> IdReturnValue` to implement `MethodImplementation` note: required by a bound in `ClassBuilderHelper::::add_method` --> $WORKSPACE/crates/objc2/src/__macro_helpers/declare_class.rs | diff --git a/crates/tests/src/block.rs b/crates/tests/src/block.rs index 267abedd7..2607989f2 100644 --- a/crates/tests/src/block.rs +++ b/crates/tests/src/block.rs @@ -35,7 +35,7 @@ unsafe impl Encode for LargeStruct { type Add12 = Block i32>; -extern "C" { +extern "C-unwind" { /// Returns a pointer to a global block that returns 7. fn get_int_block() -> *mut Block i32>; /// Returns a pointer to a copied block that returns `i`. diff --git a/crates/tests/src/exception.rs b/crates/tests/src/exception.rs index 21ca12b4b..bc7c03920 100644 --- a/crates/tests/src/exception.rs +++ b/crates/tests/src/exception.rs @@ -36,7 +36,7 @@ fn throw_catch_raise_catch() { let inner = || { autoreleasepool(|pool| { let exc = unsafe { Retained::autorelease(exc, pool) }; - unsafe { exc.raise() } + exc.raise() }) }; @@ -59,25 +59,23 @@ fn throw_catch_raise_catch() { #[test] #[cfg(feature = "catch-all")] #[should_panic = "uncaught exception = unsafe { &*(block as *const Block) }; std::println!("{block:#?}"); } diff --git a/framework-crates/objc2-foundation/src/array.rs b/framework-crates/objc2-foundation/src/array.rs index 90af6a2b2..943d7fd5b 100644 --- a/framework-crates/objc2-foundation/src/array.rs +++ b/framework-crates/objc2-foundation/src/array.rs @@ -292,8 +292,10 @@ impl NSMutableArray { #[cfg(feature = "NSObjCRuntime")] #[doc(alias = "sortUsingFunction:context:")] pub fn sort_by core::cmp::Ordering>(&self, compare: F) { - // TODO: "C-unwind" - unsafe extern "C" fn compare_with_closure core::cmp::Ordering>( + unsafe extern "C-unwind" fn compare_with_closure< + T, + F: FnMut(&T, &T) -> core::cmp::Ordering, + >( obj1: core::ptr::NonNull, obj2: core::ptr::NonNull, context: *mut core::ffi::c_void, @@ -311,7 +313,7 @@ impl NSMutableArray { } // Create function pointer - let f: unsafe extern "C" fn(_, _, _) -> _ = compare_with_closure::; + let f: unsafe extern "C-unwind" fn(_, _, _) -> _ = compare_with_closure::; // Grab a type-erased pointer to the closure (a pointer to stack). let mut closure = compare; diff --git a/framework-crates/objc2-foundation/src/exception.rs b/framework-crates/objc2-foundation/src/exception.rs index 895c34721..6b0608f91 100644 --- a/framework-crates/objc2-foundation/src/exception.rs +++ b/framework-crates/objc2-foundation/src/exception.rs @@ -53,12 +53,7 @@ impl NSException { /// exception handler. /// /// This is equivalent to using `objc2::exception::throw`. - /// - /// - /// # Safety - /// - /// Same as `objc2::exception::throw`. - pub unsafe fn raise(&self) -> ! { + pub fn raise(&self) -> ! { // SAFETY: `NSException` is immutable, so it is safe to give to // the place where `@catch` receives it. unsafe { self.raise_raw() }; diff --git a/framework-crates/objc2-foundation/src/ns_consumed.rs b/framework-crates/objc2-foundation/src/ns_consumed.rs index faad1f613..5a51b95dd 100644 --- a/framework-crates/objc2-foundation/src/ns_consumed.rs +++ b/framework-crates/objc2-foundation/src/ns_consumed.rs @@ -1,4 +1,4 @@ -extern "C" { +extern "C-unwind" { #[cfg(feature = "NSMapTable")] pub fn NSFreeMapTable(table: *mut crate::NSMapTable); } diff --git a/framework-crates/objc2-foundation/src/tests/dictionary.rs b/framework-crates/objc2-foundation/src/tests/dictionary.rs index 534175fc3..b90dbd9e9 100644 --- a/framework-crates/objc2-foundation/src/tests/dictionary.rs +++ b/framework-crates/objc2-foundation/src/tests/dictionary.rs @@ -92,45 +92,45 @@ fn new_different_lengths() { } fn base_class_builder(name: &str) -> Option { - extern "C" fn initialize(_cls: &AnyClass, _sel: Sel) {} - let mut builder = ClassBuilder::root(name, initialize as extern "C" fn(_, _))?; + extern "C-unwind" fn initialize(_cls: &AnyClass, _sel: Sel) {} + let mut builder = ClassBuilder::root(name, initialize as extern "C-unwind" fn(_, _))?; - extern "C" fn new(cls: &AnyClass, _sel: Sel) -> *mut AnyObject { + extern "C-unwind" fn new(cls: &AnyClass, _sel: Sel) -> *mut AnyObject { unsafe { ffi::class_createInstance(cls, 0) } } unsafe { - builder.add_class_method(sel!(new), new as extern "C" fn(_, _) -> _); + builder.add_class_method(sel!(new), new as extern "C-unwind" fn(_, _) -> _); } - extern "C" fn does_not_recognize_selector(obj: &AnyObject, _sel: Sel, sel: Sel) { + extern "C-unwind" fn does_not_recognize_selector(obj: &AnyObject, _sel: Sel, sel: Sel) { panic!("does not recognize: -[{} {sel}]", obj.class()); } unsafe { builder.add_method( sel!(doesNotRecognizeSelector:), - does_not_recognize_selector as extern "C" fn(_, _, _), + does_not_recognize_selector as extern "C-unwind" fn(_, _, _), ); } - extern "C" fn forward_invocation(obj: &AnyObject, _sel: Sel, invocation: &AnyObject) { + extern "C-unwind" fn forward_invocation(obj: &AnyObject, _sel: Sel, invocation: &AnyObject) { let sel: Sel = unsafe { msg_send![invocation, selector] }; panic!("does not recognize: -[{} {sel}]", obj.class()); } unsafe { builder.add_method( sel!(forwardInvocation:), - forward_invocation as extern "C" fn(_, _, _), + forward_invocation as extern "C-unwind" fn(_, _, _), ); } - extern "C" fn release(obj: *mut AnyObject, _sel: Sel) { + extern "C-unwind" fn release(obj: *mut AnyObject, _sel: Sel) { #[allow(deprecated)] unsafe { ffi::object_dispose(obj.cast()); } } unsafe { - builder.add_method(sel!(release), release as extern "C" fn(_, _)); + builder.add_method(sel!(release), release as extern "C-unwind" fn(_, _)); } Some(builder) @@ -155,22 +155,24 @@ fn test_from_base_class(cls: &AnyClass) { feature = "gnustep-1-7", ignore = "GNUStep stack overflows here for some reason?" )] -#[cfg_attr(not(feature = "gnustep-1-7"), ignore = "Requires C-unwind")] fn no_copy() { let mut builder = base_class_builder("NoCopy").unwrap(); - extern "C" fn hash(obj: &AnyObject, _sel: Sel) -> NSUInteger { + extern "C-unwind" fn hash(obj: &AnyObject, _sel: Sel) -> NSUInteger { obj as *const AnyObject as NSUInteger } unsafe { - builder.add_method(sel!(hash), hash as extern "C" fn(_, _) -> _); + builder.add_method(sel!(hash), hash as extern "C-unwind" fn(_, _) -> _); } - extern "C" fn is_equal(obj: &AnyObject, _sel: Sel, other: &AnyObject) -> Bool { + extern "C-unwind" fn is_equal(obj: &AnyObject, _sel: Sel, other: &AnyObject) -> Bool { ptr::eq(obj, other).into() } unsafe { - builder.add_method(sel!(isEqual:), is_equal as extern "C" fn(_, _, _) -> _); + builder.add_method( + sel!(isEqual:), + is_equal as extern "C-unwind" fn(_, _, _) -> _, + ); } let cls = builder.register(); @@ -184,11 +186,10 @@ fn no_copy() { feature = "gnustep-1-7", ignore = "GNUStep stack overflows here for some reason?" )] -#[cfg_attr(not(feature = "gnustep-1-7"), ignore = "Requires C-unwind")] fn no_is_equal_hash() { let mut builder = base_class_builder("NoIsEqualHash").unwrap(); - extern "C" fn copy_with_zone( + extern "C-unwind" fn copy_with_zone( obj: &AnyObject, _sel: Sel, _zone: *mut crate::NSZone, @@ -198,7 +199,7 @@ fn no_is_equal_hash() { unsafe { builder.add_method( sel!(copyWithZone:), - copy_with_zone as extern "C" fn(_, _, _) -> _, + copy_with_zone as extern "C-unwind" fn(_, _, _) -> _, ); } @@ -212,11 +213,10 @@ fn no_is_equal_hash() { feature = "gnustep-1-7", ignore = "GNUStep stack overflows here for some reason?" )] -#[cfg_attr(not(feature = "gnustep-1-7"), ignore = "Requires C-unwind")] fn root_object() { let mut builder = base_class_builder("RootObject").unwrap(); - extern "C" fn copy_with_zone( + extern "C-unwind" fn copy_with_zone( obj: &AnyObject, _sel: Sel, _zone: *mut crate::NSZone, @@ -226,22 +226,25 @@ fn root_object() { unsafe { builder.add_method( sel!(copyWithZone:), - copy_with_zone as extern "C" fn(_, _, _) -> _, + copy_with_zone as extern "C-unwind" fn(_, _, _) -> _, ); } - extern "C" fn hash(obj: &AnyObject, _sel: Sel) -> NSUInteger { + extern "C-unwind" fn hash(obj: &AnyObject, _sel: Sel) -> NSUInteger { obj as *const AnyObject as NSUInteger } unsafe { - builder.add_method(sel!(hash), hash as extern "C" fn(_, _) -> _); + builder.add_method(sel!(hash), hash as extern "C-unwind" fn(_, _) -> _); } - extern "C" fn is_equal(obj: &AnyObject, _sel: Sel, other: &AnyObject) -> Bool { + extern "C-unwind" fn is_equal(obj: &AnyObject, _sel: Sel, other: &AnyObject) -> Bool { ptr::eq(obj, other).into() } unsafe { - builder.add_method(sel!(isEqual:), is_equal as extern "C" fn(_, _, _) -> _); + builder.add_method( + sel!(isEqual:), + is_equal as extern "C-unwind" fn(_, _, _) -> _, + ); } let cls = builder.register(); diff --git a/generated b/generated index ad3941dfb..128e42c4b 160000 --- a/generated +++ b/generated @@ -1 +1 @@ -Subproject commit ad3941dfb176416ef4c85fd110478490693c8924 +Subproject commit 128e42c4b7aed72ce2cc4467f3c696a30fe87a25