mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-25 19:04:58 +00:00
LibJS: Add basic support for while loops in the bytecode engine
This introduces two new instructions: Jump and JumpIfFalse. Jumps are made to a Bytecode::Label, which is a simple object that represents a location in the bytecode stream. Note that you may not always know the target of a jump when adding the jump instruction itself, but we can just update the instruction later on during codegen once we know where the jump target is. The Bytecode::Interpreter now implements jumping via a jump slot that gets checked after each instruction to see if a jump is pending. If not, we just increment the PC as usual.
This commit is contained in:
@@ -42,4 +42,9 @@ Register Generator::allocate_register()
|
||||
return Register { m_next_register++ };
|
||||
}
|
||||
|
||||
Label Generator::make_label() const
|
||||
{
|
||||
return Label { m_block->instructions().size() };
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user