[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Starting a JIT backend for Ravi yet again
- From: Dibyendu Majumdar <mobile@...>
- Date: Thu, 28 Sep 2017 22:37:49 +0100
Hi,
On 10 September 2017 at 21:45, Dibyendu Majumdar <mobile@majumdar.org.uk> wrote:
> After implementing JIT backends using LLVM and libgccjit, now it is
> time to try again!
>
> I have been trying to figure out a way to create a small JIT backend
> that trades size for performance. Additionally, writing the backend in
> IR is tedious and errorprone, so it would be better if the backend
> could be written in a language such as C.
>
> So now I am doing just that. The new backend is being written to
> generate C code, which gets translated to machine code at runtime
> using another project of mine - dmrC. Now dmrC supports two different
> JIT engines - LLVM and NanoJIT. The support for NanoJIT is recent, and
> not yet well tested. But what better way to test it than to use it for
> Ravi?
>
Unfortunately I find that the backend I had in mind - NanoJIT - is too
simple, and the code it generates performs no better than the
interpreter. So unless I can write an efficient backend for C (which
is extremely doubtful), I am stuck with LLVM for now.
However, looking at the generated C code made me think ... perhaps it
is worth trying to write a hand-coded JIT compiler. The thing about
the generated code is that there is not a lot of stack usage - hence
register allocation is perhaps somewhat easier (i.e. mostly static
allocation, with some dynamic allocation). So just for fun and as a
learning exercise, I am planning to start a new JIT where I will use
the excellent 'dynasm' product from Mike Pall. Only X86-64 to start
with. If anyone wants to join in this adventure, you are welcome.
Regards
Dibyendu