mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-05-01 00:38:48 +00:00
LibJS: Elide empty lexical environments for parameter evaluation
If all the parameter default values end up in locals, the lexical environment we create to hold them would never be used for anything, and so we can elide it and avoid the GC work.
This commit is contained in:
parent
842a189c2e
commit
49d2a8df23
Notes:
github-actions[bot]
2025-03-20 17:52:13 +00:00
Author: https://github.com/awesomekling
Commit: 49d2a8df23
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4017
1 changed files with 9 additions and 1 deletions
|
@ -33,7 +33,15 @@ Generator::Generator(VM& vm, GC::Ptr<ECMAScriptFunctionObject const> function, M
|
|||
CodeGenerationErrorOr<void> Generator::emit_function_declaration_instantiation(ECMAScriptFunctionObject const& function)
|
||||
{
|
||||
if (function.m_has_parameter_expressions) {
|
||||
emit<Op::CreateLexicalEnvironment>();
|
||||
bool has_non_local_parameters = false;
|
||||
for (auto const& parameter_name : function.m_parameter_names) {
|
||||
if (parameter_name.value == ECMAScriptFunctionObject::ParameterIsLocal::No) {
|
||||
has_non_local_parameters = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (has_non_local_parameters)
|
||||
emit<Op::CreateLexicalEnvironment>();
|
||||
}
|
||||
|
||||
for (auto const& parameter_name : function.m_parameter_names) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue