diff --git a/Userland/Libraries/LibJS/Bytecode/Op.h b/Userland/Libraries/LibJS/Bytecode/Op.h index 0da491dd4d..109215710f 100644 --- a/Userland/Libraries/LibJS/Bytecode/Op.h +++ b/Userland/Libraries/LibJS/Bytecode/Op.h @@ -604,6 +604,10 @@ public: ThrowCompletionOr execute_impl(Bytecode::Interpreter&) const; DeprecatedString to_deprecated_string_impl(Bytecode::Executable const&) const; + IdentifierTableIndex property() const { return m_property; } + Register this_value() const { return m_this_value; } + u32 cache_index() const { return m_cache_index; } + private: IdentifierTableIndex m_property; Register m_this_value; diff --git a/Userland/Libraries/LibJS/JIT/Compiler.cpp b/Userland/Libraries/LibJS/JIT/Compiler.cpp index 959edf2ac5..0c5fc23155 100644 --- a/Userland/Libraries/LibJS/JIT/Compiler.cpp +++ b/Userland/Libraries/LibJS/JIT/Compiler.cpp @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -1431,6 +1432,26 @@ void Compiler::compile_resolve_super_base(Bytecode::Op::ResolveSuperBase const&) check_exception(); } +static Value cxx_get_by_id_with_this(VM& vm, Bytecode::IdentifierTableIndex property, Value base_value, Value this_value, u32 cache_index) +{ + return TRY_OR_SET_EXCEPTION(get_by_id(vm.bytecode_interpreter(), property, base_value, this_value, cache_index)); +} + +void Compiler::compile_get_by_id_with_this(Bytecode::Op::GetByIdWithThis const& op) +{ + m_assembler.mov( + Assembler::Operand::Register(ARG1), + Assembler::Operand::Imm(op.property().value())); + load_vm_register(ARG2, Bytecode::Register::accumulator()); + load_vm_register(ARG3, op.this_value()); + m_assembler.mov( + Assembler::Operand::Register(ARG4), + Assembler::Operand::Imm(op.cache_index())); + native_call((void*)cxx_get_by_id_with_this); + 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 f5ace1a888..af38ac7c6d 100644 --- a/Userland/Libraries/LibJS/JIT/Compiler.h +++ b/Userland/Libraries/LibJS/JIT/Compiler.h @@ -121,7 +121,8 @@ private: O(DeleteByValueWithThis, delete_by_value_with_this) \ O(GetObjectPropertyIterator, get_object_property_iterator) \ O(GetPrivateById, get_private_by_id) \ - O(ResolveSuperBase, resolve_super_base) + O(ResolveSuperBase, resolve_super_base) \ + O(GetByIdWithThis, get_by_id_with_this) # define DECLARE_COMPILE_OP(OpTitleCase, op_snake_case) \ void compile_##op_snake_case(Bytecode::Op::OpTitleCase const&);