Nicol Leung
1 min readSep 24, 2022

--

As I can recall there are at least two reasons JIT can be faster than AOT, and is becoming more likely as JIT getting more sophisticated.

1. JIT compilers have access to runtime statistics of a program, most commonly branch results, data types of field access etc. These information allows JIT compilers to generate optimized machine code according to real time statistics, which static language compilers can never have a grab on. Same analogy can be found in databases, where data statistics help query planning a lot.

2. JIT compilers know what code is included in the program, they know the "closure". Statically compiled programs do not know ahead of time what they will be dynamically linked to. Without knowledge of the call sites, many assumptions cannot be made on the implementations, which is a big downside of static compilers (unless they are closure compilers).

(I am no compiler experts, correct me if anything wrong)

--

--

No responses yet