[Haskell-cafe] I want to write a compiler

Ben Lippmeier Ben.Lippmeier at anu.edu.au
Sun Mar 8 05:19:31 EDT 2009


On 08/03/2009, at 12:45 PM, Austin Seipp wrote:
>
> For garbage collection, please see.
>
> "Accurate Garbage Collection in an Uncooperative Environment" -
> http://citeseer.ist.psu.edu/538613.html
>
> This strategy is currently used in Mercury as well as Ben L.'s DDC
> language; on that note, I think if you spent some time looking through
> the runtime/generated code of DDC, you can see exactly what the paper
> is talking about, because it's actually a very simple strategy for
> holding onto GC roots:
>
> http://code.haskell.org/ddc/ddc-head/runtime/

That paper explains the basic idea, but neither DDC or Mercury quite  
follow it (I asked Zoltan). The system in the paper keeps the GC roots  
in structs on the C stack, and chains the structs together as a linked  
list. The problem is that if you take a pointer to data on the C stack  
then GCC freaks out and disables a host of optimisations. I imagine  
it's worried about pointers going bad after the stack frame is popped  
and the space for the struct gets lost.

DDC keeps a shadow stack of GC roots in malloced memory. It's only a  
small difference, but lets the C compiler produce better code.

Ben.





More information about the Haskell-Cafe mailing list