From 1647d319357751675c07192befc77dbb9506f5ff Mon Sep 17 00:00:00 2001 From: Joyee Cheung Date: Sat, 26 Aug 2023 17:28:42 +0200 Subject: [PATCH] src: remove unused PromiseWrap-related code PromiseWrap has been removed in https://github.com/nodejs/node/pull/39135 and we do not have any internal object setting the internal field at 0 as a promise (we always set the first field as an aligned pointer to the embedder ID). As result GetAssignedPromiseWrapAsyncId() always just returns AsyncWrap::kInvalidAsyncId and turn the removed block into noops. So the block just can be removed. --- src/node_task_queue.cc | 33 --------------------------------- 1 file changed, 33 deletions(-) diff --git a/src/node_task_queue.cc b/src/node_task_queue.cc index 1a0cb082a2534f..0a5aba6e31fa79 100644 --- a/src/node_task_queue.cc +++ b/src/node_task_queue.cc @@ -43,28 +43,6 @@ static Maybe GetAssignedPromiseAsyncId(Environment* env, : v8::Just(AsyncWrap::kInvalidAsyncId); } -static Maybe GetAssignedPromiseWrapAsyncId(Environment* env, - Local promise, - Local id_symbol) { - // This check is imperfect. If the internal field is set, it should - // be an object. If it's not, we just ignore it. Ideally v8 would - // have had GetInternalField returning a MaybeLocal but this works - // for now. - Local promiseWrap = promise->GetInternalField(0).As(); - if (promiseWrap->IsObject()) { - Local maybe_async_id; - if (!promiseWrap.As()->Get(env->context(), id_symbol) - .ToLocal(&maybe_async_id)) { - return v8::Just(AsyncWrap::kInvalidAsyncId); - } - return maybe_async_id->IsNumber() - ? maybe_async_id->NumberValue(env->context()) - : v8::Just(AsyncWrap::kInvalidAsyncId); - } else { - return v8::Just(AsyncWrap::kInvalidAsyncId); - } -} - void PromiseRejectCallback(PromiseRejectMessage message) { static std::atomic unhandledRejections{0}; static std::atomic rejectionsHandledAfter{0}; @@ -122,17 +100,6 @@ void PromiseRejectCallback(PromiseRejectMessage message) { if (!GetAssignedPromiseAsyncId(env, promise, env->trigger_async_id_symbol()) .To(&trigger_async_id)) return; - if (async_id == AsyncWrap::kInvalidAsyncId && - trigger_async_id == AsyncWrap::kInvalidAsyncId) { - // That means that promise might be a PromiseWrap, so we'll - // check there as well. - if (!GetAssignedPromiseWrapAsyncId(env, promise, env->async_id_symbol()) - .To(&async_id)) return; - if (!GetAssignedPromiseWrapAsyncId( - env, promise, env->trigger_async_id_symbol()) - .To(&trigger_async_id)) return; - } - if (async_id != AsyncWrap::kInvalidAsyncId && trigger_async_id != AsyncWrap::kInvalidAsyncId) { env->async_hooks()->push_async_context(