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

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

Issue 865393004: [turbofan] Move GetCommonDominator to BasicBlock. (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 unified diff | Download patch
« no previous file with comments | « src/compiler/scheduler.cc ('k') | no next file » | 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/node.h" 5 #include "src/compiler/node.h"
6 #include "src/compiler/schedule.h" 6 #include "src/compiler/schedule.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::ElementsAre; 10 using testing::ElementsAre;
11 11
12 namespace v8 { 12 namespace v8 {
13 namespace internal { 13 namespace internal {
14 namespace compiler { 14 namespace compiler {
15 15
16 typedef TestWithZone BasicBlockTest;
17
18
19 TEST_F(BasicBlockTest, Constructor) {
20 int const id = random_number_generator()->NextInt();
21 BasicBlock b(zone(), BasicBlock::Id::FromInt(id));
22 EXPECT_FALSE(b.deferred());
23 EXPECT_GT(0, b.dominator_depth());
24 EXPECT_EQ(nullptr, b.dominator());
25 EXPECT_EQ(nullptr, b.rpo_next());
26 EXPECT_EQ(id, b.id().ToInt());
27 }
28
29
30 TEST_F(BasicBlockTest, GetCommonDominator1) {
31 BasicBlock b(zone(), BasicBlock::Id::FromInt(0));
32 EXPECT_EQ(&b, BasicBlock::GetCommonDominator(&b, &b));
33 }
34
35
36 TEST_F(BasicBlockTest, GetCommonDominator2) {
37 BasicBlock b0(zone(), BasicBlock::Id::FromInt(0));
38 BasicBlock b1(zone(), BasicBlock::Id::FromInt(1));
39 BasicBlock b2(zone(), BasicBlock::Id::FromInt(2));
40 b0.set_dominator_depth(0);
41 b1.set_dominator(&b0);
42 b1.set_dominator_depth(1);
43 b2.set_dominator(&b1);
44 b2.set_dominator_depth(2);
45 EXPECT_EQ(&b0, BasicBlock::GetCommonDominator(&b0, &b1));
46 EXPECT_EQ(&b0, BasicBlock::GetCommonDominator(&b0, &b2));
47 EXPECT_EQ(&b0, BasicBlock::GetCommonDominator(&b1, &b0));
48 EXPECT_EQ(&b0, BasicBlock::GetCommonDominator(&b2, &b0));
49 EXPECT_EQ(&b1, BasicBlock::GetCommonDominator(&b1, &b2));
50 EXPECT_EQ(&b1, BasicBlock::GetCommonDominator(&b2, &b1));
51 }
52
53
54 TEST_F(BasicBlockTest, GetCommonDominator3) {
55 BasicBlock b0(zone(), BasicBlock::Id::FromInt(0));
56 BasicBlock b1(zone(), BasicBlock::Id::FromInt(1));
57 BasicBlock b2(zone(), BasicBlock::Id::FromInt(2));
58 BasicBlock b3(zone(), BasicBlock::Id::FromInt(3));
59 b0.set_dominator_depth(0);
60 b1.set_dominator(&b0);
61 b1.set_dominator_depth(1);
62 b2.set_dominator(&b0);
63 b2.set_dominator_depth(1);
64 b3.set_dominator(&b2);
65 b3.set_dominator_depth(2);
66 EXPECT_EQ(&b0, BasicBlock::GetCommonDominator(&b1, &b3));
67 EXPECT_EQ(&b0, BasicBlock::GetCommonDominator(&b3, &b1));
68 }
69
70
16 typedef TestWithZone ScheduleTest; 71 typedef TestWithZone ScheduleTest;
17 72
18 73
19 namespace { 74 namespace {
20 75
21 const Operator kBranchOperator(IrOpcode::kBranch, Operator::kNoProperties, 76 const Operator kBranchOperator(IrOpcode::kBranch, Operator::kNoProperties,
22 "Branch", 0, 0, 0, 0, 0, 0); 77 "Branch", 0, 0, 0, 0, 0, 0);
23 const Operator kDummyOperator(IrOpcode::kParameter, Operator::kNoProperties, 78 const Operator kDummyOperator(IrOpcode::kParameter, Operator::kNoProperties,
24 "Dummy", 0, 0, 0, 0, 0, 0); 79 "Dummy", 0, 0, 0, 0, 0, 0);
25 80
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 209
155 EXPECT_EQ(1u, end->PredecessorCount()); 210 EXPECT_EQ(1u, end->PredecessorCount());
156 EXPECT_EQ(0u, end->SuccessorCount()); 211 EXPECT_EQ(0u, end->SuccessorCount());
157 EXPECT_EQ(mblock, end->PredecessorAt(0)); 212 EXPECT_EQ(mblock, end->PredecessorAt(0));
158 EXPECT_THAT(end->predecessors(), ElementsAre(mblock)); 213 EXPECT_THAT(end->predecessors(), ElementsAre(mblock));
159 } 214 }
160 215
161 } // namespace compiler 216 } // namespace compiler
162 } // namespace internal 217 } // namespace internal
163 } // namespace v8 218 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/scheduler.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698