diff --git a/Userland/Libraries/LibJS/JIT/Compiler.cpp b/Userland/Libraries/LibJS/JIT/Compiler.cpp index abbd9c5125..1345bb196a 100644 --- a/Userland/Libraries/LibJS/JIT/Compiler.cpp +++ b/Userland/Libraries/LibJS/JIT/Compiler.cpp @@ -383,6 +383,18 @@ void Compiler::compile_new_string(Bytecode::Op::NewString const& op) store_vm_register(Bytecode::Register::accumulator(), RET); } +static Value cxx_new_object(VM& vm) +{ + auto& realm = *vm.current_realm(); + return Object::create(realm, realm.intrinsics().object_prototype()); +} + +void Compiler::compile_new_object(Bytecode::Op::NewObject const&) +{ + m_assembler.native_call((void*)cxx_new_object); + store_vm_register(Bytecode::Register::accumulator(), RET); +} + static Value cxx_get_by_id(VM& vm, Value base, Bytecode::IdentifierTableIndex property, u32 cache_index) { return TRY_OR_SET_EXCEPTION(Bytecode::get_by_id(vm.bytecode_interpreter(), property, base, base, cache_index)); @@ -547,6 +559,9 @@ OwnPtr Compiler::compile(Bytecode::Executable& bytecode_execut case Bytecode::Instruction::Type::NewString: compiler.compile_new_string(static_cast(op)); break; + case Bytecode::Instruction::Type::NewObject: + compiler.compile_new_object(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 9206b08039..721ec2b28b 100644 --- a/Userland/Libraries/LibJS/JIT/Compiler.h +++ b/Userland/Libraries/LibJS/JIT/Compiler.h @@ -54,6 +54,7 @@ private: void compile_return(Bytecode::Op::Return const&); void compile_new_string(Bytecode::Op::NewString const&); + void compile_new_object(Bytecode::Op::NewObject const&); void compile_get_by_id(Bytecode::Op::GetById const&); void compile_get_by_value(Bytecode::Op::GetByValue const&); void compile_get_global(Bytecode::Op::GetGlobal const&);