1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 12:58:12 +00:00

LibJS/JIT: Compile the DeleteVariable instruction

This commit is contained in:
Simon Wanner 2023-10-29 23:59:03 +01:00 committed by Andreas Kling
parent cd18bc9d55
commit 06ea4cfc4f
2 changed files with 18 additions and 1 deletions

View file

@ -1552,6 +1552,22 @@ void Compiler::compile_get_import_meta(Bytecode::Op::GetImportMeta const&)
store_vm_register(Bytecode::Register::accumulator(), RET);
}
static Value cxx_delete_variable(VM& vm, DeprecatedFlyString const& identifier)
{
auto reference = TRY_OR_SET_EXCEPTION(vm.resolve_binding(identifier));
return Value(TRY_OR_SET_EXCEPTION(reference.delete_(vm)));
}
void Compiler::compile_delete_variable(Bytecode::Op::DeleteVariable const& op)
{
m_assembler.mov(
Assembler::Operand::Register(ARG1),
Assembler::Operand::Imm(bit_cast<u64>(&m_bytecode_executable.get_identifier(op.identifier().value()))));
native_call((void*)cxx_delete_variable);
store_vm_register(Bytecode::Register::accumulator(), RET);
check_exception();
}
void Compiler::jump_to_exit()
{
m_assembler.jump(m_exit_label);