LibJS: Defer looking up the realm in ordinary_call_evaluate_body()

We don't actually need the realm for normal function calls, so we
can avoid looking it up on the EC stack in that case.
This commit is contained in:
Andreas Kling 2025-04-28 21:25:28 +02:00 committed by Andreas Kling
parent 0f1be720bb
commit a2b7e04da3
Notes: github-actions[bot] 2025-04-29 00:10:33 +00:00

View file

@ -901,8 +901,6 @@ template void async_function_start(VM&, PromiseCapability const&, GC::Function<C
// 15.8.4 Runtime Semantics: EvaluateAsyncFunctionBody, https://tc39.es/ecma262/#sec-runtime-semantics-evaluatefunctionbody
ThrowCompletionOr<Value> ECMAScriptFunctionObject::ordinary_call_evaluate_body(VM& vm)
{
auto& realm = *vm.current_realm();
auto result_and_frame = vm.bytecode_interpreter().run_executable(*m_bytecode_executable, {});
if (result_and_frame.value.is_error()) [[unlikely]] {
@ -916,6 +914,7 @@ ThrowCompletionOr<Value> ECMAScriptFunctionObject::ordinary_call_evaluate_body(V
if (kind() == FunctionKind::Normal)
return result;
auto& realm = *vm.current_realm();
if (kind() == FunctionKind::AsyncGenerator) {
auto async_generator_object = TRY(AsyncGenerator::create(realm, result, this, vm.running_execution_context().copy()));
return async_generator_object;