Skip to content

Commit

Permalink
src: include internal/options in the snapshot
Browse files Browse the repository at this point in the history
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 <anna@addaleax.net>
Reviewed-By: Bradley Farias <bradley.meck@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
  • Loading branch information
joyeecheung authored and bengl committed Mar 20, 2022
1 parent fe01940 commit 9fc4b9b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/internal/bootstrap/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,7 @@ require('fs');
require('v8');
require('vm');
require('url');
require('internal/options');

function setupPrepareStackTrace() {
const {
Expand Down
1 change: 1 addition & 0 deletions src/node_external_reference.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ class ExternalReferenceRegistry {
V(heap_utils) \
V(messaging) \
V(native_module) \
V(options) \
V(os) \
V(performance) \
V(process_methods) \
Expand Down
7 changes: 7 additions & 0 deletions src/node_options.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#include "env-inl.h"
#include "node_binding.h"
#include "node_external_reference.h"
#include "node_internals.h"
#if HAVE_OPENSSL
#include "openssl/opensslv.h"
Expand Down Expand Up @@ -1132,6 +1133,10 @@ void Initialize(Local<Object> target,
.Check();
}

void RegisterExternalReferences(ExternalReferenceRegistry* registry) {
registry->Register(GetCLIOptions);
registry->Register(GetEmbedderOptions);
}
} // namespace options_parser

void HandleEnvOptions(std::shared_ptr<EnvironmentOptions> env_options) {
Expand Down Expand Up @@ -1198,3 +1203,5 @@ std::vector<std::string> ParseNodeOptionsEnvVar(
} // namespace node

NODE_MODULE_CONTEXT_AWARE_INTERNAL(options, node::options_parser::Initialize)
NODE_MODULE_EXTERNAL_REFERENCE(options,
node::options_parser::RegisterExternalReferences)

0 comments on commit 9fc4b9b

Please sign in to comment.