ART中AOT和JIT编译器之间的区别 [英] Difference between AOT and JIT compiler in the ART

查看:135
本文介绍了ART中AOT和JIT编译器之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在棉花糖中,ART添加了一个AOT编译器.从Android N开始,除了AOT之外,还添加了另一个编译器JIT.

In Marshmallow there was an AOT compiler added with ART. From Android N another compiler JIT was added in addition with AOT.

什么是AOT编译器特定的工作/功能,什么是JIT编译器的工作/功能?

What are AOT compiler specific job/features and what areJIT compiler job/features?

推荐答案

在Android Java类中转换为DEX字节码.DEX字节码格式可通过ART或Dalvik运行时转换为本地机器代码.

In Android Java classes converted into DEX bytecode. The DEX bytecode format is translated to native machine code via either ART or the Dalvik runtimes.

Dalvik是基于JIT(及时)编译的引擎.有因此从Android 4.4(kitkat)ART使用Dalvik的缺点是作为运行时引入的,从Android 5.0(Lollipop)开始,它具有完全取代了达尔维克.Android 7.0添加了即时(JIT)编译器具有不断分析到Android运行时(ART)的代码改善Android应用运行时的性能.

Dalvik is a JIT (Just in time) compilation based engine. There were drawbacks to use Dalvik hence from Android 4.4 (kitkat) ART was introduced as a runtime and from Android 5.0 (Lollipop) it has completely replaced Dalvik. Android 7.0 adds a just-in-time (JIT) compiler with code profiling to Android runtime (ART) that constantly improves the performance of Android apps as they run.

( Dalvik使用JIT(Just in time)编译,而ART使用AOT(Ahead of time)编译.)

及时(JIT):

使用Dalvik JIT编译器,每次运行该应用程序时,它会将Dalvik字节码的一部分动态转换为机器代码.随着执行的进行,更多的字节码将被编译和缓存.由于JIT仅编译部分代码,因此它具有较小的内存占用空间,并且在设备上使用的物理空间更少.

With the Dalvik JIT compiler, each time when the app is run, it dynamically translates a part of the Dalvik bytecode into machine code. As the execution progresses, more bytecode is compiled and cached. Since JIT compiles only a part of the code, it has a smaller memory footprint and uses less physical space on the device.

提前(AOT):

ART配备了Ahead-of-time编译器.在应用程序的安装阶段,它会将DEX字节码静态转换为机器代码,并存储在设备的存储设备中.这是一个一次性事件,发生在将应用程序安装在设备上时.

ART is equipped with an Ahead-of-Time compiler. During the app’s installation phase, it statically translates the DEX bytecode into machine code and stores in the device’s storage. This is a one-time event which happens when the app is installed on the device.

Android N包含混合运行时:

在安装过程中不会进行任何编译,并且可以立即启动应用程序,被解释的字节码.ART中有一个新的,更快的解释器,并附带了一个新的JIT,但JIT信息并未保留.而是在执行期间对代码进行概要分析,并保存结果数据.

There won’t be any compilation during install, and applications can be started right away, the bytecode being interpreted. There is a new, faster interpreter in ART and it is accompanied by a new JIT, but the JIT information is not persisted. Instead, the code is profiled during execution and the resulted data is saved.

ART的优点:

  • 安装过程中完成DEX字节码转换后,应用程序运行得更快.
  • 直接执行本机代码可减少应用程序的启动时间.
  • 提高了电池性能,因为节省了用于逐行解释字节码的电量.
  • 改进的垃圾收集器.

ART的缺点:

  • 由于安装过程中将DEX字节码转换为机器代码,因此应用程序安装会花费更多时间.

  • App Installation takes more time because of DEX bytecodes conversion into machine code during installation.

由于安装时生成的本机代码存储在内部存储器中,因此需要更多内部存储器.

As the native machine code generated on installation is stored in internal storage, more internal storage is required.

这篇关于ART中AOT和JIT编译器之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆