Fixed bug in while-loops that caused an assertion to fail.
authorfschneider@chromium.org <fschneider@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Tue, 10 Nov 2009 09:57:13 +0000 (09:57 +0000)
committerfschneider@chromium.org <fschneider@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Tue, 10 Nov 2009 09:57:13 +0000 (09:57 +0000)
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
src/fast-codegen.cc

index bac0a25..6be922c 100644 (file)
@@ -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());
 }
 
 
index bb5ed8a..1c69e21 100644 (file)
@@ -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);