This project is an API reference for Google's open-source v8 JavaScript
engine.
-
Fetch the latest version
v8
source code:$ git submodule init $ git submodule foreach git pull
-
Download doxygen binaries into
doxygen
directory. -
Run command for generating documentations:
$ ./doxygen/doxygen.exe
-
Done. All output
HTML
files are in thedocs
directory.
Recommend: You don't know JS yet - compiling code
JavaScript is in fact parsed/compiled in a separate phase before execution begins. Scope is primarily determined during compilation.
In class compiler theory, a program is processed by a compiler in three basic stages:
-
Tokenizing/Lexing: breaking up a string of characters into meaningful (to the language) chunks, called tokens.
-
Parsing: taking a stream(array) of tokens and turning it init a tree of nested elements. This is called an
abstract syntax tree(abbr, AST)
. -
Code generation: taking an AST and turning it into executable code.
-
JavaScript engines - how do they even?
-
Just in time compilation, abbr as
JIT
, 即时编译, just compiling the source code just in time as we need it -
re-compile
hot
functions with type information from previous execution, de-optimize if the type has changed#虽然 JS 是动态类型,但
v8
内部仍然是根据类型信息来优化代码实现 JIT 优化。# -
As a engine-level performance tip, always construct the same type of objects.#
function load(obj: { x: number, a: number, b: number}) { return obj.x } load(x: undefined, a: 3, b: 9) load(x: 3, a: undefined, b: 9) load(x: 4, a: 7, b: undefined)
-
Write code that looks like statically typed.
Because JIT optimization depends on type information.
-