mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[embedded] Add a more detailed explaining comment to swift_release_n_
This commit is contained in:
@@ -292,7 +292,14 @@ func swift_release_n_(object: UnsafeMutablePointer<HeapObject>?, n: UInt32) {
|
||||
let resultingRefcount = subFetchAcquireRelease(refcount, n: Int(n)) & HeapObject.refcountMask
|
||||
if resultingRefcount == 0 {
|
||||
// Set the refcount to immortalRefCount before calling the object destroyer
|
||||
// to prevent future retains/releases from having any effect.
|
||||
// to prevent future retains/releases from having any effect. Unlike the
|
||||
// full Swift runtime, we don't track the refcount inside deinit, so we
|
||||
// won't be able to detect escapes or over-releases of `self` in deinit. We
|
||||
// might want to reconsider that in the future.
|
||||
//
|
||||
// There can only be one thread with a reference at this point (because
|
||||
// we're releasing the last existing reference), so a relaxed store is
|
||||
// enough.
|
||||
storeRelaxed(refcount, newValue: HeapObject.immortalRefCount)
|
||||
|
||||
_swift_embedded_invoke_heap_object_destroy(object)
|
||||
|
||||
Reference in New Issue
Block a user