mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 15:40:19 +00:00
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:
parent
38b51b791e
commit
4d37b9e715
Notes:
sideshowbarker
2024-07-17 06:20:50 +09:00
Author: https://github.com/kalenikaliaksandr Commit: https://github.com/SerenityOS/serenity/commit/4d37b9e715 Pull-request: https://github.com/SerenityOS/serenity/pull/24403
1 changed files with 4 additions and 2 deletions
|
@ -212,13 +212,16 @@ ECMAScriptFunctionObject::ECMAScriptFunctionObject(DeprecatedFlyString name, Byt
|
||||||
|
|
||||||
HashMap<DeprecatedFlyString, ParameterIsLocal> parameter_bindings;
|
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
|
// 22. If argumentsObjectNeeded is true, then
|
||||||
if (m_arguments_object_needed) {
|
if (m_arguments_object_needed) {
|
||||||
// f. Let parameterBindings be the list-concatenation of parameterNames and « "arguments" ».
|
// f. Let parameterBindings be the list-concatenation of parameterNames and « "arguments" ».
|
||||||
parameter_bindings = m_parameter_names;
|
parameter_bindings = m_parameter_names;
|
||||||
parameter_bindings.set(vm().names.arguments.as_string(), ParameterIsLocal::No);
|
parameter_bindings.set(vm().names.arguments.as_string(), ParameterIsLocal::No);
|
||||||
|
|
||||||
(*environment_size)++;
|
if (arguments_object_needs_binding)
|
||||||
|
(*environment_size)++;
|
||||||
} else {
|
} else {
|
||||||
parameter_bindings = m_parameter_names;
|
parameter_bindings = m_parameter_names;
|
||||||
// a. Let parameterBindings be parameterNames.
|
// a. Let parameterBindings be parameterNames.
|
||||||
|
@ -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;
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue