diff --git a/Userland/Libraries/LibJS/Bytecode/Op.h b/Userland/Libraries/LibJS/Bytecode/Op.h index 23adba53ff..c40207fa79 100644 --- a/Userland/Libraries/LibJS/Bytecode/Op.h +++ b/Userland/Libraries/LibJS/Bytecode/Op.h @@ -692,6 +692,11 @@ public: ThrowCompletionOr execute_impl(Bytecode::Interpreter&) const; DeprecatedString to_deprecated_string_impl(Bytecode::Executable const&) const; + Register base() const { return m_base; } + Register this_value() const { return m_this_value; } + IdentifierTableIndex property() const { return m_property; } + PropertyKind kind() const { return m_kind; } + private: Register m_base; Register m_this_value; diff --git a/Userland/Libraries/LibJS/JIT/Compiler.cpp b/Userland/Libraries/LibJS/JIT/Compiler.cpp index 2b22d78c9b..2da08cc34a 100644 --- a/Userland/Libraries/LibJS/JIT/Compiler.cpp +++ b/Userland/Libraries/LibJS/JIT/Compiler.cpp @@ -1486,6 +1486,27 @@ void Compiler::compile_delete_by_id_with_this(Bytecode::Op::DeleteByIdWithThis c store_vm_register(Bytecode::Register::accumulator(), RET); } +static Value cxx_put_by_id_with_this(VM& vm, Value base, Value value, DeprecatedFlyString const& name, Value this_value, Bytecode::Op::PropertyKind kind) +{ + TRY_OR_SET_EXCEPTION(Bytecode::put_by_property_key(vm, base, this_value, value, name, kind)); + return {}; +} + +void Compiler::compile_put_by_id_with_this(Bytecode::Op::PutByIdWithThis const& op) +{ + load_vm_register(ARG1, op.base()); + load_vm_register(ARG2, Bytecode::Register::accumulator()); + m_assembler.mov( + Assembler::Operand::Register(ARG3), + Assembler::Operand::Imm(bit_cast(&m_bytecode_executable.get_identifier(op.property())))); + load_vm_register(ARG4, op.this_value()); + m_assembler.mov( + Assembler::Operand::Register(ARG5), + Assembler::Operand::Imm(to_underlying(op.kind()))); + native_call((void*)cxx_put_by_id_with_this); + 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 e6b30059e1..307ae911cf 100644 --- a/Userland/Libraries/LibJS/JIT/Compiler.h +++ b/Userland/Libraries/LibJS/JIT/Compiler.h @@ -124,7 +124,8 @@ private: O(ResolveSuperBase, resolve_super_base) \ O(GetByIdWithThis, get_by_id_with_this) \ O(GetByValueWithThis, get_by_value_with_this) \ - O(DeleteByIdWithThis, delete_by_id_with_this) + O(DeleteByIdWithThis, delete_by_id_with_this) \ + O(PutByIdWithThis, put_by_id_with_this) # define DECLARE_COMPILE_OP(OpTitleCase, op_snake_case) \ void compile_##op_snake_case(Bytecode::Op::OpTitleCase const&);