Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJoyee Cheung <joyeec9h3@gmail.com>2022-04-28 18:08:26 +0300
committerGitHub <noreply@github.com>2022-04-28 18:08:26 +0300
commit9c60ae255ce55e46eab2d6551af7563121abaf29 (patch)
treefa50721973a5e53c786c025a6461b2e11195c61b /src
parent63503a4f72067959b02f88f17a1ef333a1b6daed (diff)
src: make --no-node-snapshot a per-process option
We enable the shared read-only heap which currently requires that the snapshot used in different isolates in the same process to be the same. Therefore --no-node-snapshot is a per-process option. PR-URL: https://github.com/nodejs/node/pull/42864 Refs: https://github.com/nodejs/node/pull/42809 Reviewed-By: Michaƫl Zasso <targos@protonmail.com> Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com> Reviewed-By: Chengzhong Wu <legendecas@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Diffstat (limited to 'src')
-rw-r--r--src/node.cc3
-rw-r--r--src/node_options.cc9
-rw-r--r--src/node_options.h7
-rw-r--r--src/node_worker.cc9
4 files changed, 11 insertions, 17 deletions
diff --git a/src/node.cc b/src/node.cc
index 892615f1d8e..5910a400c25 100644
--- a/src/node.cc
+++ b/src/node.cc
@@ -1169,8 +1169,7 @@ int Start(int argc, char** argv) {
}
{
- bool use_node_snapshot =
- per_process::cli_options->per_isolate->node_snapshot;
+ bool use_node_snapshot = per_process::cli_options->node_snapshot;
const SnapshotData* snapshot_data =
use_node_snapshot ? SnapshotBuilder::GetEmbeddedSnapshotData()
: nullptr;
diff --git a/src/node_options.cc b/src/node_options.cc
index b2b4c2c18c7..dae1ce1866f 100644
--- a/src/node_options.cc
+++ b/src/node_options.cc
@@ -650,10 +650,6 @@ PerIsolateOptionsParser::PerIsolateOptionsParser(
"track heap object allocations for heap snapshots",
&PerIsolateOptions::track_heap_objects,
kAllowedInEnvironment);
- AddOption("--node-snapshot",
- "", // It's a debug-only option.
- &PerIsolateOptions::node_snapshot,
- kAllowedInEnvironment);
// Explicitly add some V8 flags to mark them as allowed in NODE_OPTIONS.
AddOption("--abort-on-uncaught-exception",
@@ -755,7 +751,10 @@ PerProcessOptionsParser::PerProcessOptionsParser(
"Currently only supported in the node_mksnapshot binary.",
&PerProcessOptions::build_snapshot,
kDisallowedInEnvironment);
-
+ AddOption("--node-snapshot",
+ "", // It's a debug-only option.
+ &PerProcessOptions::node_snapshot,
+ kAllowedInEnvironment);
// 12.x renamed this inadvertently, so alias it for consistency within the
// release line, while using the original name for consistency with older
// release lines.
diff --git a/src/node_options.h b/src/node_options.h
index 0757a767a16..a623f881b7e 100644
--- a/src/node_options.h
+++ b/src/node_options.h
@@ -203,7 +203,6 @@ class PerIsolateOptions : public Options {
public:
std::shared_ptr<EnvironmentOptions> per_env { new EnvironmentOptions() };
bool track_heap_objects = false;
- bool node_snapshot = true;
bool report_uncaught_exception = false;
bool report_on_signal = false;
bool experimental_top_level_await = true;
@@ -231,7 +230,11 @@ class PerProcessOptions : public Options {
bool zero_fill_all_buffers = false;
bool debug_arraybuffer_allocations = false;
std::string disable_proto;
- bool build_snapshot;
+ bool build_snapshot = false;
+ // We enable the shared read-only heap which currently requires that the
+ // snapshot used in different isolates in the same process to be the same.
+ // Therefore --node-snapshot is a per-process option.
+ bool node_snapshot = true;
std::vector<std::string> security_reverts;
bool print_bash_completion = false;
diff --git a/src/node_worker.cc b/src/node_worker.cc
index 2a509165c25..d8010ff151e 100644
--- a/src/node_worker.cc
+++ b/src/node_worker.cc
@@ -147,14 +147,7 @@ class WorkerThreadData {
SetIsolateCreateParamsForNode(&params);
params.array_buffer_allocator_shared = allocator;
- bool use_node_snapshot = true;
- if (w_->per_isolate_opts_) {
- use_node_snapshot = w_->per_isolate_opts_->node_snapshot;
- } else {
- // IsolateData is created after the Isolate is created so we'll
- // inherit the option from the parent here.
- use_node_snapshot = per_process::cli_options->per_isolate->node_snapshot;
- }
+ bool use_node_snapshot = per_process::cli_options->node_snapshot;
const SnapshotData* snapshot_data =
use_node_snapshot ? SnapshotBuilder::GetEmbeddedSnapshotData()
: nullptr;