Keep the Runtime, Derive the JIT Compiler: Runtime-Preserving Meta-Tracing with Two Coexisting Garbage Collectors
Abstract
Meta-tracing frameworks derive a tracing JIT compiler from an interpreter, but implementations built with them commonly reimplement the object model and core library of an existing runtime as well. Meta-tracing constrains only the interpreter, not the values it manipulates. In runtime-preserving meta-tracing, a framework-written interpreter executes a production runtime’s bytecode over that runtime’s own values and delegates what it does not implement, so the runtime stays authoritative for object identity, method state and the core library. We state the host interface such an embedding needs and the invariants it must maintain, independently of the host language. The two collectors cannot see references stored in each other’s heaps. We keep host objects under the host collector and interpreter frames under the framework’s. During host marking, callbacks report the host values held by interpreter frames, compiled frames and suspended coroutines, and retained values stay at fixed addresses. Under stated coverage and collection premises, a model of the two heaps shows that host marking preserves every host object either executor can reach and relocates none that the framework reads. Exact marking additionally needs exact roots, exact reports and exact-cycle marking. Our realisation, RPyYARV, uses RPython and CRuby 4.0, with a host patch of 448 added lines and no machine- code backend of its own. It passes 99.1% of ruby/spec’s language examples, 97.9% of its core examples and all 1,568 C-API examples that CRuby passes. Its output matches CRuby’s under collection and compaction stress. Compaction is also where coverage violations surface, since coverage can be argued but testing can only falsify it. It runs 87 benchmarks, including Rails, RuboCop and HexaPDF unmodified, at 0.373 of CRuby’s time, 0.970 of YJIT’s and 0.610 of ZJIT’s in the geometric mean, at a tenth to a sixteenth of TruffleRuby’s memory.
// Source
Authors: Yusuke Izawa
Institutions: Heinrich Heine University Düsseldorf, Tokyo Metropolitan University