logoalt Hacker News

beholdotoday at 2:02 AM2 repliesview on HN

The coolest interpreter technique I saw was one that put instruction bodies in static functions which the "compiler" main loop would memcpy the body of the function out to straight-line code that would be executed from memory - a poor man's jit. All instruction functions had the same args and gcc would emit position independent code with the same predictable register calling convention. Brittle as hell, sure, but great compilation speed with low run-time overhead. It was able to run interpreted code at 1/5th of compiled code speed, compared to 1/10th speed for typical highly optimized computed goto loop interpreters.

I can't find a link, but if anyone recalls or wrote such an jit interpreter, please post.


Replies

scheme271today at 2:56 AM

Sounds like a copy and patch JIT ( https://en.wikipedia.org/wiki/Copy-and-patch ). The python interpreter was experimenting with this and it provides a decent speedup.

show 1 reply
kijikitoday at 4:17 AM

qemu used to use that technique, but as you note, it was pretty brittle. They switched to the more traditional TCG backend.