본문 바로가기

Programming/JavaScript

The JavaScript Engine and Runtime

Step 1. Parsing

= Read the code

Parsing 과정동안 Abstract Syntax Trees (AST) data structure로 parse됨

 

Step 2. Compilation

Generated AST compiled to machine code

 

Step 3. Execution

machine code는 after compilation right away 바로 실행됨

due to JIT compilation

 

very unoptimized code in the begginning

-> optimization 과정을 거침 (during execution)

이 과정을 여러번 거치기도 함

각 최적화 과정 후에는 이전의 unoptimized code가 더 optimized된 코드로 바뀜 (without ever stopping execution)

그래서 V8이 속도가 빠른거임

 

이 과정은 main thread가 아닌 special thread에서 진행됨