Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 4e82521

Browse filesBrowse files
joyeecheungdanielleadams
authored andcommitted
bootstrap: update comments in bootstrap/node.js
The comments in bootstrap/node.js are now out of date due to recent changes to the bootstrap process. Update them to reflect the current status. PR-URL: #44726 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
1 parent 9151439 commit 4e82521
Copy full SHA for 4e82521

File tree

Expand file treeCollapse file tree

1 file changed

+32
-16
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+32
-16
lines changed
Open diff view settings
Collapse file

‎lib/internal/bootstrap/node.js‎

Copy file name to clipboardExpand all lines: lib/internal/bootstrap/node.js
+32-16Lines changed: 32 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,55 @@
11
// Hello, and welcome to hacking node.js!
22
//
3-
// This file is invoked by `node::RunBootstrapping()` in `src/node.cc`, and is
4-
// responsible for setting up node.js core before executing main scripts
5-
// under `lib/internal/main/`.
3+
// This file is invoked by `Realm::BootstrapNode()` in `src/node_realm.cc`,
4+
// and is responsible for setting up Node.js core before main scripts
5+
// under `lib/internal/main/` are executed.
66
//
7-
// This file is expected not to perform any asynchronous operations itself
7+
// By default, Node.js binaries come with an embedded V8 startup snapshot
8+
// that is generated at build-time with a `node_mksnapshot` executable.
9+
// The snapshot generation code can be found in `SnapshotBuilder::Generate()`
10+
// from `src/node_snapshotable.cc`.
11+
// This snapshot captures the V8 heap initialized by scripts under
12+
// `lib/internal/bootstrap/`, including this file. When initializing the main
13+
// thread, Node.js deserializes the heap from the snapshot, instead of actually
14+
// running this script and others in `lib/internal/bootstrap/`. To disable this
15+
// behavior, pass `--no-node-snapshot` when starting the process so that
16+
// Node.js actually runs this script to initialize the heap.
17+
//
18+
// This script is expected not to perform any asynchronous operations itself
819
// when being executed - those should be done in either
9-
// `lib/internal/process/pre_execution.js` or in main scripts. The majority
10-
// of the code here focuses on setting up the global proxy and the process
11-
// object in a synchronous manner.
12-
// As special caution is given to the performance of the startup process,
13-
// many dependencies are invoked lazily.
20+
// `lib/internal/process/pre_execution.js` or in main scripts. It should not
21+
// query any run-time states (e.g. command line arguments, environment
22+
// variables) when being executed - functions in this script that are invoked
23+
// at a later time can, however, query those states lazily.
24+
// The majority of the code here focuses on setting up the global object and
25+
// the process object in a synchronous, environment-independent manner.
1426
//
1527
// Scripts run before this file:
16-
// - `lib/internal/per_context/primordials.js`: to save copies of JavaScript
28+
// - `lib/internal/per_context/primordials.js`: this saves copies of JavaScript
1729
// builtins that won't be affected by user land monkey-patching for internal
1830
// modules to use.
19-
// - `lib/internal/bootstrap/loaders.js`: to setup internal binding and
31+
// - `lib/internal/per_context/domexception.js`: implementation of the
32+
// `DOMException` class.
33+
// - `lib/internal/per_context/messageport.js`: JS-side components of the
34+
// `MessagePort` implementation.
35+
// - `lib/internal/bootstrap/loaders.js`: this sets up internal binding and
2036
// module loaders, including `process.binding()`, `process._linkedBinding()`,
2137
// `internalBinding()` and `BuiltinModule`.
2238
//
23-
// This file is run to bootstrap both the main thread and the worker threads.
24-
// After this file is run, certain properties are setup according to the
25-
// configuration of the Node.js instance using the files in
39+
// The initialization done in this script is included in both the main thread
40+
// and the worker threads. After this, further initialization is done based
41+
// on the configuration of the Node.js instance by executing the scripts in
2642
// `lib/internal/bootstrap/switches/`.
2743
//
2844
// Then, depending on how the Node.js instance is launched, one of the main
2945
// scripts in `lib/internal/main` will be selected by C++ to start the actual
3046
// execution. They may run additional setups exported by
31-
// `lib/internal/process/pre_execution.js` depending on the runtime states.
47+
// `lib/internal/process/pre_execution.js` depending on the run-time states.
3248

3349
'use strict';
3450

3551
// This file is compiled as if it's wrapped in a function with arguments
36-
// passed by node::RunBootstrapping()
52+
// passed by `BuiltinLoader::CompileAndCall()`.
3753
/* global process, require, internalBinding, primordials */
3854

3955
setupPrepareStackTrace();

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.