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

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

Issue 928213003: Model exceptional edges from call nodes in TurboFan. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebased. Created 5 years, 10 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
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::IsNull; 12 using testing::IsNull;
12 13
13 namespace v8 { 14 namespace v8 {
14 namespace internal { 15 namespace internal {
15 namespace compiler { 16 namespace compiler {
16 17
17 typedef TestWithZone NodePropertiesTest; 18 typedef TestWithZone NodePropertiesTest;
18 19
19 20
21 namespace {
22
23 const Operator kMockOperator(IrOpcode::kDead, Operator::kNoProperties,
24 "MockOperator", 0, 0, 0, 1, 0, 0);
25 const Operator kMockOpEffect(IrOpcode::kDead, Operator::kNoProperties,
26 "MockOpEffect", 0, 1, 0, 1, 1, 0);
27 const Operator kMockOpControl(IrOpcode::kDead, Operator::kNoProperties,
28 "MockOpControl", 0, 0, 1, 1, 0, 1);
29
30 } // namespace
31
32
33 TEST_F(NodePropertiesTest, ReplaceWithValue_ValueUse) {
34 CommonOperatorBuilder common(zone());
35 Node* node = Node::New(zone(), 0, &kMockOperator, 0, nullptr, false);
36 Node* use_value = Node::New(zone(), 0, common.Return(), 1, &node, false);
37 Node* replacement = Node::New(zone(), 0, &kMockOperator, 0, nullptr, false);
38 NodeProperties::ReplaceWithValue(node, replacement);
39 EXPECT_EQ(replacement, use_value->InputAt(0));
40 EXPECT_EQ(0, node->UseCount());
41 EXPECT_EQ(1, replacement->UseCount());
42 EXPECT_THAT(replacement->uses(), ElementsAre(use_value));
43 }
44
45
46 TEST_F(NodePropertiesTest, ReplaceWithValue_EffectUse) {
47 CommonOperatorBuilder common(zone());
48 Node* start = Node::New(zone(), 0, common.Start(1), 0, nullptr, false);
49 Node* node = Node::New(zone(), 0, &kMockOpEffect, 1, &start, false);
50 Node* use_effect = Node::New(zone(), 0, common.EffectPhi(1), 1, &node, false);
51 Node* replacement = Node::New(zone(), 0, &kMockOperator, 0, nullptr, false);
52 NodeProperties::ReplaceWithValue(node, replacement);
53 EXPECT_EQ(start, use_effect->InputAt(0));
54 EXPECT_EQ(0, node->UseCount());
55 EXPECT_EQ(2, start->UseCount());
56 EXPECT_EQ(0, replacement->UseCount());
57 EXPECT_THAT(start->uses(), ElementsAre(node, use_effect));
58 }
59
60
61 TEST_F(NodePropertiesTest, ReplaceWithValue_ControlUse) {
62 CommonOperatorBuilder common(zone());
63 Node* start = Node::New(zone(), 0, common.Start(1), 0, nullptr, false);
64 Node* node = Node::New(zone(), 0, &kMockOpControl, 1, &start, false);
65 Node* success = Node::New(zone(), 0, common.IfSuccess(), 1, &node, false);
66 Node* use_control = Node::New(zone(), 0, common.Merge(1), 1, &success, false);
67 Node* replacement = Node::New(zone(), 0, &kMockOperator, 0, nullptr, false);
68 NodeProperties::ReplaceWithValue(node, replacement);
69 EXPECT_EQ(start, use_control->InputAt(0));
70 EXPECT_EQ(0, node->UseCount());
71 EXPECT_EQ(2, start->UseCount());
72 EXPECT_EQ(0, replacement->UseCount());
73 EXPECT_THAT(start->uses(), ElementsAre(node, use_control));
74 }
75
76
20 TEST_F(NodePropertiesTest, FindProjection) { 77 TEST_F(NodePropertiesTest, FindProjection) {
21 CommonOperatorBuilder common(zone()); 78 CommonOperatorBuilder common(zone());
22 Node* start = Node::New(zone(), 0, common.Start(1), 0, nullptr, false); 79 Node* start = Node::New(zone(), 0, common.Start(1), 0, nullptr, false);
23 Node* proj0 = Node::New(zone(), 1, common.Projection(0), 1, &start, false); 80 Node* proj0 = Node::New(zone(), 1, common.Projection(0), 1, &start, false);
24 Node* proj1 = Node::New(zone(), 2, common.Projection(1), 1, &start, false); 81 Node* proj1 = Node::New(zone(), 2, common.Projection(1), 1, &start, false);
25 EXPECT_EQ(proj0, NodeProperties::FindProjection(start, 0)); 82 EXPECT_EQ(proj0, NodeProperties::FindProjection(start, 0));
26 EXPECT_EQ(proj1, NodeProperties::FindProjection(start, 1)); 83 EXPECT_EQ(proj1, NodeProperties::FindProjection(start, 1));
27 EXPECT_THAT(NodeProperties::FindProjection(start, 2), IsNull()); 84 EXPECT_THAT(NodeProperties::FindProjection(start, 2), IsNull());
28 EXPECT_THAT(NodeProperties::FindProjection(start, 1234567890), IsNull()); 85 EXPECT_THAT(NodeProperties::FindProjection(start, 1234567890), IsNull());
29 } 86 }
(...skipping 20 matching lines...) Expand all
50 Node* if_value2 = Node::New(zone(), 4, common.IfValue(2), 1, &sw, false); 107 Node* if_value2 = Node::New(zone(), 4, common.IfValue(2), 1, &sw, false);
51 NodeProperties::CollectControlProjections(sw, result, arraysize(result)); 108 NodeProperties::CollectControlProjections(sw, result, arraysize(result));
52 EXPECT_THAT(result[0], AnyOf(if_value1, if_value2)); 109 EXPECT_THAT(result[0], AnyOf(if_value1, if_value2));
53 EXPECT_THAT(result[1], AnyOf(if_value1, if_value2)); 110 EXPECT_THAT(result[1], AnyOf(if_value1, if_value2));
54 EXPECT_EQ(if_default, result[2]); 111 EXPECT_EQ(if_default, result[2]);
55 } 112 }
56 113
57 } // namespace compiler 114 } // namespace compiler
58 } // namespace internal 115 } // namespace internal
59 } // namespace v8 116 } // namespace v8
OLDNEW
« no previous file with comments | « test/unittests/compiler/js-operator-unittest.cc ('k') | test/unittests/compiler/schedule-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698