I've seen it stated several times that AOT can run some more expensive optimizations that take too long to be used by a JIT. But I've never seen it stated what exactly these optimizations are. So I'm wondering, what are these optimizations?


Register allocation comes to mind.

According to wikipedia:

Graph coloring allocators produce efficient code, but their allocation time is high. In cases of static compilation, allocation time is not a significant concern. In cases of dynamic compilation, such as just-in-time (JIT) compilers, fast register allocation is important. An efficient technique proposed by Poletto and Sarkar is linear scan allocation. This technique requires only a single pass over the list of variable live ranges. Ranges with short lifetimes are assigned to registers, whereas those with long lifetimes tend to be spilled, or reside in memory. The results are on average only 12% less efficient than graph coloring allocators.

Also, I recently came across a stackoverflow question about an optimization that the JIT compiler doesn't do. Not sure if compile times are the reason, but it might still be worth checking.

  • That's a bit misleading. Popular AOT compilers don't use graph coloring either, they use heuristics as well (examples: LLVM, GCC). Compile time matters for AOT compilers too; the threshold is higher, but graph coloring is so darn hard that it's not feasible for them either. But yes, AOT compilers can and do invest more time in register allocation, which usually leads to better runtime performance. – user7043 Jan 3 '13 at 22:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.