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.
This commit is contained in:
Hendiadyoin1 2022-11-13 15:58:36 +01:00 committed by Ali Mohammad Pur
parent c500647eee
commit fc332be2e5
Notes: sideshowbarker 2024-07-17 20:22:04 +09:00

View File

@ -1927,6 +1927,7 @@ Bytecode::CodeGenerationErrorOr<void> TryStatement::generate_bytecode(Bytecode::
if (m_finalizer) {
auto& finalizer_block = generator.make_block();
generator.switch_to_basic_block(finalizer_block);
generator.emit<Bytecode::Op::LeaveUnwindContext>();
TRY(m_finalizer->generate_bytecode(generator));
if (!generator.is_current_block_terminated()) {
next_block = &generator.make_block();
@ -1964,7 +1965,6 @@ Bytecode::CodeGenerationErrorOr<void> TryStatement::generate_bytecode(Bytecode::
if (!generator.is_current_block_terminated()) {
if (m_finalizer) {
generator.emit<Bytecode::Op::LeaveUnwindContext>();
generator.emit<Bytecode::Op::Jump>(finalizer_target);
} else {
VERIFY(!next_block);