swift
swift copied to clipboard
[6.0][Runtime] Avoid dlsym of objc_isUniquelyReferenced.
Cherry-pick https://github.com/apple/swift/pull/73285 to release/6.0
.
We attempted to use the declaration if it exists, and fall back to dlsym. This didn't actually work and we always call dlsym. Include the right header (when available) and add a weak check to the direct call.
rdar://127116080
Explanation: We want to directly reference objc_isUniquelyReferenced
when it's available in the SDK, and look it up with dlsym
when it isn't. The previous attempt to do that didn't quite work, and always used dlsym
, which imposes a performance penalty on first use..
Original PR: https://github.com/apple/swift/pull/73285
Reviewed by: @Catfish-Man
Risk: Low. We make the same call, but in the normal way by referencing it from a header, instead of looking it up with dlsym
.
Resolves: rdar://127116080
Tests: Many existing tests exercise this code.
@swift-ci please test