4 ms·
It makes writing a JIT so pleasant that I meant to write an article walking through the process of building a simple JIT. Please do, if you have the time. DynA
by ssp 15y ago
It makes writing a JIT so pleasant that I meant to write an article walking through the process of building a simple JIT.
Please do, if you have the time. DynASM really is a stroke of genius.
The way it works is that the JIT contains bits of pre-generated machine code, and then a little bit of bytecode stitches these bits together and emits them. This means the actual runtime piece of the JIT doesn't need to know all the wacky details of x86 instruction encoding. All that is done in a preprocessor written in Lua.
I never got around to finding out how to do dynamic register allocation though. It seemed to me that there was no way to parameterize the pre-generated machine code, but presumably I'm missing something.