Skip to content

Commit 8484b40

Browse files
committed
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 ``` 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 d9d0a97 commit 8484b40

32 files changed

+84
-81
lines changed

β€Žlib/assert.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ const { openSync, closeSync, readSync } = require('fs');
3636
const { parseExpressionAt } = require('internal/deps/acorn/dist/acorn');
3737
const { inspect } = require('util');
3838
const { EOL } = require('os');
39-
const { NativeModule } = require('internal/bootstrap_loaders');
39+
const { NativeModule } = require('internal/bootstrap/loaders');
4040

4141
// Escape control characters but not \n and \t to keep the line breaks and
4242
// indentation intact.

β€Žlib/buffer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ const {
4141
// that test/parallel/test-buffer-bindingobj-no-zerofill.js is written.
4242
let isAnyArrayBuffer;
4343
try {
44-
const { internalBinding } = require('internal/bootstrap_loaders');
44+
const { internalBinding } = require('internal/bootstrap/loaders');
4545
isAnyArrayBuffer = internalBinding('types').isAnyArrayBuffer;
4646
} catch (e) {
4747
isAnyArrayBuffer = require('util').types.isAnyArrayBuffer;

β€Žlib/domain.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ const {
3434
ERR_UNHANDLED_ERROR
3535
} = require('internal/errors').codes;
3636
const { createHook } = require('async_hooks');
37-
const { internalBinding } = require('internal/bootstrap_loaders');
37+
const { internalBinding } = require('internal/bootstrap/loaders');
3838

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

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

Lines changed: 4 additions & 4 deletions
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;
@@ -224,6 +224,6 @@
224224
};
225225

226226
// This will be passed to the bootstrapNodeJSCore function in
227-
// bootstrap_node.js.
227+
// bootstrap/node.js.
228228
return loaderExports;
229229
});

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

Lines changed: 1 addition & 1 deletion
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/encoding.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const {
2323

2424
const { isArrayBufferView } = require('internal/util/types');
2525

26-
const { internalBinding } = require('internal/bootstrap_loaders');
26+
const { internalBinding } = require('internal/bootstrap/loaders');
2727
const {
2828
isArrayBuffer
2929
} = internalBinding('types');

β€Žlib/internal/http2/core.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
require('internal/util').assertCrypto();
66

7-
const { internalBinding } = require('internal/bootstrap_loaders');
7+
const { internalBinding } = require('internal/bootstrap/loaders');
88
const { async_id_symbol } = require('internal/async_hooks').symbols;
99
const { UV_EOF } = process.binding('uv');
1010
const http = require('http');

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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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/Translators.js

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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
setInitializeImportMetaObjectCallback

β€Žlib/internal/test/binding.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ process.emitWarning(
88
// These exports should be scoped as specifically as possible
99
// to avoid exposing APIs because even with that warning and
1010
// this file being internal people will still try to abuse it.
11-
const { internalBinding } = require('internal/bootstrap_loaders');
11+
const { internalBinding } = require('internal/bootstrap/loaders');
1212
module.exports = {
1313
ModuleWrap: internalBinding('module_wrap').ModuleWrap,
1414
};

β€Žlib/internal/util/comparisons.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
const { compare } = process.binding('buffer');
44
const { isArrayBufferView } = require('internal/util/types');
5-
const { internalBinding } = require('internal/bootstrap_loaders');
5+
const { internalBinding } = require('internal/bootstrap/loaders');
66
const { isDate, isMap, isRegExp, isSet } = internalBinding('types');
77

88
function objectToString(o) {

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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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');

β€Žlib/string_decoder.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
'use strict';
2323

2424
const { Buffer } = require('buffer');
25-
const { internalBinding } = require('internal/bootstrap_loaders');
25+
const { internalBinding } = require('internal/bootstrap/loaders');
2626
const {
2727
kIncompleteCharactersStart,
2828
kIncompleteCharactersEnd,

β€Žlib/util.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ const {
3939
kRejected,
4040
} = process.binding('util');
4141

42-
const { internalBinding } = require('internal/bootstrap_loaders');
42+
const { internalBinding } = require('internal/bootstrap/loaders');
4343
const types = internalBinding('types');
4444
Object.assign(types, require('internal/util/types'));
4545
const {

β€Žnode.gyp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
'node_lib_target_name%': 'node_lib',
2525
'node_intermediate_lib_type%': 'static_library',
2626
'library_files': [
27-
'lib/internal/bootstrap_loaders.js',
28-
'lib/internal/bootstrap_node.js',
27+
'lib/internal/bootstrap/loaders.js',
28+
'lib/internal/bootstrap/node.js',
2929
'lib/async_hooks.js',
3030
'lib/assert.js',
3131
'lib/buffer.js',

β€Žsrc/node.cc

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ bool config_experimental_vm_modules = false;
246246

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

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

265265
bool v8_initialized = false;
@@ -3319,23 +3319,23 @@ static Local<Function> GetBootstrapper(Environment* env, Local<String> source,
33193319
// are not safe to ignore.
33203320
try_catch.SetVerbose(false);
33213321

3322-
// Execute the factory javascript file
3323-
Local<Value> factory_v = ExecuteString(env, source, script_name);
3322+
// Execute the bootstrapper javascript file
3323+
Local<Value> bootstrapper_v = ExecuteString(env, source, script_name);
33243324
if (try_catch.HasCaught()) {
33253325
ReportException(env, try_catch);
33263326
exit(10);
33273327
}
33283328

3329-
CHECK(factory_v->IsFunction());
3330-
Local<Function> factory = Local<Function>::Cast(factory_v);
3329+
CHECK(bootstrapper_v->IsFunction());
3330+
Local<Function> bootstrapper = Local<Function>::Cast(bootstrapper_v);
33313331

3332-
return scope.Escape(factory);
3332+
return scope.Escape(bootstrapper);
33333333
}
33343334

3335-
static bool ExecuteBootstrapper(Environment* env, Local<Function> factory,
3335+
static bool ExecuteBootstrapper(Environment* env, Local<Function> bootstrapper,
33363336
int argc, Local<Value> argv[],
33373337
Local<Value>* out) {
3338-
bool ret = factory->Call(
3338+
bool ret = bootstrapper->Call(
33393339
env->context(), Null(env->isolate()), argc, argv).ToLocal(out);
33403340

33413341
// If there was an error during bootstrap then it was either handled by the
@@ -3362,16 +3362,18 @@ void LoadEnvironment(Environment* env) {
33623362
// are not safe to ignore.
33633363
try_catch.SetVerbose(false);
33643364

3365-
// The factory scripts are lib/internal/bootstrap_loaders.js and
3366-
// lib/internal/bootstrap_node.js, each included as a static C string
3365+
// The bootstrapper scripts are lib/internal/bootstrap/loaders.js and
3366+
// lib/internal/bootstrap/node.js, each included as a static C string
33673367
// defined in node_javascript.h, generated in node_javascript.cc by
33683368
// node_js2c.
3369+
Local<String> loaders_name =
3370+
FIXED_ONE_BYTE_STRING(env->isolate(), "internal/bootstrap/loaders.js");
33693371
Local<Function> loaders_bootstrapper =
3370-
GetBootstrapper(env, LoadersBootstrapperSource(env),
3371-
FIXED_ONE_BYTE_STRING(env->isolate(), "bootstrap_loaders.js"));
3372+
GetBootstrapper(env, LoadersBootstrapperSource(env), loaders_name);
3373+
Local<String> node_name =
3374+
FIXED_ONE_BYTE_STRING(env->isolate(), "internal/bootstrap/node.js");
33723375
Local<Function> node_bootstrapper =
3373-
GetBootstrapper(env, NodeBootstrapperSource(env),
3374-
FIXED_ONE_BYTE_STRING(env->isolate(), "bootstrap_node.js"));
3376+
GetBootstrapper(env, NodeBootstrapperSource(env), node_name);
33753377

33763378
// Add a reference to the global object
33773379
Local<Object> global = env->context()->Global();
@@ -4285,7 +4287,7 @@ void Init(int* argc,
42854287
#endif
42864288

42874289
// Needed for access to V8 intrinsics. Disabled again during bootstrapping,
4288-
// see lib/internal/bootstrap_node.js.
4290+
// see lib/internal/bootstrap/node.js.
42894291
const char allow_natives_syntax[] = "--allow_natives_syntax";
42904292
V8::SetFlagsFromString(allow_natives_syntax,
42914293
sizeof(allow_natives_syntax) - 1);

β€Žsrc/node_internals.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,13 +183,13 @@ extern bool config_experimental_vm_modules;
183183

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

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

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

β€Žsrc/node_url.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2275,7 +2275,7 @@ const Local<Value> URL::ToObject(Environment* env) const {
22752275
// The SetURLConstructor method must have been called already to
22762276
// set the constructor function used below. SetURLConstructor is
22772277
// called automatically when the internal/url.js module is loaded
2278-
// during the internal/bootstrap_node.js processing.
2278+
// during the internal/bootstrap/node.js processing.
22792279
ret = env->url_constructor_function()
22802280
->Call(env->context(), undef, arraysize(argv), argv);
22812281
}

β€Žtest/message/core_line_numbers.out

Lines changed: 1 addition & 1 deletion
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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@ AssertionError [ERR_ASSERTION]: 1 strictEqual 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

Lines changed: 12 additions & 12 deletions
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

Lines changed: 3 additions & 3 deletions
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

Lines changed: 4 additions & 4 deletions
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:*:*)

0 commit comments

Comments
Β (0)