LibJS: Do not count arguments as env binding when local variable is used

This is a follow up for 210a5d77dc that
actually allows to skip function environment allocation.
This commit is contained in:
Aliaksandr Kalenik 2024-05-21 14:27:15 +01:00 committed by Alexander Kalenik
parent 38b51b791e
commit 4d37b9e715
Notes: sideshowbarker 2024-07-17 06:20:50 +09:00

View file

@ -212,12 +212,15 @@ ECMAScriptFunctionObject::ECMAScriptFunctionObject(DeprecatedFlyString name, Byt
HashMap<DeprecatedFlyString, ParameterIsLocal> parameter_bindings;
auto arguments_object_needs_binding = m_arguments_object_needed && !m_local_variables_names.contains_slow(vm().names.arguments.as_string());
// 22. If argumentsObjectNeeded is true, then
if (m_arguments_object_needed) {
// f. Let parameterBindings be the list-concatenation of parameterNames and « "arguments" ».
parameter_bindings = m_parameter_names;
parameter_bindings.set(vm().names.arguments.as_string(), ParameterIsLocal::No);
if (arguments_object_needs_binding)
(*environment_size)++;
} else {
parameter_bindings = m_parameter_names;
@ -328,7 +331,6 @@ ECMAScriptFunctionObject::ECMAScriptFunctionObject(DeprecatedFlyString name, Byt
}));
}
auto arguments_object_needs_binding = m_arguments_object_needed && !m_local_variables_names.contains_slow(vm().names.arguments.as_string());
m_function_environment_needed = arguments_object_needs_binding || m_function_environment_bindings_count > 0 || m_var_environment_bindings_count > 0 || m_lex_environment_bindings_count > 0 || uses_this == UsesThis::Yes || m_contains_direct_call_to_eval;
}