diff --git a/Userland/Libraries/LibJS/Bytecode/Op.h b/Userland/Libraries/LibJS/Bytecode/Op.h index 8bbe462fbd..56f12737f5 100644 --- a/Userland/Libraries/LibJS/Bytecode/Op.h +++ b/Userland/Libraries/LibJS/Bytecode/Op.h @@ -1349,6 +1349,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 839d633c75..66599560de 100644 --- a/Userland/Libraries/LibJS/JIT/Compiler.cpp +++ b/Userland/Libraries/LibJS/JIT/Compiler.cpp @@ -1568,6 +1568,23 @@ void Compiler::compile_delete_variable(Bytecode::Op::DeleteVariable const& op) check_exception(); } +static Value cxx_get_method(VM& vm, Value value, DeprecatedFlyString const& identifier) +{ + auto method = TRY_OR_SET_EXCEPTION(value.get_method(vm, identifier)); + return method ?: js_undefined(); +} + +void Compiler::compile_get_method(Bytecode::Op::GetMethod const& op) +{ + load_vm_register(ARG1, Bytecode::Register::accumulator()); + m_assembler.mov( + Assembler::Operand::Register(ARG2), + Assembler::Operand::Imm(bit_cast(&m_bytecode_executable.get_identifier(op.property())))); + native_call((void*)cxx_get_method); + 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 cca970b38c..c2ccb206e6 100644 --- a/Userland/Libraries/LibJS/JIT/Compiler.h +++ b/Userland/Libraries/LibJS/JIT/Compiler.h @@ -129,7 +129,8 @@ private: O(PutPrivateById, put_private_by_id) \ O(ImportCall, import_call) \ O(GetImportMeta, get_import_meta) \ - O(DeleteVariable, delete_variable) + O(DeleteVariable, delete_variable) \ + O(GetMethod, get_method) # define DECLARE_COMPILE_OP(OpTitleCase, op_snake_case) \ void compile_##op_snake_case(Bytecode::Op::OpTitleCase const&);