0

I have learnt about how V8 of chrome browser works in an abstract view from this webpage https://blog.bitsrc.io/how-does-javascript-really-work-part-1-7681dd54a36d

the interpreter(ignition) converts it into bytecode... but then who will convert this bytecode to machine code ?

Jamal Ahmed
  • 411
  • 1
  • 4
  • 10
  • An ["interpreter"](https://en.wikipedia.org/wiki/Interpreter_(computing)) typically doesn't compile the bytecode into machine code - Jitting is the task of turbofan, which is however a different topic. – ASDFGerte Oct 15 '21 at 16:05
  • There's a lot of information available online describing code compilation. What other docs have you read so far, and is there a specific aspect that isn't explained very well? – boneill Oct 15 '21 at 16:08
  • I have only read this article because all other lead me to the java or some lead me to very difficult answers, which i am not able to understand. – Jamal Ahmed Oct 15 '21 at 16:15
  • i know this flow JS -> parser -> AST -> interpreter -> bytecode -> missing thing -> machine code i wanna know this missing thing. – Jamal Ahmed Oct 15 '21 at 16:17
  • Please read the wikipedia article about what an interpreter generally does, which i linked. There is typically a fork there, the code either gets interpreted, or (when hot) jit to machine code. That turbofan happens to use the bytecode [is a coincidence](https://stackoverflow.com/a/69155309/6692606). – ASDFGerte Oct 15 '21 at 16:20

1 Answers1

1

It doesn't turn the bytecode into machine code.

the Ignition interpreter takes the Abstract syntax tree and produce a bytecode from it.

after the bytecode has been produced the Ignition interpreter it start to execute those bytecodes directly.

i know it's a bit confusing when you hear that the interpreter produce a bytecodes and also execute those bytecodes.

but that's actually what the Ignition interpreter does. it's not only executing it's also producing bytecodes so don't get confused by the name.

for example we have the following bytecode

LdaSmi 5

when the Ignition sees that bytecode it will actually call a function from the engine which handles that instruction.

AngryJohn
  • 576
  • 4
  • 10