CAIE 9618 · Paper 3 · Topic 3.4.2
VM for
Intermediary Code
Bytecode · JIT Compilation · Platform Independence · .NET CLR
CSZone
Cambridge International AS & A Level Computer Science 9618
JIT Compilation
Just-In-Time: Best of Both Worlds
JIT (Just-In-Time) compilation is a technique used by VMs to improve performance. Instead of purely interpreting bytecode line by line, the JIT compiler identifies frequently executed code and compiles it to native machine code at runtime.
HOW JIT WORKS
VM starts interpreting bytecode (slow initially)
JIT profiler identifies "hot spots" — frequently executed loops or functions
Hot spots compiled to native machine code and cached
On next execution of that code, native version runs directly
Result: near-native performance for hot code paths
JIT vs AOT vs INTERPRETER
Interpreter: translate+execute each line at runtime. Slow.
AOT (Ahead of Time): fully compiled before run. Fast but platform-specific.
JIT: interpret first, compile hot paths at runtime. Portable + fast.
REAL-WORLD EXAMPLES
JVM (Java): JIT compiles hot bytecode to x86/ARM.
.NET CLR (C#): MSIL bytecode JIT-compiled.
V8 (JavaScript): JIT for browser performance.
PyPy (Python): JIT for CPython bytecode.