LibJS/Bytecode: Make NewArray a variable-length instruction

This removes a layer of indirection in the bytecode where we had to make
sure all the initializer elements were laid out in sequential registers.

Array expressions no longer clobber registers permanently, and they can
be reused immediately afterwards.
This commit is contained in:
Andreas Kling 2024-05-08 12:43:08 +02:00
commit 6873628317
Notes: sideshowbarker 2024-07-17 03:59:29 +09:00
5 changed files with 40 additions and 81 deletions

View file

@ -220,18 +220,13 @@ void Generator::grow(size_t additional_size)
m_current_basic_block->grow(additional_size);
}
ScopedOperand Generator::allocate_sequential_register()
{
VERIFY(m_next_register != NumericLimits<u32>::max());
return ScopedOperand { *this, Operand { Register { m_next_register++ } } };
}
ScopedOperand Generator::allocate_register()
{
if (!m_free_registers.is_empty()) {
return ScopedOperand { *this, Operand { m_free_registers.take_last() } };
}
return allocate_sequential_register();
VERIFY(m_next_register != NumericLimits<u32>::max());
return ScopedOperand { *this, Operand { Register { m_next_register++ } } };
}
void Generator::free_register(Register reg)