Skip to content

Commit de163d5

Browse files
joyeecheungnodejs-github-bot
authored andcommitted
src: include internal/options in the snapshot
This patch enables internal/options to be included in the snapshot, so that when lazy loading the run time options, the modules only need to make sure that the options are queried lazily and do not have to lazy load the internal/options module together. We can still guarantee that no run time options are serialized into the state-independent bootstrap snapshot with the assertion inside GetCLIOptions(). PR-URL: #42203 Refs: #37476 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Bradley Farias <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Darshan Sen <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Antoine du Hamel <[email protected]>
1 parent d8c4e37 commit de163d5

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

lib/internal/bootstrap/node.js

+1
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,7 @@ require('fs');
338338
require('v8');
339339
require('vm');
340340
require('url');
341+
require('internal/options');
341342

342343
function setupPrepareStackTrace() {
343344
const {

src/node_external_reference.h

+1
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ class ExternalReferenceRegistry {
6767
V(heap_utils) \
6868
V(messaging) \
6969
V(native_module) \
70+
V(options) \
7071
V(os) \
7172
V(performance) \
7273
V(process_methods) \

src/node_options.cc

+7
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
#include "env-inl.h"
55
#include "node_binding.h"
6+
#include "node_external_reference.h"
67
#include "node_internals.h"
78
#if HAVE_OPENSSL
89
#include "openssl/opensslv.h"
@@ -1133,6 +1134,10 @@ void Initialize(Local<Object> target,
11331134
.Check();
11341135
}
11351136

1137+
void RegisterExternalReferences(ExternalReferenceRegistry* registry) {
1138+
registry->Register(GetCLIOptions);
1139+
registry->Register(GetEmbedderOptions);
1140+
}
11361141
} // namespace options_parser
11371142

11381143
void HandleEnvOptions(std::shared_ptr<EnvironmentOptions> env_options) {
@@ -1199,3 +1204,5 @@ std::vector<std::string> ParseNodeOptionsEnvVar(
11991204
} // namespace node
12001205

12011206
NODE_MODULE_CONTEXT_AWARE_INTERNAL(options, node::options_parser::Initialize)
1207+
NODE_MODULE_EXTERNAL_REFERENCE(options,
1208+
node::options_parser::RegisterExternalReferences)

0 commit comments

Comments
 (0)