[Bug]: AsyncGeneratorResolve遇到空队列问题

在debug模式下,挂在AsyncGeneratorResolve字节码遇到空队列,
按照ECMA规范分析,执行两次next()后,状态应该为completed且队列应该为空。此时,不需要进入对应逻辑。

Issue: #I7HA9B

Signed-off-by: lichenshuai <lichenshuai@huawei.com>
Change-Id: I6559bd8d60f78341ee6783d636b6d6fa7fe55391
This commit is contained in:
lichenshuai 2023-06-30 10:02:48 +08:00
parent d9a0ed1bb7
commit a99fcc7f30
3 changed files with 14 additions and 0 deletions

View File

@ -359,6 +359,10 @@ JSTaggedValue RuntimeStubs::RuntimeAsyncGeneratorResolve(JSThread *thread, JSHan
ASSERT(flag.IsBoolean());
bool done = flag.IsTrue();
if (asyncGeneratorObjHandle->GetAsyncGeneratorState() == JSAsyncGeneratorState::COMPLETED &&
TaggedQueue::Cast(asyncGeneratorObjHandle->GetAsyncGeneratorQueue().GetTaggedObject())->Empty()) {
return JSTaggedValue::Undefined();
}
return JSAsyncGeneratorObject::AsyncGeneratorResolve(thread, asyncGeneratorObjHandle, valueHandle, done);
}

View File

@ -26,8 +26,17 @@ async function *a() {
print(c);
}
async function *f() {
return 0;
}
let b = a();
print("asyncgenerator next start");
b.next();
b.next(3);
const g = f();
g.next();
g.next();
print("asyncgenerator double next");
print("asyncgenerator next end");

View File

@ -14,6 +14,7 @@
async generator start
asyncgenerator next start
1
asyncgenerator double next
asyncgenerator next end
3
asyncgenerator return start