LibJS: Use a local variable for arguments object when possible

This allows us to skip allocating a function environment in cases where
it was previously impossible because the arguments object needed a
binding.

This change does not bring visible improvement in Kraken or Octane
benchmarks but seems useful to have anyway.
This commit is contained in:
Aliaksandr Kalenik 2024-05-21 09:32:51 +01:00 committed by Andreas Kling
parent 777e84b09b
commit 210a5d77dc
Notes: sideshowbarker 2024-07-17 02:55:44 +09:00
5 changed files with 39 additions and 11 deletions

View file

@ -328,7 +328,8 @@ ECMAScriptFunctionObject::ECMAScriptFunctionObject(DeprecatedFlyString name, Byt
}));
}
m_function_environment_needed = m_arguments_object_needed || 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;
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;
}
void ECMAScriptFunctionObject::initialize(Realm& realm)