r/Compilers • u/Tricky_Football_85 • May 11 '26
Is there a JIT compiler that recompiles the compiler using JIT so it can optimise its compiling efficiency?
15
Upvotes
r/Compilers • u/Tricky_Football_85 • May 11 '26
18
u/whizzter May 11 '26
I'm pretty sure there's been some experiments with JVM's doing this.
17
u/high_throughput May 11 '26
GraalVM does this. The JIT is written in Java and it can indeed JIT itself.
14
u/tstanisl May 11 '26
I don't think that a complier is a good candidate for JITing. It solves a problem of combinatorial optimization which usually involves a lot of branching and random memory access. Both traits gain very little from JITing. Though some parts of the compiler may benefit a bit like parsers assuming that they are not IO bound.
1
u/Patzer26 May 12 '26
Isn't this just bootstrapping? What am i missing.
2
u/FloweyTheFlower420 May 11 '26
look up "meta-tracing jit"
1
u/playX281 May 11 '26
JikesRVM
1
u/Let047 May 11 '26
Its a little bit different but in your idea direction, look up futumara projections
1
u/JVApen May 11 '26
I can't say for JIT, though for native code, like GCC and Clang, they use something called bootstrapping. They basically compile twice, once with the old compiler and once with the newly built one. If you want to go a bit further, PGO and Bolt are used to fine-tune the optimizations.
1
u/fullouterjoin May 11 '26 edited May 11 '26
Take a look at the researchers behind PyPy
https://dblp.org/pid/50/2706.html
A Lightweight Method for Generating Multi-Tier JIT Compilation Virtual Machine in a Meta-Tracing Compiler Framework
1
u/JeffD000 May 11 '26
I'm glad you brought this up! It is literally the canonical example I use for my JIT compiler on my homepage. I recently changed the compile line options, so I need to update the README. Thanks!
1
u/ChiveSalad May 12 '26
yes, it makes startup times horrendous as the first jit pass is done in an interpreted language. This is approximately what julia is, and why its slow a f
1
u/augustty1 Jun 14 '26
Yes, this is meta-tracing JIT. Real world examples are Pypy, GraalVM and Truffle.
While self-recompilation sounds like a loop that would make compilation arbitrarily fast, in practice, it hits diminishing returns. Jit compilers trade compilation latency for execution speed.