From b53277110e8f1f3e2bb6fb1173a12b14a385457d Mon Sep 17 00:00:00 2001 From: Simon Wanner Date: Sun, 29 Oct 2023 21:49:41 +0100 Subject: [PATCH] LibJS/JIT: Compile the GetByValueWithThis instruction --- Userland/Libraries/LibJS/Bytecode/Op.h | 3 +++ Userland/Libraries/LibJS/JIT/Compiler.cpp | 17 +++++++++++++++++ Userland/Libraries/LibJS/JIT/Compiler.h | 3 ++- 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/Userland/Libraries/LibJS/Bytecode/Op.h b/Userland/Libraries/LibJS/Bytecode/Op.h index 109215710f..3d195aa5be 100644 --- a/Userland/Libraries/LibJS/Bytecode/Op.h +++ b/Userland/Libraries/LibJS/Bytecode/Op.h @@ -781,6 +781,9 @@ 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; } + 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 0c5fc23155..e7607f4514 100644 --- a/Userland/Libraries/LibJS/JIT/Compiler.cpp +++ b/Userland/Libraries/LibJS/JIT/Compiler.cpp @@ -1452,6 +1452,23 @@ void Compiler::compile_get_by_id_with_this(Bytecode::Op::GetByIdWithThis const& check_exception(); } +static Value cxx_get_by_value_with_this(VM& vm, Value property_key_value, Value base, Value this_value) +{ + auto object = TRY_OR_SET_EXCEPTION(base.to_object(vm)); + auto property_key = TRY_OR_SET_EXCEPTION(property_key_value.to_property_key(vm)); + return TRY_OR_SET_EXCEPTION(object->internal_get(property_key, this_value)); +} + +void Compiler::compile_get_by_value_with_this(Bytecode::Op::GetByValueWithThis const& op) +{ + load_vm_register(ARG1, Bytecode::Register::accumulator()); + load_vm_register(ARG2, op.base()); + load_vm_register(ARG3, op.this_value()); + native_call((void*)cxx_get_by_value_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 af38ac7c6d..e7f4cbab78 100644 --- a/Userland/Libraries/LibJS/JIT/Compiler.h +++ b/Userland/Libraries/LibJS/JIT/Compiler.h @@ -122,7 +122,8 @@ private: O(GetObjectPropertyIterator, get_object_property_iterator) \ O(GetPrivateById, get_private_by_id) \ O(ResolveSuperBase, resolve_super_base) \ - O(GetByIdWithThis, get_by_id_with_this) + O(GetByIdWithThis, get_by_id_with_this) \ + O(GetByValueWithThis, get_by_value_with_this) # define DECLARE_COMPILE_OP(OpTitleCase, op_snake_case) \ void compile_##op_snake_case(Bytecode::Op::OpTitleCase const&);