1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 02:17:34 +00:00

LibJS/JIT: Compile the GetByValueWithThis instruction

This commit is contained in:
Simon Wanner 2023-10-29 21:49:41 +01:00 committed by Andreas Kling
parent 569ca57e22
commit b53277110e
3 changed files with 22 additions and 1 deletions

View file

@ -781,6 +781,9 @@ public:
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const; ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
DeprecatedString to_deprecated_string_impl(Bytecode::Executable const&) 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: private:
Register m_base; Register m_base;
Register m_this_value; Register m_this_value;

View file

@ -1452,6 +1452,23 @@ void Compiler::compile_get_by_id_with_this(Bytecode::Op::GetByIdWithThis const&
check_exception(); 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() void Compiler::jump_to_exit()
{ {
m_assembler.jump(m_exit_label); m_assembler.jump(m_exit_label);

View file

@ -122,7 +122,8 @@ private:
O(GetObjectPropertyIterator, get_object_property_iterator) \ O(GetObjectPropertyIterator, get_object_property_iterator) \
O(GetPrivateById, get_private_by_id) \ O(GetPrivateById, get_private_by_id) \
O(ResolveSuperBase, resolve_super_base) \ 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) \ # define DECLARE_COMPILE_OP(OpTitleCase, op_snake_case) \
void compile_##op_snake_case(Bytecode::Op::OpTitleCase const&); void compile_##op_snake_case(Bytecode::Op::OpTitleCase const&);