1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 13:07:46 +00:00

LibJS/JIT: Compile the GetByIdWithThis instruction

This commit is contained in:
Simon Wanner 2023-10-29 21:39:02 +01:00 committed by Andreas Kling
parent ad81f49b02
commit 569ca57e22
3 changed files with 27 additions and 1 deletions

View file

@ -604,6 +604,10 @@ 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;
IdentifierTableIndex property() const { return m_property; }
Register this_value() const { return m_this_value; }
u32 cache_index() const { return m_cache_index; }
private: private:
IdentifierTableIndex m_property; IdentifierTableIndex m_property;
Register m_this_value; Register m_this_value;

View file

@ -16,6 +16,7 @@
#include <LibJS/Runtime/Array.h> #include <LibJS/Runtime/Array.h>
#include <LibJS/Runtime/DeclarativeEnvironment.h> #include <LibJS/Runtime/DeclarativeEnvironment.h>
#include <LibJS/Runtime/ECMAScriptFunctionObject.h> #include <LibJS/Runtime/ECMAScriptFunctionObject.h>
#include <LibJS/Runtime/FunctionEnvironment.h>
#include <LibJS/Runtime/VM.h> #include <LibJS/Runtime/VM.h>
#include <LibJS/Runtime/ValueInlines.h> #include <LibJS/Runtime/ValueInlines.h>
#include <sys/mman.h> #include <sys/mman.h>
@ -1431,6 +1432,26 @@ void Compiler::compile_resolve_super_base(Bytecode::Op::ResolveSuperBase const&)
check_exception(); 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() void Compiler::jump_to_exit()
{ {
m_assembler.jump(m_exit_label); m_assembler.jump(m_exit_label);

View file

@ -121,7 +121,8 @@ private:
O(DeleteByValueWithThis, delete_by_value_with_this) \ O(DeleteByValueWithThis, delete_by_value_with_this) \
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)
# 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&);