Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

llvm/tools: lli REPL compared to LuaJIT

I was wondering if someone has had experience with the llvm/tools - lli interpreter/JIT-compiler (cf. http://llvm.org/docs/GettingStarted.html#tools). I am interested in any information that you can provide (speed, complexity, implementations, etc.).

Thanks.

UPDATE:

Okay how would bitcode execution be compared to LuaJIT VM execution, supposing that lli acts as an interpreter? What about when lli acts as a jit-compiler (same comparison)?

NOTE: I am only asking if anyone has experience/ is willing to spare some time to share.

like image 494
are Avatar asked Oct 29 '10 19:10

are


People also ask

What is LLI LLVM?

DESCRIPTION. lli directly executes programs in LLVM bitcode format. It takes a program in LLVM bitcode format and executes it using a just-in-time compiler or an interpreter. lli is not an emulator. It will not execute IR of different architectures and it can only interpret (or JIT-compile) for the host architecture.

What is LLVM JIT?

The LLVM JIT compiler is function-based because it is able to compile a single function at a time. This defines the granularity at which the compiler works, which is an important decision of a JIT system.


1 Answers

LuaJIT is a tracing JIT, which means it can re-optimize itself to better suite the data passed through the execution environment, however, LLVM is a static JIT, and thus will just generate the once-off best-case machine code for the corresponding source, which may leading it it loosing performance in tight loops or bad branch misspredictions.

The actual LuaJIT VM is also highly optimized, threaded, machine specific assembly, where as LLVM uses C++ for portability (and other reasons), so this obviously gives LuaJIT a huge advantage. LLVM also has a much higher overhead than LuaJIT, purely because LuaJIT was designed to work on much less powerful systems (such as those driven by ARM CPU's).

The LuaJIT bytecode was also specially designed for LuaJIT, where as LLVM's bitcode is a lot more generic, this will obviously make LuaJIT's execute faster. LuaJIT's bytecode is also well designed for encoding optimization hints etc for use by the JIT and the tracer.

ignoring the fact that these are two different types of JITs, the whole comparison boils down to LLVM is focused on being a generic JIT/Compiler backend, LuaJIT is focused on executing Lua as fast as possible in the best way possible, thus it gains from not being constrained by generality.

like image 60
Necrolis Avatar answered Sep 22 '22 19:09

Necrolis