From 9c0b185ab876f78e4ccb941dece140e0f4aadecf Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Mon, 7 Apr 2025 15:59:30 +0200 Subject: [PATCH] LibJS: Don't track "last result" of ScopeNode if we don't need it This prevents unnecessary bytecode register allocation. --- Libraries/LibJS/Bytecode/ASTCodegen.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Libraries/LibJS/Bytecode/ASTCodegen.cpp b/Libraries/LibJS/Bytecode/ASTCodegen.cpp index 1f1ef6717fd..ce12c6ceddf 100644 --- a/Libraries/LibJS/Bytecode/ASTCodegen.cpp +++ b/Libraries/LibJS/Bytecode/ASTCodegen.cpp @@ -56,8 +56,10 @@ Bytecode::CodeGenerationErrorOr> ScopeNode::generate_byt Optional last_result; for (auto& child : children()) { auto result = TRY(child->generate_bytecode(generator)); - if (result.has_value()) - last_result = result; + if (generator.must_propagate_completion()) { + if (result.has_value()) + last_result = result; + } if (generator.is_current_block_terminated()) break; }