mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-26 19:29:16 +00:00
LibJS: Use HeapFunction for async body closure in Array.fromAsync
This commit is contained in:
committed by
Alexander Kalenik
parent
e6d1123ce8
commit
716e86f042
@@ -734,7 +734,7 @@ void async_block_start(VM& vm, T const& async_body, PromiseCapability const& pro
|
||||
Completion result;
|
||||
|
||||
// a. If asyncBody is a Parse Node, then
|
||||
if constexpr (!IsCallableWithArguments<T, Completion>) {
|
||||
if constexpr (!IsSame<T, HeapFunction<Completion()>>) {
|
||||
// a. Let result be the result of evaluating asyncBody.
|
||||
// FIXME: Cache this executable somewhere.
|
||||
auto maybe_executable = Bytecode::compile(vm, async_body, FunctionKind::Async, "AsyncBlockStart"sv);
|
||||
@@ -746,10 +746,8 @@ void async_block_start(VM& vm, T const& async_body, PromiseCapability const& pro
|
||||
// b. Else,
|
||||
else {
|
||||
// i. Assert: asyncBody is an Abstract Closure with no parameters.
|
||||
static_assert(IsCallableWithArguments<T, Completion>);
|
||||
|
||||
// ii. Let result be asyncBody().
|
||||
result = async_body();
|
||||
result = async_body.function()();
|
||||
}
|
||||
|
||||
// c. Assert: If we return here, the async function either threw an exception or performed an implicit or explicit return; all awaiting is done.
|
||||
@@ -811,8 +809,8 @@ void async_block_start(VM& vm, T const& async_body, PromiseCapability const& pro
|
||||
template void async_block_start(VM&, NonnullRefPtr<Statement const> const& async_body, PromiseCapability const&, ExecutionContext&);
|
||||
template void async_function_start(VM&, PromiseCapability const&, NonnullRefPtr<Statement const> const& async_function_body);
|
||||
|
||||
template void async_block_start(VM&, SafeFunction<Completion()> const& async_body, PromiseCapability const&, ExecutionContext&);
|
||||
template void async_function_start(VM&, PromiseCapability const&, SafeFunction<Completion()> const& async_function_body);
|
||||
template void async_block_start(VM&, HeapFunction<Completion()> const& async_body, PromiseCapability const&, ExecutionContext&);
|
||||
template void async_function_start(VM&, PromiseCapability const&, HeapFunction<Completion()> const& async_function_body);
|
||||
|
||||
// 10.2.1.4 OrdinaryCallEvaluateBody ( F, argumentsList ), https://tc39.es/ecma262/#sec-ordinarycallevaluatebody
|
||||
// 15.8.4 Runtime Semantics: EvaluateAsyncFunctionBody, https://tc39.es/ecma262/#sec-runtime-semantics-evaluatefunctionbody
|
||||
|
||||
Reference in New Issue
Block a user