From fc332be2e56aff54d42338c7a1c082f789f84be8 Mon Sep 17 00:00:00 2001 From: Hendiadyoin1 Date: Sun, 13 Nov 2022 15:58:36 +0100 Subject: [PATCH] LibJS: Leave unwind contexts on enter of finally blocks in Bytecode Before we were doing so while exiting the catch-block, but not when exiting the try-block. This now centralizes the responsibility to exit the unwind context to the finalizer, ignoring return/break/continue. This makes it easier to handle the return case in a future commit. --- Userland/Libraries/LibJS/Bytecode/ASTCodegen.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Userland/Libraries/LibJS/Bytecode/ASTCodegen.cpp b/Userland/Libraries/LibJS/Bytecode/ASTCodegen.cpp index ccb2530c3d..6950d6d632 100644 --- a/Userland/Libraries/LibJS/Bytecode/ASTCodegen.cpp +++ b/Userland/Libraries/LibJS/Bytecode/ASTCodegen.cpp @@ -1927,6 +1927,7 @@ Bytecode::CodeGenerationErrorOr TryStatement::generate_bytecode(Bytecode:: if (m_finalizer) { auto& finalizer_block = generator.make_block(); generator.switch_to_basic_block(finalizer_block); + generator.emit(); TRY(m_finalizer->generate_bytecode(generator)); if (!generator.is_current_block_terminated()) { next_block = &generator.make_block(); @@ -1964,7 +1965,6 @@ Bytecode::CodeGenerationErrorOr TryStatement::generate_bytecode(Bytecode:: if (!generator.is_current_block_terminated()) { if (m_finalizer) { - generator.emit(); generator.emit(finalizer_target); } else { VERIFY(!next_block);