From 370322eefef68eed2ca9c6d7a734e5f31fc4b4d6 Mon Sep 17 00:00:00 2001 From: AZero13 Date: Fri, 5 Dec 2025 19:56:57 -0500 Subject: [PATCH 1/3] Remove autorelease workaround for x86_64 LLVM no longer tail-calls this on x86_64, so we do not need an autorelease pool. --- stdlib/public/stubs/SwiftNativeNSXXXBaseARC.m | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/stdlib/public/stubs/SwiftNativeNSXXXBaseARC.m b/stdlib/public/stubs/SwiftNativeNSXXXBaseARC.m index 8622699fcda5b..6541dd5c1ecfc 100644 --- a/stdlib/public/stubs/SwiftNativeNSXXXBaseARC.m +++ b/stdlib/public/stubs/SwiftNativeNSXXXBaseARC.m @@ -31,17 +31,7 @@ // decomposedStringWithCanonicalMapping implementation. Instead, we use a local // autorelease pool to prevent leaking of the temporary object into the callers // autorelease pool. -// -// -// FIXME: Right now we force an autoreleasepool here on x86_64 where we really -// do not want to do so. The reason why is that without the autoreleasepool (or -// really something like a defer), we tail call -// objc_retainAutoreleasedReturnValue which blocks the hand shake. Evidently -// this is something that we do not want to do. See: -// b79ff50f1bca97ecfd053372f5f6dc9d017398bc. Until that is resolved, just create -// an autoreleasepool here on x86_64. On arm/arm64 we do not have such an issue -// since we use an assembly marker instead. -#if defined(__i386__) || defined(__x86_64__) +#if defined(__i386__) #define AUTORELEASEPOOL @autoreleasepool #else // On other platforms we rely on the remove from autorelease pool optimization. From 0a2dc8e6ccf07a3a230d6fc3df4f1460c5ce8747 Mon Sep 17 00:00:00 2001 From: AZero13 Date: Fri, 5 Dec 2025 21:08:58 -0500 Subject: [PATCH 2/3] Remove AUTORELEASEPOOL entirely i386 is gone. --- stdlib/public/stubs/SwiftNativeNSXXXBaseARC.m | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/stdlib/public/stubs/SwiftNativeNSXXXBaseARC.m b/stdlib/public/stubs/SwiftNativeNSXXXBaseARC.m index 6541dd5c1ecfc..9467bd7baffbf 100644 --- a/stdlib/public/stubs/SwiftNativeNSXXXBaseARC.m +++ b/stdlib/public/stubs/SwiftNativeNSXXXBaseARC.m @@ -27,23 +27,10 @@ // pool which might be scoped such that repeatedly placing objects into it // results in unbounded memory growth. -// On i386 the remove from autorelease pool optimization is foiled by the -// decomposedStringWithCanonicalMapping implementation. Instead, we use a local -// autorelease pool to prevent leaking of the temporary object into the callers -// autorelease pool. -#if defined(__i386__) -#define AUTORELEASEPOOL @autoreleasepool -#else -// On other platforms we rely on the remove from autorelease pool optimization. -#define AUTORELEASEPOOL -#endif - SWIFT_CC(swift) SWIFT_RUNTIME_STDLIB_API size_t swift_stdlib_NSStringHashValue(NSString *str, bool isASCII) { - AUTORELEASEPOOL { return isASCII ? str.hash : str.decomposedStringWithCanonicalMapping.hash; - } } SWIFT_CC(swift) SWIFT_RUNTIME_STDLIB_API @@ -51,9 +38,7 @@ size_t swift_stdlib_NSStringHashValue(NSString *str, swift_stdlib_NSStringHashValuePointer(void *opaque, bool isASCII) { NSString __unsafe_unretained *str = (__bridge NSString __unsafe_unretained *)opaque; - AUTORELEASEPOOL { return isASCII ? str.hash : str.decomposedStringWithCanonicalMapping.hash; - } } #else From 7dc04e9d6b7743fbe2f15456f4a33993e7b95509 Mon Sep 17 00:00:00 2001 From: AZero13 Date: Fri, 5 Dec 2025 21:14:51 -0500 Subject: [PATCH 3/3] Fix formatting --- stdlib/public/stubs/SwiftNativeNSXXXBaseARC.m | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stdlib/public/stubs/SwiftNativeNSXXXBaseARC.m b/stdlib/public/stubs/SwiftNativeNSXXXBaseARC.m index 9467bd7baffbf..04ea678f66fe1 100644 --- a/stdlib/public/stubs/SwiftNativeNSXXXBaseARC.m +++ b/stdlib/public/stubs/SwiftNativeNSXXXBaseARC.m @@ -30,7 +30,7 @@ SWIFT_CC(swift) SWIFT_RUNTIME_STDLIB_API size_t swift_stdlib_NSStringHashValue(NSString *str, bool isASCII) { - return isASCII ? str.hash : str.decomposedStringWithCanonicalMapping.hash; + return isASCII ? str.hash : str.decomposedStringWithCanonicalMapping.hash; } SWIFT_CC(swift) SWIFT_RUNTIME_STDLIB_API @@ -38,7 +38,7 @@ size_t swift_stdlib_NSStringHashValue(NSString *str, swift_stdlib_NSStringHashValuePointer(void *opaque, bool isASCII) { NSString __unsafe_unretained *str = (__bridge NSString __unsafe_unretained *)opaque; - return isASCII ? str.hash : str.decomposedStringWithCanonicalMapping.hash; + return isASCII ? str.hash : str.decomposedStringWithCanonicalMapping.hash; } #else