javascript - V8 的点火装置究竟有什么作用?

标签 javascript google-chrome v8

关于 https://v8.dev/docs/ignition我们可以看到:

Ignition is a fast low-level register-based interpreter written using the backend of TurboFan

关于 https://docs.google.com/document/d/11T2CRex9hXxoJwbYqVQ32yIPMh0uouUZLdyrtmMoL44/edit?ts=56f27d9d#

The aim of the Ignition project is to build an interpreter for V8 which executes a low-level bytecode, thus enabling run-once or non-hot code to be stored more compactly in bytecode form.

The interpreter itself consists of a set of bytecode handler code snippets, each of which handles a specific bytecode and dispatches to the handler for the next bytecode. These bytecode handlers

To compile a function to bytecode, the JavaScript code is parsed to generate its AST (Abstract Syntax Tree). The BytecodeGenerator walks this AST and generates bytecode for each of the AST nodes as appropriate.

Once the graph for a bytecode handler is produced it is passed through a simplified version of Turbofan’s pipeline and assigned to the corresponding entry in the interpreter table.

看来 Ignition 的工作是将 BytecodeGenerator 生成的字节码转换为字节码处理程序并通过 Turbofan 执行。

但是在这里: enter image description here

这里: enter image description here

可以看出,产生字节码的是ignition。

更重要的是,在这个视频中https://youtu.be/p-iiEDtpy6I?t=722 Ignition 据说是一个基线编译器。

那是什么? 基线编译器?字节码解释器? AST 到字节码转换器?

这张图片似乎最合适: enter image description here

ignition 只是一个解释器,之前的一切都是无名字节码生成器/优化器。

enter image description here

最佳答案

这里是 V8 开发人员。

On https://v8.dev/docs/ignition we can see that:

Ignition is a fast low-level register-based interpreter written using the backend of TurboFan

是的,这就是总结。要添加更多细节:

  • “Ignition”这个名称指的是字节码生成器和字节码解释器。通常,整个事情也被视为一个大黑盒子,随便称为“解释器”,这有时会导致一些术语混淆。
  • 字节码生成器采用解析器为给定 JavaScript 函数生成的 AST,并从中生成字节码。
  • 字节码解释器获取字节码生成器生成的字节码,并通过将其发送到一组字节码处理程序来解释它来执行它。
  • 构成字节码解释器的字节码处理程序是使用 Turbofan 管道的一部分生成的。这发生在 V8 编译时,而不是运行时。换句话说,您需要 Turbofan 来构建(部分)Ignition,但不需要运行 Ignition。
  • 解析器(及其生成的 AST/抽象语法树不是 Ignition 的一部分。

Once the graph for a bytecode handler is produced it is passed through a simplified version of Turbofan’s pipeline and assigned to the corresponding entry in the interpreter table.

看来Ignition的工作就是将BytecodeGenerator生成的字节码转换为字节码处理器,通过Turbofan执行

设计文档的这一部分讨论了使用 Turbofan 的部分“提前”(即编译 V8 时)生成字节码处理程序。在运行时,字节码不会转换为处理程序,它是由现有的固定处理程序集“处理”(=运行、执行、解释),并且不涉及 Turbofan。

What is more, in this video https://youtu.be/p-iiEDtpy6I?t=722 Ignition is said to be a baseline compiler.

在那一刻,谈话指的是所有现代 JavaScript 引擎都有一个“基线编译器”的普遍想法(在非常普遍的概念意义上——我同意幻灯片本可以使这一点更清楚)。请注意,该幻灯片并未提及任何有关 Ignition 的内容。 下一张 幻灯片说 Ignition 在 V8 中扮演了这个 Angular 色。因此更准确的说法是“Ignition 取代了基线编译器”或“Ignition 是基线执行引擎”。或者您可以稍微重新定义您的术语并说“Ignition 是一个生成字节码然后解释它的编译器”。

ignition is just an interpreter and everything before is no-name bytecode generator/optimizer thing

该幻灯片将“解释器”框显示为“Ignition 字节码管道”的一部分。字节码生成器/优化器也是 Ignition 的一部分。

关于javascript - V8 的点火装置究竟有什么作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54957946/

相关文章:

javascript - 如何为移动设备实现滑动手势?

c++ - 如何在 native Node 模块中维护零拷贝?

javascript - 无法正确显示号码

python - 开发者模式扩展在 Chrome 中弹出

javascript - 使用 DELETE 获取 api 问题 - 即使 cors 良好,也会更改 OPTIONS

javascript - 无法在 Chrome 编辑 View 中验证日期格式

javascript - 如何在嵌入式 V8 中调试 javascript?

javascript - Function() 构造函数是否没有像 eval 那样被 V8 优化?

javascript - 在 AngularJS 中删除 DOM 元素之前我应该​​做什么?

javascript - 将属性值转换为对象(jquery 或 javascript)