File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -110,8 +110,8 @@ public func swift_setDeallocating(object: UnsafeMutablePointer<HeapObject>) {
110
110
111
111
@_silgen_name ( " swift_isUniquelyReferenced_nonNull_native " )
112
112
public func swift_isUniquelyReferenced_nonNull_native( object: UnsafeMutablePointer < HeapObject > ) -> Bool {
113
- // TODO/FIXME: Refcounting is not thread-safe, the following only works in single-threaded environments.
114
- return object . pointee . refcount == 1
113
+ let refcount = refcountPointer ( for : object )
114
+ return loadAcquire ( refcount) == 1
115
115
}
116
116
117
117
@_silgen_name ( " swift_retain " )
@@ -175,6 +175,10 @@ fileprivate func loadRelaxed(_ refcount: UnsafeMutablePointer<Int>) -> Int {
175
175
Int ( Builtin . atomicload_monotonic_Word ( refcount. _rawValue) )
176
176
}
177
177
178
+ fileprivate func loadAcquire( _ refcount: UnsafeMutablePointer < Int > ) -> Int {
179
+ Int ( Builtin . atomicload_acquire_Word ( refcount. _rawValue) )
180
+ }
181
+
178
182
fileprivate func subFetchAcquireRelease( _ refcount: UnsafeMutablePointer < Int > , n: Int ) -> Int {
179
183
let oldValue = Int ( Builtin . atomicrmw_sub_acqrel_Word ( refcount. _rawValue, n. _builtinWordValue) )
180
184
return oldValue - n
You can’t perform that action at this time.
0 commit comments