1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 21:48:13 +00:00

LibJS/JIT: Compile the PutByValue bytecode instruction

This commit is contained in:
Andreas Kling 2023-10-21 15:55:15 +02:00
parent c2aad0f573
commit 7097169967
3 changed files with 26 additions and 0 deletions

View file

@ -772,6 +772,10 @@ public:
ThrowCompletionOr<void> execute_impl(Bytecode::Interpreter&) const;
DeprecatedString to_deprecated_string_impl(Bytecode::Executable const&) const;
Register base() const { return m_base; }
Register property() const { return m_property; }
PropertyKind kind() const { return m_kind; }
private:
Register m_base;
Register m_property;

View file

@ -567,6 +567,24 @@ void Compiler::compile_put_by_id(Bytecode::Op::PutById const& op)
check_exception();
}
static Value cxx_put_by_value(VM& vm, Value base, Value property, Value value, Bytecode::Op::PropertyKind kind)
{
TRY_OR_SET_EXCEPTION(Bytecode::put_by_value(vm, base, property, value, kind));
return {};
}
void Compiler::compile_put_by_value(Bytecode::Op::PutByValue const& op)
{
load_vm_register(ARG1, op.base());
load_vm_register(ARG2, op.property());
load_vm_register(ARG3, Bytecode::Register::accumulator());
m_assembler.mov(
Assembler::Operand::Register(ARG4),
Assembler::Operand::Imm64(to_underlying(op.kind())));
m_assembler.native_call((void*)cxx_put_by_value);
check_exception();
}
static Value cxx_call(VM& vm, Value callee, u32 first_argument_index, u32 argument_count, Value this_value, Bytecode::Op::CallType call_type)
{
// FIXME: Uncomment this and deal with it.
@ -728,6 +746,9 @@ OwnPtr<NativeExecutable> Compiler::compile(Bytecode::Executable& bytecode_execut
case Bytecode::Instruction::Type::PutById:
compiler.compile_put_by_id(static_cast<Bytecode::Op::PutById const&>(op));
break;
case Bytecode::Instruction::Type::PutByValue:
compiler.compile_put_by_value(static_cast<Bytecode::Op::PutByValue const&>(op));
break;
case Bytecode::Instruction::Type::ToNumeric:
compiler.compile_to_numeric(static_cast<Bytecode::Op::ToNumeric const&>(op));
break;

View file

@ -70,6 +70,7 @@ private:
void compile_get_global(Bytecode::Op::GetGlobal const&);
void compile_put_by_id(Bytecode::Op::PutById const&);
void compile_put_by_value(Bytecode::Op::PutByValue const&);
void compile_call(Bytecode::Op::Call const&);
void compile_typeof_variable(Bytecode::Op::TypeofVariable const&);