Implementing Alternative Garbage Collector

Jacob Carlborg via Digitalmars-d digitalmars-d at puremagic.com
Wed Sep 2 11:25:08 PDT 2015


c
On 2015-09-02 18:09, Brandon Ragland wrote:
> This is just a figurative idea, perhaps for my own amusement...
>
> I've browsed the D runtime GC source code for the last few days and I'm
> still undecided on what the actual method of "replacing" the existing GC
> would be.
>
> Say for example, I decided to tinker and create my own GC (disregard the
> fact that it'd be slower / faster, this is for learning purposes only).
>
> Is there a way to "insert" a new GC implementation, and what is the
> actual interface the GC is using to connect to the core runtime of D?
>
> I see several GC related structs, etc. kind of spit everywhere, and
> determining which one is the actual core _interface_ is seeming more
> difficult than I thought.
>
>
> Any hints, or pointing to the correct direction would be very helpful.
>
>  From the looks of it, it doesn't seem obvious.

There's a minimal example of a GC in the druntime source code [1]. For 
actually replacing the current one with your custom, I think the easiest 
would be to just implement the necessary functions in your application. 
They will take precedence over the ones in druntime when linking.

[1] 
https://github.com/D-Programming-Language/druntime/blob/master/src/gcstub/gc.d

-- 
/Jacob Carlborg


More information about the Digitalmars-d mailing list