[D-runtime] Precise garbage collection

Rainer Schuetze r.sagitario at gmx.de
Wed Aug 7 21:54:35 PDT 2013


On 08.08.2013 03:05, Michel Fortin wrote:
> Le 7-août-2013 à 16:42, Rainer Schuetze<r.sagitario at gmx.de>  a écrit
> :
>
>>> I'm also hoping for a comment on the ambiguity of TypeInfo_Class.
>>> If implementing TypeInfo_Reference, what would
>>> TypeInfo_Reference.toString return? "C ref" as in Michel Fortin's
>>> implementation of tail const references?;-)
> Funny problem. But there's no ambiguity really because you can't
> create using "new" a memory block that'll only contain a reference to
> an object. You can thus be sure that if the root type of a memory
> block is a TypeInfo_Class it truly is an object of that class; and if
> a*variable*  has TypeInfo_Class then it's a reference.

That's what my code currently assumes. But that doesn't work if 
std.emplace is used to create a class instance into the memory of a 
struct instance. How can you distinguish that the memory is used as a 
reference or an instance of that class.

The same happens with classes generated into the data segment by the 
compiler, e.g. TypeInfo_Class objects. These currently don't have 
mutable references that could point into GC allocated memory, but a 
recent change also allows creating user defined class instances to be 
built into the data segment.


More information about the D-runtime mailing list