diff --git a/Userland/Libraries/LibJS/Bytecode/Op.h b/Userland/Libraries/LibJS/Bytecode/Op.h index 8d112f29be..c0eee56d5d 100644 --- a/Userland/Libraries/LibJS/Bytecode/Op.h +++ b/Userland/Libraries/LibJS/Bytecode/Op.h @@ -256,6 +256,8 @@ public: ThrowCompletionOr execute_impl(Bytecode::Interpreter&) const; DeprecatedString to_deprecated_string_impl(Bytecode::Executable const&) const; + Crypto::SignedBigInteger const& bigint() const { return m_bigint; } + private: Crypto::SignedBigInteger m_bigint; }; diff --git a/Userland/Libraries/LibJS/JIT/Compiler.cpp b/Userland/Libraries/LibJS/JIT/Compiler.cpp index 275bb00c00..7ce97d0aad 100644 --- a/Userland/Libraries/LibJS/JIT/Compiler.cpp +++ b/Userland/Libraries/LibJS/JIT/Compiler.cpp @@ -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(&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 Compiler::compile(Bytecode::Executable& bytecode_execut case Bytecode::Instruction::Type::NewRegExp: compiler.compile_new_regexp(static_cast(op)); break; + case Bytecode::Instruction::Type::NewBigInt: + compiler.compile_new_bigint(static_cast(op)); + break; case Bytecode::Instruction::Type::GetById: compiler.compile_get_by_id(static_cast(op)); break; diff --git a/Userland/Libraries/LibJS/JIT/Compiler.h b/Userland/Libraries/LibJS/JIT/Compiler.h index 131dbe5a54..52c70acb27 100644 --- a/Userland/Libraries/LibJS/JIT/Compiler.h +++ b/Userland/Libraries/LibJS/JIT/Compiler.h @@ -99,6 +99,7 @@ private: void compile_new_array(Bytecode::Op::NewArray const&); void compile_new_function(Bytecode::Op::NewFunction const&); void compile_new_regexp(Bytecode::Op::NewRegExp const&); + void compile_new_bigint(Bytecode::Op::NewBigInt const&); void compile_get_by_id(Bytecode::Op::GetById const&); void compile_get_by_value(Bytecode::Op::GetByValue const&);