Skip to content

Commit 9fb56b8

Browse files
authored
Remove autorelease workaround for x86_64 (#85877)
LLVM no longer tail-calls this on x86_64, so we do not need an autorelease pool. Remove it for i386 as well as that is no longer a target for ObjC interop builds.
1 parent 21440b3 commit 9fb56b8

File tree

1 file changed

+2
-27
lines changed

1 file changed

+2
-27
lines changed

stdlib/public/stubs/SwiftNativeNSXXXBaseARC.m

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -27,43 +27,18 @@
2727
// pool which might be scoped such that repeatedly placing objects into it
2828
// results in unbounded memory growth.
2929

30-
// On i386 the remove from autorelease pool optimization is foiled by the
31-
// decomposedStringWithCanonicalMapping implementation. Instead, we use a local
32-
// autorelease pool to prevent leaking of the temporary object into the callers
33-
// autorelease pool.
34-
//
35-
//
36-
// FIXME: Right now we force an autoreleasepool here on x86_64 where we really
37-
// do not want to do so. The reason why is that without the autoreleasepool (or
38-
// really something like a defer), we tail call
39-
// objc_retainAutoreleasedReturnValue which blocks the hand shake. Evidently
40-
// this is something that we do not want to do. See:
41-
// b79ff50f1bca97ecfd053372f5f6dc9d017398bc. Until that is resolved, just create
42-
// an autoreleasepool here on x86_64. On arm/arm64 we do not have such an issue
43-
// since we use an assembly marker instead.
44-
#if defined(__i386__) || defined(__x86_64__)
45-
#define AUTORELEASEPOOL @autoreleasepool
46-
#else
47-
// On other platforms we rely on the remove from autorelease pool optimization.
48-
#define AUTORELEASEPOOL
49-
#endif
50-
5130
SWIFT_CC(swift) SWIFT_RUNTIME_STDLIB_API
5231
size_t swift_stdlib_NSStringHashValue(NSString *str,
5332
bool isASCII) {
54-
AUTORELEASEPOOL {
55-
return isASCII ? str.hash : str.decomposedStringWithCanonicalMapping.hash;
56-
}
33+
return isASCII ? str.hash : str.decomposedStringWithCanonicalMapping.hash;
5734
}
5835

5936
SWIFT_CC(swift) SWIFT_RUNTIME_STDLIB_API
6037
size_t
6138
swift_stdlib_NSStringHashValuePointer(void *opaque, bool isASCII) {
6239
NSString __unsafe_unretained *str =
6340
(__bridge NSString __unsafe_unretained *)opaque;
64-
AUTORELEASEPOOL {
65-
return isASCII ? str.hash : str.decomposedStringWithCanonicalMapping.hash;
66-
}
41+
return isASCII ? str.hash : str.decomposedStringWithCanonicalMapping.hash;
6742
}
6843

6944
#else

0 commit comments

Comments
 (0)