draft proposal for ref counting in D
deadalnix
deadalnix at gmail.com
Sat Oct 12 11:31:26 PDT 2013
On Saturday, 12 October 2013 at 06:16:24 UTC, Rainer Schuetze
wrote:
> in pseudo-assembly missing null-checks:
>
> Thread1 (R = P) Thread2 (S = R)
>
> mov ecx,[R]
> ; thread suspended
You need an sequentially consistent write. You also need to
increment the refcount BEFORE ! This codegen is incorrect.
> mov eax,[P]
> inc [eax].refcnt
Same here.
> mov ebx,[R]
> mov [R],eax
> dec [ebx].refcnt ; refcnt of O now 0
> jnz done
> call delete_ebx
> ; thread resumed
> inc [ecx].refcnt
> done:
>
> The increment on [ecx].refcnt modifies garbage.
This can be done atomically (even with eventually consistent
increment, don't need full sequential consistency here, you still
need fully sequential consistent decrement).
More information about the Digitalmars-d
mailing list