diff --git a/Userland/Libraries/LibJS/Bytecode/CommonImplementations.cpp b/Userland/Libraries/LibJS/Bytecode/CommonImplementations.cpp index 0dfaa106cc..f0bb6ddf26 100644 --- a/Userland/Libraries/LibJS/Bytecode/CommonImplementations.cpp +++ b/Userland/Libraries/LibJS/Bytecode/CommonImplementations.cpp @@ -624,4 +624,15 @@ ThrowCompletionOr append(VM& vm, Value lhs, Value rhs, bool is_spread) return {}; } +ThrowCompletionOr delete_by_id(Bytecode::Interpreter& interpreter, Value base, IdentifierTableIndex property) +{ + auto& vm = interpreter.vm(); + + auto const& identifier = interpreter.current_executable().get_identifier(property); + bool strict = vm.in_strict_mode(); + auto reference = Reference { base, identifier, {}, strict }; + + return TRY(reference.delete_(vm)); +} + } diff --git a/Userland/Libraries/LibJS/Bytecode/CommonImplementations.h b/Userland/Libraries/LibJS/Bytecode/CommonImplementations.h index 6b99c9843f..3b48b623c8 100644 --- a/Userland/Libraries/LibJS/Bytecode/CommonImplementations.h +++ b/Userland/Libraries/LibJS/Bytecode/CommonImplementations.h @@ -39,5 +39,6 @@ Object* iterator_to_object(VM&, IteratorRecord); IteratorRecord object_to_iterator(VM&, Object&); ThrowCompletionOr> iterator_to_array(VM&, Value iterator); ThrowCompletionOr append(VM& vm, Value lhs, Value rhs, bool is_spread); +ThrowCompletionOr delete_by_id(Bytecode::Interpreter&, Value base, IdentifierTableIndex identifier); } diff --git a/Userland/Libraries/LibJS/Bytecode/Interpreter.cpp b/Userland/Libraries/LibJS/Bytecode/Interpreter.cpp index d5a7fdf384..59864ea9ac 100644 --- a/Userland/Libraries/LibJS/Bytecode/Interpreter.cpp +++ b/Userland/Libraries/LibJS/Bytecode/Interpreter.cpp @@ -817,12 +817,8 @@ ThrowCompletionOr PutPrivateById::execute_impl(Bytecode::Interpreter& inte ThrowCompletionOr DeleteById::execute_impl(Bytecode::Interpreter& interpreter) const { - auto& vm = interpreter.vm(); auto base_value = interpreter.accumulator(); - auto const& identifier = interpreter.current_executable().get_identifier(m_property); - bool strict = vm.in_strict_mode(); - auto reference = Reference { base_value, identifier, {}, strict }; - interpreter.accumulator() = Value(TRY(reference.delete_(vm))); + interpreter.accumulator() = TRY(Bytecode::delete_by_id(interpreter, base_value, m_property)); return {}; } diff --git a/Userland/Libraries/LibJS/Bytecode/Op.h b/Userland/Libraries/LibJS/Bytecode/Op.h index e97cc4a5c0..97c760517c 100644 --- a/Userland/Libraries/LibJS/Bytecode/Op.h +++ b/Userland/Libraries/LibJS/Bytecode/Op.h @@ -723,6 +723,8 @@ public: ThrowCompletionOr execute_impl(Bytecode::Interpreter&) const; DeprecatedString to_deprecated_string_impl(Bytecode::Executable const&) const; + IdentifierTableIndex property() const { return m_property; } + private: IdentifierTableIndex m_property; }; diff --git a/Userland/Libraries/LibJS/JIT/Compiler.cpp b/Userland/Libraries/LibJS/JIT/Compiler.cpp index 24bbab4380..eed427a85b 100644 --- a/Userland/Libraries/LibJS/JIT/Compiler.cpp +++ b/Userland/Libraries/LibJS/JIT/Compiler.cpp @@ -1336,6 +1336,22 @@ void Compiler::compile_append(Bytecode::Op::Append const& op) check_exception(); } +static Value cxx_delete_by_id(VM& vm, Value base, Bytecode::IdentifierTableIndex property) +{ + return TRY_OR_SET_EXCEPTION(Bytecode::delete_by_id(vm.bytecode_interpreter(), base, property)); +} + +void Compiler::compile_delete_by_id(Bytecode::Op::DeleteById const& op) +{ + load_vm_register(ARG1, Bytecode::Register::accumulator()); + m_assembler.mov( + Assembler::Operand::Register(ARG2), + Assembler::Operand::Imm(op.property().value())); + native_call((void*)cxx_delete_by_id); + 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 84191e552c..6a956238a4 100644 --- a/Userland/Libraries/LibJS/JIT/Compiler.h +++ b/Userland/Libraries/LibJS/JIT/Compiler.h @@ -114,7 +114,8 @@ private: O(IteratorResultValue, iterator_result_value) \ O(IteratorClose, iterator_close) \ O(IteratorToArray, iterator_to_array) \ - O(Append, append) + O(Append, append) \ + O(DeleteById, delete_by_id) # define DECLARE_COMPILE_OP(OpTitleCase, op_snake_case) \ void compile_##op_snake_case(Bytecode::Op::OpTitleCase const&);