On 19/06/12 20:12, John Cowan wrote:
Peter Bex scripsit:
The GC needs to be able to associate an object with its finalizers, so
there either needs to be a global list or some extra slot added to
each object. The latter takes up more memory when you don't have a lot
of finalizers (and finalizers are slow, so it's best not to generate too
many of them).
How about if finalizers are only attached to pointers? That seems to
be the principal use case, and adding a slot to a pointer (maybe only a
"finalizable tagged pointer" wouldn't be so expensive.
It would also be quite easy to attach such "finalizing objects" to
records, vectors, and the like (ensuring that that is the ONLY
reference) to get a notification of the parent object being GCed, too.
Ugh, that's not very clear.
What I'm saying is, you could create a finalizable tagged pointer that
doesn't actually point to anything, and only exists to be placed in an
otherwise unused slot of a record (for instance), such that when the
record is no longer reachable and gets GCed, the finalizable tagged
pointer is then also unreachable and gets finalized, acting as a proxy
for the otherwise-unfinalizable object. Perhaps the pointer could be
left pointing to whatever state might be needed to finalize the real
object, as the real object would be unreachable by the time the
finalizer was triggered.
ABS
--
Alaric Snell-Pym
http://www.snell-pym.org.uk/alaric/
_______________________________________________
Chicken-hackers mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/chicken-hackers