From 233502a10cb0824e2bb8430d8719e7d7660a7df6 Mon Sep 17 00:00:00 2001 From: Simon Wanner Date: Sun, 29 Oct 2023 16:40:30 +0100 Subject: [PATCH] LibJS/JIT: Compile the IteratorResultValue instruction --- Userland/Libraries/LibJS/JIT/Compiler.cpp | 14 ++++++++++++++ Userland/Libraries/LibJS/JIT/Compiler.h | 3 ++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/Userland/Libraries/LibJS/JIT/Compiler.cpp b/Userland/Libraries/LibJS/JIT/Compiler.cpp index 80cf463a12..ce0b637490 100644 --- a/Userland/Libraries/LibJS/JIT/Compiler.cpp +++ b/Userland/Libraries/LibJS/JIT/Compiler.cpp @@ -1269,6 +1269,20 @@ void Compiler::compile_throw_if_nullish(Bytecode::Op::ThrowIfNullish const&) check_exception(); } +static Value cxx_iterator_result_value(VM& vm, Value iterator) +{ + auto iterator_result = TRY_OR_SET_EXCEPTION(iterator.to_object(vm)); + return TRY_OR_SET_EXCEPTION(iterator_value(vm, iterator_result)); +} + +void Compiler::compile_iterator_result_value(Bytecode::Op::IteratorResultValue const&) +{ + load_vm_register(ARG1, Bytecode::Register::accumulator()); + native_call((void*)cxx_iterator_result_value); + 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 9249bb849f..daca096d1a 100644 --- a/Userland/Libraries/LibJS/JIT/Compiler.h +++ b/Userland/Libraries/LibJS/JIT/Compiler.h @@ -110,7 +110,8 @@ private: O(IteratorNext, iterator_next) \ O(IteratorResultDone, iterator_result_done) \ O(ThrowIfNotObject, throw_if_not_object) \ - O(ThrowIfNullish, throw_if_nullish) + O(ThrowIfNullish, throw_if_nullish) \ + O(IteratorResultValue, iterator_result_value) # define DECLARE_COMPILE_OP(OpTitleCase, op_snake_case) \ void compile_##op_snake_case(Bytecode::Op::OpTitleCase const&);