V8 中的数组方法是用 C++、Torque 编写的还是在运行时将 JS 转换为机器码? [英] Are array methods in V8 written in C++, Torque or is the JS converted to machine code at run time?

查看:29
本文介绍了V8 中的数组方法是用 C++、Torque 编写的还是在运行时将 JS 转换为机器码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在学习 V8 运行时,我想知道诸如 array.map 之类的数组方法是否是在 V8 中用 C++ 编写的?我在这里看到一些让我感到困惑的 Torque 文件,所以我想知道它们是否是用 Torque 而不是 C++ 编写的?

I'm learning about the V8 run time and I'm wondering if array methods for example, such as array.map, are written in C++ inside V8? I see here some Torque files that confuse me so I am wondering if maybe they are written in Torque instead of C++?

https://github.com/v8/v8/blob/master/src/builtins/array-map.tq

我的理解是,V8 使用即时 (JIT) 概念将 JavaScript 代码转换为机器代码.

My understanding is that V8 converts the JavaScript code to machine code using a Just in Time (JIT) concept.

所以我想我想知道是否有 array.map 的 C++ 或 Torque 等价物,或者 C++ 或 Torque 模块是否仅用于转换 array.map 的 JS 版本 到机器码?

So I guess I'm wondering if there are C++ or Torque equivalents of array.map, or are the C++ or Torque modules only meant to convert the JS version of array.map to machine code?

谢谢!

推荐答案

V8 开发人员在这里.我们有几种不同的内置"实现技术:有些是用 C++ 编写的,有些是用 Torque 编写的,有些是我们称之为 CodeStubAssembler 的,还有一些是直接用汇编编写的.在 V8 的早期版本中,有些是用 JavaScript 实现的.这些策略中的每一个都有自己的优势(权衡代码复杂性、可调试性、各种情况下的性能、二进制大小和内存消耗);此外,代码随着时间的推移不断发展总是有历史原因的.

V8 developer here. We have several different implementation techniques for "builtins": some are written in C++, some in Torque, some in what we call CodeStubAssembler, and a few directly in assembly. In earlier versions of V8, some were implemented in JavaScript. Each of these strategies has its own strengths (trading off code complexity, debuggability, performance in various situations, binary size, and memory consumption); plus there is always the historical reason that code has evolved over time.

这篇关于V8 中的数组方法是用 C++、Torque 编写的还是在运行时将 JS 转换为机器码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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