ysbaddaden / gc

A garbage collector for Crystal
95 stars 6 forks source link

Implement missing GC methods to work properly with Crystal 1.0+ #18

Closed ggiraldez closed 2 years ago

ggiraldez commented 2 years ago

Fixes to work properly with Crystal 1.0+

Tested on Linux with current Crystal master (1.5.0-dev)

At some point during the development of Crystal, the responsibility of pushing the GC roots was removed from fiber.cr into the default GC implementation bohem.cr. Thus this code was missing when compiling with -Dgc_none. Add a before_collect callback to push the fiber stacks as GC roots and adapt to changes to the methods to return the stack bottom of the current thread.

With these changes it compiles and runs the specs, the sample HTTP server included in the samples directory, and the Crystal compiler itself.

Pending:

Also, I'm not sure the guard for fiber.running? is correct for this GC, since by default the implementation will not consider the current stack as a source of roots for the mark phase. It's probably not a problem because when the collector runs the only fiber running is the collector fiber itself, which does not make any dynamic allocation.