From 5bfeae154c0e5fdc186e26aefb3751d5b53f87d0 Mon Sep 17 00:00:00 2001 From: Mads Marquart Date: Fri, 16 Jun 2023 17:02:33 +0300 Subject: [PATCH] Optimize objc_retainAutoreleasedReturnValue on Aarch64 --- crates/objc2/src/rc/id.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/crates/objc2/src/rc/id.rs b/crates/objc2/src/rc/id.rs index 976ea8e38..9c98db030 100644 --- a/crates/objc2/src/rc/id.rs +++ b/crates/objc2/src/rc/id.rs @@ -405,8 +405,14 @@ impl Id { }; // Supported since macOS 10.10. - #[cfg(target_arch = "aarch64")] + // + // On macOS 13.0 / iOS 16.0 / tvOS 16.0 / watchOS 9.0, the runtime + // instead checks the return pointer address, so we no longer need + // to emit these extra instructions, see this video from WWDC22: + // https://developer.apple.com/videos/play/wwdc2022/110363/ + #[cfg(all(target_arch = "aarch64", not(feature = "unstable-apple-new")))] unsafe { + // Same as `mov x29, x29` core::arch::asm!("mov fp, fp", options(nomem, preserves_flags, nostack)) };