1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 20:57:35 +00:00

LibJS/Bytecode: Add Operand in/out to all the bytecode codegen helpers

This is pure prep work for refactoring the bytecode to use more operands
instead of only registers.

generate_bytecode() virtuals now return an Optional<Operand>, and the
idea is to return an Operand referring to the value produced by this
AST node.

They also take an Optional<Operand> "preferred_dst" input. This is
intended to communicate the caller's preference for an output operand,
if any. This will be used to elide temporaries when we can store the
result directly in a local, for example.
This commit is contained in:
Andreas Kling 2024-02-03 20:16:02 +01:00
parent e46de4eb59
commit 7f1a62a1d3
4 changed files with 375 additions and 370 deletions

View file

@ -103,9 +103,9 @@ public:
No
};
CodeGenerationErrorOr<Optional<ReferenceRegisters>> emit_load_from_reference(JS::ASTNode const&, CollectRegisters);
CodeGenerationErrorOr<void> emit_store_to_reference(JS::ASTNode const&);
CodeGenerationErrorOr<void> emit_store_to_reference(ReferenceRegisters const&);
CodeGenerationErrorOr<void> emit_delete_reference(JS::ASTNode const&);
CodeGenerationErrorOr<Optional<Operand>> emit_store_to_reference(JS::ASTNode const&);
CodeGenerationErrorOr<Optional<Operand>> emit_store_to_reference(ReferenceRegisters const&);
CodeGenerationErrorOr<Optional<Operand>> emit_delete_reference(JS::ASTNode const&);
CodeGenerationErrorOr<ReferenceRegisters> emit_super_reference(MemberExpression const&);