Reviewers: jarin,
Description:
[turbofan] Properly kill Terminate nodes when removing loops.
BUG=chromium:491578
LOG=n
[email protected]
Please review this at https://codereview.chromium.org/1161583002/
Base URL: https://chromium.googlesource.com/v8/v8.git@master
Affected files (+18, -7 lines):
M src/compiler/control-reducer.cc
A + test/mjsunit/compiler/regress-491578.js
Index: src/compiler/control-reducer.cc
diff --git a/src/compiler/control-reducer.cc
b/src/compiler/control-reducer.cc
index
59c63f7f9bd1335109ac6a5e43feffcb756a345f..3d19edb5ed23c274d166bff523d72878120de2a6
100644
--- a/src/compiler/control-reducer.cc
+++ b/src/compiler/control-reducer.cc
@@ -423,10 +423,16 @@ class ControlReducerImpl final : public
AdvancedReducer {
if (live == 0) return dead(); // no remaining inputs.
- // Gather phis and effect phis to be edited.
+ // Gather terminates, phis and effect phis to be edited.
NodeVector phis(zone_);
+ Node* terminate = nullptr;
for (Node* const use : node->uses()) {
- if (NodeProperties::IsPhi(use)) phis.push_back(use);
+ if (NodeProperties::IsPhi(use)) {
+ phis.push_back(use);
+ } else if (use->opcode() == IrOpcode::kTerminate) {
+ DCHECK_NULL(terminate);
+ terminate = use;
+ }
}
if (live == 1) {
@@ -434,6 +440,8 @@ class ControlReducerImpl final : public AdvancedReducer
{
for (Node* const phi : phis) {
Replace(phi, phi->InputAt(live_index));
}
+ // The terminate is not needed anymore.
+ if (terminate) Replace(terminate, dead());
// The merge itself is redundant.
return node->InputAt(live_index);
}
Index: test/mjsunit/compiler/regress-491578.js
diff --git a/test/mjsunit/compiler/regress-445876.js
b/test/mjsunit/compiler/regress-491578.js
similarity index 58%
copy from test/mjsunit/compiler/regress-445876.js
copy to test/mjsunit/compiler/regress-491578.js
index
30e10e56c3ac424fb8843b700bec2af5ded334ac..c27570456c31e9a191fe1f4f1ea17b80f29de98e
100644
--- a/test/mjsunit/compiler/regress-445876.js
+++ b/test/mjsunit/compiler/regress-491578.js
@@ -4,9 +4,12 @@
// Flags: --allow-natives-syntax
-function f(x) {
- while (1) { s++; }
- while (x) { s++; }
+function foo(x) {
+ if (x === undefined) return;
+ while (true) {
+ while (1 || 2) { }
+ f();
+ }
}
-
-assertThrows(function () { f(1); });
+%OptimizeFunctionOnNextCall(foo);
+foo();
--
--
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.