diff --git a/Userland/Libraries/LibJS/Bytecode/Op.h b/Userland/Libraries/LibJS/Bytecode/Op.h index 00903594d0..a8dfff7eff 100644 --- a/Userland/Libraries/LibJS/Bytecode/Op.h +++ b/Userland/Libraries/LibJS/Bytecode/Op.h @@ -559,6 +559,9 @@ public: ThrowCompletionOr execute_impl(Bytecode::Interpreter&) const; DeprecatedString to_deprecated_string_impl(Bytecode::Executable const&) const; + IdentifierTableIndex property() const { return m_property; } + u32 cache_index() const { return m_cache_index; } + private: IdentifierTableIndex m_property; u32 m_cache_index { 0 }; diff --git a/Userland/Libraries/LibJS/JIT/Compiler.cpp b/Userland/Libraries/LibJS/JIT/Compiler.cpp index d44962bd42..1720623847 100644 --- a/Userland/Libraries/LibJS/JIT/Compiler.cpp +++ b/Userland/Libraries/LibJS/JIT/Compiler.cpp @@ -5,6 +5,7 @@ */ #include +#include #include #include #include @@ -366,6 +367,25 @@ void Compiler::compile_new_string(Bytecode::Op::NewString const& op) store_vm_register(Bytecode::Register::accumulator(), RET); } +static Value cxx_get_by_id(VM& vm, Value base, Bytecode::IdentifierTableIndex property, u32 cache_index) +{ + return TRY_OR_SET_EXCEPTION(Bytecode::get_by_id(vm.bytecode_interpreter(), property, base, base, cache_index)); +} + +void Compiler::compile_get_by_id(Bytecode::Op::GetById const& op) +{ + load_vm_register(ARG1, Bytecode::Register::accumulator()); + m_assembler.mov( + Assembler::Operand::Register(ARG2), + Assembler::Operand::Imm64(op.property().value())); + m_assembler.mov( + Assembler::Operand::Register(ARG3), + Assembler::Operand::Imm64(op.cache_index())); + m_assembler.native_call((void*)cxx_get_by_id); + store_vm_register(Bytecode::Register::accumulator(), RET); + check_exception(); +} + OwnPtr Compiler::compile(Bytecode::Executable& bytecode_executable) { if (getenv("LIBJS_NO_JIT")) @@ -430,6 +450,9 @@ OwnPtr Compiler::compile(Bytecode::Executable& bytecode_execut case Bytecode::Instruction::Type::NewString: compiler.compile_new_string(static_cast(op)); break; + case Bytecode::Instruction::Type::GetById: + compiler.compile_get_by_id(static_cast(op)); + break; #define DO_COMPILE_COMMON_BINARY_OP(TitleCaseName, snake_case_name) \ case Bytecode::Instruction::Type::TitleCaseName: \ diff --git a/Userland/Libraries/LibJS/JIT/Compiler.h b/Userland/Libraries/LibJS/JIT/Compiler.h index d1b264a018..01c5ac15fb 100644 --- a/Userland/Libraries/LibJS/JIT/Compiler.h +++ b/Userland/Libraries/LibJS/JIT/Compiler.h @@ -23,6 +23,7 @@ private: static constexpr auto ARG0 = Assembler::Reg::RDI; static constexpr auto ARG1 = Assembler::Reg::RSI; static constexpr auto ARG2 = Assembler::Reg::RDX; + static constexpr auto ARG3 = Assembler::Reg::RCX; static constexpr auto RET = Assembler::Reg::RAX; static constexpr auto STACK_POINTER = Assembler::Reg::RSP; static constexpr auto REGISTER_ARRAY_BASE = Assembler::Reg::R8; @@ -49,6 +50,7 @@ private: void compile_return(Bytecode::Op::Return const&); void compile_new_string(Bytecode::Op::NewString const&); + void compile_get_by_id(Bytecode::Op::GetById const&); void store_vm_register(Bytecode::Register, Assembler::Reg); void load_vm_register(Assembler::Reg, Bytecode::Register);