mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-05-02 01:08:48 +00:00
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:
parent
777e84b09b
commit
210a5d77dc
Notes:
sideshowbarker
2024-07-17 02:55:44 +09:00
Author: https://github.com/kalenikaliaksandr
Commit: 210a5d77dc
Pull-request: https://github.com/SerenityOS/serenity/pull/24399
5 changed files with 39 additions and 11 deletions
|
@ -45,10 +45,15 @@ CodeGenerationErrorOr<void> Generator::emit_function_declaration_instantiation(E
|
|||
}
|
||||
|
||||
if (function.m_arguments_object_needed) {
|
||||
Optional<Operand> dst;
|
||||
auto local_var_index = function.m_local_variables_names.find_first_index("arguments"sv);
|
||||
if (local_var_index.has_value())
|
||||
dst = local(local_var_index.value());
|
||||
|
||||
if (function.m_strict || !function.has_simple_parameter_list()) {
|
||||
emit<Op::CreateArguments>(Op::CreateArguments::Kind::Unmapped, function.m_strict);
|
||||
emit<Op::CreateArguments>(dst, Op::CreateArguments::Kind::Unmapped, function.m_strict);
|
||||
} else {
|
||||
emit<Op::CreateArguments>(Op::CreateArguments::Kind::Mapped, function.m_strict);
|
||||
emit<Op::CreateArguments>(dst, Op::CreateArguments::Kind::Mapped, function.m_strict);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue