diff --git a/Userland/Libraries/LibJS/JIT/Compiler.cpp b/Userland/Libraries/LibJS/JIT/Compiler.cpp index 808f6768f3..710858099a 100644 --- a/Userland/Libraries/LibJS/JIT/Compiler.cpp +++ b/Userland/Libraries/LibJS/JIT/Compiler.cpp @@ -1212,6 +1212,21 @@ void Compiler::compile_get_iterator(Bytecode::Op::GetIterator const& op) check_exception(); } +static Value cxx_iterator_next(VM& vm, Value iterator) +{ + auto iterator_object = TRY_OR_SET_EXCEPTION(iterator.to_object(vm)); + auto iterator_record = Bytecode::object_to_iterator(vm, iterator_object); + return TRY_OR_SET_EXCEPTION(iterator_next(vm, iterator_record)); +} + +void Compiler::compile_iterator_next(Bytecode::Op::IteratorNext const&) +{ + load_vm_register(ARG1, Bytecode::Register::accumulator()); + native_call((void*)cxx_iterator_next); + store_vm_register(Bytecode::Register::accumulator(), RET); + check_exception(); +} + void Compiler::jump_to_exit() { m_assembler.jump(m_exit_label); diff --git a/Userland/Libraries/LibJS/JIT/Compiler.h b/Userland/Libraries/LibJS/JIT/Compiler.h index bdbc03a65b..7e3a76dd2e 100644 --- a/Userland/Libraries/LibJS/JIT/Compiler.h +++ b/Userland/Libraries/LibJS/JIT/Compiler.h @@ -106,7 +106,8 @@ private: O(ConcatString, concat_string) \ O(BlockDeclarationInstantiation, block_declaration_instantiation) \ O(SuperCallWithArgumentArray, super_call_with_argument_array) \ - O(GetIterator, get_iterator) + O(GetIterator, get_iterator) \ + O(IteratorNext, iterator_next) # define DECLARE_COMPILE_OP(OpTitleCase, op_snake_case) \ void compile_##op_snake_case(Bytecode::Op::OpTitleCase const&);