From 7097169967c1e402c2054dffee855bdcf1a2b590 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sat, 21 Oct 2023 15:55:15 +0200 Subject: [PATCH] LibJS/JIT: Compile the PutByValue bytecode instruction --- Userland/Libraries/LibJS/Bytecode/Op.h | 4 ++++ Userland/Libraries/LibJS/JIT/Compiler.cpp | 21 +++++++++++++++++++++ Userland/Libraries/LibJS/JIT/Compiler.h | 1 + 3 files changed, 26 insertions(+) diff --git a/Userland/Libraries/LibJS/Bytecode/Op.h b/Userland/Libraries/LibJS/Bytecode/Op.h index a2b369c446..c3bec8b25e 100644 --- a/Userland/Libraries/LibJS/Bytecode/Op.h +++ b/Userland/Libraries/LibJS/Bytecode/Op.h @@ -772,6 +772,10 @@ public: ThrowCompletionOr execute_impl(Bytecode::Interpreter&) const; DeprecatedString to_deprecated_string_impl(Bytecode::Executable const&) const; + Register base() const { return m_base; } + Register property() const { return m_property; } + PropertyKind kind() const { return m_kind; } + private: Register m_base; Register m_property; diff --git a/Userland/Libraries/LibJS/JIT/Compiler.cpp b/Userland/Libraries/LibJS/JIT/Compiler.cpp index a31f03b7d9..3949eae861 100644 --- a/Userland/Libraries/LibJS/JIT/Compiler.cpp +++ b/Userland/Libraries/LibJS/JIT/Compiler.cpp @@ -567,6 +567,24 @@ void Compiler::compile_put_by_id(Bytecode::Op::PutById const& op) check_exception(); } +static Value cxx_put_by_value(VM& vm, Value base, Value property, Value value, Bytecode::Op::PropertyKind kind) +{ + TRY_OR_SET_EXCEPTION(Bytecode::put_by_value(vm, base, property, value, kind)); + return {}; +} + +void Compiler::compile_put_by_value(Bytecode::Op::PutByValue const& op) +{ + load_vm_register(ARG1, op.base()); + load_vm_register(ARG2, op.property()); + load_vm_register(ARG3, Bytecode::Register::accumulator()); + m_assembler.mov( + Assembler::Operand::Register(ARG4), + Assembler::Operand::Imm64(to_underlying(op.kind()))); + m_assembler.native_call((void*)cxx_put_by_value); + check_exception(); +} + static Value cxx_call(VM& vm, Value callee, u32 first_argument_index, u32 argument_count, Value this_value, Bytecode::Op::CallType call_type) { // FIXME: Uncomment this and deal with it. @@ -728,6 +746,9 @@ OwnPtr Compiler::compile(Bytecode::Executable& bytecode_execut case Bytecode::Instruction::Type::PutById: compiler.compile_put_by_id(static_cast(op)); break; + case Bytecode::Instruction::Type::PutByValue: + compiler.compile_put_by_value(static_cast(op)); + break; case Bytecode::Instruction::Type::ToNumeric: compiler.compile_to_numeric(static_cast(op)); break; diff --git a/Userland/Libraries/LibJS/JIT/Compiler.h b/Userland/Libraries/LibJS/JIT/Compiler.h index 266045f663..04d377fd12 100644 --- a/Userland/Libraries/LibJS/JIT/Compiler.h +++ b/Userland/Libraries/LibJS/JIT/Compiler.h @@ -70,6 +70,7 @@ private: void compile_get_global(Bytecode::Op::GetGlobal const&); void compile_put_by_id(Bytecode::Op::PutById const&); + void compile_put_by_value(Bytecode::Op::PutByValue const&); void compile_call(Bytecode::Op::Call const&); void compile_typeof_variable(Bytecode::Op::TypeofVariable const&);