V8引擎简单介绍

V8 is a JavaScript and WebAssembly engine developed by Google for its Chrome browser.

V8 is free and open-source software that is part of the Chromium project and also used separately in non-browser contexts, notably the Node.js runtime system.

V8是由Google为其Chrome浏览器开发的JavaScriptWebAssembly引擎。

V8是开源软件,属于Chromium项目的一部分,并且在非浏览器上下文中单独使用,特别是在Node.js运行时系统中。

History

Google created V8 for its Chrome browser, and both were first released in 2008.

The lead developer of V8 was Lars Bak, and it was named for the powerful car engine.

For several years, Chrome was faster than other browsers at executing JavaScript.

The V8 assembler is based on the Strongtalk assembler.

On 7 December 2010, a new compiling infrastructure named Crankshaft was released, with speed improvements.

Google为其Chrome浏览器创建了V8,两者最初都是在2008年发布的。

V8的首席开发者是Lars Bak,它的命名取自强大的汽车引擎

在几年的时间里,Chrome在执行JavaScript方面比其他浏览器更快。

V8的汇编器基于Strongtalk汇编器

在2010年12月7日,发布了一个名为Crankshaft的新的编译基础设施,获得了速度上的改进。

In version 41 of Chrome in 2015, project TurboFan was added to provide more performance improvements with previously challenging workloads such as asm.js.

Much of V8’s development is strongly inspired by the Java HotSpot Virtual Machine developed by Sun Microsystems, with the newer execution pipelines being very similar to those of HotSpot's.

在2015年Chrome的41版本中,项目TurboFan被添加,以提供更多性能改进,先前具有挑战性的工作负载,例如asm.js

V8的许多开发受到了Sun Microsystems开发的Java HotSpot虚拟机的强烈启发,更新的执行流水线HotSpot的非常相似。

Support for the new WebAssembly language began in 2015.

In 2016, the Ignition interpreter was added to V8 with the design goal of reducing the memory usage on small memory Android phones in comparison with TurboFan and Crankshaft.

对新的WebAssembly语言的支持始于2015年。

2016年,向V8添加了Ignition解释器,旨在减少与TurboFanCrankshaft相比

在小内存Android手机上的内存使用。

Ignition is a register based machine and shares a similar (albeit not the exact same) design to the templating interpreter utilized by HotSpot.

Ignition是一个基于寄存器的机器,与HotSpot使用的模板解释器设计类似(虽然并非完全相同)。

In 2017, V8 shipped a brand-new compiler pipeline, consisting of Ignition (the interpreter) and TurboFan (the optimizing compiler).

在2017年,V8推出了全新的编译器流程, Ignition解释器)和 TurboFan优化编译器)组成。

Starting with V8 version 5.9, Full-codegen (the early baseline compiler) and Crankshaft are no longer used in V8 for JavaScript execution, since the team believed they were no longer able to keep pace with new JavaScript language features and the optimizations those features required.

V8版本5.9开始,Full-codegen(早期基线编译器)和Crankshaft不再用于V8的JavaScript执行,因为团队认为它们无法再跟上新的JavaScript语言特性和这些特性所需的优化

In 2021, a new tiered compilation pipeline was introduced with the release of the SparkPlug compiler, which supplements the existing TurboFan compiler within V8, in a direct parallel to the profiling C1 Compiler used by HotSpot.

In 2023, the Maglev SSA-based compiler was added, which is 10 times slower than Sparkplug but 10 times faster than TurboFan, bridging the gap between Sparkplug and TurboFan for less frequently run loops that do not get “hot” enough to be optimised by TurboFan, as is the case for most web applications that spend more time interacting with the browser than in JavaScript execution.

在2021年,随着SparkPlug编译器的发布,引入了一套新的分层编译流程,它在V8内部补充了现有的TurboFan编译器,直接与HotSpot使用的基于性能分析的C1编译器并行。

到了2023年,添加了基于SSAMaglev编译器,比Sparkplug慢10倍但比TurboFan快10倍,弥合了不够“热”以在TurboFan进行优化的频率较低的循环而言的SparkplugTurboFan之间的差距,这是大多数Web应用的情况,它们花费的时间与浏览器交互要比在JavaScript执行上花费的时间更多。

Design

V8 first generates an abstract syntax tree with its own parser.

Then, Ignition generates bytecode from this syntax tree using the internal V8 bytecode format.

TurboFan compiles this bytecode into machine code.

V8首先使用自己的解析器生成抽象语法树

然后,Ignition使用内部V8字节码格式从这棵语法树生成字节码。

TurboFan将这些字节码编译成机器码

In other words, V8 compiles ECMAScript directly to native machine code using just-in-time compilation before executing it.

The compiled code is additionally optimized (and re-optimized) dynamically at runtime, based on heuristics of the code's execution profile.

Optimization techniques used include inlining, elision of expensive runtime properties, and inline caching.

The garbage collector is a generational incremental collector.

换句话说,V8在执行代码之前直接将ECMAScript编译成本地机器码使用即时编译

编译后的代码在运行时动态进行附加优化(和再优化),基于代码的执行样本的启发式。

使用的优化技术包括内联,省略昂贵的运行时属性,和内联缓存

垃圾回收器是分代 增量 回收器。

Usage

V8 can compile to x86, ARM or MIPS instruction set architectures in both their 32-bit and 64-bit editions;

it has additionally been ported to PowerPC, and to IBM ESA/390 and z/Architecture, for use in servers.

V8 can be used in a browser or integrated into independent projects.

V8可以将代码编译成x86ARMMIPS 指令集体系结构,包括它们的32位64位版本;

此外,V8还被移植到PowerPC,以及用于服务器的IBM ESA/390z/Architecture

V8可以在浏览器中使用,也可以集成到独立项目中。

V8 is used in the following software:

V8被用在以下软件中:

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值