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 ?
-
An "interpreter" typically doesn't compile the bytecode into machine code - Jitting is the task of turbofan, which is however a different topic.ASDFGerte– ASDFGerte2021年10月15日 16:05:14 +00:00Commented Oct 15, 2021 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– boneill2021年10月15日 16:08:33 +00:00Commented Oct 15, 2021 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– Jamal Ahmed2021年10月15日 16:15:21 +00:00Commented Oct 15, 2021 at 16:15
-
i know this flow JS -> parser -> AST -> interpreter -> bytecode -> missing thing -> machine code i wanna know this missing thing.Jamal Ahmed– Jamal Ahmed2021年10月15日 16:17:21 +00:00Commented Oct 15, 2021 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.ASDFGerte– ASDFGerte2021年10月15日 16:20:52 +00:00Commented Oct 15, 2021 at 16:20
1 Answer 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.