My Language Feature Requests
Christopher Wright
dhasenan at gmail.com
Sun Dec 23 07:34:07 PST 2007
Frits van Bommel wrote:
> Christopher Wright wrote:
>> While there is a fixed reference to the GC object, it is pinned. If
>> that reference is rebound to another GC object, the original object is
>> unpinned and the new one is pinned.
>>
>> How to mark these is a difficult problem. On a 64-bit machine, I'd say
>> you just use the most significant bit as a flag; you're not going to
>> use petabytes of address space.
>
> Since "fixedness" as proposed would be a compile-time property, and you
> already need metadata to find pointers to implement a moving GC, such a
> flag could be in that metadata instead of in the pointer itself. (The
> OffsetTypeInfo could say "there's a pointer at offset 8, of type Object,
> and it's fixed")
Yes, I thought of that. Currently, however, offTi isn't populated. Just
like the Interface* that's supposed to be the first element of each
interface's vtbl pointer. It would be useful if it existed, but no cheese.
> If run-time pinning is used instead (where whether the GC cell pointed
> to by a pointer is pinned is not known at compile time), it could be a
> simple (synchronized) counter that starts out at 0 for each memory cell,
> that's incremented when pinned and decremented when unpinned. The GC is
> then only allowed to move cells whose counter is 0.
You would do both. During a collection, you mark each block to see if
it's referenced, and mark it again if it's got a fixed reference. Then
you collect every section that's not referenced and optionally move the
sections that aren't marked as pinned to a more advantageous layout.
If you are proposing a compile-time garbage collector, one that
determines when to delete an object using static analysis, I will be
quite impressed if you come up with an implementation.
More information about the Digitalmars-d
mailing list