[runtime] Cleaning up PromiseHook runtime functions
- remove redundant checks - use switch over PromiseHookType Change-Id: I89a5328009634a7025feb77e22334773c2886868 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2224225 Reviewed-by: Sathya Gunasekaran <gsathya@chromium.org> Reviewed-by: Simon Zünd <szuend@chromium.org> Commit-Queue: Camillo Bruni <cbruni@chromium.org> Cr-Commit-Position: refs/heads/master@{#68210}
This commit is contained in:
parent
f3dd0f4803
commit
e23f0aa694
@ -4142,18 +4142,20 @@ void Isolate::RunPromiseHook(PromiseHookType type, Handle<JSPromise> promise,
|
||||
void Isolate::RunPromiseHookForAsyncEventDelegate(PromiseHookType type,
|
||||
Handle<JSPromise> promise) {
|
||||
if (!async_event_delegate_) return;
|
||||
if (type == PromiseHookType::kResolve) return;
|
||||
|
||||
if (type == PromiseHookType::kBefore) {
|
||||
switch (type) {
|
||||
case PromiseHookType::kResolve:
|
||||
return;
|
||||
case PromiseHookType::kBefore:
|
||||
if (!promise->async_task_id()) return;
|
||||
async_event_delegate_->AsyncEventOccurred(debug::kDebugWillHandle,
|
||||
promise->async_task_id(), false);
|
||||
} else if (type == PromiseHookType::kAfter) {
|
||||
async_event_delegate_->AsyncEventOccurred(
|
||||
debug::kDebugWillHandle, promise->async_task_id(), false);
|
||||
break;
|
||||
case PromiseHookType::kAfter:
|
||||
if (!promise->async_task_id()) return;
|
||||
async_event_delegate_->AsyncEventOccurred(debug::kDebugDidHandle,
|
||||
promise->async_task_id(), false);
|
||||
} else {
|
||||
DCHECK(type == PromiseHookType::kInit);
|
||||
async_event_delegate_->AsyncEventOccurred(
|
||||
debug::kDebugDidHandle, promise->async_task_id(), false);
|
||||
break;
|
||||
case PromiseHookType::kInit:
|
||||
debug::DebugAsyncActionType type = debug::kDebugPromiseThen;
|
||||
bool last_frame_was_promise_builtin = false;
|
||||
JavaScriptFrameIterator it(this);
|
||||
@ -4182,7 +4184,8 @@ void Isolate::RunPromiseHookForAsyncEventDelegate(PromiseHookType type,
|
||||
} else if (info->builtin_id() == Builtins::kPromisePrototypeCatch) {
|
||||
type = debug::kDebugPromiseCatch;
|
||||
last_frame_was_promise_builtin = true;
|
||||
} else if (info->builtin_id() == Builtins::kPromisePrototypeFinally) {
|
||||
} else if (info->builtin_id() ==
|
||||
Builtins::kPromisePrototypeFinally) {
|
||||
type = debug::kDebugPromiseFinally;
|
||||
last_frame_was_promise_builtin = true;
|
||||
}
|
||||
|
@ -217,10 +217,8 @@ RUNTIME_FUNCTION(Runtime_PromiseHookBefore) {
|
||||
return ReadOnlyRoots(isolate).undefined_value();
|
||||
Handle<JSPromise> promise = Handle<JSPromise>::cast(maybe_promise);
|
||||
if (isolate->debug()->is_active()) isolate->PushPromise(promise);
|
||||
if (promise->IsJSPromise()) {
|
||||
isolate->RunPromiseHook(PromiseHookType::kBefore, promise,
|
||||
isolate->factory()->undefined_value());
|
||||
}
|
||||
return ReadOnlyRoots(isolate).undefined_value();
|
||||
}
|
||||
|
||||
@ -232,10 +230,8 @@ RUNTIME_FUNCTION(Runtime_PromiseHookAfter) {
|
||||
return ReadOnlyRoots(isolate).undefined_value();
|
||||
Handle<JSPromise> promise = Handle<JSPromise>::cast(maybe_promise);
|
||||
if (isolate->debug()->is_active()) isolate->PopPromise();
|
||||
if (promise->IsJSPromise()) {
|
||||
isolate->RunPromiseHook(PromiseHookType::kAfter, promise,
|
||||
isolate->factory()->undefined_value());
|
||||
}
|
||||
return ReadOnlyRoots(isolate).undefined_value();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user