mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-30 00:31:14 +00:00
LibJS: Generate update Jump in for/in/of only if block is not terminated
The body of for/in/of can contain an unconditional block terminator (e.g. return, throw), so we have to check for that before generating the Jump to the loop update block.
This commit is contained in:
parent
741745baab
commit
88901182b8
Notes:
sideshowbarker
2024-07-17 16:38:18 +09:00
Author: https://github.com/Lubrsi Commit: https://github.com/SerenityOS/serenity/commit/88901182b8 Pull-request: https://github.com/SerenityOS/serenity/pull/13312 Reviewed-by: https://github.com/awesomekling Reviewed-by: https://github.com/linusg ✅
|
@ -1999,7 +1999,11 @@ static Bytecode::CodeGenerationErrorOr<void> for_in_of_body_evaluation(Bytecode:
|
|||
// 3. If iteratorKind is async, return ? AsyncIteratorClose(iteratorRecord, status).
|
||||
// 4. Return ? IteratorClose(iteratorRecord, status).
|
||||
// o. If result.[[Value]] is not empty, set V to result.[[Value]].
|
||||
generator.emit<Bytecode::Op::Jump>().set_targets(Bytecode::Label { loop_update }, {});
|
||||
|
||||
// The body can contain an unconditional block terminator (e.g. return, throw), so we have to check for that before generating the Jump.
|
||||
if (!generator.is_current_block_terminated())
|
||||
generator.emit<Bytecode::Op::Jump>().set_targets(Bytecode::Label { loop_update }, {});
|
||||
|
||||
generator.switch_to_basic_block(loop_end);
|
||||
return {};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue