An Annotation-Free Meta-Tracing JIT for Existing Interpreters
A meta-tracing JIT records the execution of a programming language’s interpreter and compiles the recording into machine code, so that programs run fast without a JIT compiler implemented for each language. A meta-tracing JIT, however, requires the implementer of the interpreter to add annotations to the interpreter’s source code that convey the information needed for recording and optimization. We propose an approach that obtains this information by profiling the execution of the interpreter, and thereby applies a meta-tracing JIT to existing interpreters without adding annotations to their source code. Our approach takes as input an interpreter compiled to WebAssembly. First, in prior profiling, our approach observes the sequence of values received by each branch instruction and identifies the branch instruction that dispatches bytecode instructions. Next, starting from the identified branch instruction, our approach follows data dependencies backward through the instructions that computed the received values, and identifies the instruction that fetches bytecode instructions. We profiled four language implementations, PUC-Rio Lua, CRuby, QuickJS, and CPython, by running multiple different programs on each of them for up to 23 minutes. In 51 of the 52 resulting profiles, the same instructions were identified for each language implementation. All of the identified instructions were contained in the functions that dispatch and fetch bytecode instructions in the source code. Of nine programs written in Lua, our implementation was 1.17–10.7~times faster on six than wasmtime running the same interpreter compiled to WebAssembly, and faster than the native Lua interpreter on two.