From 842a189c2e29cbd9b661d1627de239dbe3570bd3 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Thu, 20 Mar 2025 08:48:28 -0500 Subject: [PATCH] LibJS: Elide empty lexical environment when direct eval() is present Direct eval() always creates a new lexical environment, so we don't have to worry about those here. The var environments still need special care. --- Libraries/LibJS/Bytecode/Generator.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Libraries/LibJS/Bytecode/Generator.cpp b/Libraries/LibJS/Bytecode/Generator.cpp index b219b7e5b20..40ceadb568c 100644 --- a/Libraries/LibJS/Bytecode/Generator.cpp +++ b/Libraries/LibJS/Bytecode/Generator.cpp @@ -164,8 +164,8 @@ CodeGenerationErrorOr Generator::emit_function_declaration_instantiation(E } if (!function.m_strict) { - bool can_elide_declarative_environment = !function.m_contains_direct_call_to_eval && (!scope_body || !scope_body->has_non_local_lexical_declarations()); - if (!can_elide_declarative_environment) { + bool can_elide_lexical_environment = !scope_body || !scope_body->has_non_local_lexical_declarations(); + if (!can_elide_lexical_environment) { emit(function.m_lex_environment_bindings_count); } }