[D-runtime] Precise garbage collection

Rainer Schuetze r.sagitario at gmx.de
Mon Jun 24 11:04:21 PDT 2013


On 24.06.2013 16:40, Steven Schveighoffer wrote:
>
> Here is a possibility for rectifying: any time you share immutable
> data by reference, the compiler generates a call to some
> 'makeImmutableArrayShared' function with the pointer, and that
> removes the block's APPENDABLE bit (if part of the GC).  That would
> make any immutable shared arrays truly immutable, and avoid this
> problem.
>
> Thoughts?  Is it possible to intercept the moment immutable data
> becomes shared?

I think you can make the length update lock- and race-free with a single 
CAS operation on the length, that pretty much does what is currently 
done in __setArrayAllocLength. You don't even have to care for problems 
like ABA, as the size always increases.

The cost of adding this to the non-shared code path aswell (or better 
not making the distinction at all) is propably more than offset by 
removing the tests for sharedness.




More information about the D-runtime mailing list