Reviewers: Benedikt Meurer,

Message:
Could you take a look, please?

Description:
Do not reduce effect phis for loops.

This prevents eliminating effectful statements before the loop.

BUG=

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

Base URL: https://chromium.googlesource.com/v8/v8.git@master

Affected files (+16, -6 lines):
  M src/compiler/control-reducer.cc
  A + test/mjsunit/compiler/regress-ntl-effect.js


Index: src/compiler/control-reducer.cc
diff --git a/src/compiler/control-reducer.cc b/src/compiler/control-reducer.cc index e738ccf24e82f874447cb4584a78b8c488e71a57..acb2f06b04ea116e9c1ccbbf08978e72ae49d532 100644
--- a/src/compiler/control-reducer.cc
+++ b/src/compiler/control-reducer.cc
@@ -403,6 +403,14 @@ class ControlReducerImpl {
     if (n <= 1) return dead();            // No non-control inputs.
     if (n == 2) return node->InputAt(0);  // Only one non-control input.

+ // Never remove an effect phi from a (potentially non-terminating) loop.
+    // Otherwise, we might end up eliminating effect nodes, such as calls,
+    // before the loop.
+    if (node->opcode() == IrOpcode::kEffectPhi &&
+ NodeProperties::GetControlInput(node)->opcode() == IrOpcode::kLoop) {
+      return node;
+    }
+
     Node* replacement = NULL;
     Node::Inputs inputs = node->inputs();
     for (InputIter it = inputs.begin(); n > 1; --n, ++it) {
Index: test/mjsunit/compiler/regress-ntl-effect.js
diff --git a/test/mjsunit/regress/regress-crbug-387636.js b/test/mjsunit/compiler/regress-ntl-effect.js
similarity index 51%
copy from test/mjsunit/regress/regress-crbug-387636.js
copy to test/mjsunit/compiler/regress-ntl-effect.js
index 1e50ace45a293c8561042f1a09c8fcd505b43dc2..708fe32828c9197dfa3d8c371ab01cbc1ad3317a 100644
--- a/test/mjsunit/regress/regress-crbug-387636.js
+++ b/test/mjsunit/compiler/regress-ntl-effect.js
@@ -1,14 +1,16 @@
-// Copyright 2014 the V8 project authors. All rights reserved.
+// 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: --allow-natives-syntax

+function g() {
+  throw 0;
+}
+
 function f() {
-  [].indexOf(0x40000000);
+  g();
+  while (1) {}
 }

-f();
-f();
-%OptimizeFunctionOnNextCall(f);
-f();
+assertThrows(function () { f(); });


--
--
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