Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

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?

share|improve this question
add comment

1 Answer

up vote 5 down vote accepted

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.

share|improve this answer
    
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. –  delnan Jan 3 '13 at 22:58
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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