Enhance Slang with Separate Compilation
The Pharo VM is written in Slang, a Smalltalk subset that is transpiled to C by the CCodeGenerator. Currently, the entire VM is generated into a handful of large monolithic C files where code from completely different subsystems the garbage collector, the interpreter, and the JIT compiler are all merged together into a single output stream. This makes the generated code difficult to read, navigate, and maintain, and means that changing a single method triggers recompilation of the entire VM rather than just the relevant module. This project introduces separate compilation to Slang by refactoring CCodeGenerator to route generated C code into multiple files, one per class hierarchy, while correctly tracking and emitting #include dependencies between them. The approach involves extending CCodeGenerator to maintain per-hierarchy output streams, implementing a dependency graph builder to determine which hierarchies reference which others, generating corresponding header files with the necessary forward declarations and prototypes, and updating the CMake build system to automatically discover the new files. The deliverables are: a working dependency graph builder for TMethod objects, a refactored CCodeGenerator supporting multiple output streams, successful extraction of the SpurMemoryManager garbage collector hierarchy into its own standalone C file with correct includes as a proof of concept, header file generation for all separated modules, extension of separate compilation to the Cogit JIT compiler and remaining hierarchies, and an updated CMake build configuration. All existing VM tests will pass throughout, ensuring no regressions in the generated code.
Project details
Technologies
Not listed in the archive