From 091c7a23062d4b93287a4d562aad6440816c7ec7 Mon Sep 17 00:00:00 2001 From: "fschneider@chromium.org" Date: Tue, 10 Nov 2009 09:57:13 +0000 Subject: [PATCH] Fixed bug in while-loops that caused an assertion to fail. We forgot resetting true-/false-label to NULL after evaluating the condition expression in dowhile- and while-loops. This change fixes this. This causes an assertion to fail in VisitIfStatement whenever there is an if-statement after a while-loop before. e.g. like in: var i=0, j=0; while(j<5) { j++; } if (i ==0 ) { j++; } Review URL: http://codereview.chromium.org/371070 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@3255 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/compiler.cc | 12 ++++++++++-- src/fast-codegen.cc | 4 ++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/compiler.cc b/src/compiler.cc index bac0a25..6be922c 100644 --- a/src/compiler.cc +++ b/src/compiler.cc @@ -708,12 +708,20 @@ void CodeGenSelector::VisitSwitchStatement(SwitchStatement* stmt) { void CodeGenSelector::VisitDoWhileStatement(DoWhileStatement* stmt) { - BAILOUT("DoWhileStatement"); + // We do not handle loops with breaks or continue statements in their + // body. We will bailout when we hit those statements in the body. + ProcessExpression(stmt->cond(), Expression::kTest); + CHECK_BAILOUT; + Visit(stmt->body()); } void CodeGenSelector::VisitWhileStatement(WhileStatement* stmt) { - BAILOUT("WhileStatement"); + // We do not handle loops with breaks or continue statements in their + // body. We will bailout when we hit those statements in the body. + ProcessExpression(stmt->cond(), Expression::kTest); + CHECK_BAILOUT; + Visit(stmt->body()); } diff --git a/src/fast-codegen.cc b/src/fast-codegen.cc index bb5ed8a..1c69e21 100644 --- a/src/fast-codegen.cc +++ b/src/fast-codegen.cc @@ -320,6 +320,8 @@ void FastCodeGenerator::VisitDoWhileStatement(DoWhileStatement* stmt) { false_label_ = &exit; ASSERT(stmt->cond()->context() == Expression::kTest); Visit(stmt->cond()); + true_label_ = NULL; + false_label_ = NULL; __ bind(&exit); @@ -347,6 +349,8 @@ void FastCodeGenerator::VisitWhileStatement(WhileStatement* stmt) { false_label_ = &exit; ASSERT(stmt->cond()->context() == Expression::kTest); Visit(stmt->cond()); + true_label_ = NULL; + false_label_ = NULL; __ bind(&exit); -- 2.7.4