Michal Wallace wrote:
It seems that instead of looking at the *count*
of references, the DOD system actually walks
through the graph of references. So it seems
you could fake refcounting just by adding references and removing
pointers from somewhere in the tree that gets walked.
Yes, as Nick said, using the DOD register opcodes/API is an albeit slow
equivalent for the Py_{INC,DEC}REF() macros.
So: Py_INCREF(x) could be rewritten to (for example)
append a reference to x in a parrot array, and Py_DECREF(x) would pop it
off the array.
Actually its a hash with the PMC's address being the key and the value
is the reference count.
Am I on the right track here? I'm sure this is
a very naive and inefficient implementation, but
I don't see why it wouldn't work. If it would work,
is there a better way?
Not really, except the compiler can determine that the object is live
anyway, because it's used elesewhere too.
Also, my understanding is that parrot uses only
a Mark and Sweep system. Is that correct? pdd09
describes the three general methods, but doesn't
say which one(s) parrot actually usess. memory_internals.html
seems to imply the mark and sweep system only...
Or does parrot do all three?
Parrot has currently a Mark & Sweep GC for PObjs (PMCs, Strings,...) -
the DOD in the docs and a Mark & Copy collector for string and buffer
memory (the GC in the docs). The latter depends on the mark phase of the
Mark & Sweep collector.
But the implementation is likely to change.
- Michal
leo