JIT binary translation using libgccjit?
Basile Starynkevitch
basile@starynkevitch.net
Thu Jan 1 00:00:00 GMT 2015
On 10/20/2015 01:08 AM, Kaz Nishimura wrote:
> I am looking for a "light-weight" (that is not much slower than direct
> instruction emulation) code generator. If libgccjit is currently
> invokes external tools to generate "host" code, I feel it is too heavy
> for my plan. Because binary code has no strict function structure, I
> guess it will be tricky to translate "guest" code by a
> function-oriented JIT code generator.
Yes, GCCJIT requires to have functions.
If you cannot afford functions (like C have them, and most ELF files also)
then you cannot follow the common existing ABI. And you need
a target-specific JIT library. For x86-64 consider asmjit.
https://github.com/kobalicek/asmjit
Notice also that without functions, you probably won't be able to get
optimized code. Hence
to get a little bit of efficiency, you'll need to somehow deal yourself
with things like register allocation and instruction scheduling. At the
very least, you want to avoid emitting the store of a register into some
call stack slot followed by the reload of the same register from the
same slot (like e.g. TinyCC is doing).
Cheers
--
Basile STARYNKEVITCH http://starynkevitch.net/Basile/
email: basile<at>starynkevitch<dot>net mobile: +33 6 8501 2359
8, rue de la Faiencerie, 92340 Bourg La Reine, France
*** opinions {are only mine, sont seulement les miennes} ***
More information about the Jit
mailing list