Chris Hamons
Jun 3, 2017 · 1 min read

The standard .NET build system always does a complication pass when converting your C#/F# code from .cs files to binaries (.dll or .exe). It parses your code, converts it into IL (https://en.wikipedia.org/wiki/Common_Intermediate_Language).

The “normal” .NET execution model then loads these binaries into memory and compiles that IL into machine code “Just in Time”. This has some benefits (runtime could JIT different code based on machine type/workload/etc) and downsides (JIT takes some amount of time).

Ahead of Time complication (AOT) does that last bit as a secondary build process. It compiles the IL into specific machine code and writes it to disk (as dylibs in Xamarin.Mac’s case). On some platforms, where code generation is restricted like iOS, AOT is required. On macOS however, it is a optional step. If the runtime does not find AOT images, it will just JIT from the IL.

So the reason that we label it AOT is to distinguish it from the “first pass” compilation that converts source code to IL assemblies.

One thing to note, unless you enable “hybrid” AOT, the JIT code of mono may still generate some code on load. Some trampoline and generic code can be generated significantly better at runtime and takes very little time to handle.

    Chris Hamons

    Written by

    C# Monkey, Xamarin.Mac Lead