请输入您要查询的百科知识:

 

词条 Ahead-of-time compilation
释义

  1. Reduced runtime overhead

  2. Performance trade-offs

  3. Example

  4. See also

  5. References

  6. External links

{{More footnotes|date=February 2014}}{{Program execution}}

In computer science, ahead-of-time compilation (AOT compilation) is the act of compiling a higher-level programming language such as C or C++, or an intermediate representation such as Java bytecode or .NET Framework Common Intermediate Language (CIL) code, into a native (system-dependent) machine code so that the resulting binary file can execute natively.

AOT produces machine optimized code, just like a standard native compiler. The difference is that AOT transforms the bytecode of an extant virtual machine (VM) into machine code.

Reduced runtime overhead

Some programming languages with a managed code runtime that can be compiled to an intermediate representation, use just-in-time (JIT) compiling. This, briefly, compiles intermediate code into machine code for a native run while the intermediate code is executing, which may slow an application's performance. Ahead-of-time compiling eliminates the need for this step by occurring before execution rather than during execution.

Ahead-of-time compiling for dynamically typed languages to native machine code or other static VM bytecode is possible in a limited number of cases only.{{Citation needed|date=February 2011}} For example, the High Performance Erlang Project (HiPE) AOT compiler for the language Erlang can do this because of advanced static type reconstruction techniques and type speculations.

In most situations with fully AOT compiled programs and libraries, it is possible to drop a useful fraction of a runtime environment, thus saving disk space, memory, battery life, and startup times (no JIT warmup phase), etc. Because of this, it can be useful in embedded or mobile devices.

Performance trade-offs

AOT compilers can perform complex and advanced code optimizations, which in most cases of JITing will be considered much too costly. In contrast, AOT usually cannot perform some optimizations possible in JIT, like runtime profile-guided optimization (PGO), pseudo-constant propagation, or indirect-virtual function inlining.

Further, JIT compilers can speculatively optimize hot code by making assumptions on the code. The generated code can be deoptimized if a speculative assumption later proves wrong. Such operation slows the performance of the running software until code is optimized again by adaptive optimization. An AOT compiler cannot make such assumptions and needs to infer as much information as possible at compile time. It needs to resort to less specialized code because it cannot know what types will go through a method. Such problems can be alleviated by profile-guided optimizations. But even in this case, the generated code cannot be adapted dynamically to the changing runtime profile as a JIT compiler would do.

Example

The Android mobile operating system was delivered in 2008 with Dalvik, a virtual machine using a JIT compiler. In 2013, it was replaced by Android Runtime, a new virtual machine using AOT compilation, but in 2017, it received a JIT compiler.[1]

See also

{{Portal|Computer programming}}{{Div col|colwidth=20em}}
  • asm.js compiler (JavaScript)
  • Bartok (CIL)
  • Excelsior JET (Java)
  • GNU Compiler for Java
  • IL2CPU (CIL)
  • Native Image Generator (CIL)
  • RubyMotion (Ruby)
  • SharpOS AOT (CIL)
{{div col end}}

References

1. ^{{cite web |url=https://source.android.com/devices/tech/dalvik/jit-compiler |title=Implementing ART Just-In-Time (JIT) Compiler |website=android.com |access-date=25 January 2018}}

External links

  • Speed: NGen Revs Up Your Performance with Powerful New Features – MSDN Magazine, April 2005
  • Mono AOT
  • Excelsior JET – Certified Java SE Implementation with AOT compiler
  • [https://web.archive.org/web/20160802232148/http://gcc.gnu.org/java/ GNU Compiler for Java]
  • [https://blog.mozilla.org/luke/2014/01/14/asm-js-aot-compilation-and-startup-performance/ AOT compilation of asm.js]
  • Real-time Java, Part 2: Comparing compilation techniques – IBM developerWorks, April 2007
  • Improving Swing Performance: JIT vs AOT Compilation – LinuxWorld Magazine, November 2004
  • [https://web.archive.org/web/20090507103601/http://www.cs.vu.nl/manta/ Manta]

1 : Compilers

随便看

 

开放百科全书收录14589846条英语、德语、日语等多语种百科知识,基本涵盖了大多数领域的百科知识,是一部内容自由、开放的电子版国际百科全书。

 

Copyright © 2023 OENC.NET All Rights Reserved
京ICP备2021023879号 更新时间:2024/11/14 1:52:55