Преглед изворни кода

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.
Hendiadyoin1 пре 2 година
родитељ
комит
fc332be2e5
1 измењених фајлова са 1 додато и 1 уклоњено
  1. 1 1
      Userland/Libraries/LibJS/Bytecode/ASTCodegen.cpp

+ 1 - 1
Userland/Libraries/LibJS/Bytecode/ASTCodegen.cpp

@@ -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);