mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-01 21:59:07 +00:00
LibJS/Bytecode: Avoid unnecessary copy of call expression callee
If the callee is already a temporary register, we don't need to copy it to *another* temporary before evaluating arguments. None of the arguments will clobber the existing temporary anyway.
This commit is contained in:
parent
56a3ccde1a
commit
96511a7d19
Notes:
sideshowbarker
2024-07-16 23:44:30 +09:00
Author: https://github.com/awesomekling
Commit: 96511a7d19
Pull-request: https://github.com/SerenityOS/serenity/pull/24276
Reviewed-by: https://github.com/Hendiadyoin1
Reviewed-by: https://github.com/shannonbooth
1 changed files with 10 additions and 3 deletions
|
@ -1652,9 +1652,16 @@ Bytecode::CodeGenerationErrorOr<Optional<ScopedOperand>> CallExpression::generat
|
|||
original_callee = TRY(m_callee->generate_bytecode(generator)).value();
|
||||
}
|
||||
|
||||
// NOTE: We copy the callee to a new register to avoid overwriting it while evaluating arguments.
|
||||
auto callee = generator.allocate_register();
|
||||
generator.emit<Bytecode::Op::Mov>(callee, *original_callee);
|
||||
// NOTE: If the callee isn't already a temporary, we copy it to a new register
|
||||
// to avoid overwriting it while evaluating arguments.
|
||||
auto callee = [&]() -> ScopedOperand {
|
||||
if (!original_callee->operand().is_register()) {
|
||||
auto callee = generator.allocate_register();
|
||||
generator.emit<Bytecode::Op::Mov>(callee, *original_callee);
|
||||
return callee;
|
||||
}
|
||||
return *original_callee;
|
||||
}();
|
||||
|
||||
Bytecode::Op::CallType call_type;
|
||||
if (is<NewExpression>(*this)) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue