From 06ea4cfc4f70c2fe73864140a08b6e928439d5bd Mon Sep 17 00:00:00 2001 From: Simon Wanner Date: Sun, 29 Oct 2023 23:59:03 +0100 Subject: [PATCH] LibJS/JIT: Compile the DeleteVariable instruction --- Userland/Libraries/LibJS/JIT/Compiler.cpp | 16 ++++++++++++++++ Userland/Libraries/LibJS/JIT/Compiler.h | 3 ++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/Userland/Libraries/LibJS/JIT/Compiler.cpp b/Userland/Libraries/LibJS/JIT/Compiler.cpp index aa756f4702..839d633c75 100644 --- a/Userland/Libraries/LibJS/JIT/Compiler.cpp +++ b/Userland/Libraries/LibJS/JIT/Compiler.cpp @@ -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(&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); diff --git a/Userland/Libraries/LibJS/JIT/Compiler.h b/Userland/Libraries/LibJS/JIT/Compiler.h index e6d385a5e1..cca970b38c 100644 --- a/Userland/Libraries/LibJS/JIT/Compiler.h +++ b/Userland/Libraries/LibJS/JIT/Compiler.h @@ -128,7 +128,8 @@ private: O(PutByIdWithThis, put_by_id_with_this) \ O(PutPrivateById, put_private_by_id) \ O(ImportCall, import_call) \ - O(GetImportMeta, get_import_meta) + O(GetImportMeta, get_import_meta) \ + O(DeleteVariable, delete_variable) # define DECLARE_COMPILE_OP(OpTitleCase, op_snake_case) \ void compile_##op_snake_case(Bytecode::Op::OpTitleCase const&);