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 danielleadams committed Apr 24, 2022
1 parent e918570 commit 376b3c4
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
Expand Up @@ -380,6 +380,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
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
Expand Up @@ -3,6 +3,7 @@

#include "env-inl.h"
#include "node_binding.h"
#include "node_external_reference.h"
#include "node_internals.h"

#include <errno.h>
Expand Down Expand Up @@ -1124,6 +1125,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 @@ -1190,3 +1195,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 376b3c4

Please sign in to comment.