[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: GCC JIT vs others JIT ....



2013/10/22 Basile Starynkevitch <basile@starynkevitch.net>:
> Hello David Malcom and all,
>
> I am trying to understand what are the conceptual differences between
> GCC JIT (when it will be mature enough) and other JIT libraries like GNU
> lightning http://www.gnu.org/software/lightning/ or LLVM
> http://llvm.org/ or GNU libjit http://www.gnu.org/software/libjit/ from
> the point of view of the developer using the JIT library.
>
> GNU lightning is probably much lower level than GCC JIT. It probably has
> the advantage of generating quickly rather slow machine code. It mostly
> gives a small set of register like variables.

  GNU lightning does not use abstract "values", that may be either a
register or an immediate, it is required to explicitly state if the argument
is a register or an immediate, e.g. jit_addr(JIT_R0, JIT_R1, JIT_R2)
and jit_addi(JIT_R0, JIT_R1, 2). When using immediates, they are
always the last argument.

  GNU lightning major limitations are:
o Can call varargs but does not create varargs jit functions
o No dynamic alloca
o No aggregate arguments/return by value

  The major advantages are:
o Self contained, but binutils support is advised otherwise without
  disassembly, debugging may be quite difficult.
o Tailored for operations that need to know if there is overflow/carry
  and have the values ready (carry/borrow only need to know about,
  but multiplication high word and division remainder are quite useful).

  For starters, I would suggest looking at lightning's check/*.tst files,
for an overview of how to generate code. For example, bp.tst for
the classic recursive Fibonacci and fib.tst for the interactive one.
Other tests may be complex due to using the C preprocessor to
generate complex macros to brute force test all/most register/value
combinations.

  A more complex, still WIP, use case example of lightning is
https://github.com/pcpa/owl (lib/oemit*c files are the lightning
interfaces)

  Well, enough GNU lightning advertising :-)

> LLVM probably is the equivalent competitor, since both GCC JIT and LLVM
> are derived from ahead of time compilers (of course, for LLVM it was
> initially not much true). So probably both GCC JIT and LLVM would
> produce, a bit slowly, some good machine code. (In particular because
> GCC JIT is, AFAIK, emitting assembly code).
>
> BTW, I have no idea if GCC JIT has some option to set the optimization
> level.
>
> Libjit seems superficially similar in terms of API (to both LLVM and GCC
> JIT): it offers a mini-C like intermediate representation.
>
> I also believe that GCC JIT is probably the JIT library which runs on
> much more processors than others (because GCC has a wide set of
> targets).
>
> David, do you think that a libit based JIT engine could quickly switch
> to GCC JIT once it has matured? I am guessing it would be quite easy.
>
> 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} ***


Paulo