Skip to content

Commit cbb3f11

Browse files
committed
[sil] Add clarity to how load_weak [take] and store_weak effect an objects weak ref count.
1 parent 532c006 commit cbb3f11

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

docs/SIL.rst

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2827,6 +2827,12 @@ which must be an initialized weak reference. The result is value of type
28272827
``$Optional<T>``, except that it is ``null`` if the heap object has begun
28282828
deallocation.
28292829

2830+
If ``[take]`` is specified then the underlying weak reference is invalidated
2831+
implying that the weak reference count of the loaded value is decremented. If
2832+
``[take]`` is not specified then the underlying weak reference count is not
2833+
effected by this operation (i.e. it is a +0 weak ref count operation). In either
2834+
case, the strong reference count will be incremented.
2835+
28302836
This operation must be atomic with respect to the final ``strong_release`` on
28312837
the operand heap object. It need not be atomic with respect to ``store_weak``
28322838
operations on the same address.
@@ -2845,7 +2851,9 @@ Initializes or reassigns a weak reference. The operand may be ``nil``.
28452851

28462852
If ``[initialization]`` is given, the weak reference must currently either be
28472853
uninitialized or destroyed. If it is not given, the weak reference must
2848-
currently be initialized.
2854+
currently be initialized and after the evaluation the value that was originally
2855+
referenced by the weak reference will have its weak reference count decremented
2856+
by 1.
28492857

28502858
This operation must be atomic with respect to the final ``strong_release`` on
28512859
the operand (source) heap object. It need not be atomic with respect to

0 commit comments

Comments
 (0)