Tune break/continue exception trampoline block generation.
authorErik Verbruggen <erik.verbruggen@digia.com>
Thu, 15 Nov 2012 12:33:36 +0000 (13:33 +0100)
committerLars Knoll <lars.knoll@digia.com>
Thu, 15 Nov 2012 12:47:06 +0000 (13:47 +0100)
If the break/continue trampoline blocks get reached, there cannot be a
pending exception, so don't bother with saving it.

Change-Id: Id079d48d961f21dd236dbc33fad1712edbd2df97
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
qv4codegen.cpp

index 9c5ce2c..e14df95 100644 (file)
@@ -2053,8 +2053,10 @@ bool Codegen::visit(TryStatement *ast)
     if (loop) {
         // now do the codegen for each break/continue block
         for (Loop *it = loop, *it2 = _loop; it && it2; it = it->parent, it2 = it2->parent) {
-            generateFinallyBlock(it->breakBlock, !catchBody, ast->finallyExpression->statement, hasException, it2->breakBlock);
-            generateFinallyBlock(it->continueBlock, !catchBody, ast->finallyExpression->statement, hasException, it2->continueBlock);
+            // if the break/continue trampoline blocks get reached, there cannot
+            // be a pending exception, so don't bother with saving it.
+            generateFinallyBlock(it->breakBlock, false, ast->finallyExpression->statement, hasException, it2->breakBlock);
+            generateFinallyBlock(it->continueBlock, false, ast->finallyExpression->statement, hasException, it2->continueBlock);
         }
 
         // we don't need the Loop struct itself anymore.
@@ -2089,6 +2091,9 @@ void Codegen::generateFinallyBlock(IR::BasicBlock *finallyBlock, bool exceptionN
         _block = realFinallyBlock;
     }
 
+    // TODO: this will not re-throw when there is a pending exception, and
+    // the finally block contains a break/continue. Should another set of
+    // break/continue trampoline blocks get inserted?
     _block->EXP(_block->CALL(_block->NAME(IR::Name::builtin_delete_exception_handler, 0, 0), 0));
     if (ast)
         statement(ast);
@@ -2133,7 +2138,7 @@ bool Codegen::visit(WhileStatement *ast)
 
 bool Codegen::visit(WithStatement *)
 {
-    assert(!"not implemented");
+    assert(!"with not implemented");
     return false;
 }