RawRefCount translation in Mu back-end
PyPy supports CPython extensions through linking
PyObjects with RPython objects. This is done in the
rawrefcount RPython library (
rpython/rlib/rawrefcount). Calls to functions in
rawrefcount in the RPython source code are translated into
gc_rawrefcount_* operations in the CFG, and are then handled by the back-end.
The Incremental Minimark GC implements these operations in
rpython/memory/gc/incminimark.py. As part of the GC code it is written in RPython and compiled. It involves pinning the object, converting the address to an integer and stored in the header of the allocated
A make-shift solution in
ll2mu might be possible, but it will be quite messy.
A perhaps better solution would be to write a Mu GC transformer and a GC class that handles the translation of GC operations like this.
The translation of
gc_identityhash operation can also benefit from this approach.
- Investigate more on how the existing GC and GC transformers work, and evaluate how much work needs to be done;
- Possibly write a Mu GC and GC transformer that handles things like these;
- What other things can be benefited from having these two classes?