Are array methods in V8 written in C++, Torque or is the JS converted to machine code at run time?

眉间皱痕 提交于 2020-01-25 02:20:41

问题


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

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

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?

Thanks!


回答1:


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.



来源:https://stackoverflow.com/questions/56585898/are-array-methods-in-v8-written-in-c-torque-or-is-the-js-converted-to-machine

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!