|
1 | 1 | // Hello, and welcome to hacking node.js!
|
2 | 2 | //
|
3 |
| -// This file is invoked by node::LoadEnvironment in src/node.cc, and is |
4 |
| -// responsible for bootstrapping the node.js core. As special caution is given |
5 |
| -// to the performance of the startup process, many dependencies are invoked |
6 |
| -// lazily. |
| 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/`. |
| 6 | +// This file is currently run to bootstrap both the main thread and the worker |
| 7 | +// threads. Some setups are conditional, controlled with isMainThread and |
| 8 | +// ownsProcessState. |
| 9 | +// This file is expected not to perform any asynchronous operations itself |
| 10 | +// when being executed - those should be done in either |
| 11 | +// `lib/internal/bootstrap/pre_execution.js` or in main scripts. The majority |
| 12 | +// of the code here focus on setting up the global proxy and the process |
| 13 | +// object in a synchronous manner. |
| 14 | +// As special caution is given to the performance of the startup process, |
| 15 | +// many dependencies are invoked lazily. |
7 | 16 | //
|
8 |
| -// Before this file is run, lib/internal/bootstrap/loaders.js gets run first |
9 |
| -// to bootstrap the internal binding and module loaders, including |
10 |
| -// process.binding(), process._linkedBinding(), internalBinding() and |
11 |
| -// NativeModule. And then { internalBinding, NativeModule } will be passed |
12 |
| -// into this bootstrapper to bootstrap Node.js core. |
| 17 | +// Scripts run before this file: |
| 18 | +// - `lib/internal/bootstrap/context.js`: to setup the v8::Context with |
| 19 | +// Node.js-specific tweaks - this is also done in vm contexts. |
| 20 | +// - `lib/internal/bootstrap/primordials.js`: to save copies of JavaScript |
| 21 | +// builtins that won't be affected by user land monkey-patching for internal |
| 22 | +// modules to use. |
| 23 | +// - `lib/internal/bootstrap/loaders.js`: to setup internal binding and |
| 24 | +// module loaders, including `process.binding()`, `process._linkedBinding()`, |
| 25 | +// `internalBinding()` and `NativeModule`. |
| 26 | +// |
| 27 | +// After this file is run, one of the main scripts under `lib/internal/main/` |
| 28 | +// will be selected by C++ to start the actual execution. The main scripts may |
| 29 | +// run additional setups exported by `lib/internal/bootstrap/pre_execution.js`, |
| 30 | +// depending on the execution mode. |
| 31 | + |
13 | 32 | 'use strict';
|
14 | 33 |
|
15 | 34 | // This file is compiled as if it's wrapped in a function with arguments
|
16 |
| -// passed by node::LoadEnvironment() |
| 35 | +// passed by node::RunBootstrapping() |
17 | 36 | /* global process, loaderExports, isMainThread, ownsProcessState */
|
18 | 37 |
|
19 | 38 | const { internalBinding, NativeModule } = loaderExports;
|
|
0 commit comments