5

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
  • As an observation, your link is a mirror of chromium.googlesource.com/v8/v8.git, which claims "V8 is written in C++ and is used in Google Chrome, the open source browser from Google." Commented Jun 13, 2019 at 17:50

1 Answer 1

5

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.