Skip to content

Commit 292273a

Browse files
authored
Merge pull request swiftlang#819 from al45tair/eng/PR-123945799
Remove objc_retainAutoreleasedReturnValue workaround.
2 parents 3a566c9 + daa2345 commit 292273a

File tree

2 files changed

+0
-50
lines changed

2 files changed

+0
-50
lines changed

src/swift/CMakeLists.txt

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,3 @@
1-
2-
# NOTE(compnerd) Today regardless of whether or not ObjC interop is enabled,
3-
# swift will use an autoreleased return value convention for certain CF
4-
# functions (including some that are used/related to dispatch). This means that
5-
# the swift compiler in callers to such functions will call the function, and
6-
# then pass the result of the function to objc_retainAutoreleasedReturnValue. In
7-
# a context where we have ObjC interop disabled, we do not have access to the
8-
# objc runtime so an implementation of objc_retainAutoreleasedReturnValue is not
9-
# available. To work around this, we provide a shim for
10-
# objc_retainAutoreleasedReturnValue in DispatchStubs.cc that just calls retain
11-
# on the object. Once we fix the swift compiler to switch to a different model
12-
# for handling these arguments with objc-interop disabled these shims can be
13-
# eliminated.
141
add_library(DispatchStubs STATIC
152
DispatchStubs.cc)
163
target_include_directories(DispatchStubs PRIVATE

src/swift/DispatchStubs.cc

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -56,40 +56,3 @@ static void _dispatch_overlay_constructor() {
5656
}
5757

5858
#endif /* USE_OBJC */
59-
60-
#if !USE_OBJC
61-
DISPATCH_RUNTIME_STDLIB_INTERFACE
62-
extern "C" void * objc_retainAutoreleasedReturnValue(void *obj);
63-
#endif
64-
65-
#if !USE_OBJC
66-
67-
// For CF functions with 'Get' semantics, the compiler currently assumes that
68-
// the result is autoreleased and must be retained. It does so on all platforms
69-
// by emitting a call to objc_retainAutoreleasedReturnValue. On Darwin, this is
70-
// implemented by the ObjC runtime. On non-ObjC platforms, there is no runtime,
71-
// and therefore we have to stub it out here ourselves. The compiler will
72-
// eventually call swift_release to balance the retain below. This is a
73-
// workaround until the compiler no longer emits this callout on non-ObjC
74-
// platforms.
75-
extern "C"
76-
#if defined(_WIN32)
77-
__declspec(dllimport)
78-
#endif
79-
void swift_retain(void *);
80-
81-
DISPATCH_RUNTIME_STDLIB_INTERFACE
82-
extern "C" void * objc_retainAutoreleasedReturnValue(void *obj) {
83-
if (obj) {
84-
swift_retain(obj);
85-
return obj;
86-
}
87-
else return NULL;
88-
}
89-
90-
#if defined(_WIN32)
91-
extern "C" void *(*__imp_objc_retainAutoreleasedReturnValue)(void *) =
92-
&objc_retainAutoreleasedReturnValue;
93-
#endif
94-
95-
#endif // !USE_OBJC

0 commit comments

Comments
 (0)