Skip to content

Commit d2c0f4d

Browse files
committed
src: make build_snapshot a per-Isolate option, rather than a global one
1 parent e9bfb48 commit d2c0f4d

File tree

5 files changed

+10
-10
lines changed

5 files changed

+10
-10
lines changed

src/node.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ MaybeLocal<Value> StartExecution(Environment* env, StartExecutionCallback cb) {
307307
return StartExecution(env, "internal/main/inspect");
308308
}
309309

310-
if (per_process::cli_options->build_snapshot) {
310+
if (env->isolate_data()->options()->build_snapshot) {
311311
return StartExecution(env, "internal/main/mksnapshot");
312312
}
313313

@@ -1221,7 +1221,7 @@ static ExitCode StartInternal(int argc, char** argv) {
12211221
uv_loop_configure(uv_default_loop(), UV_METRICS_IDLE_TIME);
12221222

12231223
// --build-snapshot indicates that we are in snapshot building mode.
1224-
if (per_process::cli_options->build_snapshot) {
1224+
if (per_process::cli_options->per_isolate->build_snapshot) {
12251225
if (result->args().size() < 2) {
12261226
fprintf(stderr,
12271227
"--build-snapshot must be used with an entry point script.\n"

src/node_options.cc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -773,6 +773,11 @@ PerIsolateOptionsParser::PerIsolateOptionsParser(
773773
Implies("--experimental-shadow-realm", "--harmony-shadow-realm");
774774
Implies("--harmony-shadow-realm", "--experimental-shadow-realm");
775775
ImpliesNot("--no-harmony-shadow-realm", "--experimental-shadow-realm");
776+
AddOption("--build-snapshot",
777+
"Generate a snapshot blob when the process exits."
778+
" Currently only supported in the node_mksnapshot binary.",
779+
&PerIsolateOptions::build_snapshot,
780+
kDisallowedInEnvvar);
776781

777782
Insert(eop, &PerIsolateOptions::get_per_env_options);
778783
}
@@ -811,11 +816,6 @@ PerProcessOptionsParser::PerProcessOptionsParser(
811816
"disable Object.prototype.__proto__",
812817
&PerProcessOptions::disable_proto,
813818
kAllowedInEnvvar);
814-
AddOption("--build-snapshot",
815-
"Generate a snapshot blob when the process exits."
816-
" Currently only supported in the node_mksnapshot binary.",
817-
&PerProcessOptions::build_snapshot,
818-
kDisallowedInEnvvar);
819819
AddOption("--node-snapshot",
820820
"", // It's a debug-only option.
821821
&PerProcessOptions::node_snapshot,

src/node_options.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,7 @@ class PerIsolateOptions : public Options {
224224
bool report_on_signal = false;
225225
bool experimental_shadow_realm = false;
226226
std::string report_signal = "SIGUSR2";
227+
bool build_snapshot = false;
227228
inline EnvironmentOptions* get_per_env_options();
228229
void CheckOptions(std::vector<std::string>* errors,
229230
std::vector<std::string>* argv) override;
@@ -248,7 +249,6 @@ class PerProcessOptions : public Options {
248249
bool zero_fill_all_buffers = false;
249250
bool debug_arraybuffer_allocations = false;
250251
std::string disable_proto;
251-
bool build_snapshot = false;
252252
// We enable the shared read-only heap which currently requires that the
253253
// snapshot used in different isolates in the same process to be the same.
254254
// Therefore --node-snapshot is a per-process option.

src/node_snapshotable.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1116,7 +1116,7 @@ ExitCode SnapshotBuilder::Generate(SnapshotData* out,
11161116

11171117
// It's only possible to be kDefault in node_mksnapshot.
11181118
SnapshotMetadata::Type snapshot_type =
1119-
per_process::cli_options->build_snapshot
1119+
per_process::cli_options->per_isolate->build_snapshot
11201120
? SnapshotMetadata::Type::kFullyCustomized
11211121
: SnapshotMetadata::Type::kDefault;
11221122

tools/snapshot/node_mksnapshot.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ int BuildSnapshot(int argc, char* argv[]) {
7272
CHECK_EQ(result->exit_code(), 0);
7373

7474
std::string out_path;
75-
if (node::per_process::cli_options->build_snapshot) {
75+
if (node::per_process::cli_options->per_isolate->build_snapshot) {
7676
out_path = result->args()[2];
7777
} else {
7878
out_path = result->args()[1];

0 commit comments

Comments
 (0)