Rendered at 02:40:52 GMT+0000 (Coordinated Universal Time) with Cloudflare Workers.
beholdo 39 minutes ago [-]
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.
dmitrygr 3 hours ago [-]
At the end it is not emulation but static recompilation (which is, arguably, cooler)
throwaway27448 2 hours ago [-]
How do you differentiate the two? What is the benefit of such a distinction? Why not use eg threaded emulation vs recompiled emulation?
drunken_thor 2 hours ago [-]
In my limited understanding, static recompiling is like JIT transpilation from one arch to another where emulation runs each instruction calling behaviour depending on the instruction. As for tradeoffs my knowledge is not wide enough to declare anything certain.
throwaway27448 1 hours ago [-]
What is the distinction in your mind? Can recompiling not call each instruction? Can threaded interpretation not perform optimization?
dmitrygr 2 hours ago [-]
Emulation visits instructions as they are executed. Static recompilation will (at translation time) visit instructions that can be discovered, even if they never run.
eg:
if (rand64() == 0x123456789abcdef0ull)
baz = bar;
an emulator will likely never visit that assignment. A static recompiler will translate it.
throwaway27448 2 hours ago [-]
Hm. What is the utility of this distinction?
Anyway, qemu certainly seems like it would fall under your definition of "emulator" despite obviously dynamically recompiling.
dmitrygr 1 hours ago [-]
which is why i said "static recompiler" and not just "recompiler"
distinction is that an emulator is much simpler, while a static recompiler is a lot more work and thus ~30% more cool
throwaway27448 1 hours ago [-]
Ah. I admit I've only ever made dynamic recompilers
I can't find a link, but if anyone recalls or wrote such an jit interpreter, please post.
eg:
an emulator will likely never visit that assignment. A static recompiler will translate it.Anyway, qemu certainly seems like it would fall under your definition of "emulator" despite obviously dynamically recompiling.
distinction is that an emulator is much simpler, while a static recompiler is a lot more work and thus ~30% more cool