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

Side by Side Diff: src/compiler/graph-reducer-unittest.cc

Issue 540253003: [turbofan] Nodes are killed by resetting all their inputs to zero. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Nit Created 6 years, 3 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | src/compiler/node.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/compiler/graph.h" 5 #include "src/compiler/graph.h"
6 #include "src/compiler/graph-reducer.h" 6 #include "src/compiler/graph-reducer.h"
7 #include "src/compiler/operator.h" 7 #include "src/compiler/operator.h"
8 #include "src/test/test-utils.h" 8 #include "src/test/test-utils.h"
9 #include "testing/gmock/include/gmock/gmock.h" 9 #include "testing/gmock/include/gmock/gmock.h"
10 10
11 using testing::_; 11 using testing::_;
12 using testing::DefaultValue; 12 using testing::DefaultValue;
13 using testing::Return; 13 using testing::Return;
14 using testing::Sequence; 14 using testing::Sequence;
15 using testing::StrictMock; 15 using testing::StrictMock;
16 16
17 namespace v8 { 17 namespace v8 {
18 namespace internal { 18 namespace internal {
19 namespace compiler { 19 namespace compiler {
20 20
21 namespace { 21 namespace {
22 22
23 SimpleOperator OP0(0, Operator::kNoWrite, 0, 0, "op0"); 23 SimpleOperator OP0(0, Operator::kNoWrite, 0, 1, "op0");
24 SimpleOperator OP1(1, Operator::kNoProperties, 1, 1, "op1");
24 25
25 26
26 struct MockReducer : public Reducer { 27 struct MockReducer : public Reducer {
27 MOCK_METHOD1(Reduce, Reduction(Node*)); 28 MOCK_METHOD1(Reduce, Reduction(Node*));
28 }; 29 };
29 30
30 } // namespace 31 } // namespace
31 32
32 33
33 class GraphReducerTest : public TestWithZone { 34 class GraphReducerTest : public TestWithZone {
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 reducer.ReduceNode(node); 67 reducer.ReduceNode(node);
67 } 68 }
68 69
69 Graph* graph() { return &graph_; } 70 Graph* graph() { return &graph_; }
70 71
71 private: 72 private:
72 Graph graph_; 73 Graph graph_;
73 }; 74 };
74 75
75 76
77 TEST_F(GraphReducerTest, NodeIsDeadAfterReplace) {
78 StrictMock<MockReducer> r;
79 Node* node0 = graph()->NewNode(&OP0);
80 Node* node1 = graph()->NewNode(&OP1, node0);
81 Node* node2 = graph()->NewNode(&OP1, node0);
82 EXPECT_CALL(r, Reduce(node1)).WillOnce(Return(Reducer::Replace(node2)));
83 ReduceNode(node1, &r);
84 EXPECT_FALSE(node0->IsDead());
85 EXPECT_TRUE(node1->IsDead());
86 EXPECT_FALSE(node2->IsDead());
87 }
88
89
76 TEST_F(GraphReducerTest, ReduceOnceForEveryReducer) { 90 TEST_F(GraphReducerTest, ReduceOnceForEveryReducer) {
77 StrictMock<MockReducer> r1, r2; 91 StrictMock<MockReducer> r1, r2;
78 Node* node0 = graph()->NewNode(&OP0); 92 Node* node0 = graph()->NewNode(&OP0);
79 EXPECT_CALL(r1, Reduce(node0)); 93 EXPECT_CALL(r1, Reduce(node0));
80 EXPECT_CALL(r2, Reduce(node0)); 94 EXPECT_CALL(r2, Reduce(node0));
81 ReduceNode(node0, &r1, &r2); 95 ReduceNode(node0, &r1, &r2);
82 } 96 }
83 97
84 98
85 TEST_F(GraphReducerTest, ReduceAgainAfterChanged) { 99 TEST_F(GraphReducerTest, ReduceAgainAfterChanged) {
86 Sequence s1, s2; 100 Sequence s1, s2;
87 StrictMock<MockReducer> r1, r2, r3; 101 StrictMock<MockReducer> r1, r2, r3;
88 Node* node0 = graph()->NewNode(&OP0); 102 Node* node0 = graph()->NewNode(&OP0);
89 EXPECT_CALL(r1, Reduce(node0)); 103 EXPECT_CALL(r1, Reduce(node0));
90 EXPECT_CALL(r2, Reduce(node0)); 104 EXPECT_CALL(r2, Reduce(node0));
91 EXPECT_CALL(r3, Reduce(node0)).InSequence(s1, s2).WillOnce( 105 EXPECT_CALL(r3, Reduce(node0)).InSequence(s1, s2).WillOnce(
92 Return(Reducer::Changed(node0))); 106 Return(Reducer::Changed(node0)));
93 EXPECT_CALL(r1, Reduce(node0)).InSequence(s1); 107 EXPECT_CALL(r1, Reduce(node0)).InSequence(s1);
94 EXPECT_CALL(r2, Reduce(node0)).InSequence(s2); 108 EXPECT_CALL(r2, Reduce(node0)).InSequence(s2);
95 ReduceNode(node0, &r1, &r2, &r3); 109 ReduceNode(node0, &r1, &r2, &r3);
96 } 110 }
97 111
98
99 TEST_F(GraphReducerTest, OperatorIsNullAfterReplace) {
100 StrictMock<MockReducer> r;
101 Node* node0 = graph()->NewNode(&OP0);
102 Node* node1 = graph()->NewNode(&OP0);
103 EXPECT_CALL(r, Reduce(node0)).WillOnce(Return(Reducer::Replace(node1)));
104 ReduceNode(node0, &r);
105 EXPECT_EQ(NULL, node0->op());
106 EXPECT_EQ(&OP0, node1->op());
107 }
108
109 } // namespace compiler 112 } // namespace compiler
110 } // namespace internal 113 } // namespace internal
111 } // namespace v8 114 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/compiler/node.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698