I. Explanation of related nouns
Compiler: Compiled languages are compiled into a binary file before code is executed, which is then ready to run. C ++, C, go interpreters: interpreted languages that are dynamically interpreted and executed at every run time. Python, JavaScript,
Interpreter translation code flow: source code (through lexical analysis, syntax analysis)===== Abstract syntax tree (AST) (lexical analysis)===== bytecode (interpretation execution)===== execution
V8 executes the code flow
1, source code through lexical analysis and parsing to generate abstract syntax and execution context (some code environment information: variable environment, lexical environment, this, external environment). Abstract syntax trees are needed in both ESLint (check JavaScript code writing specifications) and Babel (ES6 to ES5).
2. Generate bytecode through interpreter and interpret and execute bytecode. Why there is bytecode: V8 originally converted abstract syntax trees into machine code, but took up too much memory on the phone, using imported bytecode.
3. If a piece of code is found to have been repeatedly executed during interpreter execution, it will use the compiler to compile it into machine code, and then need to execute the code again, only the machine code needs to be executed.
Bytecode + interpreter and compiler this technique is called just-in-time compilation (JIT).