From a2b7e04da30fbcf4785d941f66e706e5b2cbbf2a Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Mon, 28 Apr 2025 21:25:28 +0200 Subject: [PATCH] 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. --- Libraries/LibJS/Runtime/ECMAScriptFunctionObject.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.cpp b/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.cpp index a67a622bf5e..f4887e07241 100644 --- a/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.cpp +++ b/Libraries/LibJS/Runtime/ECMAScriptFunctionObject.cpp @@ -901,8 +901,6 @@ template void async_function_start(VM&, PromiseCapability const&, GC::Function 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 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;