From bdf446f59007e1a19ffea21d550db4b186790e98 Mon Sep 17 00:00:00 2001 From: jarin Date: Sat, 3 Jan 2015 04:45:46 -0800 Subject: [PATCH] Do not reduce effect phis for loops. This prevents eliminating effectful statements before the loop. BUG= Review URL: https://codereview.chromium.org/830923002 Cr-Commit-Position: refs/heads/master@{#25953} --- src/compiler/control-reducer.cc | 8 ++++++++ test/mjsunit/compiler/regress-ntl-effect.js | 16 ++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 test/mjsunit/compiler/regress-ntl-effect.js diff --git a/src/compiler/control-reducer.cc b/src/compiler/control-reducer.cc index e738ccf..acb2f06 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) { diff --git a/test/mjsunit/compiler/regress-ntl-effect.js b/test/mjsunit/compiler/regress-ntl-effect.js new file mode 100644 index 0000000..708fe32 --- /dev/null +++ b/test/mjsunit/compiler/regress-ntl-effect.js @@ -0,0 +1,16 @@ +// 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() { + g(); + while (1) {} +} + +assertThrows(function () { f(); }); -- 2.7.4