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

LibJS/JIT: Compile the TypeofLocal bytecode instruction

This commit is contained in:
Andreas Kling 2023-10-27 16:22:14 +02:00
parent a645b9c6c3
commit 17b2c7d965
3 changed files with 18 additions and 0 deletions

View file

@ -100,6 +100,18 @@ void Compiler::compile_set_local(Bytecode::Op::SetLocal const& op)
store_vm_local(op.index(), GPR0);
}
static Value cxx_typeof_local(VM& vm, Value value)
{
return PrimitiveString::create(vm, value.typeof());
}
void Compiler::compile_typeof_local(Bytecode::Op::TypeofLocal const& op)
{
load_vm_local(ARG1, op.index());
m_assembler.native_call((void*)cxx_typeof_local);
store_vm_register(Bytecode::Register::accumulator(), GPR0);
}
void Compiler::compile_jump(Bytecode::Op::Jump const& op)
{
m_assembler.jump(label_for(op.true_target()->block()));
@ -937,6 +949,9 @@ OwnPtr<NativeExecutable> Compiler::compile(Bytecode::Executable& bytecode_execut
case Bytecode::Instruction::Type::SetLocal:
compiler.compile_set_local(static_cast<Bytecode::Op::SetLocal const&>(op));
break;
case Bytecode::Instruction::Type::TypeofLocal:
compiler.compile_typeof_local(static_cast<Bytecode::Op::TypeofLocal const&>(op));
break;
case Bytecode::Instruction::Type::Jump:
compiler.compile_jump(static_cast<Bytecode::Op::Jump const&>(op));
break;