JIT binary translation using libgccjit?
Kaz Nishimura
kazssym@vx68k.org
Thu Jan 1 00:00:00 GMT 2015
Since "guest" binary code can jump into another function (or
subroutine) without a return due to compiler optimizations, I must
synthesize a "function" from the sequence of instructions without any
hint of program structure. As I am looking for a portable JIT code
generator, asmjit is not an option now.
I also want redundant code elimination as the condition code can
easily be overridden by the next instruction. If such condition code
computation could be automatically eliminated, translation would be
much easier, I expect. I felt libjit was the closest to what I
wanted, but is still searching for an alternative.
On Tue, Oct 20, 2015 at 1:48 PM Basile Starynkevitch
<basile@starynkevitch.net> wrote:
>
> 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