Commit bbe2ef4c authored by Camillo Bruni's avatar Camillo Bruni Committed by V8 LUCI CQ

[web snapshot] Fix error reporting when running snapshots in d8

Bug: v8:11525
Change-Id: I5bc01779cbc7edf4f50377bc55a26dca1f96f5b8
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3401587Reviewed-by: 's avatarMarja Hölttä <marja@chromium.org>
Commit-Queue: Camillo Bruni <cbruni@chromium.org>
Cr-Commit-Position: refs/heads/main@{#78705}
parent abebfa68
......@@ -1425,6 +1425,8 @@ bool Shell::ExecuteWebSnapshot(Isolate* isolate, const char* file_name) {
PerIsolateData* data = PerIsolateData::Get(isolate);
Local<Context> realm = data->realms_[data->realm_current_].Get(isolate);
Context::Scope context_scope(realm);
TryCatch try_catch(isolate);
bool success = false;
std::string absolute_path = NormalizePath(file_name, GetWorkingDirectory());
......@@ -1432,12 +1434,17 @@ bool Shell::ExecuteWebSnapshot(Isolate* isolate, const char* file_name) {
std::unique_ptr<uint8_t[]> snapshot_data(
reinterpret_cast<uint8_t*>(ReadChars(absolute_path.c_str(), &length)));
if (length == 0) {
isolate->ThrowError("Error reading the web snapshot");
return false;
isolate->ThrowError("Could not read the web snapshot file");
} else {
i::WebSnapshotDeserializer deserializer(isolate);
success = deserializer.UseWebSnapshot(snapshot_data.get(),
static_cast<size_t>(length));
}
i::WebSnapshotDeserializer deserializer(isolate);
return deserializer.UseWebSnapshot(snapshot_data.get(),
static_cast<size_t>(length));
if (!success) {
CHECK(try_catch.HasCaught());
ReportException(isolate, &try_catch);
}
return success;
}
PerIsolateData::PerIsolateData(Isolate* isolate)
......
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