Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I was curious, so I looked into it.

- TCG = Tiny Code Generator; QEMU's framework for emulating CPU architectures via translating instructions[1]

- TCI = Tiny Code Interpreter? The source code says: "(TCG with bytecode interpreter, experimental and slow)"[2]

- TCTI = Tiny Code Threaded-Dispatch Interpreter? The source code says: "TCTI (TCG with threaded-dispatch bytecode interpreter, experimental and slow; but faster than TCI)"[3]

So, apparently, it's some kind of optimized interpreter. Exactly what it means by "threaded-dispatch" is unclear, there's some surprisingly tricky looking things going on[4]. Does threaded refer to OS threading, or does it maybe mean that it's doing something a bit more like a cached interpreter? I wonder if it's even more clever than that.

[1]: https://wiki.qemu.org/Documentation/TCG

[2]: https://github.com/tctiSH/qemu/blob/1e4d72b004c26724cd049798...

[3]: https://github.com/tctiSH/qemu/blob/1e4d72b004c26724cd049798...

[4]: https://github.com/tctiSH/qemu/commit/1e4d72b004c26724cd0497...



Threaded code is a way to make an interpreter run slightly faster without requiring a JIT, which iOS bans. https://en.wikipedia.org/wiki/Threaded_code


Threaded interpreters are a kind of interpreter that runs code by having an array of jump addresses in a row representing the ops to interpret so that you can amortize out the decode step.

It works kind of like ROP/JOP gadgets.


Ah, I either didn't know about the term threaded code or forgot about it. Thanks for the pointers. (Replying to you but also the sibling comment since both were posted around the same time.)

At first I was thinking of cached interpreters as often seen in video game console emulators, but actually, this reminds me more of the "virtual machines" used in executable packers/obfuscators like VMProtect and Themida.


> but actually, this reminds me more of the "virtual machines" used in executable packers/obfuscators like VMProtect and Themida.

Yeah, totally. Only changing the stack at runtime is helpful for avoiding the ire of anti-virus.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: