Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is llvm considered unsuitable for implementing a JIT?

Tags:

jit

llvm

Many dynamic languages implement (or want to implement) a JIT Compiler in order to speed up their execution times. Inevitably, someone from the peanut gallery asks why they don't use LLVM. The answer is often, "LLVM is unsuitable for building a JIT." (For Example, Armin Rigo's comment here.)

Why is LLVM Unsuitable for building a JIT?

Note: I know LLVM has its own JIT. If LLVM used to be unsuitable, but now is suitable, please say what changed. I'm not talking about running LLVM Bytecode on the LLVM JIT, I'm talking about using the LLVM libraries to implement a JIT for a dynamic language.

like image 943
Sean McMillan Avatar asked Jul 26 '11 16:07

Sean McMillan


People also ask

Is JIT faster than compiled?

A JIT compiler can be faster because the machine code is being generated on the exact machine that it will also execute on. This means that the JIT has the best possible information available to it to emit optimized code.

Why JIT is faster than interpreter?

The JIT-compiled code is actually running directly on the bare metal whereas interpreted code has to be continually reinterpreted by the interpreter. The interpreter is no longer having to reprocess and reprocess the byte code.

What is the difference between JIT compiler and interpreter?

The basic difference between Interpreter and JIT compiler is that interpreter is a software that converts the source code into native machine code line by line while JIT compiler is a component in JVM that improves the performance of Java programs by compiling bytecodes into native machine codes at run time.

What is the purpose of JIT compiler?

The JIT compiler helps improve the performance of Java programs by compiling bytecodes into native machine code at run time. The JIT compiler is enabled by default. When a method has been compiled, the JVM calls the compiled code of that method directly instead of interpreting it.


1 Answers

Why is LLVM Unsuitable for building a JIT?

I wrote HLVM, a high-level virtual machine with a rich static type system including value types, tail call elimination, generic printing, C FFI and POSIX threads with support for both static and JIT compilation. In particular, HLVM offers incredible performance for a high-level VM. I even implemented an ML-like interactive front-end with variant types and pattern matching using the JIT compiler, as seen in this computer algebra demonstration. All of my HLVM-related work combined totals just a few weeks work (and I am not a computer scientist, just a dabbler).

I think the results speak for themselves and demonstrate unequivocally that LLVM is perfectly suitable for JIT compilation.

like image 91
J D Avatar answered Sep 22 '22 11:09

J D