AOT compiler
Encyclopedia
An ahead-of-time compiler is a compiler
that implements ahead-of-time compilation. This refers to the act of compiling an intermediate language, such as Java bytecode
, .NET Common Intermediate Language
(CIL), or IBM System/38 or IBM System i
"Technology Independent Machine Interface" code, into a system-dependent binary.
Most languages with a managed code
runtime that can be compiled to an intermediate language take advantage of just-in-time
(JIT).This, briefly, compiles intermediate code into machine code
for a native run while the intermediate code is executing, which may decrease an application's performance. Ahead-of-time compilation eliminates the need for this step by performing the compilation before execution rather than during execution.
Ahead-of-time compilation for dynamically typed languages to native machine code or other static VM
bytecode is possible only in a limited number of cases. For example the HiPE AOT compiler for Erlang can do this because of advanced static type reconstruction techniques and types speculations.
AOT compilation is mostly beneficial in cases where the interpreter (which is small) is too slow or JIT
is too complex or introduces undesirable latencies. In most situations with fully AOT compiled programs and libraries it is possible to drop considerable fraction of runtime environment, thus saving disk space, memory and starting time. Because of this it can be useful in embedded or mobile devices.
AOT in most cases produces machine optimized code, just like a 'standard' native compiler. The difference is that AOT transforms the bytecode of an existing virtual machine into machine code. AOT compilers can perform complex and advanced code optimizations which in most cases of JITing will be considered much too costly. On the other hand AOT can't usually perform some optimizations possible in JIT, like runtime profile-guided optimizations
, pseudo-constant propagation or indirect/virtual function
inlining.
Java:
Compiler
A compiler is a computer program that transforms source code written in a programming language into another computer language...
that implements ahead-of-time compilation. This refers to the act of compiling an intermediate language, such as Java bytecode
Java bytecode
Java bytecode is the form of instructions that the Java virtual machine executes. Each bytecode opcode is one byte in length, although some require parameters, resulting in some multi-byte instructions. Not all of the possible 256 opcodes are used. 51 are reserved for future use...
, .NET Common Intermediate Language
Common Intermediate Language
Common Intermediate Language is the lowest-level human-readable programming language defined by the Common Language Infrastructure specification and is used by the .NET Framework and Mono...
(CIL), or IBM System/38 or IBM System i
IBM System i
The IBM System i is IBM's previous generation of midrange computer systems for IBM i users, and was subsequently replaced by the IBM Power Systems in April 2008....
"Technology Independent Machine Interface" code, into a system-dependent binary.
Most languages with a managed code
Managed code
Managed code is a term coined by Microsoft to identify computer program code that requires and will only execute under the "management" of a Common Language Runtime virtual machine ....
runtime that can be compiled to an intermediate language take advantage of just-in-time
Just-in-time compilation
In computing, just-in-time compilation , also known as dynamic translation, is a method to improve the runtime performance of computer programs. Historically, computer programs had two modes of runtime operation, either interpreted or static compilation...
(JIT).This, briefly, compiles intermediate code into machine code
Machine code
Machine code or machine language is a system of impartible instructions executed directly by a computer's central processing unit. Each instruction performs a very specific task, typically either an operation on a unit of data Machine code or machine language is a system of impartible instructions...
for a native run while the intermediate code is executing, which may decrease an application's performance. Ahead-of-time compilation eliminates the need for this step by performing the compilation before execution rather than during execution.
Ahead-of-time compilation for dynamically typed languages to native machine code or other static VM
VM
VM may stand for:In business*VM Motori, a diesel engine manufacturer*Vauxhall Motors, a British car maker*Viaggio Air *Virgin Media, a cable provider in the United Kingdom*Virgin Mobile, a mobile phone service...
bytecode is possible only in a limited number of cases. For example the HiPE AOT compiler for Erlang can do this because of advanced static type reconstruction techniques and types speculations.
AOT compilation is mostly beneficial in cases where the interpreter (which is small) is too slow or JIT
Just-in-time compilation
In computing, just-in-time compilation , also known as dynamic translation, is a method to improve the runtime performance of computer programs. Historically, computer programs had two modes of runtime operation, either interpreted or static compilation...
is too complex or introduces undesirable latencies. In most situations with fully AOT compiled programs and libraries it is possible to drop considerable fraction of runtime environment, thus saving disk space, memory and starting time. Because of this it can be useful in embedded or mobile devices.
AOT in most cases produces machine optimized code, just like a 'standard' native compiler. The difference is that AOT transforms the bytecode of an existing virtual machine into machine code. AOT compilers can perform complex and advanced code optimizations which in most cases of JITing will be considered much too costly. On the other hand AOT can't usually perform some optimizations possible in JIT, like runtime profile-guided optimizations
Profile-guided optimization
Profile-guided optimization is a compiler optimization technique in computer programming to improve program runtime performance. In contrast to traditional optimization techniques that solely use the source code, PGO uses the results of test runs of the instrumented program to optimize the final...
, pseudo-constant propagation or indirect/virtual function
Virtual function
In object-oriented programming, a virtual function or virtual method is a function or method whose behaviour can be overridden within an inheriting class by a function with the same signature...
inlining.
See also
- SharpOS AOTSharpOS AOT (compiler)SharpOS AOT is an AOT compiler that is written using a Common Intermediate Language compliant language . It targets Common Intermediate Language. It targets SharpOS specifically.- See also :* SharpOS* .NET Framework* Bartok* Open CIL JIT* IL2CPU...
(CIL) - IL2CPUIL2CPU (compiler)IL2CPU is an AOT compiler that is written using a Common Intermediate Language compliant language . It translates Common Intermediate Language to machine code. IL2CPU is the primary component of the Cosmos Project, and is developed by the same team.- See also :* Cosmos* .NET Framework* Bartok*...
(CIL) - Native Image GeneratorNative Image GeneratorThe Native Image Generator, or simply NGEN is the Ahead-of-time compilation service of the .NET Framework. It allows a .NET assembly to be pre-compiled instead of letting the Common Language Runtime do a Just-in-time compilation at runtime...
(CIL) - GNU Compiler for Java
- Excelsior JET (Java)
External links
.NET:- Speed: NGen Revs Up Your Performance with Powerful New Features -- MSDN Magazine, April 2005
- Mono AOT
Java: