11. Executing code with JIT Compilation
Console.WriteLine("Hi");
Console.WriteLine("There");
JIT Compiler
-Lookup IL for method
-Compile IL to native
-Modify metadata to
point to compiled code
-Jump to compiled
code
Console metadata
static void
WriteLine(string)
JIT Compiler Address
static void WriteLine()
JIT Compiler Address
Native CPU
Instructions
Native Address
12. Executing code with JIT Compilation
Console.WriteLine("Hi");
Console.WriteLine("There");
Console metadata
static void
WriteLine(string)
JIT Compiler
-Lookup IL for method
-Compile IL to native
-Modify metadata to
point to compiled code
-Jump to compiled code
Native Address
static void WriteLine()
JIT Compiler Address
Native CPU
Instructions
24. JIT - Local variable elimination
PrintUser(GetUser(3));
Before
After
25. JIT – Range check elimination
static int[] _array = new int[10];
static volatile int _i;
static void Main(string[] args)
{
int[] localRef = _array;
for (int i = 0; i < localRef.Length; ++i)
_i += localRef[i];
}
Before
After
26. JIT – Method Inlining
public class Program {
static void Main(string[] args) {
int i = 5 & 4;
}
}
Before
After