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

LibJS: Compile the NewBigInt bytecode instruction

This commit is contained in:
Idan Horowitz 2023-10-28 19:58:36 +03:00 committed by Andreas Kling
parent d200361620
commit 2b65a80ecb
3 changed files with 20 additions and 0 deletions

View file

@ -637,6 +637,20 @@ void Compiler::compile_new_regexp(Bytecode::Op::NewRegExp const& op)
store_vm_register(Bytecode::Register::accumulator(), RET);
}
static Value cxx_new_bigint(VM& vm, Crypto::SignedBigInteger const& bigint)
{
return BigInt::create(vm, bigint);
}
void Compiler::compile_new_bigint(Bytecode::Op::NewBigInt const& op)
{
m_assembler.mov(
Assembler::Operand::Register(ARG1),
Assembler::Operand::Imm(bit_cast<u64>(&op.bigint())));
native_call((void*)cxx_new_bigint);
store_vm_register(Bytecode::Register::accumulator(), RET);
}
static Value cxx_new_object(VM& vm)
{
auto& realm = *vm.current_realm();
@ -1106,6 +1120,9 @@ OwnPtr<NativeExecutable> Compiler::compile(Bytecode::Executable& bytecode_execut
case Bytecode::Instruction::Type::NewRegExp:
compiler.compile_new_regexp(static_cast<Bytecode::Op::NewRegExp const&>(op));
break;
case Bytecode::Instruction::Type::NewBigInt:
compiler.compile_new_bigint(static_cast<Bytecode::Op::NewBigInt const&>(op));
break;
case Bytecode::Instruction::Type::GetById:
compiler.compile_get_by_id(static_cast<Bytecode::Op::GetById const&>(op));
break;