Reviewers: titzer,

Description:
Fix continue statements within for-in loops.

[email protected]
TEST=cctest/test-run-jsbranches/ForInContinueStatement
BUG=v8:3522
LOG=N

Please review this at https://codereview.chromium.org/502043002/

SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge

Affected files (+21, -1 lines):
  M src/compiler/ast-graph-builder.cc
  M test/cctest/compiler/test-run-jsbranches.cc


Index: src/compiler/ast-graph-builder.cc
diff --git a/src/compiler/ast-graph-builder.cc b/src/compiler/ast-graph-builder.cc index 66a371bcebd8bf4e70c4e67d409ab47a58f7f117..0e642c9e6698064a6d2ebc9a3238b30940a742a6 100644
--- a/src/compiler/ast-graph-builder.cc
+++ b/src/compiler/ast-graph-builder.cc
@@ -744,13 +744,13 @@ void AstGraphBuilder::VisitForInStatement(ForInStatement* stmt) {
         // Bind value and do loop body.
         VisitForInAssignment(stmt->each(), value);
         VisitIterationBody(stmt, &for_loop, 5);
+        for_loop.EndBody();
         // Inc counter and continue.
         Node* index_inc =
             NewNode(javascript()->Add(), index, jsgraph()->OneConstant());
         // TODO(jarin): provide real bailout id.
         PrepareFrameState(index_inc, BailoutId::None());
         environment()->Poke(0, index_inc);
-        for_loop.EndBody();
         for_loop.EndLoop();
         environment()->Drop(5);
         // PrepareForBailoutForId(stmt->ExitId(), NO_REGISTERS);
Index: test/cctest/compiler/test-run-jsbranches.cc
diff --git a/test/cctest/compiler/test-run-jsbranches.cc b/test/cctest/compiler/test-run-jsbranches.cc index 2eb4fa6d0f758763672a50d743ef72382c0e4807..df2fcdcb6d68c5573a175e95eac8d5062a52b6e2 100644
--- a/test/cctest/compiler/test-run-jsbranches.cc
+++ b/test/cctest/compiler/test-run-jsbranches.cc
@@ -148,6 +148,26 @@ TEST(ForInStatement) {
 }


+TEST(ForInContinueStatement) {
+  const char* src =
+      "(function(a,b) {"
+      "  var r = '-';"
+      "  for (var x in a) {"
+      "    r += 'A-';"
+      "    if (b) continue;"
+      "    r += 'B-';"
+      "  }"
+      "  return r;"
+      "})";
+  FunctionTester T(src);
+
+  T.CheckCall(T.Val("-A-B-"), T.NewObject("({x:1})"), T.false_value());
+ T.CheckCall(T.Val("-A-B-A-B-"), T.NewObject("({x:1,y:2})"), T.false_value());
+  T.CheckCall(T.Val("-A-"), T.NewObject("({x:1})"), T.true_value());
+  T.CheckCall(T.Val("-A-A-"), T.NewObject("({x:1,y:2})"), T.true_value());
+}
+
+
 TEST(SwitchStatement) {
   const char* src =
       "(function(a,b) {"


--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to