Skip to content

Commit 88f30d0

Browse files
joyeecheungdanielleadams
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 a09a756 commit 88f30d0

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
@@ -380,6 +380,7 @@ require('fs');
380380
require('v8');
381381
require('vm');
382382
require('url');
383+
require('internal/options');
383384

384385
function setupPrepareStackTrace() {
385386
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

89
#include <errno.h>
@@ -1124,6 +1125,10 @@ void Initialize(Local<Object> target,
11241125
.Check();
11251126
}
11261127

1128+
void RegisterExternalReferences(ExternalReferenceRegistry* registry) {
1129+
registry->Register(GetCLIOptions);
1130+
registry->Register(GetEmbedderOptions);
1131+
}
11271132
} // namespace options_parser
11281133

11291134
void HandleEnvOptions(std::shared_ptr<EnvironmentOptions> env_options) {
@@ -1190,3 +1195,5 @@ std::vector<std::string> ParseNodeOptionsEnvVar(
11901195
} // namespace node
11911196

11921197
NODE_MODULE_CONTEXT_AWARE_INTERNAL(options, node::options_parser::Initialize)
1198+
NODE_MODULE_EXTERNAL_REFERENCE(options,
1199+
node::options_parser::RegisterExternalReferences)

0 commit comments

Comments
 (0)