summaryrefslogtreecommitdiff
path: root/Userland/Libraries
diff options
context:
space:
mode:
authorLuke Wilde <lukew@serenityos.org>2022-06-30 14:29:43 +0100
committerAli Mohammad Pur <Ali.mpfard@gmail.com>2022-06-30 18:35:18 +0430
commitbc08d39754e82d9a2139cf93509eecc5afc832c7 (patch)
tree614febdc428e7f802e022fc7aee568f025c6898b /Userland/Libraries
parentc1b0931d2e81b0fdc471febbbefed77ac05d5d9b (diff)
downloadserenity-bc08d39754e82d9a2139cf93509eecc5afc832c7.zip
LibJS/Bytecode: Make for, do/while and while always switch to end block
Previously we only did this if the body block was not terminated. If it was, all future codegen would happen in this block terminated body block until another switch occurred, dropping all generated instructions in this time on the floor.
Diffstat (limited to 'Userland/Libraries')
-rw-r--r--Userland/Libraries/LibJS/Bytecode/ASTCodegen.cpp14
1 files changed, 7 insertions, 7 deletions
diff --git a/Userland/Libraries/LibJS/Bytecode/ASTCodegen.cpp b/Userland/Libraries/LibJS/Bytecode/ASTCodegen.cpp
index 27184a4106..cf243901f7 100644
--- a/Userland/Libraries/LibJS/Bytecode/ASTCodegen.cpp
+++ b/Userland/Libraries/LibJS/Bytecode/ASTCodegen.cpp
@@ -738,10 +738,10 @@ Bytecode::CodeGenerationErrorOr<void> WhileStatement::generate_labelled_evaluati
generator.emit<Bytecode::Op::Jump>().set_targets(
Bytecode::Label { test_block },
{});
- generator.switch_to_basic_block(end_block);
- generator.emit<Bytecode::Op::Load>(result_reg);
}
+ generator.switch_to_basic_block(end_block);
+ generator.emit<Bytecode::Op::Load>(result_reg);
return {};
}
@@ -789,10 +789,10 @@ Bytecode::CodeGenerationErrorOr<void> DoWhileStatement::generate_labelled_evalua
generator.emit<Bytecode::Op::Jump>().set_targets(
Bytecode::Label { test_block },
{});
- generator.switch_to_basic_block(end_block);
- generator.emit<Bytecode::Op::Load>(result_reg);
}
+ generator.switch_to_basic_block(end_block);
+ generator.emit<Bytecode::Op::Load>(result_reg);
return {};
}
@@ -895,15 +895,15 @@ Bytecode::CodeGenerationErrorOr<void> ForStatement::generate_labelled_evaluation
generator.emit<Bytecode::Op::Jump>().set_targets(
Bytecode::Label { *test_block_ptr },
{});
-
- generator.switch_to_basic_block(end_block);
- generator.emit<Bytecode::Op::Load>(result_reg);
}
if (has_lexical_environment)
generator.end_variable_scope();
generator.end_breakable_scope();
+
+ generator.switch_to_basic_block(end_block);
+ generator.emit<Bytecode::Op::Load>(result_reg);
return {};
}