Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(241)

Unified Diff: test/unittests/compiler/control-reducer-unittest.cc

Issue 875263004: [turbofan] Ensure that NTLs are always properly connected to the end. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « test/unittests/compiler/common-operator-unittest.cc ('k') | test/unittests/compiler/graph-unittest.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/unittests/compiler/control-reducer-unittest.cc
diff --git a/test/unittests/compiler/control-reducer-unittest.cc b/test/unittests/compiler/control-reducer-unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..5e9b0ef4b1b532c0b1f6a5c29de39de4f96be270
--- /dev/null
+++ b/test/unittests/compiler/control-reducer-unittest.cc
@@ -0,0 +1,124 @@
+// 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.
+
+#include "src/compiler/control-reducer.h"
+#include "src/compiler/js-graph.h"
+#include "src/compiler/js-operator.h"
+#include "src/compiler/machine-operator.h"
+#include "src/compiler/node.h"
+#include "test/unittests/compiler/graph-unittest.h"
+#include "test/unittests/compiler/node-test-utils.h"
+#include "testing/gmock-support.h"
+
+using testing::_;
+using testing::AllOf;
+using testing::Capture;
+using testing::CaptureEq;
+
+namespace v8 {
+namespace internal {
+namespace compiler {
+
+class ControlReducerTest : public GraphTest {
+ protected:
+ void ReduceGraph() {
+ JSOperatorBuilder javascript(zone());
+ MachineOperatorBuilder machine(zone());
+ JSGraph jsgraph(isolate(), graph(), common(), &javascript, &machine);
+ ControlReducer::ReduceGraph(zone(), &jsgraph, common());
+ }
+};
+
+
+TEST_F(ControlReducerTest, NonTerminatingLoop) {
+ Node* loop = graph()->NewNode(common()->Loop(2), graph()->start());
+ loop->AppendInput(graph()->zone(), loop);
+ ReduceGraph();
+ Capture<Node*> branch;
+ EXPECT_THAT(
+ graph()->end(),
+ IsEnd(IsMerge(
+ graph()->start(),
+ IsReturn(IsUndefinedConstant(), graph()->start(),
+ IsIfFalse(
+ AllOf(CaptureEq(&branch),
+ IsBranch(IsAlways(),
+ AllOf(loop, IsLoop(graph()->start(),
+ IsIfTrue(CaptureEq(
+ &branch)))))))))));
+}
+
+
+TEST_F(ControlReducerTest, NonTerminatingLoopWithEffectPhi) {
+ Node* loop = graph()->NewNode(common()->Loop(2), graph()->start());
+ loop->AppendInput(graph()->zone(), loop);
+ Node* ephi = graph()->NewNode(common()->EffectPhi(2), graph()->start());
+ ephi->AppendInput(graph()->zone(), ephi);
+ ephi->AppendInput(graph()->zone(), loop);
+ ReduceGraph();
+ Capture<Node*> branch;
+ EXPECT_THAT(
+ graph()->end(),
+ IsEnd(IsMerge(
+ graph()->start(),
+ IsReturn(IsUndefinedConstant(),
+ AllOf(ephi, IsEffectPhi(graph()->start(), ephi, loop)),
+ IsIfFalse(
+ AllOf(CaptureEq(&branch),
+ IsBranch(IsAlways(),
+ AllOf(loop, IsLoop(graph()->start(),
+ IsIfTrue(CaptureEq(
+ &branch)))))))))));
+}
+
+
+TEST_F(ControlReducerTest, NonTerminatingLoopWithTwoEffectPhis) {
+ Node* loop = graph()->NewNode(common()->Loop(2), graph()->start());
+ loop->AppendInput(graph()->zone(), loop);
+ Node* ephi1 = graph()->NewNode(common()->EffectPhi(2), graph()->start());
+ ephi1->AppendInput(graph()->zone(), ephi1);
+ ephi1->AppendInput(graph()->zone(), loop);
+ Node* ephi2 = graph()->NewNode(common()->EffectPhi(2), graph()->start());
+ ephi2->AppendInput(graph()->zone(), ephi2);
+ ephi2->AppendInput(graph()->zone(), loop);
+ ReduceGraph();
+ Capture<Node*> branch;
+ EXPECT_THAT(
+ graph()->end(),
+ IsEnd(IsMerge(
+ graph()->start(),
+ IsReturn(
+ IsUndefinedConstant(),
+ IsEffectSet(
+ AllOf(ephi1, IsEffectPhi(graph()->start(), ephi1, loop)),
+ AllOf(ephi2, IsEffectPhi(graph()->start(), ephi2, loop))),
+ IsIfFalse(AllOf(
+ CaptureEq(&branch),
+ IsBranch(
+ IsAlways(),
+ AllOf(loop, IsLoop(graph()->start(),
+ IsIfTrue(CaptureEq(&branch)))))))))));
+}
+
+
+TEST_F(ControlReducerTest, NonTerminatingLoopWithDeadEnd) {
+ Node* loop = graph()->NewNode(common()->Loop(2), graph()->start());
+ loop->AppendInput(graph()->zone(), loop);
+ graph()->end()->ReplaceInput(0, graph()->NewNode(common()->Dead()));
+ ReduceGraph();
+ Capture<Node*> branch;
+ EXPECT_THAT(
+ graph()->end(),
+ IsEnd(IsReturn(
+ IsUndefinedConstant(), graph()->start(),
+ IsIfFalse(AllOf(
+ CaptureEq(&branch),
+ IsBranch(IsAlways(),
+ AllOf(loop, IsLoop(graph()->start(),
+ IsIfTrue(CaptureEq(&branch))))))))));
+}
+
+} // namespace compiler
+} // namespace internal
+} // namespace v8
« no previous file with comments | « test/unittests/compiler/common-operator-unittest.cc ('k') | test/unittests/compiler/graph-unittest.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698