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

Side by Side Diff: test/unittests/compiler/node-properties-unittest.cc

Issue 1022783002: [turbofan] Remove last_use_ field from Node. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 9 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
« no previous file with comments | « test/cctest/compiler/test-node.cc ('k') | test/unittests/compiler/node-test-utils.cc » ('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 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 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/common-operator.h" 5 #include "src/compiler/common-operator.h"
6 #include "src/compiler/node-properties.h" 6 #include "src/compiler/node-properties.h"
7 #include "test/unittests/test-utils.h" 7 #include "test/unittests/test-utils.h"
8 #include "testing/gmock/include/gmock/gmock.h" 8 #include "testing/gmock/include/gmock/gmock.h"
9 9
10 using testing::AnyOf; 10 using testing::AnyOf;
11 using testing::ElementsAre; 11 using testing::ElementsAre;
12 using testing::IsNull; 12 using testing::IsNull;
13 using testing::UnorderedElementsAre;
13 14
14 namespace v8 { 15 namespace v8 {
15 namespace internal { 16 namespace internal {
16 namespace compiler { 17 namespace compiler {
17 18
18 typedef TestWithZone NodePropertiesTest; 19 typedef TestWithZone NodePropertiesTest;
19 20
20 21
21 namespace { 22 namespace {
22 23
(...skipping 26 matching lines...) Expand all
49 CommonOperatorBuilder common(zone()); 50 CommonOperatorBuilder common(zone());
50 Node* start = Node::New(zone(), 0, common.Start(1), 0, nullptr, false); 51 Node* start = Node::New(zone(), 0, common.Start(1), 0, nullptr, false);
51 Node* node = Node::New(zone(), 0, &kMockOpEffect, 1, &start, false); 52 Node* node = Node::New(zone(), 0, &kMockOpEffect, 1, &start, false);
52 Node* use_effect = Node::New(zone(), 0, common.EffectPhi(1), 1, &node, false); 53 Node* use_effect = Node::New(zone(), 0, common.EffectPhi(1), 1, &node, false);
53 Node* replacement = Node::New(zone(), 0, &kMockOperator, 0, nullptr, false); 54 Node* replacement = Node::New(zone(), 0, &kMockOperator, 0, nullptr, false);
54 NodeProperties::ReplaceWithValue(node, replacement); 55 NodeProperties::ReplaceWithValue(node, replacement);
55 EXPECT_EQ(start, use_effect->InputAt(0)); 56 EXPECT_EQ(start, use_effect->InputAt(0));
56 EXPECT_EQ(0, node->UseCount()); 57 EXPECT_EQ(0, node->UseCount());
57 EXPECT_EQ(2, start->UseCount()); 58 EXPECT_EQ(2, start->UseCount());
58 EXPECT_EQ(0, replacement->UseCount()); 59 EXPECT_EQ(0, replacement->UseCount());
59 EXPECT_THAT(start->uses(), ElementsAre(node, use_effect)); 60 EXPECT_THAT(start->uses(), UnorderedElementsAre(use_effect, node));
60 } 61 }
61 62
62 63
63 TEST_F(NodePropertiesTest, ReplaceWithValue_ControlUse) { 64 TEST_F(NodePropertiesTest, ReplaceWithValue_ControlUse) {
64 CommonOperatorBuilder common(zone()); 65 CommonOperatorBuilder common(zone());
65 Node* start = Node::New(zone(), 0, common.Start(1), 0, nullptr, false); 66 Node* start = Node::New(zone(), 0, common.Start(1), 0, nullptr, false);
66 Node* node = Node::New(zone(), 0, &kMockOpControl, 1, &start, false); 67 Node* node = Node::New(zone(), 0, &kMockOpControl, 1, &start, false);
67 Node* success = Node::New(zone(), 0, common.IfSuccess(), 1, &node, false); 68 Node* success = Node::New(zone(), 0, common.IfSuccess(), 1, &node, false);
68 Node* use_control = Node::New(zone(), 0, common.Merge(1), 1, &success, false); 69 Node* use_control = Node::New(zone(), 0, common.Merge(1), 1, &success, false);
69 Node* replacement = Node::New(zone(), 0, &kMockOperator, 0, nullptr, false); 70 Node* replacement = Node::New(zone(), 0, &kMockOperator, 0, nullptr, false);
70 NodeProperties::ReplaceWithValue(node, replacement); 71 NodeProperties::ReplaceWithValue(node, replacement);
71 EXPECT_EQ(start, use_control->InputAt(0)); 72 EXPECT_EQ(start, use_control->InputAt(0));
72 EXPECT_EQ(0, node->UseCount()); 73 EXPECT_EQ(0, node->UseCount());
73 EXPECT_EQ(2, start->UseCount()); 74 EXPECT_EQ(2, start->UseCount());
74 EXPECT_EQ(0, replacement->UseCount()); 75 EXPECT_EQ(0, replacement->UseCount());
75 EXPECT_THAT(start->uses(), ElementsAre(node, use_control)); 76 EXPECT_THAT(start->uses(), UnorderedElementsAre(use_control, node));
76 } 77 }
77 78
78 79
79 TEST_F(NodePropertiesTest, FindProjection) { 80 TEST_F(NodePropertiesTest, FindProjection) {
80 CommonOperatorBuilder common(zone()); 81 CommonOperatorBuilder common(zone());
81 Node* start = Node::New(zone(), 0, common.Start(1), 0, nullptr, false); 82 Node* start = Node::New(zone(), 0, common.Start(1), 0, nullptr, false);
82 Node* proj0 = Node::New(zone(), 1, common.Projection(0), 1, &start, false); 83 Node* proj0 = Node::New(zone(), 1, common.Projection(0), 1, &start, false);
83 Node* proj1 = Node::New(zone(), 2, common.Projection(1), 1, &start, false); 84 Node* proj1 = Node::New(zone(), 2, common.Projection(1), 1, &start, false);
84 EXPECT_EQ(proj0, NodeProperties::FindProjection(start, 0)); 85 EXPECT_EQ(proj0, NodeProperties::FindProjection(start, 0));
85 EXPECT_EQ(proj1, NodeProperties::FindProjection(start, 1)); 86 EXPECT_EQ(proj1, NodeProperties::FindProjection(start, 1));
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 Node* if_value2 = Node::New(zone(), 4, common.IfValue(2), 1, &sw, false); 122 Node* if_value2 = Node::New(zone(), 4, common.IfValue(2), 1, &sw, false);
122 NodeProperties::CollectControlProjections(sw, result, arraysize(result)); 123 NodeProperties::CollectControlProjections(sw, result, arraysize(result));
123 EXPECT_THAT(result[0], AnyOf(if_value1, if_value2)); 124 EXPECT_THAT(result[0], AnyOf(if_value1, if_value2));
124 EXPECT_THAT(result[1], AnyOf(if_value1, if_value2)); 125 EXPECT_THAT(result[1], AnyOf(if_value1, if_value2));
125 EXPECT_EQ(if_default, result[2]); 126 EXPECT_EQ(if_default, result[2]);
126 } 127 }
127 128
128 } // namespace compiler 129 } // namespace compiler
129 } // namespace internal 130 } // namespace internal
130 } // namespace v8 131 } // namespace v8
OLDNEW
« no previous file with comments | « test/cctest/compiler/test-node.cc ('k') | test/unittests/compiler/node-test-utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698