Commit 1efe8685 authored by Marja Hölttä's avatar Marja Hölttä Committed by V8 LUCI CQ

[web snapshots / d8] Make the output file name configurable

Bug: v8:11525
Change-Id: I16191bfa03bb9bbfb57a48015244c780e8cf30e1
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3217190Reviewed-by: 's avatarCamillo Bruni <cbruni@chromium.org>
Commit-Queue: Marja Hölttä <marja@chromium.org>
Cr-Commit-Position: refs/heads/main@{#77311}
parent 91b6d666
......@@ -745,6 +745,11 @@ bool Shell::ExecuteString(Isolate* isolate, Local<String> source,
data->realm_current_ = data->realm_switch_;
if (options.web_snapshot_config) {
const char* web_snapshot_output_file_name = "web.snap";
if (options.web_snapshot_output) {
web_snapshot_output_file_name = options.web_snapshot_output;
}
MaybeLocal<PrimitiveArray> maybe_exports =
ReadLines(isolate, options.web_snapshot_config);
Local<PrimitiveArray> exports;
......@@ -759,12 +764,17 @@ bool Shell::ExecuteString(Isolate* isolate, Local<String> source,
i::WebSnapshotData snapshot_data;
if (serializer.TakeSnapshot(context, exports, snapshot_data)) {
DCHECK_NOT_NULL(snapshot_data.buffer);
WriteChars("web.snap", snapshot_data.buffer, snapshot_data.buffer_size);
WriteChars(web_snapshot_output_file_name, snapshot_data.buffer,
snapshot_data.buffer_size);
} else {
CHECK(try_catch.HasCaught());
ReportException(isolate, &try_catch);
return false;
}
} else if (options.web_snapshot_output) {
isolate->ThrowError(
"Web snapshots: --web-snapshot-config is needed when "
"--web-snapshot-output is passed");
}
}
Local<Value> result;
......@@ -4360,6 +4370,9 @@ bool Shell::SetOptions(int argc, char* argv[]) {
} else if (strncmp(argv[i], "--web-snapshot-config=", 22) == 0) {
options.web_snapshot_config = argv[i] + 22;
argv[i] = nullptr;
} else if (strncmp(argv[i], "--web-snapshot-output=", 22) == 0) {
options.web_snapshot_output = argv[i] + 22;
argv[i] = nullptr;
} else if (strcmp(argv[i], "--experimental-d8-web-snapshot-api") == 0) {
options.d8_web_snapshot_api = true;
argv[i] = nullptr;
......
......@@ -436,6 +436,8 @@ class ShellOptions {
"enable-system-instrumentation", false};
DisallowReassignment<const char*> web_snapshot_config = {
"web-snapshot-config", nullptr};
DisallowReassignment<const char*> web_snapshot_output = {
"web-snapshot-output", nullptr};
DisallowReassignment<bool> d8_web_snapshot_api = {
"experimental-d8-web-snapshot-api", false};
DisallowReassignment<bool> compile_only = {"compile-only", false};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment