3 ms·
If you're interested in trace based compilation then the origins go much further back than Andreas Gal's work and into research in the 1970s into compilers for
by jashmatthews 6y ago
If you're interested in trace based compilation then the origins go much further back than Andreas Gal's work and into research in the 1970s into compilers for VLIW architectures [1]
It's not the dispatch to the next instruction that's expensive in most virtual machines. It's the sheer complexity of each instruction as it maps to the underlying assembly instructions [2]
Just getting rid of the dispatch loop doesn't help much and in many cases the increased pressure on the instruction cache makes performance worse.
I'm trying to help with this problem at the moment for the CRuby JIT compiler.
SpiderMonkey, LuaJIT and Dalvik record the trace in the bytecode interpreter. There's no generating baseline JITed code with additional trace recording stuff.
What PyPy does is quite different. PyPy is a Python virtual machine written in a language called RPython and has an interpreter and trace compiler for RPython.
It adds a whole layer of indirection compared to traditional trace compilers which makes it harder to do some optimizations but makes it easier to implement some more basic parts of trace recording and compilation and crucially, makes it somewhat re-usable for different languages.
[1] https://archive.org/details/optimizationofho00fish/mode/2up https://archive.org/details/optimizationofho00fish/mode/2up
[2] https://www.sciencedirect.com/science/article/pii/S1571066109004617 https://www.sciencedirect.com/science/article/pii/S157106610...