V8中与JIT编译的混淆 [英] The confusion with JIT compilation in V8

查看:55
本文介绍了V8中与JIT编译的混淆的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究V8的内部工作原理,遇到了JIT编译器一词.最初,我在本文中阅读了 https://www.quora.com/How-does-the-JIT-compiler-work-in-JS 将V8中的JIT编译器称为点火器",它是解释器.然后,我得出的结论是JIT编译器只是解释器.但是后来我发现了另一篇文章 https://blog.logrocket.com/how-javascript-works-optimizing-the-v8-compiler-for-efficiency/将jit编译描述为解释器和编译器的组合.伙计们,JIT编译器真的是解释器和编译器的结合吗?还是JIT编译器仅是解释器?

I was studying the inner workings of V8 and came across the term JIT compiler. Initially, I read in this article https://www.quora.com/How-does-the-JIT-compiler-work-in-JS that JIT compiler in V8 is called "Ignition" which is interpreter. Then, I came to conclusion that JIT compiler is just interpreter. But later I found another article https://blog.logrocket.com/how-javascript-works-optimizing-the-v8-compiler-for-efficiency/ describing jit-compilation as the combination of both interpreter and compiler. Guys, is JIT compiler a really a combination of interpreter and compiler? or Is JIT compiler is just interpreter only?

推荐答案

V8开发人员在此处.只是为了澄清和扩大评论者已经指出的内容:

V8 developer here. Just to clarify and expand what commenters have been pointing out already:

  • "JIT"的意思是准时",意味着某些执行环境动态地(即在运行时)决定产生某种东西(通常是机器代码-通常,"JIT"的意思是准时").-

  • "JIT" means "just in time", and means that some execution environment dynamically (i.e. at runtime) decides to produce something (typically machine code -- colloquially, "JIT" tends to mean "just-in-time compilation", although if you decide to prepare a meal exactly when you're hungry and then eat it right away when it's done, then that's technically also "JIT" preparation.) The canonical opposite would be a language like C/C++, which is compiled by the developer, long before being delivered to and executed by the user. Another "opposite" in a different direction is an execution environment that executes something without producing machine code dynamically. Such environments are typically called "interpreters".

过去,V8始终用于生成机器代码.它根本无法执行不涉及首先将其编译为机器代码的JavaScript.显然,这是在客户端发生的,因此这是一个即时编译器的教科书示例(或更准确地说,是一组几个编译器……哦,详细信息!).

In the past, V8 used to always produce machine code. It simply had no way to execute JavaScript that did not involve compiling it to machine code first. Obviously this happened on the client, so it was a textbook example of a just-in-time compiler (or, more accurately, a set of several compilers... oh well, details!).

近年来,V8将解释器作为其第一个执行层.现在,术语的用法变得复杂了,因为此解释器及时"将JavaScript编译"为字节码(然后进行解释),但是当有人说"JIT编译器"时,它们通常表示它不是解释器.

In recent years, V8 has had an interpreter as its first execution tier. Now usage of terms gets complicated, because this interpreter "compiles" JavaScript "just in time" to bytecode (which is then interpreted), but when someone says "JIT compiler", they usually mean that it's not an interpreter.

V8还具有一个优化的编译器,可以生成机器代码.它在运行时运行(当功能被认为很热时),因此它是即时编译器.

V8 also has an optimizing compiler that produces machine code. It runs at runtime (when a function is considered hot), so it's a just-in-time compiler.

这篇关于V8中与JIT编译的混淆的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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