即时编译和提前编译

Just-in-time compilation is a method for improving the performance of interpreted programs. During execution the program may be compiled into native code to improve its performance. It is also known as dynamic compilation.

即时编译是一种提高解释程序性能的方法。 在执行期间,可以将程序编译为本机代码以提高其性能。 也称为动态编译。

Dynamic compilation has some advantages over static compilation. When running Java or C# applications, the runtime environment can profile the application while it is being run. This allows for more optimized code to be generated. If the behavior of the application changes while it is running, the runtime environment can recompile the code.

动态编译比静态编译具有一些优势。 在运行Java或C#应用程序时,运行时环境可以在运行应用程序时对其进行概要分析。 这允许生成更多优化的代码。 如果应用程序在运行时的行为发生了变化,则运行时环境可以重新编译代码。

Some of the disadvantages include startup delays and the overhead of compilation during runtime. To limit the overhead, many JIT compilers only compile the code paths that are frequently used.

一些缺点包括启动延迟和运行时编译的开销。 为了限制开销,许多JIT编译器仅编译经常使用的代码路径。

总览 (Overview)

Traditionally there are two methods for converting source code into a form that can be run on a platform. Static compilation converts the code into a language for a specific platform. An interpreter directly executes the source code.

传统上,有两种方法可以将源代码转换为可以在平台上运行的形式。 静态编译将代码转换为特定平台的语言。 解释器直接执行源代码。

JIT compilation attempts to use the benefits of both. While the interpreted program is being run, the JIT compiler determines the most frequently used code and compiles it to machine code. Depending on the compiler, this can be done on a method or smaller section of code.

JIT编译尝试利用两者的好处。 在运行解释程序时,JIT编译器确定最常用的代码并将其编译为机器代码。 根据编译器的不同,可以在方法或代码的较小部分上完成此操作。

Dynamic compilation was first described in a paper by J. McCarthy on LISP in 1960.

动态编译最初是由J. McCarthy在1960年关于LISP的论文中描述的。

Just In Time Compilation, JIT, or Dynamic Translation, is compilation that is being done during the execution of a program. Meaning, at run time, as opposed to prior to execution. What happens is the translation to machine code. The advantages of a JIT are due to the fact, that since the compilation takes place in run time, a JIT compiler has access to dynamic runtime information enabling it to make better optimizations (such as inlining functions).

即时编译,JIT或动态翻译是在程序执行期间进行的编译。 意思是在运行时,而不是在执行之前。 发生的是翻译成机器代码。 JIT的优点是由于以下事实:既然编译是在运行时进行的,那么JIT编译器可以访问动态运行时信息,从而可以进行更好的优化(例如内联函数)。

What is important to understand about the JIT compilation, is that it will compile the bytecode into machine code instructions of the running machine. Meaning, that the resulting machine code is optimized for the running machine’s CPU architecture.

要了解有关JIT编译的重要信息,那就是它将字节码编译为正在运行的机器的机器代码指令。 这意味着,生成的机器代码已针对正在运行的机器的CPU架构进行了优化。

Some examples of JIT Compilers are JVM (Java Virtual Machine) in Java and CLR (Common Language Runtime), in C#.

JIT编译器的一些示例是Java中的JVM(Java虚拟机)和C#中的CLR(公共语言运行时)。

历史 (History)

In the beginning, a compiler was responsible for turning a high-level language (defined as higher level than assembler) into object code (machine instructions), which would then be linked (by a linker) into an executable.

最初,编译器负责将高级语言(定义为比汇编器高的语言)转换为目标代码(机器指令),然后将其(通过链接器)链接为可执行文件。

At one point in the evolution of languages, compilers would compile a high-level language into pseudo-code, which would then be interpreted (by an interpreter) to run your program. This eliminated the object code and executables, and allowed these languages to be portable to multiple operating systems and hardware platforms. Pascal (which compiled to P-Code) was one of the first; Java and C# are more recent examples. Eventually the term P-Code was replaced with bytecode, since most of the pseudo-operations are a byte long.

在语言发展的某一时刻,编译器会将高级语言编译为伪代码,然后将其解释(由解释器)以运行您的程序。 这消除了目标代码和可执行文件,并允许这些语言可移植到多个操作系统和硬件平台。 Pascal(编译为P-Code)是最早的一个。 Java和C#是最近的示例。 最终,术语P-Code替换为字节码,因为大多数伪操作都是一个字节长。

A Just-In-Time (JIT) compiler is a feature of the run-time interpreter, that instead of interpreting bytecode every time a method is invoked, will compile the bytecode into the machine code instructions of the running machine, and then invoke this object code instead. Ideally the efficiency of running object code will overcome the inefficiency of recompiling the program every time it runs.

即时(JIT)编译器是运行时解释器的功能,它不是在每次调用方法时都解释字节码,而是将字节码编译为正在运行的计算机的机器代码指令,然后调用此代码。目标代码。 理想情况下,运行目标代码的效率将克服每次运行时重新编译程序的效率低下的问题。

典型场景 (Typical scenario)

The source code is completely converted into machine code

源代码已完全转换为机器代码

JIT场景 (JIT scenario)

The source code will be converted into assembly language like structure [for ex IL (intermediate language) for C#, ByteCode for java].

源代码将被转换为汇编语言,如结构[对于C#来说,是ex IL(中间语言),对于Java是ByteCode)。

The intermediate code is converted into machine language only when the application needs that is required codes are only converted to machine code.

仅当应用程序需要的中间代码仅转换为机器代码时,才将中间代码转换为机器语言。

JIT与非JIT比较 (JIT vs Non-JIT comparison)

In JIT not all the code is converted into machine code first a part of the code that is necessary will be converted into machine code then if a method or functionality called is not in machine then that will be turned into machine code, which reduces burden on the CPU. As the machine code will be generated on run time, the JIT compiler will produce machine code that is optimized for running machine’s CPU architecture.

在JIT中,并非所有代码都首先转换为机器代码,一部分必需的代码将被转换为机器代码,然后,如果所调用的方法或功能不在机器中,则将其转换为机器代码,从而减轻了负担CPU。 由于机器代码将在运行时生成,因此JIT编译器将生成针对机器的CPU体系结构进行了优化的机器代码。

Some examples of JIT are:

JIT的一些示例是:

  • Java: JVM (Java Virtual Machine) Java:JVM(Java虚拟机)
  • C#: CLR (Common Language Runtime) C#:CLR(公共语言运行时)
  • Android: DVM (Dalvik Virtual Machine) or ART (Android RunTime) in newer versionsAndroid:较新版本的DVM(Dalvik虚拟机)或ART(Android运行时)

The Java Virtual Machine (JVM) executes bytecode and maintains a count as of how many time a function is executed. If this count exceeds a predefined limit JIT compiles the code into machine language which can directly be executed by the processor (unlike the normal case in which javac compiles the code into bytecode and then Java, the interpreter interprets this bytecode line by line converts it into machine code and executes).

Java虚拟机(JVM)执行字节码并维护一个函数执行多少次的计数。 如果此计数超过预定义的限制,则JIT会将代码编译为机器语言,该语言可以直接由处理器执行(不同于正常情况下,javac将该代码编译为字节码,然后由Java编译,解释器逐行解释此字节码,将其转换为机器代码并执行)。

Also next time this function is calculated same compiled code is executed again unlike normal interpretation in which the code is interpreted again line by line. This makes execution faster.

同样,下次计算此函数时,将再次执行相同的编译代码,这与正常解释不同,在正常解释中,代码逐行再次解释。 这使执行速度更快。

翻译自: https://www.freecodecamp.org/news/just-in-time-compilation-explained/

即时编译和提前编译

即时编译和提前编译_即时编译说明相关推荐

  1. wxapkg反编译后的数据_反编译微信小程序

    首先声明:本文章仅供学习之用,不可它用. 一.前言 看到人家上线的小程序的效果,纯靠推测,部分效果在绞尽脑汁后能做出大致的实现,但是有些细节,费劲全力都没能做出来.很想一窥源码?查看究竟?看看大厂的前 ...

  2. java反编译微信小程序_反编译微信小程序(最新)

    首先声明:本文章仅供学习之用,不可它用. 一.前言 看到人家上线的小程序的效果,纯靠推测,部分效果在绞尽脑汁后能做出大致的实现,但是有些细节,费劲全力都没能做出来.很想一窥源码?查看究竟?看看大厂的前 ...

  3. 编译原理实验语义分析_「编译原理」LL(1)文法分析,简单优先分析

    首先我们来介绍一下LL(1)文法分析. LL(1)文法是一种自顶向下的分析方式,是从非终结符到终结符的分析方式,这种方式和我们之前说的LR(0)分析方式是刚好相反的,在我们使用LR(0)分析方式的时候 ...

  4. 微信小程序反编译wxss文件缺失_反编译任何微信小程序和如何还原wxss

    首先需要了解一下微信小程序它执行是需要把源码下载到本地的,下载下来的是一个 .wxapk后缀的文件 ,那么问题来了.下载的源码在那? 这里我们以安卓为例(因为我没用过苹果手机,哈哈哈) 使用到的工具 ...

  5. linux 编译mqtt静态库_编译MQTT C++ Client

    nmake  -f  ms\nt.mak(这是静态库,动态库是ntdll.mak) nmake  -f  ms\nt.mak test(测试命令,如果成功则最后显示"passed all t ...

  6. build文件_把编译时间加入到目标文件

    出处:https://www.cnblogs.com/pingwen/p/8183728.html 1.问题背景:如何保证发布出去的bin文件是最终测试通过的版本? 一般的来讲,代码到了测试后期,ma ...

  7. mysql openwrt 编译_如何编译OpenWrt

    (!文末,附加人生如戏写的编译OPENWRT的TXT内容,可直接跳至末尾,有例子) Openwrt 官方正式的发行版是已编译好了的映像文件(后缀名bin或trx.trx2),此映像文件可从Openwr ...

  8. jadx重新打包_反编译一款APP然后重新打包(Windows环境)

    最近有小伙伴私信我,怎么把一款APP改成自己的信息呀,咳咳,这又来送题材了,今天水一把APP反编译+回编译,文中会针对一款APP进行简单的修改信息,问问题的小伙伴还不火速右上角支持一下. MacOS跟 ...

  9. 微信小程序反编译wxss文件缺失_微信小程序反编译~2020年

    摘要 安装wxappUnpacker小程序反编译工具并使用(2020.03) 关键词: 微信小程序反编译 wxss 介绍 上次分享了web前端爬取工具 ,那么这次也同样讲讲微信小程序反编译吧,对于像博 ...

最新文章

  1. 用leangoo做阶段式游戏新产品研发
  2. 【驱动】linux下I2C驱动架构全面分析
  3. Linux不能上网ping:unknown host问题怎么解决?
  4. c: realloc()函数解析
  5. 北京计算机科学与技术学院,计算机科学与技术学院
  6. pdh光端机相关知识介绍
  7. Android ——SoundPool播放音频
  8. 翻译:group_concat()函数(已提交到MariaDB官方手册)
  9. Lyft 基于 Flink 的大规模准实时数据分析平台(附FFA大会视频)
  10. Android开发点滴 - 实现层级式导航(API 16+)
  11. glide scaletype 无效_android 自定义圆角ImageView,后设置scaleType=centerCrop无效?
  12. 如何写好简历与迎接面试
  13. 微机原理-80386(2)
  14. 光纤传输技术——光器件(三)
  15. 猪齿鱼开源四周年庆典,邀您共享精彩瞬间
  16. JavaTutorials之Operators
  17. HttpClient请求https类型的网站接口碰到ssl证书不受信任问题处理
  18. 2019/8/18 ECU和DCU
  19. 计算机的冷启动与热启动
  20. pandas的loc[ ]和iloc[ ]方法解析

热门文章

  1. IDEA配置GitHub报错GitHub Invalid authentication data.404 Not Found-Not Found
  2. 后盾网php多少钱_复合排水网价格多少钱
  3. iOS开发业界毒瘤 Hook
  4. 阿里巴巴持续投入,etcd 正式加入 CNCF
  5. 《Kinect应用开发实战:用最自然的方式与机器对话》一3.4 深度图像成像原理...
  6. Tslib移植与分析【转】
  7. 数据库创建索引的原则
  8. python中的文档字符串(docString)
  9. Android中Handler
  10. 性能优化工具 MVC Mini Profiler