Reviewers: Michael Starzinger,
Description:
[turbofan] Fix --turbo-osr for OSRing into inner loop inside for-in.
[email protected]
BUG=chromium:462775
LOG=Y
Please review this at https://codereview.chromium.org/988423003/
Base URL: https://chromium.googlesource.com/v8/v8.git@master
Affected files (+37, -0 lines):
M src/compiler/ast-graph-builder.cc
A test/mjsunit/compiler/osr-forin-nested.js
Index: src/compiler/ast-graph-builder.cc
diff --git a/src/compiler/ast-graph-builder.cc
b/src/compiler/ast-graph-builder.cc
index
96809fc2dff053b92817c2ffd0bdf7ad66a819d5..eebb4e345d86a8c808376a8009b343726a28d071
100644
--- a/src/compiler/ast-graph-builder.cc
+++ b/src/compiler/ast-graph-builder.cc
@@ -1195,7 +1195,9 @@ void AstGraphBuilder::VisitForInBody(ForInStatement*
stmt) {
VisitForInAssignment(stmt->each(), value, stmt->AssignmentId());
VisitIterationBody(stmt, &for_loop);
for_loop.EndBody();
+
// Inc counter and continue.
+ index = environment()->Peek(0);
Node* index_inc =
NewNode(javascript()->Add(), index, jsgraph()->OneConstant());
// TODO(jarin): provide real bailout id.
Index: test/mjsunit/compiler/osr-forin-nested.js
diff --git a/test/mjsunit/compiler/osr-forin-nested.js
b/test/mjsunit/compiler/osr-forin-nested.js
new file mode 100644
index
0000000000000000000000000000000000000000..ad55b30bd883a13d148b8572031177fb0fa7ec4e
--- /dev/null
+++ b/test/mjsunit/compiler/osr-forin-nested.js
@@ -0,0 +1,35 @@
+// Copyright 2015 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Flags: --turbo-osr --allow-natives-syntax
+
+function test(e, f, v) {
+ assertEquals(e, f(v));
+ assertEquals(e, f(v));
+ assertEquals(e, f(v));
+}
+
+function foo(t) {
+ for (var x in t) {
+ for (var i = 0; i < 2; i++) {
+ %OptimizeOsr();
+ }
+ }
+ return 5;
+}
+
+test(5, foo, {x:20});
+
+function bar(t) {
+ var sum = 0;
+ for (var x in t) {
+ for (var i = 0; i < 2; i++) {
+ %OptimizeOsr();
+ sum += t[x];
+ }
+ }
+ return sum;
+}
+
+test(62, bar, {x:20,y:11});
--
--
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.