Tiny D suitable for embedded JIT

Dibyendu Majumdar mobile at majumdar.org.uk
Wed May 23 20:26:29 UTC 2018


On Wednesday, 23 May 2018 at 20:08:53 UTC, Jonathan Marler wrote:
> I've recently been looking into how QEMU works and it uses 
> something called TCG (Tiny Code Generator).  QEMU works by 
> taking code from another platform/cpu and translates it to TCG, 
> which then gets "jitted" to the instructions for the host.
>
> From what I understand, TCG is fairly small.  I think it aims 
> to be simple rather than highly optimized, unlike LLVM which 
> allows more complexity for the sake of performance.
>
> TCG: 
> https://git.qemu.org/?p=qemu.git;a=blob_plain;f=tcg/README;hb=HEAD

Thank you for pointing me to this - I wasn't aware of it. I 
already use something similar - a little more complex product 
that supports floating points too - NanoJIT. However to my 
knowledge most of these products do register allocation locally 
within a basic block - and spill registers when jumping across 
blocks. This basically results in unacceptable performance in any 
code that has branching or loops. I could enhance NanoJIT but its 
written in a way that makes changes difficult (i.e. too many low 
level optimizations in the code).

It seems there is a lack of something in between LLVM and these 
implementations - either you get all powerful optimizations or 
you get very little ... my intention is to create something that 
is small but also has at least some form of global (actually per 
function) register allocator.

I thought of hacking DMD as it favours speed of compilation and 
simplicity - but what I am not sure about is how easy / difficult 
it would be to modify DMD (mostly remove stuff).

Regards
Dibyendu



More information about the Digitalmars-d mailing list