diff --git a/Userland/Libraries/LibJS/Runtime/ArrayConstructor.cpp b/Userland/Libraries/LibJS/Runtime/ArrayConstructor.cpp index ef538d0b7c7..37da813c0e1 100644 --- a/Userland/Libraries/LibJS/Runtime/ArrayConstructor.cpp +++ b/Userland/Libraries/LibJS/Runtime/ArrayConstructor.cpp @@ -306,7 +306,7 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayConstructor::from_async) auto promise_capability = MUST(new_promise_capability(vm, realm.intrinsics().promise_constructor())); // 3. Let fromAsyncClosure be a new Abstract Closure with no parameters that captures C, mapfn, and thisArg and performs the following steps when called: - SafeFunction from_async_closure = [constructor, mapfn, this_arg, &vm, &realm, async_items]() mutable -> Completion { + auto from_async_closure = create_heap_function(realm.heap(), [constructor, mapfn, this_arg, &vm, &realm, async_items]() mutable -> Completion { bool mapping; // a. If mapfn is undefined, let mapping be false. @@ -510,10 +510,10 @@ JS_DEFINE_NATIVE_FUNCTION(ArrayConstructor::from_async) // ix. Return Completion Record { [[Type]]: return, [[Value]]: A, [[Target]]: empty }. return Completion { Completion::Type::Return, array }; } - }; + }); // 4. Perform AsyncFunctionStart(promiseCapability, fromAsyncClosure). - async_function_start(vm, promise_capability, from_async_closure); + async_function_start(vm, promise_capability, *from_async_closure); // 5. Return promiseCapability.[[Promise]]. return promise_capability->promise(); diff --git a/Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.cpp b/Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.cpp index e9ac7a03afa..c6123c4389c 100644 --- a/Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.cpp +++ b/Userland/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.cpp @@ -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) { + if constexpr (!IsSame>) { // 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); - // 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 const& async_body, PromiseCapability const&, ExecutionContext&); template void async_function_start(VM&, PromiseCapability const&, NonnullRefPtr const& async_function_body); -template void async_block_start(VM&, SafeFunction const& async_body, PromiseCapability const&, ExecutionContext&); -template void async_function_start(VM&, PromiseCapability const&, SafeFunction const& async_function_body); +template void async_block_start(VM&, HeapFunction const& async_body, PromiseCapability const&, ExecutionContext&); +template void async_function_start(VM&, PromiseCapability const&, HeapFunction 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