即时编译和提前编译_即时编译说明
即时编译和提前编译
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/
即时编译和提前编译
相关文章:

bzoj 2588 Spoj 10628. Count on a tree (可持久化线段树)
Spoj 10628. Count on a tree Time Limit: 12 Sec Memory Limit: 128 MBSubmit: 7669 Solved: 1894[Submit][Status][Discuss]Description 给定一棵N个节点的树,每个点有一个权值,对于M个询问(u,v,k),你需要回答u xor lastans和v这两个节点…

.Net SqlDbHelper
using System.Configuration; using System.Data.SqlClient; using System.Data;namespace ExamDAL {class SqHelper{#region 属性区// 连接字符串private static string strConn;public static string StrConn{get{return ConfigurationManager.ConnectionStrings["Exam&…

C语言的一个之前没有见过的特性
代码: #include <stdio.h>int test(){int a ({int aa 0;int bb 1;int cc 2;if(aa 0 && bb 1)printf("aa %d, bb %d\n", aa, bb);//return -2;cc;});return a; }int main(){typeof(4) a test();printf("a %d\n", a); } …

如何构建顶部导航条_如何构建导航栏
如何构建顶部导航条导航栏 (Navigation Bars) Navigation bars are a very important element to any website. They provide the main method of navigation by providing a main list of links to a user. There are many methods to creating a navigation bar. The easiest…

SPSS聚类分析:K均值聚类分析
SPSS聚类分析:K均值聚类分析 一、概念:(分析-分类-K均值聚类) 1、此过程使用可以处理大量个案的算法,根据选定的特征尝试对相对均一的个案组进行标识。不过,该算法要求您指定聚类的个数。如果知道ÿ…

[ 总结 ] nginx 负载均衡 及 缓存
操作系统:centos6.4 x64 前端使用nginx做反向代理,后端服务器为:apache php mysql 1. nginx负载均衡。 nginx编译安装(编译安装前面的文章已经写过)、apache php mysql 直接使用yum安装。 nginx端口:80…

中国剩余定理(孙子定理)的证明和c++求解
《孙子算经》里面的"物不知数"说的是这样的一个题目:一堆东西不知道具体数目,3个一数剩2个,5个一数剩3个,7个一数剩2个,问一共有多少个。 书里面给了计算过程及答案:70*2 21*3 15*2 -105*2 2…

osi七层网络层_OSI层速成课程
osi七层网络层介绍 (Introduction) Have you ever wondered how data is sent through the network from one machine to another? If yes, then the Open System Interconnected model is what you are looking for.您是否曾经想过如何通过网络将数据从一台机器发送到另一台机…

KMP算法求回溯数组的步骤
KMP算法到底是什么原理就不说了,各种资料上讲的明明白白,下面我就如何用代码来实现做一下说明和记录. KMP的核心思想就是,主串不回溯,只模式串回溯。而模式串匹配到第几位时失配,要回溯多少,由模式串本身来…
【.Net】vs2017 自带发布工具 ClickOnce发布包遇到的问题
一、遇到的问题 在安装了vs2017 社区版(Community)之后 想打包安装程序(winform) 还是想用之前的 installshield来打包 发现居然打不了,在官网查了 installshield不支持社区版(Community)&…

windows平台,开发环境变量配置
1.打开我的电脑--属性--高级--环境变量 JAVA配置环境变量变量名:JAVA_HOME 变量值:C:\Program Files\Java\jdk1.7.0 变量名:CLASSPATH 变量值:.;%JAVA_HOME%\lib\dt.jar;%JAVA_HOME%\lib\tools.jar; 变量名:Path 变…

如何编写可测试的代码 哈利勒的方法论
Understanding how to write testable code is one of the biggest frustrations I had when I finished school and started working at my first real-world job. 当我完成学业并开始从事第一份现实世界的工作时,了解如何编写可测试的代码是我最大的挫败之一。 T…

【Java入门提高篇】Day6 Java内部类——成员内部类
内部类是什么,简单来说,就是定义在类内部的类(一本正经的说着废话)。 一个正经的内部类是长这样的: public class Outer {class Inner{} } 这是为了演示而写的类,没有什么luan用,可以看到Inner类…

POJ 1001(高精度乘法 java的2种解法)
方法1: import java.math.BigDecimal; import java.util.Scanner; public class Main {public static void main(String[] args) {Scanner sc new Scanner(System.in);while(sc.hasNext()){String d sc.next();int z sc.nextInt();BigDecimal bd new BigDecimal(d);BigDeci…

Java编写的电梯模拟系统《结对作业》
作业代码:https://coding.net/u/liyi175/p/Dianti/git 伙伴成员:李伊 http://home.cnblogs.com/u/Yililove/ 对于这次作业,我刚开始一点思绪都没有,在老师安排了结对伙伴李伊之后,我的搭档问我,我们需要什么…

HTML属性说明
HTML elements can have attributes, which contain additional information about the element.HTML元素可以具有属性,其中包含有关该元素的其他信息。 HTML attributes generally come in name-value pairs, and always go in the opening tag of an element. Th…

css中的选择器
1.在html中引入css的方法:四种方式: a.行内式(也称内联式) 如: <h1 style"color:red;test</h1> b.内嵌式 <style type"text/css"> h1{ color:red; font-size: 10.5pt; font-family: Calibri, sans-serif; line-height: normal; widow…

javascript的call()方法与apply()方法的理解
先看一段代码 function cat() {} cat.prototype{food:fish,say:function () {console.log(I love this.food);} };var blackCat new cat(); blackCat.say(); 这时,控制台输出 I love fish若此时,有另一个对象 Dog{food:bones and shit}; dog对象没有say…

java排序算法(冒泡,插入,选择,快速,堆,归并,希尔,基数)
import java.util.Arrays; import java.util.LinkedList;/*** * * 各种排序: 冒泡,插入,选择,快速,堆,归并,希尔,基数*/ public class Sorts {//1. 冒泡://时间复杂度:n(n-1)/2O(n^2…

边界填充算法讲解_边界填充算法
边界填充算法讲解Boundary fill is the algorithm used frequently in computer graphics to fill a desired color inside a closed polygon having the same boundary color for all of its sides.边界填充是在计算机图形学中经常使用的算法,用于在其所有边都具有…

使用Git管理源代码
git是个了不起但却复杂的源代码管理系统。它能支持复杂的任务,却因此经常被认为太过复杂而不适用于简单的日常工作。让我们诚实一记吧:Git是复杂的,我们不要装作它不是。但我仍然会试图教会你用(我的)基本的Git和远程代…

[.Net跨平台]部署DTCMS到Jexus遇到的问题及解决思路---Linux环境搭建
最近朋友托我帮忙研究如何把一个DTCMS部署到Linux下,经过1天的研究,部署基本成功,可能有些细节还未注意到,现在把心得分享一下。过程比预期的要简单 身为.Net程序员,这个问题的第一步可能就是如何搭建一个Linux环境来测…

Sequence point 中文
摘自维基百科: In C[4] and C,[5] sequence points occur in the following places. (In C, overloaded operators act like functions, and thus operators that have been overloaded introduce sequence points in the same way as function calls.) Between ev…

python中pop函数_Python中的Pop函数
python中pop函数什么是弹出功能? (What is the pop function?) The method pop() removes and returns the last element from a list. There is an optional parameter which is the index of the element to be removed from the list. If no index is specified…

第六周学习进度条
日期 任务 听课 编程 阅读 准备考试 日总计 周日 周一 120 300 0 0 420 100 周二 0 120 0 0 120 周三 0 0 0 0 0 周四 0 0 0 0 0 周五 0 0 0 0 0 周六 0 120 100 0 …

1071. 小赌怡情(15)
常言道“小赌怡情”。这是一个很简单的小游戏:首先由计算机给出第一个整数;然后玩家下注赌第二个整数将会比第一个数大还是小;玩家下注t个筹码后,计算机给出第二个数。若玩家猜对了,则系统奖励玩家t个筹码;…

关于年长程序员的5个误传
原文链接:http://kb.cnblogs.com/page/150932/ 英文原文:Five Pervasive Myths About Older Software Developers 最近我刚过完40岁生日,一个朋友向我开玩笑地说“嘿,你已经老了,不适合做程序员了!”我虽然…

java中getter_Java中的Getter和Setters解释了
java中getterGetters and setters are used to protect your data, particularly when creating classes. Getter和Setter用于保护数据,尤其是在创建类时。 For each instance variable, a getter method returns its value while a setter method sets or updates…

Loadrunner手动关联详解
Loadrunner手动关联详解 一、关联的含义: 关联(correlation):在脚本回放过程中,客户端发出请求,通过关联函数所定义的左右边界值(也就是关联规则),在服务器所响应的内容中…

解决Visual Studio禁止使用strlen函数的问题
问题描述: 在学习C的复制构造函数以及复制赋值运算符的重载时,需要用到使用C风格的字符串作为引入,由于我用的是VS2015(社区版),在编译时出错。编译器提醒strcpy函数是不安全的,建议改用strlen_…