mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
runtime lib: a mechanism to set an "immutable" flag on an object for COW buffer runtime checking.
In an assert built of the library, store an extra boolean flag (isImmutable) in the object side-buffer table. This flag can be set and get by the Array implementation to sanity check the immutability status of the buffer object.
This commit is contained in:
@@ -887,6 +887,23 @@ WeakReference *swift::swift_weakTakeAssign(WeakReference *dest,
|
||||
|
||||
#ifndef NDEBUG
|
||||
|
||||
/// Returns true if the "immutable" flag is set on \p object.
|
||||
///
|
||||
/// Used for runtime consistency checking of COW buffers.
|
||||
SWIFT_RUNTIME_EXPORT
|
||||
bool _swift_isImmutableCOWBuffer(HeapObject *object) {
|
||||
return object->refCounts.isImmutableCOWBuffer();
|
||||
}
|
||||
|
||||
/// Sets the "immutable" flag on \p object to \p immutable and returns the old
|
||||
/// value of the flag.
|
||||
///
|
||||
/// Used for runtime consistency checking of COW buffers.
|
||||
SWIFT_RUNTIME_EXPORT
|
||||
bool _swift_setImmutableCOWBuffer(HeapObject *object, bool immutable) {
|
||||
return object->refCounts.setIsImmutableCOWBuffer(immutable);
|
||||
}
|
||||
|
||||
void HeapObject::dump() const {
|
||||
auto *Self = const_cast<HeapObject *>(this);
|
||||
printf("HeapObject: %p\n", Self);
|
||||
|
||||
Reference in New Issue
Block a user