diff --git a/Userland/Libraries/LibJS/Bytecode/Generator.h b/Userland/Libraries/LibJS/Bytecode/Generator.h index 8d4fb234c92..e481d66686d 100644 --- a/Userland/Libraries/LibJS/Bytecode/Generator.h +++ b/Userland/Libraries/LibJS/Bytecode/Generator.h @@ -283,11 +283,13 @@ public: // * Interpreter::run_bytecode::handle_ContinuePendingUnwind // * Return::execute_impl // * Yield::execute_impl - emit(Operand(Register::saved_return_value()), value); + if constexpr (IsSame) + emit(Operand(Register::saved_return_value()), value); + else + emit(Operand(Register::saved_return_value()), value); emit(Operand(Register::exception()), add_constant(Value {})); // FIXME: Do we really need to clear the return value register here? emit(Operand(Register::return_value()), add_constant(Value {})); - emit(Label { *m_current_basic_block->finalizer() }); return; } diff --git a/Userland/Libraries/LibJS/Bytecode/Instruction.h b/Userland/Libraries/LibJS/Bytecode/Instruction.h index ec026b9c896..f30793758f4 100644 --- a/Userland/Libraries/LibJS/Bytecode/Instruction.h +++ b/Userland/Libraries/LibJS/Bytecode/Instruction.h @@ -110,6 +110,7 @@ O(NewRegExp) \ O(NewTypeError) \ O(Not) \ + O(PrepareYield) \ O(PostfixDecrement) \ O(PostfixIncrement) \ O(PutById) \ diff --git a/Userland/Libraries/LibJS/Bytecode/Interpreter.cpp b/Userland/Libraries/LibJS/Bytecode/Interpreter.cpp index 76ebf165af6..0b206058e8d 100644 --- a/Userland/Libraries/LibJS/Bytecode/Interpreter.cpp +++ b/Userland/Libraries/LibJS/Bytecode/Interpreter.cpp @@ -161,6 +161,22 @@ ALWAYS_INLINE void Interpreter::set(Operand op, Value value) m_registers_and_constants_and_locals.data()[op.index()] = value; } +ALWAYS_INLINE Value Interpreter::do_yield(Value value, Optional