Skip to content

Commit ebdcf91

Browse files
joyeecheungtargos
authored andcommitted
src: put bootstrappers in lib/internal/bootstrap/
Create `lib/internal/bootstrap/` and put bootstrappers there: Before: ``` lib/internal β”œβ”€β”€ ... β”œβ”€β”€ bootstrap_loaders.js └── bootstrap_node.js ``` After: ``` lib/internal β”œβ”€β”€ ... └── bootstrap β”œβ”€β”€ loaders.js └── node.js ``` Backport-PR-URL: #19374 PR-URL: #19177 Refs: #19112 Reviewed-By: Gus Caplan <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]>
1 parent ff7a116 commit ebdcf91

25 files changed

+76
-73
lines changed

β€Žlib/domain.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ const util = require('util');
3030
const EventEmitter = require('events');
3131
const errors = require('internal/errors');
3232
const { createHook } = require('async_hooks');
33-
const { internalBinding } = require('internal/bootstrap_loaders');
33+
const { internalBinding } = require('internal/bootstrap/loaders');
3434

3535
// overwrite process.domain with a getter/setter that will allow for more
3636
// effective optimizations

β€Žlib/internal/bootstrap_loaders.js β€Žlib/internal/bootstrap/loaders.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// modules. In contrast, user land modules are loaded using
33
// lib/module.js (CommonJS Modules) or lib/internal/loader/* (ES Modules).
44
//
5-
// This file is compiled and run by node.cc before bootstrap_node.js
5+
// This file is compiled and run by node.cc before bootstrap/node.js
66
// was called, therefore the loaders are bootstraped before we start to
77
// actually bootstrap Node.js. It creates the following objects:
88
//
@@ -29,7 +29,7 @@
2929
// so they can be loaded faster without the cost of I/O. This class makes the
3030
// lib/internal/*, deps/internal/* modules and internalBinding() available by
3131
// default to core modules, and lets the core modules require itself via
32-
// require('internal/bootstrap_loaders') even when this file is not written in
32+
// require('internal/bootstrap/loaders') even when this file is not written in
3333
// CommonJS style.
3434
//
3535
// Other objects:
@@ -111,7 +111,7 @@
111111
// Think of this as module.exports in this file even though it is not
112112
// written in CommonJS style.
113113
const loaderExports = { internalBinding, NativeModule };
114-
const loaderId = 'internal/bootstrap_loaders';
114+
const loaderId = 'internal/bootstrap/loaders';
115115
NativeModule.require = function(id) {
116116
if (id === loaderId) {
117117
return loaderExports;
@@ -211,6 +211,6 @@
211211
};
212212

213213
// This will be passed to the bootstrapNodeJSCore function in
214-
// bootstrap_node.js.
214+
// bootstrap/node.js.
215215
return loaderExports;
216216
});

β€Žlib/internal/bootstrap_node.js β€Žlib/internal/bootstrap/node.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// to the performance of the startup process, many dependencies are invoked
66
// lazily.
77
//
8-
// Before this file is run, lib/internal/bootstrap_loaders.js gets run first
8+
// Before this file is run, lib/internal/bootstrap/loaders.js gets run first
99
// to bootstrap the internal binding and module loaders, including
1010
// process.binding(), process._linkedBinding(), internalBinding() and
1111
// NativeModule. And then { internalBinding, NativeModule } will be passed

β€Žlib/internal/loader/CreateDynamicModule.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict';
22

3-
const { internalBinding } = require('internal/bootstrap_loaders');
3+
const { internalBinding } = require('internal/bootstrap/loaders');
44
const { ModuleWrap } = internalBinding('module_wrap');
55
const debug = require('util').debuglog('esm');
66
const ArrayJoin = Function.call.bind(Array.prototype.join);

β€Žlib/internal/loader/DefaultResolve.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
const { URL } = require('url');
44
const CJSmodule = require('module');
55
const internalFS = require('internal/fs');
6-
const { NativeModule, internalBinding } = require('internal/bootstrap_loaders');
6+
const { NativeModule, internalBinding } = require('internal/bootstrap/loaders');
77
const { extname } = require('path');
88
const { realpathSync } = require('fs');
99
const preserveSymlinks = !!process.binding('config').preserveSymlinks;

β€Žlib/internal/loader/ModuleJob.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict';
22

3-
const { internalBinding } = require('internal/bootstrap_loaders');
3+
const { internalBinding } = require('internal/bootstrap/loaders');
44
const { ModuleWrap } = internalBinding('module_wrap');
55
const { SafeSet, SafePromise } = require('internal/safe_globals');
66
const { decorateErrorStack } = require('internal/util');

β€Žlib/internal/loader/ModuleWrap.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22

33
// exposes ModuleWrap for testing
44

5-
const { internalBinding } = require('internal/bootstrap_loaders');
5+
const { internalBinding } = require('internal/bootstrap/loaders');
66
module.exports = internalBinding('module_wrap').ModuleWrap;

β€Žlib/internal/loader/Translators.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict';
22

3-
const { NativeModule, internalBinding } = require('internal/bootstrap_loaders');
3+
const { NativeModule, internalBinding } = require('internal/bootstrap/loaders');
44
const { ModuleWrap } = internalBinding('module_wrap');
55
const internalCJSModule = require('internal/module');
66
const CJSModule = require('module');

β€Žlib/internal/process/modules.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict';
22

3-
const { internalBinding } = require('internal/bootstrap_loaders');
3+
const { internalBinding } = require('internal/bootstrap/loaders');
44
const {
55
setImportModuleDynamicallyCallback
66
} = internalBinding('module_wrap');

β€Žlib/internal/vm/Module.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict';
22

3-
const { internalBinding } = require('internal/bootstrap_loaders');
3+
const { internalBinding } = require('internal/bootstrap/loaders');
44
const { emitExperimentalWarning } = require('internal/util');
55
const { URL } = require('internal/url');
66
const { kParsingContext, isContext } = process.binding('contextify');

β€Žlib/module.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
'use strict';
2323

24-
const { NativeModule } = require('internal/bootstrap_loaders');
24+
const { NativeModule } = require('internal/bootstrap/loaders');
2525
const util = require('util');
2626
const { decorateErrorStack } = require('internal/util');
2727
const { getURLFromFilePath } = require('internal/url');

β€Žnode.gyp

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
'node_lib_target_name%': 'node_lib',
2626
'node_intermediate_lib_type%': 'static_library',
2727
'library_files': [
28-
'lib/internal/bootstrap_loaders.js',
29-
'lib/internal/bootstrap_node.js',
28+
'lib/internal/bootstrap/loaders.js',
29+
'lib/internal/bootstrap/node.js',
3030
'lib/async_hooks.js',
3131
'lib/assert.js',
3232
'lib/buffer.js',

β€Žsrc/node.cc

+17-15
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ bool config_experimental_vm_modules = false;
250250

251251
// Set in node.cc by ParseArgs when --loader is used.
252252
// Used in node_config.cc to set a constant on process.binding('config')
253-
// that is used by lib/internal/bootstrap_node.js
253+
// that is used by lib/internal/bootstrap/node.js
254254
std::string config_userland_loader; // NOLINT(runtime/string)
255255

256256
// Set by ParseArgs when --pending-deprecation or NODE_PENDING_DEPRECATION
@@ -263,7 +263,7 @@ std::string config_warning_file; // NOLINT(runtime/string)
263263
// Set in node.cc by ParseArgs when --expose-internals or --expose_internals is
264264
// used.
265265
// Used in node_config.cc to set a constant on process.binding('config')
266-
// that is used by lib/internal/bootstrap_node.js
266+
// that is used by lib/internal/bootstrap/node.js
267267
bool config_expose_internals = false;
268268

269269
bool v8_initialized = false;
@@ -3645,23 +3645,23 @@ static Local<Function> GetBootstrapper(Environment* env, Local<String> source,
36453645
// are not safe to ignore.
36463646
try_catch.SetVerbose(false);
36473647

3648-
// Execute the factory javascript file
3649-
Local<Value> factory_v = ExecuteString(env, source, script_name);
3648+
// Execute the bootstrapper javascript file
3649+
Local<Value> bootstrapper_v = ExecuteString(env, source, script_name);
36503650
if (try_catch.HasCaught()) {
36513651
ReportException(env, try_catch);
36523652
exit(10);
36533653
}
36543654

3655-
CHECK(factory_v->IsFunction());
3656-
Local<Function> factory = Local<Function>::Cast(factory_v);
3655+
CHECK(bootstrapper_v->IsFunction());
3656+
Local<Function> bootstrapper = Local<Function>::Cast(bootstrapper_v);
36573657

3658-
return scope.Escape(factory);
3658+
return scope.Escape(bootstrapper);
36593659
}
36603660

3661-
static bool ExecuteBootstrapper(Environment* env, Local<Function> factory,
3661+
static bool ExecuteBootstrapper(Environment* env, Local<Function> bootstrapper,
36623662
int argc, Local<Value> argv[],
36633663
Local<Value>* out) {
3664-
bool ret = factory->Call(
3664+
bool ret = bootstrapper->Call(
36653665
env->context(), Null(env->isolate()), argc, argv).ToLocal(out);
36663666

36673667
// If there was an error during bootstrap then it was either handled by the
@@ -3688,16 +3688,18 @@ void LoadEnvironment(Environment* env) {
36883688
// are not safe to ignore.
36893689
try_catch.SetVerbose(false);
36903690

3691-
// The factory scripts are lib/internal/bootstrap_loaders.js and
3692-
// lib/internal/bootstrap_node.js, each included as a static C string
3691+
// The bootstrapper scripts are lib/internal/bootstrap/loaders.js and
3692+
// lib/internal/bootstrap/node.js, each included as a static C string
36933693
// defined in node_javascript.h, generated in node_javascript.cc by
36943694
// node_js2c.
3695+
Local<String> loaders_name =
3696+
FIXED_ONE_BYTE_STRING(env->isolate(), "internal/bootstrap/loaders.js");
36953697
Local<Function> loaders_bootstrapper =
3696-
GetBootstrapper(env, LoadersBootstrapperSource(env),
3697-
FIXED_ONE_BYTE_STRING(env->isolate(), "bootstrap_loaders.js"));
3698+
GetBootstrapper(env, LoadersBootstrapperSource(env), loaders_name);
3699+
Local<String> node_name =
3700+
FIXED_ONE_BYTE_STRING(env->isolate(), "internal/bootstrap/node.js");
36983701
Local<Function> node_bootstrapper =
3699-
GetBootstrapper(env, NodeBootstrapperSource(env),
3700-
FIXED_ONE_BYTE_STRING(env->isolate(), "bootstrap_node.js"));
3702+
GetBootstrapper(env, NodeBootstrapperSource(env), node_name);
37013703

37023704
// Add a reference to the global object
37033705
Local<Object> global = env->context()->Global();

β€Žsrc/node_internals.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -180,13 +180,13 @@ extern bool config_experimental_vm_modules;
180180

181181
// Set in node.cc by ParseArgs when --loader is used.
182182
// Used in node_config.cc to set a constant on process.binding('config')
183-
// that is used by lib/internal/bootstrap_node.js
183+
// that is used by lib/internal/bootstrap/node.js
184184
extern std::string config_userland_loader;
185185

186186
// Set in node.cc by ParseArgs when --expose-internals or --expose_internals is
187187
// used.
188188
// Used in node_config.cc to set a constant on process.binding('config')
189-
// that is used by lib/internal/bootstrap_node.js
189+
// that is used by lib/internal/bootstrap/node.js
190190
extern bool config_expose_internals;
191191

192192
// Set in node.cc by ParseArgs when --redirect-warnings= is used.

β€Žsrc/node_url.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -2311,7 +2311,7 @@ const Local<Value> URL::ToObject(Environment* env) const {
23112311
// The SetURLConstructor method must have been called already to
23122312
// set the constructor function used below. SetURLConstructor is
23132313
// called automatically when the internal/url.js module is loaded
2314-
// during the internal/bootstrap_node.js processing.
2314+
// during the internal/bootstrap/node.js processing.
23152315
ret = env->url_constructor_function()
23162316
->Call(env->context(), undef, arraysize(argv), argv);
23172317
}

β€Žtest/message/core_line_numbers.out

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ RangeError: Invalid input
1212
at tryModuleLoad (module.js:*:*)
1313
at Function.Module._load (module.js:*:*)
1414
at Function.Module.runMain (module.js:*:*)
15-
at startup (bootstrap_node.js:*:*)
15+
at startup (internal/bootstrap/node.js:*:*)

β€Žtest/message/error_exit.out

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@ AssertionError [ERR_ASSERTION]: 1 === 2
1111
at tryModuleLoad (module.js:*:*)
1212
at Function.Module._load (module.js:*:*)
1313
at Function.Module.runMain (module.js:*:*)
14-
at startup (bootstrap_node.js:*:*)
15-
at bootstrapNodeJSCore (bootstrap_node.js:*:*)
14+
at startup (internal/bootstrap/node.js:*:*)
15+
at bootstrapNodeJSCore (internal/bootstrap/node.js:*:*)

β€Žtest/message/eval_messages.out

+12-12
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ SyntaxError: Strict mode code may not include a with statement
88
at Object.runInThisContext (vm.js:*:*)
99
at Object.<anonymous> ([eval]-wrapper:*:*)
1010
at Module._compile (module.js:*:*)
11-
at evalScript (bootstrap_node.js:*:*)
12-
at startup (bootstrap_node.js:*:*)
13-
at bootstrapNodeJSCore (bootstrap_node.js:*:*)
11+
at evalScript (internal/bootstrap/node.js:*:*)
12+
at startup (internal/bootstrap/node.js:*:*)
13+
at bootstrapNodeJSCore (internal/bootstrap/node.js:*:*)
1414
42
1515
42
1616
[eval]:1
@@ -23,9 +23,9 @@ Error: hello
2323
at Object.runInThisContext (vm.js:*:*)
2424
at Object.<anonymous> ([eval]-wrapper:*:*)
2525
at Module._compile (module.js:*:*)
26-
at evalScript (bootstrap_node.js:*:*)
27-
at startup (bootstrap_node.js:*:*)
28-
at bootstrapNodeJSCore (bootstrap_node.js:*:*)
26+
at evalScript (internal/bootstrap/node.js:*:*)
27+
at startup (internal/bootstrap/node.js:*:*)
28+
at bootstrapNodeJSCore (internal/bootstrap/node.js:*:*)
2929

3030
[eval]:1
3131
throw new Error("hello")
@@ -37,9 +37,9 @@ Error: hello
3737
at Object.runInThisContext (vm.js:*:*)
3838
at Object.<anonymous> ([eval]-wrapper:*:*)
3939
at Module._compile (module.js:*:*)
40-
at evalScript (bootstrap_node.js:*:*)
41-
at startup (bootstrap_node.js:*:*)
42-
at bootstrapNodeJSCore (bootstrap_node.js:*:*)
40+
at evalScript (internal/bootstrap/node.js:*:*)
41+
at startup (internal/bootstrap/node.js:*:*)
42+
at bootstrapNodeJSCore (internal/bootstrap/node.js:*:*)
4343
100
4444
[eval]:1
4545
var x = 100; y = x;
@@ -51,9 +51,9 @@ ReferenceError: y is not defined
5151
at Object.runInThisContext (vm.js:*:*)
5252
at Object.<anonymous> ([eval]-wrapper:*:*)
5353
at Module._compile (module.js:*:*)
54-
at evalScript (bootstrap_node.js:*:*)
55-
at startup (bootstrap_node.js:*:*)
56-
at bootstrapNodeJSCore (bootstrap_node.js:*:*)
54+
at evalScript (internal/bootstrap/node.js:*:*)
55+
at startup (internal/bootstrap/node.js:*:*)
56+
at bootstrapNodeJSCore (internal/bootstrap/node.js:*:*)
5757

5858
[eval]:1
5959
var ______________________________________________; throw 10

β€Žtest/message/events_unhandled_error_common_trace.out

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ Error: foo:bar
1212
at tryModuleLoad (module.js:*:*)
1313
at Function.Module._load (module.js:*:*)
1414
at Function.Module.runMain (module.js:*:*)
15-
at startup (bootstrap_node.js:*:*)
15+
at startup (internal/bootstrap/node.js:*:*)
1616
Emitted 'error' event at:
1717
at quux (*events_unhandled_error_common_trace.js:*:*)
1818
at Object.<anonymous> (*events_unhandled_error_common_trace.js:*:*)
1919
at Module._compile (module.js:*:*)
2020
[... lines matching original stack trace ...]
21-
at startup (bootstrap_node.js:*:*)
22-
at bootstrapNodeJSCore (bootstrap_node.js:*:*)
21+
at startup (internal/bootstrap/node.js:*:*)
22+
at bootstrapNodeJSCore (internal/bootstrap/node.js:*:*)

β€Žtest/message/events_unhandled_error_nexttick.out

+4-4
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ Error
1010
at tryModuleLoad (module.js:*:*)
1111
at Function.Module._load (module.js:*:*)
1212
at Function.Module.runMain (module.js:*:*)
13-
at startup (bootstrap_node.js:*:*)
14-
at bootstrapNodeJSCore (bootstrap_node.js:*:*)
13+
at startup (internal/bootstrap/node.js:*:*)
14+
at bootstrapNodeJSCore (internal/bootstrap/node.js:*:*)
1515
Emitted 'error' event at:
1616
at process.nextTick (*events_unhandled_error_nexttick.js:*:*)
1717
at process._tickCallback (internal/process/next_tick.js:*:*)
1818
at Function.Module.runMain (module.js:*:*)
19-
at startup (bootstrap_node.js:*:*)
20-
at bootstrapNodeJSCore (bootstrap_node.js:*:*)
19+
at startup (internal/bootstrap/node.js:*:*)
20+
at bootstrapNodeJSCore (internal/bootstrap/node.js:*:*)

β€Žtest/message/events_unhandled_error_sameline.out

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ Error
1010
at tryModuleLoad (module.js:*:*)
1111
at Function.Module._load (module.js:*:*)
1212
at Function.Module.runMain (module.js:*:*)
13-
at startup (bootstrap_node.js:*:*)
14-
at bootstrapNodeJSCore (bootstrap_node.js:*:*)
13+
at startup (internal/bootstrap/node.js:*:*)
14+
at bootstrapNodeJSCore (internal/bootstrap/node.js:*:*)
1515
Emitted 'error' event at:
1616
at Object.<anonymous> (*events_unhandled_error_sameline.js:*:*)
1717
at Module._compile (module.js:*:*)
1818
[... lines matching original stack trace ...]
19-
at bootstrapNodeJSCore (bootstrap_node.js:*:*)
19+
at bootstrapNodeJSCore (internal/bootstrap/node.js:*:*)

β€Žtest/message/nexttick_throw.out

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ ReferenceError: undefined_reference_error_maker is not defined
66
at *test*message*nexttick_throw.js:*:*
77
at process._tickCallback (internal/process/next_tick.js:*:*)
88
at Function.Module.runMain (module.js:*:*)
9-
at startup (bootstrap_node.js:*:*)
10-
at bootstrapNodeJSCore (bootstrap_node.js:*:*)
9+
at startup (internal/bootstrap/node.js:*:*)
10+
at bootstrapNodeJSCore (internal/bootstrap/node.js:*:*)

β€Žtest/message/stdin_messages.out

+8-8
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ SyntaxError: Strict mode code may not include a with statement
88
at Object.runInThisContext (vm.js:*)
99
at Object.<anonymous> ([stdin]-wrapper:*:*)
1010
at Module._compile (module.js:*:*)
11-
at evalScript (bootstrap_node.js:*:*)
12-
at Socket.<anonymous> (bootstrap_node.js:*:*)
11+
at evalScript (internal/bootstrap/node.js:*:*)
12+
at Socket.<anonymous> (internal/bootstrap/node.js:*:*)
1313
at Socket.emit (events.js:*:*)
1414
at endReadableNT (_stream_readable.js:*:*)
1515
at process._tickCallback (internal/process/next_tick.js:*:*)
@@ -25,8 +25,8 @@ Error: hello
2525
at Object.runInThisContext (vm.js:*)
2626
at Object.<anonymous> ([stdin]-wrapper:*:*)
2727
at Module._compile (module.js:*:*)
28-
at evalScript (bootstrap_node.js:*:*)
29-
at Socket.<anonymous> (bootstrap_node.js:*:*)
28+
at evalScript (internal/bootstrap/node.js:*:*)
29+
at Socket.<anonymous> (internal/bootstrap/node.js:*:*)
3030
at Socket.emit (events.js:*:*)
3131
at endReadableNT (_stream_readable.js:*:*)
3232
at process._tickCallback (internal/process/next_tick.js:*:*)
@@ -40,8 +40,8 @@ Error: hello
4040
at Object.runInThisContext (vm.js:*)
4141
at Object.<anonymous> ([stdin]-wrapper:*:*)
4242
at Module._compile (module.js:*:*)
43-
at evalScript (bootstrap_node.js:*:*)
44-
at Socket.<anonymous> (bootstrap_node.js:*:*)
43+
at evalScript (internal/bootstrap/node.js:*:*)
44+
at Socket.<anonymous> (internal/bootstrap/node.js:*:*)
4545
at Socket.emit (events.js:*:*)
4646
at endReadableNT (_stream_readable.js:*:*)
4747
at process._tickCallback (internal/process/next_tick.js:*:*)
@@ -56,8 +56,8 @@ ReferenceError: y is not defined
5656
at Object.runInThisContext (vm.js:*)
5757
at Object.<anonymous> ([stdin]-wrapper:*:*)
5858
at Module._compile (module.js:*:*)
59-
at evalScript (bootstrap_node.js:*:*)
60-
at Socket.<anonymous> (bootstrap_node.js:*:*)
59+
at evalScript (internal/bootstrap/node.js:*:*)
60+
at Socket.<anonymous> (internal/bootstrap/node.js:*:*)
6161
at Socket.emit (events.js:*:*)
6262
at endReadableNT (_stream_readable.js:*:*)
6363
at process._tickCallback (internal/process/next_tick.js:*:*)

0 commit comments

Comments
Β (0)