Currently, the code base, especially gc.c, is littered with ad-hoc #ifdef MMTK blocks. While it works, it is better if we can isolate MMTk-related functions and data structures into a dedicated source file, such as mmtk.c.
There are some difficulties doing so.
- Some functions and macros can only be accessed from
gc.c. They are related to object layouts, marking, sweeping and so on. gc.c has been the only source file related to GC in the Ruby code base. This may explain why there has never been a need to expose any GC implementation details to other files.
- There isn't a "VM-GC interface" that makes GC pluggable. In comparison, OpenJDK 10 did a major refactoring on the GC code, and it is now able to put every GC algorithms in a separate directory. This refactoring is also key to making it possible to make MMTk one of its GC provider. See https://openjdk.org/jeps/304
Isolating MMTk-related code is one small step towards making a well-defined VM-GC interface for Ruby, because the places that need to be changed indicates the difference between GC implementations as well as places where the GC is too tightly coupled with the VM.
Currently, the code base, especially
gc.c, is littered with ad-hoc#ifdef MMTKblocks. While it works, it is better if we can isolate MMTk-related functions and data structures into a dedicated source file, such asmmtk.c.There are some difficulties doing so.
gc.c. They are related to object layouts, marking, sweeping and so on.gc.chas been the only source file related to GC in the Ruby code base. This may explain why there has never been a need to expose any GC implementation details to other files.gc.cis large, too, having about 16000 lines of code. Although it is much better than the 35000+ lines of code ingc.cppin .NET core (See Discussion on reorganizing gc.cpp dotnet/runtime#4024 and the avatar of https://github.com/Maoni0), it is still very hard to maintain.Isolating MMTk-related code is one small step towards making a well-defined VM-GC interface for Ruby, because the places that need to be changed indicates the difference between GC implementations as well as places where the GC is too tightly coupled with the VM.