inside the GHC code generator
Ben Rudiak-Gould
Benjamin.Rudiak-Gould at cl.cam.ac.uk
Fri Feb 24 16:13:32 EST 2006
Simon Peyton-Jones wrote:
> | [...] put a static table in the executable with
> | information about register and stack usage indexed by procedure return
> | point, and use that to unwind the stack and find roots.
>
> Every accurate garbage collector (including GHC's) uses a technique like
> this, but the solution is invariably tightly-coupled to the garbage
> collector, compiler and run-time system.
Okay, I don't know what I was thinking when I wrote that no languages that
compile via C use compacting collectors, since obviously lots of them do.
But they do it by using various hacks to force local heap pointers into
locations where the GC can find them. Most of this effort is wasted, because
the local variables disappear before the GC runs. What I'm talking about is
idiomatic C code which manipulates heap pointers like any other object, and
which can be optimized as usual (e.g. holding heap pointers in callee-saved
registers across function calls) without causing GC problems. There's no
reason in principle that this couldn't be done.
-- Ben
More information about the Glasgow-haskell-users
mailing list