mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-06 16:45:03 +00:00
LibJS: Devirtualize and pack the bytecode stream :^)
This patch changes the LibJS bytecode to be a stream of instructions packed one-after-the-other in contiguous memory, instead of a vector of OwnPtr<Instruction>. This should be a lot more cache-friendly. :^) Instructions are also devirtualized and instead have a type field using a new Instruction::Type enum. To iterate over a bytecode stream, one must now use Bytecode::InstructionStreamIterator.
This commit is contained in:
@@ -52,12 +52,12 @@ Value Interpreter::run(Bytecode::Block const& block)
|
||||
m_register_windows.append(make<RegisterWindow>());
|
||||
registers().resize(block.register_count());
|
||||
|
||||
size_t pc = 0;
|
||||
while (pc < block.instructions().size()) {
|
||||
auto& instruction = block.instructions()[pc];
|
||||
Bytecode::InstructionStreamIterator pc(block.instruction_stream());
|
||||
while (!pc.at_end()) {
|
||||
auto& instruction = *pc;
|
||||
instruction.execute(*this);
|
||||
if (m_pending_jump.has_value()) {
|
||||
pc = m_pending_jump.release_value();
|
||||
pc.jump(m_pending_jump.release_value());
|
||||
continue;
|
||||
}
|
||||
if (!m_return_value.is_empty())
|
||||
|
||||
Reference in New Issue
Block a user