mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
runtime: Fix overflow of swift_unownedRetain reference counts
On 32bit platforms there are 7 bits reserved for the unowned retain count. This makes overflow a likely scenario. Implement overflow into the side table. rdar://33495003
This commit is contained in:
@@ -143,6 +143,22 @@ HeapObjectSideTableEntry* RefCounts<InlineRefCountBits>::formWeakReference()
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
template <typename RefCountBits>
|
||||
void RefCounts<RefCountBits>::incrementUnownedSlow(uint32_t n) {
|
||||
auto side = allocateSideTable();
|
||||
if (side)
|
||||
return side->incrementUnowned(n);
|
||||
// Overflow but side table allocation failed.
|
||||
swift_abortUnownedRetainOverflow();
|
||||
}
|
||||
|
||||
template void RefCounts<InlineRefCountBits>::incrementUnownedSlow(uint32_t n);
|
||||
template <>
|
||||
void RefCounts<SideTableRefCountBits>::incrementUnownedSlow(uint32_t n) {
|
||||
// Overflow from side table to a new side table?!
|
||||
swift_abortUnownedRetainOverflow();
|
||||
}
|
||||
|
||||
// namespace swift
|
||||
} // namespace swift
|
||||
|
||||
|
||||
Reference in New Issue
Block a user