Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 658d2f4

Browse filesBrowse files
addaleaxMylesBorins
authored andcommitted
src: make build_snapshot a per-Isolate option, rather than a global one
PR-URL: #45888 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
1 parent 6801d37 commit 658d2f4
Copy full SHA for 658d2f4

File tree

Expand file treeCollapse file tree

5 files changed

+10
-10
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

5 files changed

+10
-10
lines changed
Open diff view settings
Collapse file

‎src/node.cc‎

Copy file name to clipboardExpand all lines: src/node.cc
+2-2Lines 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"
Collapse file

‎src/node_options.cc‎

Copy file name to clipboardExpand all lines: src/node_options.cc
+5-5Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -777,6 +777,11 @@ PerIsolateOptionsParser::PerIsolateOptionsParser(
777777
Implies("--experimental-shadow-realm", "--harmony-shadow-realm");
778778
Implies("--harmony-shadow-realm", "--experimental-shadow-realm");
779779
ImpliesNot("--no-harmony-shadow-realm", "--experimental-shadow-realm");
780+
AddOption("--build-snapshot",
781+
"Generate a snapshot blob when the process exits."
782+
" Currently only supported in the node_mksnapshot binary.",
783+
&PerIsolateOptions::build_snapshot,
784+
kDisallowedInEnvvar);
780785

781786
Insert(eop, &PerIsolateOptions::get_per_env_options);
782787
}
@@ -815,11 +820,6 @@ PerProcessOptionsParser::PerProcessOptionsParser(
815820
"disable Object.prototype.__proto__",
816821
&PerProcessOptions::disable_proto,
817822
kAllowedInEnvvar);
818-
AddOption("--build-snapshot",
819-
"Generate a snapshot blob when the process exits."
820-
" Currently only supported in the node_mksnapshot binary.",
821-
&PerProcessOptions::build_snapshot,
822-
kDisallowedInEnvvar);
823823
AddOption("--node-snapshot",
824824
"", // It's a debug-only option.
825825
&PerProcessOptions::node_snapshot,
Collapse file

‎src/node_options.h‎

Copy file name to clipboardExpand all lines: src/node_options.h
+1-1Lines 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.
Collapse file

‎src/node_snapshotable.cc‎

Copy file name to clipboardExpand all lines: src/node_snapshotable.cc
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1136,7 +1136,7 @@ ExitCode SnapshotBuilder::Generate(SnapshotData* out,
11361136

11371137
// It's only possible to be kDefault in node_mksnapshot.
11381138
SnapshotMetadata::Type snapshot_type =
1139-
per_process::cli_options->build_snapshot
1139+
per_process::cli_options->per_isolate->build_snapshot
11401140
? SnapshotMetadata::Type::kFullyCustomized
11411141
: SnapshotMetadata::Type::kDefault;
11421142

Collapse file

‎tools/snapshot/node_mksnapshot.cc‎

Copy file name to clipboardExpand all lines: tools/snapshot/node_mksnapshot.cc
+1-1Lines 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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.