mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-26 19:29:16 +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:
committed by
Alexander Kalenik
parent
56a3ccde1a
commit
96511a7d19
@@ -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)) {
|
||||
|
||||
Reference in New Issue
Block a user