mirror of
https://github.com/RGBCube/serenity
synced 2025-05-20 13:55:08 +00:00
LibJS: Introduce an accumulator register to Bytecode::Interpreter
This commit introduces the concept of an accumulator register to LibJS's bytecode interpreter. The accumulator register is always register 0, and most simple instructions use it for reading and writing. Not only does this slim down the AST, but it also simplifies a lot of the code. For example, the generate_bytecode methods no longer need to return an Optional<Register>, as any opcode which has a "return" value will always put it into the accumulator. This also renames the old Op::Load to Op::LoadImmediate, and uses Op::Load to load from a register into the accumulator. There is also an Op::Store to put the value in the accumulator into another register.
This commit is contained in:
parent
6c256bb400
commit
9bed2e4f4a
8 changed files with 377 additions and 432 deletions
|
@ -26,7 +26,7 @@ Generator::~Generator()
|
|||
OwnPtr<Block> Generator::generate(ASTNode const& node)
|
||||
{
|
||||
Generator generator;
|
||||
[[maybe_unused]] auto dummy = node.generate_bytecode(generator);
|
||||
node.generate_bytecode(generator);
|
||||
generator.m_block->set_register_count({}, generator.m_next_register);
|
||||
generator.m_block->seal();
|
||||
return move(generator.m_block);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue