Allow setting fatal error callbacks during Isolate initialization

This will enable proper reporting of OOM errors during snapshot
deserialization, for example https://crbug.com/614440#c27.

Bug: chromium:614440
Change-Id: I226fb763d2630d0b21f7552070ed1a4cc222f69b
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3445203
Reviewed-by: Toon Verwaest <verwaest@chromium.org>
Commit-Queue: Kevin Babbitt <kbabbitt@microsoft.com>
Cr-Commit-Position: refs/heads/main@{#79055}
This commit is contained in:
Kevin Babbitt 2022-02-07 22:39:34 -08:00 committed by V8 LUCI CQ
parent 318719a14d
commit e08f7ae558
2 changed files with 15 additions and 0 deletions

View File

@ -282,6 +282,12 @@ class V8_EXPORT Isolate {
int embedder_wrapper_type_index = -1;
int embedder_wrapper_object_index = -1;
/**
* Callbacks to invoke in case of fatal or OOM errors.
*/
FatalErrorCallback fatal_error_callback = nullptr;
OOMErrorCallback oom_error_callback = nullptr;
/**
* The following parameter is experimental and may change significantly.
* This is currently for internal testing.

View File

@ -8591,6 +8591,15 @@ void Isolate::Initialize(Isolate* isolate,
} else {
i_isolate->set_snapshot_blob(i::Snapshot::DefaultSnapshotBlob());
}
if (params.fatal_error_callback) {
isolate->SetFatalErrorHandler(params.fatal_error_callback);
}
if (params.oom_error_callback) {
isolate->SetOOMErrorHandler(params.oom_error_callback);
}
if (params.counter_lookup_callback) {
isolate->SetCounterFunction(params.counter_lookup_callback);
}